From dd2e4e53925097f8ffa777d85edee424c64d23d7 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 23 Nov 2026 00:08:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin-ui):=20=E6=92=A4=E5=9B=9E=20ui=201?= =?UTF-8?q?=EF=BC=8C=E5=B7=A5=E5=85=B7=E8=A1=8C=E7=9A=84=20choose=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20ui=200=20=E5=86=85=E7=9A=84=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/crates/plugin-manifest/src/views.rs | 21 +++------------ rust/crates/plugin-model/src/capabilities.rs | 5 ++-- rust/crates/plugin-ui/src/lib.rs | 26 +++++-------------- rust/crates/plugin-ui/src/tree.rs | 6 ----- shared/plugins/contract/v1/README.md | 13 +++++----- .../contract/v1/fixtures/ui/view-results.json | 8 +++++- .../contract/v1/plugin-manifest.schema.json | 2 +- .../plugins/contract/v1/plugin-ui.schema.json | 4 +-- .../reference/capabilities-and-versions.md | 2 -- shared/plugins/reference/domains/settings.md | 4 +-- shared/plugins/reference/domains/ui.md | 8 +++--- .../plugins/reference/protocol-changelog.md | 4 +-- 12 files changed, 36 insertions(+), 67 deletions(-) diff --git a/rust/crates/plugin-manifest/src/views.rs b/rust/crates/plugin-manifest/src/views.rs index 745a1012..0f0438d0 100644 --- a/rust/crates/plugin-manifest/src/views.rs +++ b/rust/crates/plugin-manifest/src/views.rs @@ -9,7 +9,7 @@ //! same results; the host only renders. use crate::{validate_manifest_value, DeclarativePluginManifest}; -use lithe_plugin_model::{capabilities, decode_payload, outcome, PluginRejection, Validation}; +use lithe_plugin_model::{decode_payload, outcome, PluginRejection, Validation}; use lithe_plugin_ui::{Context, Surface, INVALID_VIEW}; use lithe_protocol::CoreError; use serde::Deserialize; @@ -55,7 +55,6 @@ pub fn apply_result_command(payload: Value) -> Result { settings: &manifest.settings, actions: &manifest.setting_actions, tools: &tools, - ui_version: manifest.capability_version(capabilities::UI), }; let (view, changed) = lithe_plugin_ui::apply(&context, payload.view.as_ref(), &payload.result)?; @@ -198,23 +197,9 @@ mod tests { } #[test] - fn a_tool_picker_follows_the_declared_ui_version() { + fn a_settings_region_accepts_a_tool_picker() { let picker = json!({"view": [{"type": "tool", "tool": "node", "choose": true}]}); - let outcome = apply(json!({"settingRegionID": "overview"}), None, picker.clone()); - assert_eq!(outcome["status"], "rejected", "{outcome}"); - assert_eq!( - outcome["error"]["field"], "result.view[0].choose", - "{outcome}" - ); - - let mut manifest = manifest(); - manifest["requires"]["ui"] = json!(1); - let outcome = apply_result_command(json!({ - "manifest": manifest, - "surface": {"settingRegionID": "overview"}, - "result": picker, - })) - .expect("outcome"); + let outcome = apply(json!({"settingRegionID": "overview"}), None, picker); assert_eq!(outcome["status"], "ok", "{outcome}"); } diff --git a/rust/crates/plugin-model/src/capabilities.rs b/rust/crates/plugin-model/src/capabilities.rs index 9bee5fd8..e2f13787 100644 --- a/rust/crates/plugin-model/src/capabilities.rs +++ b/rust/crates/plugin-model/src/capabilities.rs @@ -62,8 +62,7 @@ pub const SETTINGS: &str = "settings"; /// compiler pages and guarded native staging receipts. pub const SOURCE_SETTINGS: &str = "sourceSettings"; /// `ui`: tool windows with text, web, or plugin view content, plugin views in -/// settings regions, and commands. Version 1 adds the tool picker: a settings -/// region's tool row with `choose`. +/// settings regions, and commands. pub const UI: &str = "ui"; /// Declarative build detection, models, and command plans. /// Version 1 adds command-based test discovery. Version 2 adds registry @@ -151,7 +150,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[ (SOURCE_SETTINGS, &[0, 1]), (TOOL_DEFINITIONS, &[0, 1]), (TOOLCHAIN_PROVIDERS, &[0]), - (UI, &[0, 1]), + (UI, &[0]), (VCS_PROVIDERS, &[0]), ]; diff --git a/rust/crates/plugin-ui/src/lib.rs b/rust/crates/plugin-ui/src/lib.rs index c2a5e1d2..9d696311 100644 --- a/rust/crates/plugin-ui/src/lib.rs +++ b/rust/crates/plugin-ui/src/lib.rs @@ -73,9 +73,6 @@ pub struct Context<'a> { pub actions: &'a [SettingAction], /// Tools the plugin defines or requires; tool rows name them. pub tools: &'a BTreeSet, - /// The `ui` capability version the manifest declares (`requires.ui`); a - /// tool row with `choose` needs version 1. - pub ui_version: u32, } /// Checks a complete view against the vocabulary, the budgets and the @@ -166,7 +163,6 @@ mod tests { settings: &self.settings, actions: &self.actions, tools: &self.tools, - ui_version: 0, } } } @@ -310,18 +306,11 @@ mod tests { } #[test] - fn a_tool_picker_needs_ui_1() { + fn a_tool_row_can_be_a_picker_in_a_settings_region() { let fixture = Fixture::new(); + let settings = fixture.context(Surface::Settings); let picker = json!([{"type":"tool","tool":"maven","choose":true}]); - assert_eq!( - field(&fixture.context(Surface::Settings), picker.clone()), - "view[0].choose" - ); - let settings = Context { - ui_version: 1, - ..fixture.context(Surface::Settings) - }; - check(&settings, &picker).expect("tool picker with ui 1"); + check(&settings, &picker).expect("tool picker"); assert_eq!( field( &settings, @@ -329,11 +318,10 @@ mod tests { ), "view[0].choose" ); - let tool_window = Context { - ui_version: 1, - ..fixture.context(Surface::ToolWindow) - }; - assert_eq!(field(&tool_window, picker), "view[0]"); + assert_eq!( + field(&fixture.context(Surface::ToolWindow), picker), + "view[0]" + ); } #[test] diff --git a/rust/crates/plugin-ui/src/tree.rs b/rust/crates/plugin-ui/src/tree.rs index 18dce3cf..2ba0a5c0 100644 --- a/rust/crates/plugin-ui/src/tree.rs +++ b/rust/crates/plugin-ui/src/tree.rs @@ -171,12 +171,6 @@ impl<'c> Walk<'c> { )); } boolean(map, path, "choose")?; - if map.contains_key("choose") && self.context.ui_version < 1 { - return Err(fail( - at(path, "choose"), - "A tool row with choose needs ui 1 in requires.", - )); - } Ok(()) } "tree" => self.tree(value, path), diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index e9c195ad..834aa09d 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -5501,8 +5501,7 @@ holds golden `plugins.ui.applyResult` cases. `view: {function}` names a private [plugin function](#plugin-functions) of the plugin's own [backend](#plugin-backend) (letters and digits in dot-separated segments, at most 128 characters). A manifest with a view needs `backend`, -`requires.ui` (0, or 1 for a [tool picker](#tool-rows-and-pickers)), the -`ui.contribute` permission, and, for a settings region, +`requires.ui: 0`, the `ui.contribute` permission, and, for a settings region, `requires.settings: 0`. A tool window still declares `onView:`; a settings region starts the backend when its page opens. Results are described by [`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, the home, and the reason when nothing resolves. Pressing it opens the tool on the host's toolchain page. -With `choose: true`, which needs `requires.ui: 1`, the row is also the tool's -picker, like an interpreter menu: pressing it opens the host's choices for the +With `choose: true`, the row is also the tool's picker, like an interpreter menu: pressing it opens the host's choices for the tool in that scope, the same choices the toolchain page lists. They are the automatic choice, every installation the host found or the user added, with 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 row shows the pending choice until then. A region never stores the choice itself; once applied, the plugin's launches and runs receive the chosen installation as they receive any resolved tool (see -[Tool references](#tool-references)). A plugin that writes `choose` -with `requires.ui: 0` has the whole result refused with `plugin.ui.invalidView` -at `choose`. +[Tool references](#tool-references)). `choose` is a boolean; any other value +refuses the whole result with `plugin.ui.invalidView` at `choose`. A host whose +Core predates `choose` refuses a result that writes it the same way, so a plugin +writes it once a desktop release that includes it is out. #### Canvas diff --git a/shared/plugins/contract/v1/fixtures/ui/view-results.json b/shared/plugins/contract/v1/fixtures/ui/view-results.json index 0ecc4dcf..257d143f 100644 --- a/shared/plugins/contract/v1/fixtures/ui/view-results.json +++ b/shared/plugins/contract/v1/fixtures/ui/view-results.json @@ -121,9 +121,15 @@ "expected": {"status": "rejected", "field": "result.view[0]"} }, { - "name": "a tool picker needs ui 1, which this manifest does not declare", + "name": "a settings region's tool row can be the tool's picker", "surface": {"settingRegionID": "overview"}, "result": {"view": [{"type": "tool", "tool": "node", "choose": true}]}, + "expected": {"status": "ok", "changed": true, "view": "result.view"} + }, + { + "name": "choose on a tool row is a boolean", + "surface": {"settingRegionID": "overview"}, + "result": {"view": [{"type": "tool", "tool": "node", "choose": "yes"}]}, "expected": {"status": "rejected", "field": "result.view[0].choose"} }, { diff --git a/shared/plugins/contract/v1/plugin-manifest.schema.json b/shared/plugins/contract/v1/plugin-manifest.schema.json index a06bee7d..d681c166 100644 --- a/shared/plugins/contract/v1/plugin-manifest.schema.json +++ b/shared/plugins/contract/v1/plugin-manifest.schema.json @@ -54,7 +54,7 @@ "toolchainProviders": { "enum": [0] }, "keymapImportProviders": { "enum": [0] }, "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] }, - "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] }, + "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] }, "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] } } }, diff --git a/shared/plugins/contract/v1/plugin-ui.schema.json b/shared/plugins/contract/v1/plugin-ui.schema.json index a556f6af..64de4bd0 100644 --- a/shared/plugins/contract/v1/plugin-ui.schema.json +++ b/shared/plugins/contract/v1/plugin-ui.schema.json @@ -304,7 +304,7 @@ } }, "toolRow": { - "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.", + "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.", "type": "object", "additionalProperties": false, "required": ["type", "tool"], @@ -312,7 +312,7 @@ "type": { "const": "tool" }, "id": { "$ref": "#/$defs/id" }, "tool": { "type": "string", "minLength": 1, "maxLength": 128 }, - "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" } + "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" } } }, "tree": { diff --git a/shared/plugins/reference/capabilities-and-versions.md b/shared/plugins/reference/capabilities-and-versions.md index 423ddf30..b2ac6d54 100644 --- a/shared/plugins/reference/capabilities-and-versions.md +++ b/shared/plugins/reference/capabilities-and-versions.md @@ -49,7 +49,6 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https | `sourceSettings` `0` | 真实配置来源表单、编译器页、私有暂存与显式保存 | ✅ | ✅ | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) | | `sourceSettings` `1` | 在 `0` 之上加:模块列表布局 `sidebar`(来源可用 `parent` 嵌套)、字段 `section`(标签页或小标题)、有序类型化条目列表 `entryList`(添加菜单、文件/目录选择器、可选项、按条目的属性列) | ✅ | ✅ | [Entry lists](../contract/v1/README.md#source-backed-settings-editors) | | `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) | -| `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) | | `buildSystems` `0` | 不带 `provider` 的 [`buildSystems[]`](../contract/v1/README.md#build-systems):检测、选项、项目模型、任务、运行入口、测试、诊断、依赖、同步和[声明式项目准备](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [声明式构建系统](domains/build-systems.md) | | `buildSystems` `1` | 新增 [命令式测试发现](../contract/v1/README.md#test-discovery),复用声明的构建工具和测试选择器 | ✅ | 待宿主声明 | [声明式构建系统](domains/build-systems.md) | | `buildSystems` `2` | 构建提供者的应用运行声明可使用 `debug.configurationType`,包括按源文件发现的入口 | ✅ | 待宿主接入 | [构建提供者](domains/build-providers.md) | @@ -168,7 +167,6 @@ Each row is one capability. `requires` lists **exactly** the capabilities a mani | `sourceSettings` `0` | Native source forms, compiler pages, private staging and explicit Save | ✅ | ✅ | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) | | `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) | | `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) | -| `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) | | `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) | | `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) | | `buildSystems` `2` | Allows build provider application runs to declare `debug.configurationType`, including source entrypoints | ✅ | Pending host integration | [Build providers](domains/build-providers.md) | diff --git a/shared/plugins/reference/domains/settings.md b/shared/plugins/reference/domains/settings.md index 6ef4dcf5..0c745b6f 100644 --- a/shared/plugins/reference/domains/settings.md +++ b/shared/plugins/reference/domains/settings.md @@ -84,7 +84,7 @@ ``` - `keywords`:1–32 个,忽略大小写互不相同,每个 1–64 个字符、不换行、首尾没有空白。设置搜索除了页面标题和声明的行,也按这些词找到页面,并打开到这个插件的部分。 -- `view`:`{function}`,插件后端的视图函数,画在页面标题和插件声明的行之间。视图可以放宿主控件、画布,也可以用绑定控件编辑本插件的设置(和声明的行改的是同一份草稿)、放本插件按钮和显示本插件工具解析结果的工具行,但不能放树。工具行带 `choose` 时同时是该工具的选择器,需要 `ui` 1。需要 `backend`、`ui` 0 和 `ui.contribute` 权限;页面打开时宿主启动后端。 +- `view`:`{function}`,插件后端的视图函数,画在页面标题和插件声明的行之间。视图可以放宿主控件、画布,也可以用绑定控件编辑本插件的设置(和声明的行改的是同一份草稿)、放本插件按钮和显示本插件工具解析结果的工具行,但不能放树。工具行带 `choose` 时同时是该工具的[选择器](../../contract/v1/README.md#tool-rows-and-pickers),旧宿主会拒绝带它的视图,要等包含它的桌面端发布后再写。需要 `backend`、`ui` 0 和 `ui.contribute` 权限;页面打开时宿主启动后端。 - 只写关键词的区域不需要后端。区域本身不保存任何值。声明区域也算使用了 `settings`。 - 区域里的画布要跟随窗口宽度时,按事件里的 `width` 排版:`viewBox` 的宽度就设成 `width`,`height` 取在这个宽度下画出来需要的高度,并在画布的 `on` 里写 `resize`。用户调整窗口大小、停下 400 ms 后,宿主发 `resize` 和新的 `width`,插件按新宽度返回重新排版的场景,场景始终一个单位一个点。不写 `pan` 时,宿主在答复到达前按[画布](../../contract/v1/README.md#canvas)的规则显示整个 `viewBox`,不会放大到裁掉下半部分。事件里没有 `width` 的旧宿主不发 `resize`,也可能拒绝写了它的画布,所以这时不写 `resize`,按固定宽度排版:桌面端窗口最小时,语言页的区域约 610 点宽,构建系统页和编译器页右侧详情里的区域约 340 点宽。 @@ -237,7 +237,7 @@ Content that declared rows cannot draw goes in `settingRegions` (at most 16, uni ``` - `keywords`: 1–32, distinct ignoring case, each 1–64 characters without line breaks or surrounding spaces. Settings search finds the page by them in addition to the page title and the declared rows, and opens the page at this plugin's part. -- `view`: `{function}`, a view function of the plugin's backend, drawn between the page header and the plugin's declared rows. The view may hold host controls and canvases, edit the plugin's own settings through bound controls (the same draft the declared rows edit), show the plugin's buttons and tool rows with how its tools resolve, but no tree. A tool row with `choose` is also the tool's picker and needs `ui` 1. It needs `backend`, `ui` 0, and the `ui.contribute` permission; the host starts the backend when the page opens. +- `view`: `{function}`, a view function of the plugin's backend, drawn between the page header and the plugin's declared rows. The view may hold host controls and canvases, edit the plugin's own settings through bound controls (the same draft the declared rows edit), show the plugin's buttons and tool rows with how its tools resolve, but no tree. A tool row with `choose` is also the tool's [picker](../../contract/v1/README.md#tool-rows-and-pickers); an older host refuses a view that writes it, so write it once a desktop release that includes it is out. It needs `backend`, `ui` 0, and the `ui.contribute` permission; the host starts the backend when the page opens. - A region with keywords only needs no backend. A region stores no values. Declaring regions counts as using `settings`. - A canvas in a region that follows the window lays itself out for the event's `width`: its `viewBox` is `width` wide, its `height` is what the scene needs at that width, and its `on` lists `resize`. Once the user stops resizing the window for 400 ms, the host sends `resize` with the new `width`, and the plugin answers the scene laid out again, so it always draws at one point a unit. Without `pan`, the host shows the whole `viewBox` until the answer arrives (see [canvas](../../contract/v1/README.md#canvas)), never scaled up so far that its bottom is cut off. An older host sends no `width` and no `resize` and may refuse a canvas that lists it, so without `width` a plugin leaves `resize` out and lays the scene out for a fixed width: in Lithe desktop's smallest window a region is about 610 points wide on a language page and about 340 in the detail pane of a build system or compiler page. diff --git a/shared/plugins/reference/domains/ui.md b/shared/plugins/reference/domains/ui.md index 5d113d53..d358f880 100644 --- a/shared/plugins/reference/domains/ui.md +++ b/shared/plugins/reference/domains/ui.md @@ -9,7 +9,7 @@ | 项目 | 内容 | | --- | --- | | 清单字段 | `ui.toolWindows`、`ui.commands`(可选 `icon`) | -| 能力版本 | `ui` 0;`ui` 1 加上设置区域里的工具选择器(工具行的 `choose`)。插件视图的结果形状见 [`plugin-ui.schema.json`](../../contract/v1/plugin-ui.schema.json),不另带版本号。见[版本对照](../capabilities-and-versions.md#能力版本requires) | +| 能力版本 | `ui` 0;插件视图的结果形状见 [`plugin-ui.schema.json`](../../contract/v1/plugin-ui.schema.json),不另带版本号。见[版本对照](../capabilities-and-versions.md#能力版本requires) | | 协议 | 网页通过 `functions.*` 调用[插件后端](backend.md);插件视图由宿主经 `lithe/function/invoke` 按事件调用视图函数,每个结果交给 Core 命令 `plugins.ui.applyResult` 校验;没有窗口的命令通过 `litheFunctions` 0 的 `lithe/host/commands/didRun` 通知后端 | | API 编号 | API-02、03、13、14、17,见 [API 总表](../api-catalog.md#现在能用的-api) | | 权限 | `ui.contribute`;网页加 `ui.web`;没有窗口的命令加 `backend.launch`;后端弹出消息用 `window.messages` | @@ -21,7 +21,7 @@ - **工具窗口**:1–64 个。每个窗口有稳定的 `id`、`title`、初始 `placement`(`left`、`bottom` 或 `right`)、整数 `order`(默认 0),以及且只能有一种内容:`text`(纯文本)、`web`(包内网页)或 `view`(插件视图)。 - **命令**:最多 128 个,`placements` 非空,取值为 `commandPalette`、`toolbar`、`menu`。带 `toolWindowID` 的命令打开同一插件的一个窗口;省略 `toolWindowID` 的命令只通知后端,此时 `toolWindows` 可以为空或省略。 - **网页窗口**:`web.entry` 是包内 `.html` 文件的相对路径,需要 `ui.web` 权限。网页的桥接和生命周期见[网页内容](../../contract/v1/README.md#web-content)。 -- **插件视图**:`view.function` 是插件后端的私有函数,清单需要 `backend`、`ui` 0 和 `ui.contribute` 权限。宿主按事件(`open`、`click`、`change`、`select`、`viewport` 等)调用它,为某个工作区显示的视图调用时带着该窗口的工作区上下文,函数返回整个视图或按节点 ID 的补丁。一个视图最多 512 个界面节点、深度 16、2000 个树项和 8 个画布,每个画布最多 2000 个节点;超出预算或违反界面规则的结果整体拒绝,宿主保留上一版视图并显示错误和重试。工具窗口里不能绑定设置,设置区域里不能放树。设置区域里的工具行带 `choose` 时是该工具的选择器,需要 `ui` 1。官方 SDK 都用 `view(id, handler)`(Go 是 `View(id, handler)`)声明视图函数([Node.js](../../sdk/node/README.md#plugin-views)、[Rust](../../sdk/rust/README.md#plugin-views)、[Go](../../sdk/go/README.md#plugin-views)、[Java](../../sdk/java/README.md#plugin-views))。 +- **插件视图**:`view.function` 是插件后端的私有函数,清单需要 `backend`、`ui` 0 和 `ui.contribute` 权限。宿主按事件(`open`、`click`、`change`、`select`、`viewport` 等)调用它,为某个工作区显示的视图调用时带着该窗口的工作区上下文,函数返回整个视图或按节点 ID 的补丁。一个视图最多 512 个界面节点、深度 16、2000 个树项和 8 个画布,每个画布最多 2000 个节点;超出预算或违反界面规则的结果整体拒绝,宿主保留上一版视图并显示错误和重试。工具窗口里不能绑定设置,设置区域里不能放树。设置区域里的工具行带 `choose` 时是该工具的[选择器](../../contract/v1/README.md#tool-rows-and-pickers)。官方 SDK 都用 `view(id, handler)`(Go 是 `View(id, handler)`)声明视图函数([Node.js](../../sdk/node/README.md#plugin-views)、[Rust](../../sdk/rust/README.md#plugin-views)、[Go](../../sdk/go/README.md#plugin-views)、[Java](../../sdk/java/README.md#plugin-views))。 - **没有窗口的命令**:需要 `backend`(清单 `requires`)、`ui.contribute` 和 `backend.launch` 权限,以及 `onCommand:` 激活事件。`commands/didRun` 只是事件,不代表命令的业务动作成功。 - 所有 ID 以插件 ID 加点开头。标题最多 256 字节,窗口文本最多 65536 字节,按原样显示,不作为 HTML 或脚本执行。 @@ -65,7 +65,7 @@ A plugin can place tool windows and commands in the workbench. The window shell | Item | Value | | --- | --- | | Manifest fields | `ui.toolWindows`, `ui.commands` (optional `icon`) | -| Capability versions | `ui` 0; `ui` 1 adds the tool picker in settings regions (`choose` on a tool row). The shape of plugin view results is [`plugin-ui.schema.json`](../../contract/v1/plugin-ui.schema.json), which carries no version of its own. See [versions](../capabilities-and-versions.md#capability-versions-requires) | +| Capability versions | `ui` 0; the shape of plugin view results is [`plugin-ui.schema.json`](../../contract/v1/plugin-ui.schema.json), which carries no version of its own. See [versions](../capabilities-and-versions.md#capability-versions-requires) | | Protocols | Pages call the [plugin backend](backend.md) through `functions.*`; for a plugin view the host calls the view function through `lithe/function/invoke` once per event and passes each result to the Core command `plugins.ui.applyResult`; a command without a window notifies the backend with `lithe/host/commands/didRun` (`litheFunctions` 0) | | API IDs | API-02, 03, 13, 14, 17; see the [API catalog](../api-catalog.md#apis-usable-now) | | Permissions | `ui.contribute`; `ui.web` for web pages; `backend.launch` for a command without a window; `window.messages` for messages shown by the backend | @@ -77,7 +77,7 @@ A plugin can place tool windows and commands in the workbench. The window shell - **Tool windows**: 1–64. Each has a stable `id`, `title`, initial `placement` (`left`, `bottom`, or `right`), integer `order` (default 0), and exactly one kind of content: `text` (plain text), `web` (a packaged page), or `view` (a plugin view). - **Commands**: up to 128. `placements` is nonempty and takes `commandPalette`, `toolbar`, or `menu`. A command with `toolWindowID` opens one of the same plugin's windows. A command without `toolWindowID` only notifies the backend; `toolWindows` may then be empty or omitted. - **Web windows**: `web.entry` is a package-relative `.html` path and requires the `ui.web` permission. The bridge and lifecycle are in [Web content](../../contract/v1/README.md#web-content). -- **Plugin views**: `view.function` is a private function of the plugin's backend; the manifest needs `backend`, `ui` 0, and the `ui.contribute` permission. The host calls it once per event (`open`, `click`, `change`, `select`, `viewport`, and so on), with the window's workspace context when the view is shown for a workspace, and it returns a whole view or patches by node ID. A view holds at most 512 UI nodes, depth 16, 2000 tree items and 8 canvases of at most 2000 nodes each; a result over budget or against a surface rule is refused whole, and the host keeps the last view with an error and Retry. A tool window cannot bind settings, and a settings region cannot show a tree. A tool row with `choose` in a settings region is the tool's picker and needs `ui` 1. All official SDKs declare a view function with `view(id, handler)` (`View(id, handler)` in Go) ([Node.js](../../sdk/node/README.md#plugin-views), [Rust](../../sdk/rust/README.md#plugin-views), [Go](../../sdk/go/README.md#plugin-views), [Java](../../sdk/java/README.md#plugin-views)). +- **Plugin views**: `view.function` is a private function of the plugin's backend; the manifest needs `backend`, `ui` 0, and the `ui.contribute` permission. The host calls it once per event (`open`, `click`, `change`, `select`, `viewport`, and so on), with the window's workspace context when the view is shown for a workspace, and it returns a whole view or patches by node ID. A view holds at most 512 UI nodes, depth 16, 2000 tree items and 8 canvases of at most 2000 nodes each; a result over budget or against a surface rule is refused whole, and the host keeps the last view with an error and Retry. A tool window cannot bind settings, and a settings region cannot show a tree. A tool row with `choose` in a settings region is the tool's [picker](../../contract/v1/README.md#tool-rows-and-pickers). All official SDKs declare a view function with `view(id, handler)` (`View(id, handler)` in Go) ([Node.js](../../sdk/node/README.md#plugin-views), [Rust](../../sdk/rust/README.md#plugin-views), [Go](../../sdk/go/README.md#plugin-views), [Java](../../sdk/java/README.md#plugin-views)). - **Commands without a window**: require `backend` (in `requires`), `ui.contribute`, and `backend.launch`, plus the `onCommand:` activation event. `commands/didRun` is an event; it does not show that the command's business action succeeded. - Every ID starts with the plugin ID and a dot. Titles are at most 256 bytes and window text at most 65536 bytes; text is shown literally and never evaluated as HTML or script. diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index d524afdf..54629d88 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,7 +14,8 @@ ## 待合入 -- [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174),[@xiaoyumuxi](https://github.com/xiaoyumuxi),**`ui` 1**(API-13、API-23):设置区域视图的 `tool` 行新增可选的布尔字段 `choose`,带上后这一行同时是该工具的选择器,像解释器下拉框一样列出自动选择、已发现和已添加的安装(带版本和来源)、添加目录和打开工具链页的入口;选择只改设置窗口的草稿,“应用”提交、“取消”丢弃,行上显示待提交的选择,应用后启动和运行拿到选中的安装。清单 `requires.ui` 为 0 时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`。契约 README 的插件视图一节补充:为某个工作区显示的视图(项目窗口里的工具窗口,或从项目窗口打开的设置页)调用时,带上该窗口的工作区上下文作为 invoke 的 `params.context`,后端可以在 `click` 里用它调用 `run/start` 等需要上下文的宿主方法;没有工作区时不带。fixture `ui/view-results.json` 新增一个用例,Node SDK 的视图节点类型加上 `choose`,Rust 和 Go SDK 的工作区上下文说明随之修正。没有新增宿主方法、通知或进程协议字段。 +- [#175](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/175),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`ui` 0 内的补充(API-13、API-23):撤回 #174 新增的 `ui` 1,设置区域 `tool` 行的可选布尔字段 `choose` 改为 `ui` 0 内的补充,清单写 `requires.ui: 0` 即可使用。`capabilities.rs` 和清单 schema 的 `requires.ui` 回到只有 0,能力对照表删去 `ui` 1 一行。`choose` 不是布尔值时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`;旧宿主的 Core 不认识这个字段,同样会拒绝带它的视图,所以插件要等包含本改动的桌面端发布后再写。fixture `ui/view-results.json` 改为两个用例(接受选择器、`choose` 不是布尔值时拒绝),替换原来“`requires.ui` 为 0 时拒绝”的用例。`ui` 1 没有随任何宿主发布过。没有新增能力版本、宿主方法、通知或进程协议字段。 +- [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174),[@xiaoyumuxi](https://github.com/xiaoyumuxi),**`ui` 1**(API-13、API-23):设置区域视图的 `tool` 行新增可选的布尔字段 `choose`,带上后这一行同时是该工具的选择器,像解释器下拉框一样列出自动选择、已发现和已添加的安装(带版本和来源)、添加目录和打开工具链页的入口;选择只改设置窗口的草稿,“应用”提交、“取消”丢弃,行上显示待提交的选择,应用后启动和运行拿到选中的安装。清单 `requires.ui` 为 0 时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`。契约 README 的插件视图一节补充:为某个工作区显示的视图(项目窗口里的工具窗口,或从项目窗口打开的设置页)调用时,带上该窗口的工作区上下文作为 invoke 的 `params.context`,后端可以在 `click` 里用它调用 `run/start` 等需要上下文的宿主方法;没有工作区时不带。fixture `ui/view-results.json` 新增一个用例,Node SDK 的视图节点类型加上 `choose`,Rust 和 Go SDK 的工作区上下文说明随之修正。没有新增宿主方法、通知或进程协议字段。(`ui` 1 已由 #175 撤回,`choose` 改为 `ui` 0 内的补充。) - [#173](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/173),[@xiaoyumuxi](https://github.com/xiaoyumuxi),市场索引 `schemaVersion` 0 内的补充(—):`plugins.marketplace.resolveSource` 的结果新增 `revision: { repository: { owner, name }, ref }`(托管在 GitHub 且不带查询参数的索引才有,否则为 null),输入新增可选的 `commit`,带上后结果多出 `pinned: { commit, indexURL, recommendationsURL }`,即同一批文件在该提交上的地址;`commit` 不是完整的 SHA-1 或 SHA-256 时返回新的拒绝码 `plugin.source.commitInvalid`。`indexURL` 仍是来源身份。宿主借此绕过 raw.githubusercontent.com 对分支地址约 5 分钟的缓存,查询或固定下载失败时退回原地址。fixture `marketplace/source-urls.json` 从 11 个用例增加到 17 个。索引格式、插件清单、宿主方法和能力版本都不变。 - [#171](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/171),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`pluginAPIVersion` 0 内的说明修正(Go SDK):Go SDK 需要的最低 Go 版本从 1.22 提高到 1.27.4,和桌面端构建用的 Go 一致。`shared/plugins/sdk/go/go.mod` 改为 `go 1.27.4`,契约 README 的 Official backend SDK 中 `sdk/go` 一段、插件总览、原生构建指南和四个 SDK 的 README 随之更新。插件升级到这个版本的 SDK 后,自己的 `go.mod` 也要写 `go 1.27.4` 或更高。SDK 代码和对外接口不变,没有新增版本号、宿主方法、通知或协议字段。 - [#151](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/151),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`pluginAPIVersion` 0 内的补充(API-05、API-35、API-40):远程工作区上下文的 `authority` 新增 `platform: { os, arch }`,取值同托管运行时(`os` 为 `linux`,`arch` 为 `arm64` 或 `x86_64`),本地上下文没有这个字段。新增宿主方法 `workspace/getHostPaths`:返回远程上下文的根目录在远端主机上的绝对 POSIX 路径 `hostPath`,可选的 `rootIDs`(1–256 个不重复的根目录 ID)决定返回哪些根目录和顺序;它是 `workspace.metadata` 下单独的方法授权,本地上下文返回 `plugin.host.authorityUnsupported`,未知根目录返回 `plugin.host.notFound`;声明 `workspace.metadata` 的插件,启动计划的 `backend.hostServices` 因此多出 `lithe/host/workspace/getHostPaths`,宿主传给 `lsp.startServer` 时去掉自己没有注册处理器的方法授权,后端调用它们得到 `plugin.host.permissionDenied`。新增失败码 `plugin.host.remoteDisconnected`(`-32078`,操作进行中与远端主机断开)和 `plugin.host.platformUnavailable`(`-32079`,插件没有适合远端平台的程序包或托管运行时)。插件函数中转不再拒绝远程工作区的上下文,导出的 `context: "workspace"` 指两种来源的工作区,Core 不读也不改写参数和结果里的路径。四个官方 SDK 新增远端平台读取、`getHostPaths`、按来源选择进程所用路径的辅助方法和两个失败码,`path` 与 `hostPath` 是不同类型。没有新增能力版本、通知或 SDK 版本。 @@ -75,7 +76,6 @@ | `toolDefinitions` | 1 | 2026-11-18 | [#99](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/99) | | `toolchainProviders` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `ui` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | -| `ui` | 1 | 2026-11-22 | [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174) | | `vcsProviders` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | ### 进程协议版本