Skip to content

Commit dd2e4e5

Browse files
committed
fix(plugin-ui): 撤回 ui 1,工具行的 choose 改为 ui 0 内的可选字段
1 parent cc2b03e commit dd2e4e5

12 files changed

Lines changed: 36 additions & 67 deletions

File tree

‎rust/crates/plugin-manifest/src/views.rs‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! same results; the host only renders.
1010
1111
use crate::{validate_manifest_value, DeclarativePluginManifest};
12-
use lithe_plugin_model::{capabilities, decode_payload, outcome, PluginRejection, Validation};
12+
use lithe_plugin_model::{decode_payload, outcome, PluginRejection, Validation};
1313
use lithe_plugin_ui::{Context, Surface, INVALID_VIEW};
1414
use lithe_protocol::CoreError;
1515
use serde::Deserialize;
@@ -55,7 +55,6 @@ pub fn apply_result_command(payload: Value) -> Result<Value, CoreError> {
5555
settings: &manifest.settings,
5656
actions: &manifest.setting_actions,
5757
tools: &tools,
58-
ui_version: manifest.capability_version(capabilities::UI),
5958
};
6059
let (view, changed) =
6160
lithe_plugin_ui::apply(&context, payload.view.as_ref(), &payload.result)?;
@@ -198,23 +197,9 @@ mod tests {
198197
}
199198

200199
#[test]
201-
fn a_tool_picker_follows_the_declared_ui_version() {
200+
fn a_settings_region_accepts_a_tool_picker() {
202201
let picker = json!({"view": [{"type": "tool", "tool": "node", "choose": true}]});
203-
let outcome = apply(json!({"settingRegionID": "overview"}), None, picker.clone());
204-
assert_eq!(outcome["status"], "rejected", "{outcome}");
205-
assert_eq!(
206-
outcome["error"]["field"], "result.view[0].choose",
207-
"{outcome}"
208-
);
209-
210-
let mut manifest = manifest();
211-
manifest["requires"]["ui"] = json!(1);
212-
let outcome = apply_result_command(json!({
213-
"manifest": manifest,
214-
"surface": {"settingRegionID": "overview"},
215-
"result": picker,
216-
}))
217-
.expect("outcome");
202+
let outcome = apply(json!({"settingRegionID": "overview"}), None, picker);
218203
assert_eq!(outcome["status"], "ok", "{outcome}");
219204
}
220205

‎rust/crates/plugin-model/src/capabilities.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ pub const SETTINGS: &str = "settings";
6262
/// compiler pages and guarded native staging receipts.
6363
pub const SOURCE_SETTINGS: &str = "sourceSettings";
6464
/// `ui`: tool windows with text, web, or plugin view content, plugin views in
65-
/// settings regions, and commands. Version 1 adds the tool picker: a settings
66-
/// region's tool row with `choose`.
65+
/// settings regions, and commands.
6766
pub const UI: &str = "ui";
6867
/// Declarative build detection, models, and command plans.
6968
/// Version 1 adds command-based test discovery. Version 2 adds registry
@@ -151,7 +150,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[
151150
(SOURCE_SETTINGS, &[0, 1]),
152151
(TOOL_DEFINITIONS, &[0, 1]),
153152
(TOOLCHAIN_PROVIDERS, &[0]),
154-
(UI, &[0, 1]),
153+
(UI, &[0]),
155154
(VCS_PROVIDERS, &[0]),
156155
];
157156

‎rust/crates/plugin-ui/src/lib.rs‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ pub struct Context<'a> {
7373
pub actions: &'a [SettingAction],
7474
/// Tools the plugin defines or requires; tool rows name them.
7575
pub tools: &'a BTreeSet<String>,
76-
/// The `ui` capability version the manifest declares (`requires.ui`); a
77-
/// tool row with `choose` needs version 1.
78-
pub ui_version: u32,
7976
}
8077

8178
/// Checks a complete view against the vocabulary, the budgets and the
@@ -166,7 +163,6 @@ mod tests {
166163
settings: &self.settings,
167164
actions: &self.actions,
168165
tools: &self.tools,
169-
ui_version: 0,
170166
}
171167
}
172168
}
@@ -310,30 +306,22 @@ mod tests {
310306
}
311307

312308
#[test]
313-
fn a_tool_picker_needs_ui_1() {
309+
fn a_tool_row_can_be_a_picker_in_a_settings_region() {
314310
let fixture = Fixture::new();
311+
let settings = fixture.context(Surface::Settings);
315312
let picker = json!([{"type":"tool","tool":"maven","choose":true}]);
316-
assert_eq!(
317-
field(&fixture.context(Surface::Settings), picker.clone()),
318-
"view[0].choose"
319-
);
320-
let settings = Context {
321-
ui_version: 1,
322-
..fixture.context(Surface::Settings)
323-
};
324-
check(&settings, &picker).expect("tool picker with ui 1");
313+
check(&settings, &picker).expect("tool picker");
325314
assert_eq!(
326315
field(
327316
&settings,
328317
json!([{"type":"tool","tool":"maven","choose":"yes"}])
329318
),
330319
"view[0].choose"
331320
);
332-
let tool_window = Context {
333-
ui_version: 1,
334-
..fixture.context(Surface::ToolWindow)
335-
};
336-
assert_eq!(field(&tool_window, picker), "view[0]");
321+
assert_eq!(
322+
field(&fixture.context(Surface::ToolWindow), picker),
323+
"view[0]"
324+
);
337325
}
338326

339327
#[test]

‎rust/crates/plugin-ui/src/tree.rs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ impl<'c> Walk<'c> {
171171
));
172172
}
173173
boolean(map, path, "choose")?;
174-
if map.contains_key("choose") && self.context.ui_version < 1 {
175-
return Err(fail(
176-
at(path, "choose"),
177-
"A tool row with choose needs ui 1 in requires.",
178-
));
179-
}
180174
Ok(())
181175
}
182176
"tree" => self.tree(value, path),

‎shared/plugins/contract/v1/README.md‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5501,8 +5501,7 @@ holds golden `plugins.ui.applyResult` cases.
55015501
`view: {function}` names a private [plugin function](#plugin-functions) of the
55025502
plugin's own [backend](#plugin-backend) (letters and digits in dot-separated
55035503
segments, at most 128 characters). A manifest with a view needs `backend`,
5504-
`requires.ui` (0, or 1 for a [tool picker](#tool-rows-and-pickers)), the
5505-
`ui.contribute` permission, and, for a settings region,
5504+
`requires.ui: 0`, the `ui.contribute` permission, and, for a settings region,
55065505
`requires.settings: 0`. A tool window still declares `onView:<id>`; a settings
55075506
region starts the backend when its page opens. Results are described by
55085507
[`plugin-ui.schema.json`](plugin-ui.schema.json); the rules JSON Schema cannot
@@ -5621,8 +5620,7 @@ scope (the global settings, or the project of a project window): the version,
56215620
the home, and the reason when nothing resolves. Pressing it opens the tool on
56225621
the host's toolchain page.
56235622

5624-
With `choose: true`, which needs `requires.ui: 1`, the row is also the tool's
5625-
picker, like an interpreter menu: pressing it opens the host's choices for the
5623+
With `choose: true`, the row is also the tool's picker, like an interpreter menu: pressing it opens the host's choices for the
56265624
tool in that scope, the same choices the toolchain page lists. They are the
56275625
automatic choice, every installation the host found or the user added, with
56285626
its version and source, and adding an installation directory, plus a way to
@@ -5631,9 +5629,10 @@ tool, which Apply commits and Cancel discards, as on the toolchain page; the
56315629
row shows the pending choice until then. A region never stores the choice
56325630
itself; once applied, the plugin's launches and runs receive the chosen
56335631
installation as they receive any resolved tool (see
5634-
[Tool references](#tool-references)). A plugin that writes `choose`
5635-
with `requires.ui: 0` has the whole result refused with `plugin.ui.invalidView`
5636-
at `choose`.
5632+
[Tool references](#tool-references)). `choose` is a boolean; any other value
5633+
refuses the whole result with `plugin.ui.invalidView` at `choose`. A host whose
5634+
Core predates `choose` refuses a result that writes it the same way, so a plugin
5635+
writes it once a desktop release that includes it is out.
56375636

56385637
#### Canvas
56395638

‎shared/plugins/contract/v1/fixtures/ui/view-results.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@
121121
"expected": {"status": "rejected", "field": "result.view[0]"}
122122
},
123123
{
124-
"name": "a tool picker needs ui 1, which this manifest does not declare",
124+
"name": "a settings region's tool row can be the tool's picker",
125125
"surface": {"settingRegionID": "overview"},
126126
"result": {"view": [{"type": "tool", "tool": "node", "choose": true}]},
127+
"expected": {"status": "ok", "changed": true, "view": "result.view"}
128+
},
129+
{
130+
"name": "choose on a tool row is a boolean",
131+
"surface": {"settingRegionID": "overview"},
132+
"result": {"view": [{"type": "tool", "tool": "node", "choose": "yes"}]},
127133
"expected": {"status": "rejected", "field": "result.view[0].choose"}
128134
},
129135
{

‎shared/plugins/contract/v1/plugin-manifest.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"toolchainProviders": { "enum": [0] },
5555
"keymapImportProviders": { "enum": [0] },
5656
"pluginFunctions": { "description": "Required exactly when pluginFunctions is present: functions this plugin's backend exports to other plugins, and exported functions it calls. Needs backend.", "enum": [0] },
57-
"ui": { "description": "Required exactly when ui is present or a settings region declares a view. Covers tool windows with text, web content, or a plugin view, settings-region views, and backend-only commands. Version 1 adds the tool picker (choose on a settings region's tool row).", "enum": [0, 1] },
57+
"ui": { "description": "Required exactly when ui is present or a settings region declares a view. Covers tool windows with text, web content, or a plugin view, settings-region views, and backend-only commands.", "enum": [0] },
5858
"vcsProviders": { "description": "Required exactly when vcsProviders is non-empty. The provider protocol itself is negotiated in initialize (https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/contracts/vcs-provider-v1.md).", "enum": [0] }
5959
}
6060
},

‎shared/plugins/contract/v1/plugin-ui.schema.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@
304304
}
305305
},
306306
"toolRow": {
307-
"description": "settings only: the host's row for a tool this plugin defines (toolDefinitions) or requires (requiresTools): its resolved version and path, as the toolchain pages draw it. With choose (requires.ui 1) the row is also the tool's picker.",
307+
"description": "settings only: the host's row for a tool this plugin defines (toolDefinitions) or requires (requiresTools): its resolved version and path, as the toolchain pages draw it. With choose the row is also the tool's picker.",
308308
"type": "object",
309309
"additionalProperties": false,
310310
"required": ["type", "tool"],
311311
"properties": {
312312
"type": { "const": "tool" },
313313
"id": { "$ref": "#/$defs/id" },
314314
"tool": { "type": "string", "minLength": 1, "maxLength": 128 },
315-
"choose": { "description": "requires.ui 1: the row opens the host's choices for the tool in the settings page's scope: the automatic choice, every installation the host found or the user added, and adding a directory. A choice edits the settings window's draft, which Apply commits and Cancel discards, as on the toolchain page.", "type": "boolean" }
315+
"choose": { "description": "The row opens the host's choices for the tool in the settings page's scope: the automatic choice, every installation the host found or the user added, and adding a directory. A choice edits the settings window's draft, which Apply commits and Cancel discards, as on the toolchain page.", "type": "boolean" }
316316
}
317317
},
318318
"tree": {

‎shared/plugins/reference/capabilities-and-versions.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https
4949
| `sourceSettings` `0` | 真实配置来源表单、编译器页、私有暂存与显式保存 | ✅ | ✅ | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) |
5050
| `sourceSettings` `1` | 在 `0` 之上加:模块列表布局 `sidebar`(来源可用 `parent` 嵌套)、字段 `section`(标签页或小标题)、有序类型化条目列表 `entryList`(添加菜单、文件/目录选择器、可选项、按条目的属性列) | ✅ | ✅ | [Entry lists](../contract/v1/README.md#source-backed-settings-editors) |
5151
| `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui):文本、[包内网页](../contract/v1/README.md#web-content)和[插件视图](../contract/v1/README.md#plugin-views)的工具窗口、设置区域里的插件视图、命令,以及[不打开工具窗口的后端命令](../contract/v1/README.md#backend-only-commands);视图函数的结果由 Core 命令 `plugins.ui.applyResult` 校验,形状见 [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [界面](domains/ui.md) |
52-
| `ui` `1` | 在 `0` 之上加[工具选择器](../contract/v1/README.md#tool-rows-and-pickers):设置区域的 `tool` 行写 `choose: true` 时,按下打开宿主为该工具列出的选项(自动、已发现或已添加的安装、添加目录),选择写入设置窗口草稿,按“应用”生效 | ✅ | 配套宿主接入后声明 | [Tool rows and pickers](../contract/v1/README.md#tool-rows-and-pickers) |
5352
| `buildSystems` `0` | 不带 `provider` 的 [`buildSystems[]`](../contract/v1/README.md#build-systems):检测、选项、项目模型、任务、运行入口、测试、诊断、依赖、同步和[声明式项目准备](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [声明式构建系统](domains/build-systems.md) |
5453
| `buildSystems` `1` | 新增 [命令式测试发现](../contract/v1/README.md#test-discovery),复用声明的构建工具和测试选择器 | ✅ | 待宿主声明 | [声明式构建系统](domains/build-systems.md) |
5554
| `buildSystems` `2` | 构建提供者的应用运行声明可使用 `debug.configurationType`,包括按源文件发现的入口 | ✅ | 待宿主接入 | [构建提供者](domains/build-providers.md) |
@@ -168,7 +167,6 @@ Each row is one capability. `requires` lists **exactly** the capabilities a mani
168167
| `sourceSettings` `0` | Native source forms, compiler pages, private staging and explicit Save | ✅ | ✅ | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) |
169168
| `sourceSettings` `1` | Adds to `0`: the `sidebar` module-list layout with sources nested by `parent`, field `section`s shown as tabs or subheadings, and ordered typed `entryList`s with an add menu, file and folder pickers, offered choices and per-entry attribute columns | ✅ | ✅ | [Entry lists](../contract/v1/README.md#source-backed-settings-editors) |
170169
| `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui): text, [web](../contract/v1/README.md#web-content), and [plugin view](../contract/v1/README.md#plugin-views) tool windows, plugin views in settings regions, commands, and [backend-only commands](../contract/v1/README.md#backend-only-commands) without a tool window; the Core command `plugins.ui.applyResult` checks view function results, shaped as in [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [UI](domains/ui.md) |
171-
| `ui` `1` | Extends `0` with the [tool picker](../contract/v1/README.md#tool-rows-and-pickers): a settings region's `tool` row with `choose: true` opens the host's choices for the tool (automatic, found or added installations, adding a directory); a choice edits the settings window's draft, which Apply commits | ✅ | Declared with companion host integration | [Tool rows and pickers](../contract/v1/README.md#tool-rows-and-pickers) |
172170
| `buildSystems` `0` | [`buildSystems[]`](../contract/v1/README.md#build-systems) without `provider`: detection, options, project model, tasks, run entries, tests, diagnostics, dependencies, sync, and [declarative preparation](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [Declarative build systems](domains/build-systems.md) |
173171
| `buildSystems` `1` | Adds [command test discovery](../contract/v1/README.md#test-discovery) using the declared build tool and the existing test selectors | ✅ | Pending host declaration | [Declarative build systems](domains/build-systems.md) |
174172
| `buildSystems` `2` | Allows build provider application runs to declare `debug.configurationType`, including source entrypoints | ✅ | Pending host integration | [Build providers](domains/build-providers.md) |

0 commit comments

Comments
 (0)