diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index c0377f890..eac7f8d22 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1448,6 +1448,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.pluginView.resetZoom": "Reset zoom to 100%", "desktop.pluginView.resetZoomHint": "Reset zoom", "desktop.pluginView.timedOut": "The plugin took too long to update this view.", + "desktop.pluginView.toolPickerToolchains": "Manage in Toolchains…", "desktop.pluginView.zoom": "Canvas zoom", "desktop.pluginWeb.dialogTitle": "{plugin}: {title}", "desktop.pluginWeb.fileFilter": "Files ({extensions})", @@ -5385,6 +5386,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.pluginView.resetZoom": "缩放重置为 100%", "desktop.pluginView.resetZoomHint": "重置缩放", "desktop.pluginView.timedOut": "插件更新此视图超时。", + "desktop.pluginView.toolPickerToolchains": "在“工具链”中管理…", "desktop.pluginView.zoom": "画布缩放", "desktop.pluginWeb.dialogTitle": "{plugin}:{title}", "desktop.pluginWeb.fileFilter": "文件({extensions})", diff --git a/desktop/internal/pluginview/node.go b/desktop/internal/pluginview/node.go index 13cd33156..30829aa91 100644 --- a/desktop/internal/pluginview/node.go +++ b/desktop/internal/pluginview/node.go @@ -47,6 +47,8 @@ type Node struct { Columns []Column `json:"columns,omitempty"` Rows [][]string `json:"rows,omitempty"` Tool string `json:"tool,omitempty"` + // Choose makes a tool row in a settings region also the tool's picker. + Choose bool `json:"choose,omitempty"` // Height, ViewBox, Pan, Zoom, On and Nodes describe a canvas. Height float64 `json:"height,omitempty"` ViewBox [4]float64 `json:"viewBox,omitempty"` diff --git a/desktop/internal/pluginview/render.go b/desktop/internal/pluginview/render.go index fbee46d9c..dd49b996f 100644 --- a/desktop/internal/pluginview/render.go +++ b/desktop/internal/pluginview/render.go @@ -32,9 +32,10 @@ type SettingsHost interface { // Row draws the page's own row for a declared setting, exactly as the page draws it. // It reports false when the page has no such row. Row(c ui.C, setting string) bool - // Tool draws the toolchain pages' row for a tool the plugin defines or requires. - // It reports false when the host has no row for it. - Tool(c ui.C, tool string) bool + // Tool draws the toolchain pages' row for a tool the plugin defines or requires; with + // choose the row is also the tool's picker, whose choice edits the page's toolchain + // draft. It reports false when the host has no row for it. + Tool(c ui.C, tool string, choose bool) bool // Binding is the draft of a declared setting for a control bound to it. Binding(setting string) (Binding, bool) // Action runs a setting action through the page's confirmation flow. It runs @@ -254,7 +255,7 @@ func (r *renderer) node(c ui.C, n *Node) { } case "tool": if r.host.Settings != nil { - r.host.Settings.Tool(c, n.Tool) + r.host.Settings.Tool(c, n.Tool, n.Choose) } case "tree": r.tree(c, n) diff --git a/desktop/internal/settingswindow/plugin_region_view.go b/desktop/internal/settingswindow/plugin_region_view.go index 9d6f08428..d687c1226 100644 --- a/desktop/internal/settingswindow/plugin_region_view.go +++ b/desktop/internal/settingswindow/plugin_region_view.go @@ -9,8 +9,10 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/icons" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginview" + "github.com/1lck/Lithe-IDEA/desktop/internal/toolchain" "github.com/vivaui/viva/ui" ) @@ -48,8 +50,18 @@ type regionView struct { // sent is the settings, encoded, that the paint before found, so a paint that finds // them changed tells the view. sent string + // picker is the tool whose picker is open, empty when none is; pickerShown says this + // paint drew it, so a picker whose row the view no longer shows closes. + picker string + pickerShown bool } +// The tool picker's width, and the height its choices scroll beyond. +const ( + toolPickerWidth = 560 + toolPickerMaxHeight = 320 +) + // pluginRegionOf is the region the form's plugin placed on the page on screen: on a page // under Build or a contributed page the contributor's, on the plugin's own Settings tab the // editor's. It is nil when the plugin placed none there. @@ -98,7 +110,11 @@ func (w *window) pluginRegion(c ui.C, p *pluginSettingsForm, hasSource bool) { } v.host.Palette, v.host.Language = w.regionPalette(), language v.host.Settings = regionSettings{w: w, p: p, hasSource: hasSource} + v.pickerShown = false pluginview.Draw(c.Key("plugin-region:"+region.ID), v.session, &v.host, false) + if !v.pickerShown { + v.picker = "" + } } // openRegion makes and opens the view of key. Its calls carry the editor the form holds now, @@ -194,16 +210,31 @@ func (s regionSettings) Row(c ui.C, setting string) bool { return true } -// Tool draws the toolchains list's row for the tool, in the scope the toolchain pages show. -// Choosing it opens the Toolchains page with the tool chosen, where it is configured. -func (s regionSettings) Tool(c ui.C, tool string) bool { +// toolScope is the toolchain scope beside the scope the page shows: the project's pins beside +// the project's settings, the machine's defaults beside the global ones. A window without the +// two scopes has the one it has. +func (s regionSettings) toolScope(t *toolchainState) *toolchainScope { + name := scopeGlobal + if s.p.scope == 1 { + name = scopeProject + } + if scope := t.scopes[name]; scope != nil { + return scope + } + return t.current() +} + +// Tool draws the toolchains list's row for the tool, in the toolchain scope beside the scope +// the page shows. Pressing it opens the Toolchains page in that scope with the tool chosen; +// with choose, a tool the user may pin opens its picker instead (toolPicker). +func (s regionSettings) Tool(c ui.C, tool string, choose bool) bool { w := s.w t := w.toolchains if t == nil || !t.available() { return false } t.ensureLoaded() - scope := t.current() + scope := s.toolScope(t) if scope == nil || !scope.loaded { return false } @@ -213,16 +244,89 @@ func (s regionSettings) Tool(c ui.C, tool string) bool { } b := &w.bp language := w.marketLanguage() + v := w.region + // Only a tool the scope holds and the user may pin has choices; any other row stays the + // way to the Toolchains page, which says why. + fresh := scope.tool(tool) + picks := choose && v != nil && fresh != nil && !fresh.ManagedOnly + open := picks && v.picker == tool row := ui.ButtonBase(c, entry.tool.DisplayName).FillWidth().Height(toolchainToolRow).PadSides(0, 12, 0, 14). Gap(9).Items(ui.Center).Radius(6).Border(1, b.line).Hover(ui.Look{}.Background(b.hover)) - if row.Clicked() { - t.reveal(tool, t.view.group(tool)) - w.openBuildChild(pageToolchains) + if open { + row = row.Border(1, b.accent) + } + clicked := row.Clicked() + row.Children(func() { + w.toolchainToolContent(c, language, scope, entry, "") + if picks { + ui.Icon(c, icons.ChevronDown).Size(14, 14).Color(b.sub).Shrink(0) + } + }) + if !picks { + if clicked { + s.revealTool(t, scope, tool) + } + return true + } + if open { + v.pickerShown = true + s.toolPicker(c.Part("picker"), row, language, scope, fresh, &open) + } else if clicked { + // The add-directory field checks in the Toolchains page's scope, so the page follows + // the picker's. + t.setScope(scope.name) + open, v.pickerShown = true, true + } + switch { + case open: + v.picker = tool + case v.picker == tool: + v.picker = "" } - row.Children(func() { w.toolchainToolContent(c, language, scope, entry, "") }) return true } +// revealTool opens the Toolchains page in the scope with the tool chosen. +func (s regionSettings) revealTool(t *toolchainState, scope *toolchainScope, tool string) { + t.setScope(scope.name) + t.reveal(tool, t.view.group(tool)) + s.w.openBuildChild(pageToolchains) +} + +// toolPicker is the menu a tool row with choose opens, like an IDE's interpreter menu: the +// Toolchains page's choices for the tool in the scope (the automatic or inherited choice, then +// every home the scope knows with its version and sources), the field that adds a directory, +// and the way to the page. A choice is the scope's draft, which the footer's Apply writes and +// Cancel drops, and it closes the menu. +func (s regionSettings) toolPicker(c ui.C, row ui.Box, language i18n.Language, scope *toolchainScope, tool *toolchain.Tool, open *bool) { + w := s.w + t := w.toolchains + title := i18n.Shared(language, "desktop.buildSettings.optionsGlobal") + if scope.name == scopeProject { + title = i18n.Shared(language, "desktop.buildSettings.optionsProject") + } + spec := ui.PopoverSpec{Align: ui.Start, Width: toolPickerWidth, ConsumeOutsidePress: true, Title: title} + ui.PopoverWith(c, row, spec, open, func() { + before := scope.wanted(tool.ID) + current := toolchainCurrent(tool) + ui.Scroll(c.Part("choices")).Scrollbars().FillWidth().MaxHeight(toolPickerMaxHeight).Children(func() { + for _, option := range t.options(language, scope, tool) { + w.toolchainOption(c.Key("option:"+option.home), language, scope, tool, option, option.home == before, current) + } + }) + w.toolchainAddRow(c.Part("add"), language, scope, tool) + ui.Row(c).FillWidth().PadX(8).PadY(4).Items(ui.Center).Children(func() { + if w.button(c.Part("toolchains"), buttonLinkSmall, i18n.Shared(language, "desktop.pluginView.toolPickerToolchains"), false) { + *open = false + s.revealTool(t, scope, tool.ID) + } + }) + if scope.wanted(tool.ID) != before { + *open = false + } + }) +} + // Binding is the draft of a declared setting a control can edit: a text, file, directory or // integer setting's text, a boolean's switch and an enum's choice. func (s regionSettings) Binding(setting string) (pluginview.Binding, bool) { diff --git a/desktop/internal/settingswindow/plugin_region_view_test.go b/desktop/internal/settingswindow/plugin_region_view_test.go index bb3aa4104..864149b1a 100644 --- a/desktop/internal/settingswindow/plugin_region_view_test.go +++ b/desktop/internal/settingswindow/plugin_region_view_test.go @@ -18,6 +18,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/marketplace" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginsettings" + "github.com/1lck/Lithe-IDEA/desktop/internal/toolchain" ) // regionPlugin is the synthetic plugin whose settings page carries a region view. @@ -408,3 +409,94 @@ func TestSearchFindsAPluginPageByItsRegionKeywords(t *testing.T) { w.searchField.SetText("no such words") d.until("a search no region matches", func() bool { return w.query == foldQuery("no such words") && !listed() }) } + +// regionToolWindow opens the synthetic plugin's Settings tab, its region one row of the fixture +// tool the loader serves, the tool's picker with choose, and waits for the row. +func regionToolWindow(t *testing.T, loader ToolchainLoader, choose bool) (*window, *windowDriver) { + t.Helper() + view, _ := json.Marshal([]map[string]any{{"type": "tool", "tool": fixtureTool, "choose": choose}}) + source := ®ionSource{calls: make(chan regionCall, 32), view: view} + fetch := func(context.Context) (marketplace.Snapshot, error) { + return marketplace.Snapshot{Index: core.MarketplaceIndex{Plugins: []core.MarketplacePlugin{{ID: regionPlugin, Name: "Region Fixture", LatestVersion: "1.0.0"}}}}, nil + } + w := newWindow(NewController(Options{ + Marketplace: fetch, MarketplaceInstalled: fetch, PluginSettings: source, Toolchains: loader, + PluginState: func(string) PluginState { return PluginState{Installed: true, Enabled: true, Version: "1.0.0"} }, + InstalledPlugins: func() []PluginFacts { + return []PluginFacts{{ID: regionPlugin, Name: "Region Fixture", Version: "1.0.0", Settings: len(regionEditor().Snapshot.State.Rows)}} + }, + }), Values{}) + w.sess.page = pagePlugins + w.installed.tab = installedSettings + d := openWindow(t, w) + d.until("the region's tool row", func() bool { return d.has("Compiler") }) + d.pump() + return w, d +} + +// A tool row with choose opens the tool's choices under it in the plugin page's scope; a +// choice is a draft of that scope that closes the choices and waits for the footer's Apply. +func TestRegionToolPickerChoosesIntoTheToolchainDraft(t *testing.T) { + loader := &scopedToolchainLoader{fakeToolchainLoader{snapshot: fixtureSnapshot(), saved: make(chan []toolchain.Edit, 1)}} + w, d := regionToolWindow(t, loader, true) + manage := en("desktop.pluginView.toolPickerToolchains") + if d.has(manage) || d.has("/fixture/compiler") { + t.Fatal("the tool's choices show before the row is pressed") + } + // The plugin page shows the global settings, and the project scope is the one the + // Toolchains page shows; the picker follows the plugin page. + w.toolchains.setScope(scopeProject) + d.click("Compiler") + d.until("the tool's choices", func() bool { return d.has(manage) && d.has("/fixture/compiler") }) + if w.toolchains.scope != scopeGlobal { + t.Fatalf("the picker opened with the Toolchains page in the %s scope, want the plugin page's", w.toolchains.scope) + } + d.click("/fixture/compiler") + d.pump() + global := w.toolchains.scopes[scopeGlobal] + if global.draft[fixtureTool] != "/fixture/compiler" || w.toolchains.drafts(scopeProject) != 0 { + t.Fatalf("the choice drafted %v globally and %d in the project, want the installation globally", global.draft, w.toolchains.drafts(scopeProject)) + } + if d.has(manage) || w.region.picker != "" { + t.Fatal("the choices stayed open after a choice") + } + select { + case edits := <-loader.saved: + t.Fatalf("choosing wrote %+v before Apply", edits) + default: + } + d.applyBuild() + select { + case edits := <-loader.saved: + if len(edits) != 1 || edits[0].Tool != fixtureTool || edits[0].Pin == nil || edits[0].Pin.Home != "/fixture/compiler" { + t.Fatalf("Apply wrote %+v, want the chosen installation pinned", edits) + } + default: + t.Fatal("Apply did not write the choice") + } + if len(global.draft) != 0 { + t.Fatalf("the applied choice is still a draft: %v", global.draft) + } +} + +// The picker's way to the Toolchains page, and a press on a row without choose, open the page +// in the plugin page's scope with the tool chosen. +func TestRegionToolRowOpensTheToolchainsPage(t *testing.T) { + for _, choose := range []bool{true, false} { + w, d := regionToolWindow(t, &scopedToolchainLoader{fakeToolchainLoader{snapshot: fixtureSnapshot()}}, choose) + w.toolchains.setScope(scopeProject) + d.click("Compiler") + if choose { + manage := en("desktop.pluginView.toolPickerToolchains") + d.until("the tool's choices", func() bool { return d.has(manage) }) + d.click(manage) + } + d.until("the Toolchains page", func() bool { return w.sess.page == pageToolchains }) + if w.toolchains.scope != scopeGlobal || w.toolchains.selected != fixtureTool { + t.Fatalf("choose %v: the Toolchains page opened in the %s scope on %q, want the global scope on the tool", choose, w.toolchains.scope, w.toolchains.selected) + } + if w.region != nil && w.region.picker != "" { + t.Fatalf("choose %v: the picker stayed open after leaving for the Toolchains page", choose) + } + } +} diff --git a/desktop/internal/settingswindow/plugin_region_visual_test.go b/desktop/internal/settingswindow/plugin_region_visual_test.go index 06b7352ba..5ed337936 100644 --- a/desktop/internal/settingswindow/plugin_region_visual_test.go +++ b/desktop/internal/settingswindow/plugin_region_visual_test.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "testing" + "time" "github.com/1lck/Lithe-IDEA/desktop/internal/contractfixture" "github.com/1lck/Lithe-IDEA/desktop/internal/core" @@ -53,7 +54,7 @@ func (s regionViewSource) View(context.Context, pluginservice.SettingsEditor, st } // visualRegionView is a settings region that binds declared settings, shows the host's row -// for one setting and one tool, and draws a summary on a canvas. +// for one setting and the picker of one tool, and draws a summary on a canvas. func visualRegionView() json.RawMessage { view, _ := json.Marshal([]map[string]any{ {"type": "banner", "tone": "accent", "text": "These settings apply to every project the plugin indexes."}, @@ -61,7 +62,7 @@ func visualRegionView() json.RawMessage { {"type": "toggle", "id": "watch", "label": "Watch files", "setting": "watch"}, {"type": "textField", "id": "name", "label": "Name", "setting": "name", "width": 24}, {"type": "setting", "setting": "threads"}, - {"type": "tool", "tool": fixtureTool}, + {"type": "tool", "tool": fixtureTool, "choose": true}, {"type": "keyValue", "items": []map[string]any{ {"label": "Indexed", "value": "1,284 files"}, {"label": "Last check", "value": "Passed", "tone": "success"}, @@ -77,9 +78,9 @@ func visualRegionView() json.RawMessage { return view } -// TestVisualPluginRegion renders the view-panel fixture's Settings tab with its region, in the -// dark and the light theme. Opt in with -tags 'vivahead lithevisual' and -// LITHE_VISUAL_OUTPUT_DIR. +// TestVisualPluginRegion renders the view-panel fixture's Settings tab with its region, then with +// the tool row's choices open, in English and Chinese and in the dark and the light theme. Opt in with +// -tags 'vivahead lithevisual' and LITHE_VISUAL_OUTPUT_DIR. func TestVisualPluginRegion(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -88,51 +89,63 @@ func TestVisualPluginRegion(t *testing.T) { if err := os.MkdirAll(out, 0755); err != nil { t.Fatal(err) } - language := i18n.English manifest := viewPanelManifest(t) fetch := func(context.Context) (marketplace.Snapshot, error) { return marketplace.Snapshot{Index: core.MarketplaceIndex{Plugins: []core.MarketplacePlugin{{ID: viewPanelPlugin, Name: "View Panel", LatestVersion: "1.0.0"}}}}, nil } - for _, theme := range []string{"dark", "light"} { - t.Run(theme, func(t *testing.T) { - // The preference directory does not exist, so the page reads the defaults and shows - // a fixed path rather than the machine's temporary directory; nothing here saves. - source := regionViewSource{ - settingsFormSource: settingsFormSource{store: pluginsettings.New(core.NewClient(), "/fixture/preferences"), manifest: manifest, workspace: t.TempDir()}, - view: visualRegionView(), - } - // Core validates the manifest; a rule it adds would otherwise show only as a window - // that never draws the region. - if _, err := source.Load(context.Background(), viewPanelPlugin, language); err != nil { - t.Fatalf("Core did not load the view-panel fixture's settings: %v", err) - } - w := newWindow(NewController(Options{ - Text: func() *i18n.Messages { return i18n.For(language) }, Language: func() i18n.Language { return language }, - SystemDark: func() bool { return theme == "dark" }, - Marketplace: fetch, MarketplaceInstalled: fetch, PluginSettings: source, - Toolchains: &fakeToolchainLoader{snapshot: globalVisualToolchains()}, - PluginState: func(string) PluginState { return PluginState{Installed: true, Enabled: true, Version: "1.0.0"} }, - InstalledPlugins: func() []PluginFacts { - return []PluginFacts{{ID: viewPanelPlugin, Name: "View Panel", Vendor: "Example", Version: "1.0.0", Settings: 4}} - }, - }), Values{Theme: theme, Language: language.Code()}) - w.sess.page = pagePlugins - w.installed.tab = installedSettings - config := w.config() - config.Height = 1180 - session, err := headless.Open(config, nil, headless.Options{}) - if err != nil { - t.Fatal(err) - } - t.Cleanup(session.Close) - d := &windowDriver{t: t, w: w, driver: session.Driver()} - d.until("the region's view and the tool row", func() bool { - return d.text("Indexed") && d.has("Compiler") && d.has("Fast") + for _, language := range []i18n.Language{i18n.English, i18n.Chinese} { + for _, theme := range []string{"dark", "light"} { + t.Run(language.Code()+"/"+theme, func(t *testing.T) { + // The preference directory does not exist, so the page reads the defaults and shows + // a fixed path rather than the machine's temporary directory; nothing here saves. + source := regionViewSource{ + settingsFormSource: settingsFormSource{store: pluginsettings.New(core.NewClient(), "/fixture/preferences"), manifest: manifest, workspace: t.TempDir()}, + view: visualRegionView(), + } + // Core validates the manifest; a rule it adds would otherwise show only as a window + // that never draws the region. + if _, err := source.Load(context.Background(), viewPanelPlugin, language); err != nil { + t.Fatalf("Core did not load the view-panel fixture's settings: %v", err) + } + w := newWindow(NewController(Options{ + Text: func() *i18n.Messages { return i18n.For(language) }, Language: func() i18n.Language { return language }, + SystemDark: func() bool { return theme == "dark" }, + Marketplace: fetch, MarketplaceInstalled: fetch, PluginSettings: source, + Toolchains: &scopedToolchainLoader{fakeToolchainLoader{snapshot: globalVisualToolchains()}}, + PluginState: func(string) PluginState { return PluginState{Installed: true, Enabled: true, Version: "1.0.0"} }, + InstalledPlugins: func() []PluginFacts { + return []PluginFacts{{ID: viewPanelPlugin, Name: "View Panel", Vendor: "Example", Version: "1.0.0", Settings: 4}} + }, + }), Values{Theme: theme, Language: language.Code()}) + w.sess.page = pagePlugins + w.installed.tab = installedSettings + config := w.config() + config.Height = 1180 + session, err := headless.Open(config, nil, headless.Options{}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(session.Close) + d := &windowDriver{t: t, w: w, driver: session.Driver()} + d.until("the region's view and the tool row", func() bool { + return d.text("Indexed") && d.has("Compiler") && d.has("Fast") + }) + d.pump() + if err := session.Screenshot(filepath.Join(out, "plugin-settings-region-"+language.Code()+"-"+theme+".png")); err != nil { + t.Fatal(err) + } + d.click("Compiler") + manage := i18n.Shared(language, "desktop.pluginView.toolPickerToolchains") + d.until("the tool's choices", func() bool { return d.has(manage) && d.has("/fixture/sdk8") }) + d.pump() + // The choices fade in; the capture waits for them to finish. + if err := session.Advance(300 * time.Millisecond); err != nil { + t.Fatal(err) + } + if err := session.Screenshot(filepath.Join(out, "plugin-settings-tool-picker-"+language.Code()+"-"+theme+".png")); err != nil { + t.Fatal(err) + } }) - d.pump() - if err := session.Screenshot(filepath.Join(out, "plugin-settings-region-"+theme+".png")); err != nil { - t.Fatal(err) - } - }) + } } } diff --git a/docs/assets/plugin-settings-tool-picker/plugin-settings-region-en-dark.png b/docs/assets/plugin-settings-tool-picker/plugin-settings-region-en-dark.png new file mode 100644 index 000000000..4f02b0af4 Binary files /dev/null and b/docs/assets/plugin-settings-tool-picker/plugin-settings-region-en-dark.png differ diff --git a/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-en-dark.png b/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-en-dark.png new file mode 100644 index 000000000..ef7f20f44 Binary files /dev/null and b/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-en-dark.png differ diff --git a/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-zh-Hans-light.png b/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-zh-Hans-light.png new file mode 100644 index 000000000..b1752831f Binary files /dev/null and b/docs/assets/plugin-settings-tool-picker/plugin-settings-tool-picker-zh-Hans-light.png differ diff --git a/docs/development/macos-plugin-api-plan.md b/docs/development/macos-plugin-api-plan.md index 5bbb4f781..7dfc82cf2 100644 --- a/docs/development/macos-plugin-api-plan.md +++ b/docs/development/macos-plugin-api-plan.md @@ -35,7 +35,7 @@ Windows 不在本轮,平台矩阵的 partial/pending 保持真实。 | API-10 | 已公开 | applyEdits/replaceSelections/insertText;版本校验、IME/只读拒绝、一次 Undo | | API-11 | 未做 | 公共 save/saveAs/close 与工作区文件变更接口未接入 | | API-12 | 部分完成 | 已公开 `documents/registerContentProvider`(只读内容,≤1 MiB,每窗口每 scheme 一个,仅 macOS);公共多文件 edit、showDiff 未接入 | -| API-13 | 部分完成 | 插件视图(ui 0):工具窗口和设置区域的内容由插件后端返回节点树(宿主控件、树、画布),Core `plugins.ui.applyResult` 校验,桌面端用 Viva 原生绘制;旧的 Tree/List/Form 已删除;插件主动推送、树懒加载/分页、`views.reveal` 未做 | +| API-13 | 部分完成 | 插件视图(ui 0):工具窗口和设置区域的内容由插件后端返回节点树(宿主控件、树、画布),Core `plugins.ui.applyResult` 校验,桌面端用 Viva 原生绘制;设置区域的工具行可带 `choose`(ui 0 内的可选字段)成为该工具的选择器(工具链草稿,Viva 桌面端);旧的 Tree/List/Form 已删除;插件主动推送、树懒加载/分页、`views.reveal` 未做 | | API-14 | 部分完成 | 既有包内网页 bridge、状态/生命周期;通用双向页面消息未做 | | API-15 | 部分完成 | editor/open/reveal 返回 documentID/version;range 只起点光标,替换预览标签未做 | | API-16 | 已公开 | preview/openHTML 支持 split/previewOnly;browser/openExternal 支持 HTTP(S)/已保存 HTML | diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 1171457f2..91df09e66 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -350,7 +350,10 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # #173 plugins.marketplace.resolveSource reports the repository and branch an index follows and # pins its address to a commit past raw.githubusercontent.com's branch cache, and the GitHub # requests gain latestCommit and listReleases for that pin and the installed plugins' changelog. -PINNED_CORE_REVISION="44307192d7a45cbd586c0dffc29ff1bbeb3fd7d5" +# Lithe-core-rust branch feat/ui-tool-picker at a50cea1 (#174, not merged yet): a settings +# region's tool row may carry choose, an optional field within ui 0, and become the tool's picker; +# the contract says a view call carries the window's workspace context. +PINNED_CORE_REVISION="a50cea18bff3971bd32288e09fa4042b4f006e3b" PROFILE="debug" CHECKOUT_ONLY="no" while [[ $# -gt 0 ]]; do diff --git a/shared/i18n/features/plugin-views.json b/shared/i18n/features/plugin-views.json index 787faac8c..5dc10fa8d 100644 --- a/shared/i18n/features/plugin-views.json +++ b/shared/i18n/features/plugin-views.json @@ -42,6 +42,13 @@ "platforms": [ "desktop" ] + }, + { + "id": "desktop.pluginView.toolPickerToolchains", + "description": "Plugin settings region: link at the end of a tool picker (a tool row with choose), which opens the tool on the Toolchains settings page", + "platforms": [ + "desktop" + ] } ], "locales": { @@ -51,7 +58,8 @@ "desktop.pluginView.invalid": "The plugin returned a view Lithe cannot show.", "desktop.pluginView.zoom": "Canvas zoom", "desktop.pluginView.resetZoom": "Reset zoom to 100%", - "desktop.pluginView.resetZoomHint": "Reset zoom" + "desktop.pluginView.resetZoomHint": "Reset zoom", + "desktop.pluginView.toolPickerToolchains": "Manage in Toolchains…" }, "zh-CN": { "desktop.pluginView.failed": "插件无法更新此视图。", @@ -59,7 +67,8 @@ "desktop.pluginView.invalid": "插件返回的视图无法显示。", "desktop.pluginView.zoom": "画布缩放", "desktop.pluginView.resetZoom": "缩放重置为 100%", - "desktop.pluginView.resetZoomHint": "重置缩放" + "desktop.pluginView.resetZoomHint": "重置缩放", + "desktop.pluginView.toolPickerToolchains": "在“工具链”中管理…" } } } diff --git a/shared/platform-feature-matrix/features/plugin-registered-settings-pages.json b/shared/platform-feature-matrix/features/plugin-registered-settings-pages.json index 3c147344c..c82f93704 100644 --- a/shared/platform-feature-matrix/features/plugin-registered-settings-pages.json +++ b/shared/platform-feature-matrix/features/plugin-registered-settings-pages.json @@ -2,7 +2,7 @@ "id": "plugin-registered-settings-pages", "area": "插件", "group": "插件管理", - "capability": "插件通过 settings(当前契约版本 0)在 plugin.json 里把设置项和按钮注册到“语言与框架 › <语言>”或“构建、执行、部署 › <构建系统>”页,按 section 分组;设置可声明项目级覆盖(写入项目 .lithe/plugin-settings.json)和生效方式(重启、立即、重新加载、下次运行),“立即生效”的值经 workspace/configuration 推给正在运行的语言服务器;按钮调用插件自己的插件函数。宿主只提供通用页面和控件,不内置任何语言或构建工具的页面;语言服务状态写在“语言与框架”目录的语言行上,语言页本身不重复,只有一个插件贡献的页面也不显示插件选择器;路径选择按钮保持完整可见,窄面板由输入框和标题列缩短以容纳状态标签;settingRegions 让插件在设置页或插件详情的“设置”页签声明区域:区域带搜索关键词,内容由插件视图绘制,控件可绑定已声明的设置(宿主读写真实来源)、嵌入宿主自己的设置行(setting)和工具链工具行(tool),值变化后去抖发送 settings 事件让插件重画", + "capability": "插件通过 settings(当前契约版本 0)在 plugin.json 里把设置项和按钮注册到“语言与框架 › <语言>”或“构建、执行、部署 › <构建系统>”页,按 section 分组;设置可声明项目级覆盖(写入项目 .lithe/plugin-settings.json)和生效方式(重启、立即、重新加载、下次运行),“立即生效”的值经 workspace/configuration 推给正在运行的语言服务器;按钮调用插件自己的插件函数。宿主只提供通用页面和控件,不内置任何语言或构建工具的页面;语言服务状态写在“语言与框架”目录的语言行上,语言页本身不重复,只有一个插件贡献的页面也不显示插件选择器;路径选择按钮保持完整可见,窄面板由输入框和标题列缩短以容纳状态标签;settingRegions 让插件在设置页或插件详情的“设置”页签声明区域:区域带搜索关键词,内容由插件视图绘制,控件可绑定已声明的设置(宿主读写真实来源)、嵌入宿主自己的设置行(setting)和工具链工具行(tool),值变化后去抖发送 settings 事件让插件重画;tool 行带 choose(ui 0 内的可选字段)时在原处弹出该工具在“工具链”页的选择(自动、已发现安装、添加安装目录、在“工具链”中管理),选中值进设置窗口的工具链草稿,按“应用/确定”保存、“取消”丢弃;tool 行跳到“工具链”页时沿用插件页当前的全局/项目作用域", "macos": { "implementationStatus": "partial", "verificationStatus": "pending", @@ -42,7 +42,7 @@ ] }, "owner": "Plugin Platform", - "verification": "自动化:scripts/desktop/desktop-go.sh test ./internal/settingswindow/ ./internal/pluginsettings/ ./internal/pluginservice/,覆盖 Core 投影的动态插件页(Core 契约 fixture 与 rust/fixtures 的设置清单)共享草稿、按页过滤按钮、刷新干净表单、项目层存储和编辑器投影。设置区域:scripts/desktop/desktop-go.sh test -run 'Region' ./internal/settingswindow/,覆盖绑定设置的草稿类型、可编辑与只读、settings 事件携带的生效值与草稿、随页面打开关闭及切换语言重开,以及按 Core 契约 fixture view-panel 的区域关键词搜索定位页面;无头截图 LITHE_VISUAL_OUTPUT_DIR=<目录> scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run TestVisualPluginRegion ./internal/settingswindow/(Core 契约 fixture view-panel,深浅主题),检查区域控件、setting 行与 tool 行。原生整机验收 pending:安装一个声明了设置页面(page/section/scope/effect/settingActions/settingRegions)的测试插件并启用,确认设置侧栏的对应分组下出现该语言或构建系统页,页内按插件和 section 分组显示设置、按钮与区域;搜索设置标题或区域关键词能定位到该页。打开项目后把 scope 为 project 的设置切到“此项目”并修改,确认项目下生成 .lithe/plugin-settings.json 且显示“已在此项目覆盖”,恢复默认后文件被删除。修改 effect 为 immediate 的设置,确认语言服务器不重启而配置生效;修改 restart 设置时出现重启提示。点击带 confirm 的按钮先弹确认,再调用插件函数并给出结果通知。在区域里修改绑定值,确认写回来源、插件重画。停用插件后页面与区域消失。只装一个 Go 插件时打开“语言与框架 › Go”,确认页面直接是插件设置,没有插件选择器和语言服务状态卡;再装一个也贡献 Go 页的插件,确认出现选择器并可切换。Windows 使用同一 Go Viva 桌面端,需在 Windows 虚拟机上重复原生验收。", + "verification": "自动化:scripts/desktop/desktop-go.sh test ./internal/settingswindow/ ./internal/pluginsettings/ ./internal/pluginservice/,覆盖 Core 投影的动态插件页(Core 契约 fixture 与 rust/fixtures 的设置清单)共享草稿、按页过滤按钮、刷新干净表单、项目层存储和编辑器投影。设置区域:scripts/desktop/desktop-go.sh test -run 'Region' ./internal/settingswindow/,覆盖绑定设置的草稿类型、可编辑与只读、settings 事件携带的生效值与草稿、随页面打开关闭及切换语言重开,以及按 Core 契约 fixture view-panel 的区域关键词搜索定位页面;无头截图 LITHE_VISUAL_OUTPUT_DIR=<目录> scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run TestVisualPluginRegion ./internal/settingswindow/(Core 契约 fixture view-panel,中英文、深浅主题),检查区域控件、setting 行与 tool 行,同一测试再点开 tool 行截取工具选择器。工具选择器:TestRegionToolPickerChoosesIntoTheToolchainDraft(插件页在全局作用域、工具链页停在项目作用域时,选项按全局作用域列出,选中后只写全局草稿、关闭选择器、不立即保存,按“应用”后保存一次并清空草稿)与 TestRegionToolRowOpensTheToolchainsPage(带与不带 choose 的 tool 行跳到工具链页并定位该工具,作用域跟随插件页)。原生整机验收 pending:安装一个声明了设置页面(page/section/scope/effect/settingActions/settingRegions)的测试插件并启用,确认设置侧栏的对应分组下出现该语言或构建系统页,页内按插件和 section 分组显示设置、按钮与区域;搜索设置标题或区域关键词能定位到该页。打开项目后把 scope 为 project 的设置切到“此项目”并修改,确认项目下生成 .lithe/plugin-settings.json 且显示“已在此项目覆盖”,恢复默认后文件被删除。修改 effect 为 immediate 的设置,确认语言服务器不重启而配置生效;修改 restart 设置时出现重启提示。点击带 confirm 的按钮先弹确认,再调用插件函数并给出结果通知。在区域里修改绑定值,确认写回来源、插件重画。停用插件后页面与区域消失。只装一个 Go 插件时打开“语言与框架 › Go”,确认页面直接是插件设置,没有插件选择器和语言服务状态卡;再装一个也贡献 Go 页的插件,确认出现选择器并可切换。Windows 使用同一 Go Viva 桌面端,需在 Windows 虚拟机上重复原生验收。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { @@ -72,5 +72,5 @@ "verificationStatus": "not-applicable" } }, - "notes": "Viva:settings_surfaces.go 按 core.SettingsPage(Key、Kind、Contributors、Sections)动态生成插件设置页,带确认的页面按钮在 plugin_settings_actions_view.go;pluginsettings/store.go 提供项目层存储,pluginservice/settings.go 的 ApplyLanguageSettings 把配置推给运行中的语言服务器;pluginhost 声明 settings 0(契约 2026-11-11 版本归 0)。 设置区域:settingswindow/plugin_region_view.go 用 pluginview 渲染器绘制插件区域,绑定设置走与声明设置行相同的编辑器(可编辑条件:已加载、作用域可写且设置有真实来源)。 2026-11-21:语言页不再重复“语言与框架”目录行里已有的内容:只有一个插件贡献时直接显示它的设置,不再显示插件选择器和语言服务状态卡;两个以上插件贡献同一页时仍显示选择器(与构建、执行、部署的分栏页一致)。TestLanguagePageDoesNotRepeatItsDirectoryRow 覆盖一个插件和两个插件两种情况。" + "notes": "Viva:settings_surfaces.go 按 core.SettingsPage(Key、Kind、Contributors、Sections)动态生成插件设置页,带确认的页面按钮在 plugin_settings_actions_view.go;pluginsettings/store.go 提供项目层存储,pluginservice/settings.go 的 ApplyLanguageSettings 把配置推给运行中的语言服务器;pluginhost 声明 settings 0(契约 2026-11-11 版本归 0)。 设置区域:settingswindow/plugin_region_view.go 用 pluginview 渲染器绘制插件区域,绑定设置走与声明设置行相同的编辑器(可编辑条件:已加载、作用域可写且设置有真实来源)。 2026-11-21:语言页不再重复“语言与框架”目录行里已有的内容:只有一个插件贡献时直接显示它的设置,不再显示插件选择器和语言服务状态卡;两个以上插件贡献同一页时仍显示选择器(与构建、执行、部署的分栏页一致)。TestLanguagePageDoesNotRepeatItsDirectoryRow 覆盖一个插件和两个插件两种情况。 2026-11-22:工具选择器(Core 契约 choose,ui 0 内的可选字段,能力版本不变):plugin_region_view.go 的 Tool 在 choose 为真时把 tool 行画成带边框和下拉箭头的选择框,点开后用 Viva 浮层列出工具链页同一份选项;pluginhost 仍声明 ui 0。选择框和原生工具链页共用草稿,不另存一份。原生整机与 Windows 实机验收 pending。" }