diff --git a/.agents/notes/implemented/feature/2026-10-15-macos-settings-hierarchy.md b/.agents/notes/implemented/feature/2026-10-15-macos-settings-hierarchy.md index d4e6acfc2..cc7de05c8 100644 --- a/.agents/notes/implemented/feature/2026-10-15-macos-settings-hierarchy.md +++ b/.agents/notes/implemented/feature/2026-10-15-macos-settings-hierarchy.md @@ -31,7 +31,7 @@ AI 分组内,Agent 可加载的资源(指令、技能、Hooks、MCP 配置)收进可折叠的“资源库”,与 AI 服务商、Agents、AI 与提交并列。二级折叠由子分组声明,页面仍归父分组所有,面包屑为“AI › 资源库 › 页面”。只有同类资源达到三个以上页面时才新增二级折叠。 -“构建、执行、部署”下插件声明的页面按种类(构建工具、编译器)折叠:同一种类不到 3 个页面时直接列在侧栏;达到 3 个时收成一个种类文件夹,展开后最多列 6 个页面,其余由最后一行“全部 N 个…”打开该种类的文件夹页。文件夹页列出全部页面和提供插件,可以按名称或插件筛选;“构建、执行、部署”目录页每个种类只写前 3 个名称并计数其余。这些插件页是额外的聚合入口:同样的设置仍然留在插件详情的「设置」标签,不从那里移走。阈值和条数只写在设置窗口的 `folderMin`、`folderLimit`、`kindNames` 常量里,不要为某个插件或种类单独改。详细结构见[构建、执行、部署设置页在大量插件注入时的结构](2026-11-18-build-execution-settings-at-scale.md)。 +“构建、执行、部署”下插件声明的页面按种类(构建工具、编译器)归类:每个有页面的种类在侧栏只占一行,行尾是页面数,不展开;点开是和「工具链」「调试器」一样的分栏页,左侧列出这一类的全部页面和提供插件,可以按名称或插件筛选,右侧是选中页面的设置。再次打开时回到这一类上次看的页面。插件页只在侧栏搜索命中时才单独出现在侧栏,点结果在分栏页里打开。“构建、执行、部署”目录页每个种类只写前 3 个名称并计数其余,条数只写在设置窗口的 `kindNames` 常量里,不要为某个插件或种类单独改。这些插件页是额外的聚合入口:同样的设置仍然留在插件详情的「设置」标签,不从那里移走。详细结构见[构建、执行、部署设置页在大量插件注入时的结构](2026-11-18-build-execution-settings-at-scale.md)。 ### 开发者怎么做 @@ -64,7 +64,7 @@ AI 分组内,Agent 可加载的资源(指令、技能、Hooks、MCP 配置 ## 验证 -- `scripts/desktop/desktop-go.sh test ./internal/settingswindow -count=1`:验证侧栏、面包屑、搜索展开与“关于”排在 AI 之后;`TestBuildKindFoldsIntoAFolderThatListsSix` 等验证插件页的种类文件夹。 +- `scripts/desktop/desktop-go.sh test ./internal/settingswindow -count=1`:验证侧栏、面包屑、搜索展开与“关于”排在 AI 之后;`TestBuildKindIsOneRowThatOpensItsPage` 等验证插件页的种类行与分栏页。 - 实机打开设置窗口:确认侧栏分组、面包屑,以及从其它入口跳转到某个页面时展开所属分组。 ## 适用范围 diff --git a/.agents/notes/implemented/feature/2026-11-18-build-execution-settings-at-scale.md b/.agents/notes/implemented/feature/2026-11-18-build-execution-settings-at-scale.md index c24c8c91d..20c33d6e3 100644 --- a/.agents/notes/implemented/feature/2026-11-18-build-execution-settings-at-scale.md +++ b/.agents/notes/implemented/feature/2026-11-18-build-execution-settings-at-scale.md @@ -4,7 +4,7 @@ ## 先说结论 -「构建、执行、部署」原来一页装着作用域与保存、每个插件的工具卡片和调试器单步过滤,页面高度随插件数量线性增长。现在分组页是**目录**,宿主固定两个子页「工具链」「调试器」,插件声明的页面按种类排在后面,多了就折叠成文件夹。 +「构建、执行、部署」原来一页装着作用域与保存、每个插件的工具卡片和调试器单步过滤,页面高度随插件数量线性增长。现在分组页是**目录**,宿主固定两个子页「工具链」「调试器」,插件声明的页面按种类排在后面,每个种类只占一行,点开是分栏页。 这里是**聚合,不是搬家**:插件自己的设置位置不变,插件详情的「设置」标签照样列出该插件的全部设置(包括声明了 `page` 的那些);「构建、执行、部署」只是把各插件里和构建相关的内容额外汇到一处。两处编辑的是同一份设置、同一份草稿,宿主不按插件名写分支。界面按原型 [`docs/design/build-execution-settings.html`](../../../../docs/design/build-execution-settings.html) 复刻,偏差见下文“与原型的差异”。还没做的契约缺口见[构建设置剩余的契约缺口](../../proposed/feature/2026-11-18-build-settings-remaining-contract-gaps.md)。 @@ -25,7 +25,7 @@ | 「构建、执行、部署」分组页 | 目录:最上面汇总需要处理的工具,下面是子页、两个作用域的状态和插件页种类 | 宿主 | | 「工具链」固定子页 | 所有插件声明的工具(`toolDefinitions`,API-23) | 宿主固定页面,行来自插件声明 | | 「调试器」固定子页 | 支持单步过滤的调试器(API-30) | 宿主固定页面,行来自插件声明 | -| 插件页 | 插件用 `settings[].page`(API-19)声明的构建工具页、编译器页 | 插件声明;折叠规则见[设置页分类](2026-10-15-macos-settings-hierarchy.md) | +| 插件页 | 插件用 `settings[].page`(API-19)声明的构建工具页、编译器页 | 插件声明;侧栏规则见[设置页分类](2026-10-15-macos-settings-hierarchy.md) | 插件页里的设置同时留在插件详情的「设置」标签:Core 的设置文档把全部设置放进详情的 `sections`,`page` 只额外生成一个聚合页(`pages`)。两处由同一个按插件 ID 的表单渲染,在一处改了、没应用就切到另一处,看到的是同一份草稿。 @@ -42,6 +42,13 @@ 左侧列出声明了单步过滤的调试器、提供插件和「已自定义」标记,可筛选;右侧编辑。「不进入的代码」是逐条列表,可以添加、删除;跳过合成方法等开关只显示调试器声明支持的。插件没有给出名称时,图标用调试器名称的字母。 +### 构建工具、编译器页 + +- 侧栏每个有页面的种类只有一行,行尾是页面数,不展开;插件再多侧栏也不变长。Core 的导航把种类标成分组,宿主投影后固定为不展开的普通行。 +- 点开是和调试器页一样的分栏:左侧是这一类的页面,每行写页面名和提供插件,按需渲染,可按页面名或插件名筛选,底部是页面数;右侧是选中页面的设置,表单和插件详情「设置」标签是同一个。 +- 再次从侧栏或目录页打开这一类时,回到上次看的页面;没有看过时打开第一页。面包屑是「构建、执行、部署 › 种类」。 +- 插件页只在侧栏搜索命中时单独出现在侧栏;点结果在分栏页里打开该页并清空搜索。 + ### 提交和搜索 - 提交统一走窗口底部的「应用 / 好」。只有在 Build 相关页面或有草稿时才显示「应用」;没有草稿时「好」直接关闭窗口。 @@ -58,12 +65,13 @@ ### 正确做法 - Gradle 插件声明 `toolDefinitions`(Gradle,`category` 为构建工具)。宿主在「工具链」的“构建工具”组里放一行 Gradle,插件不写页面。 -- 八个插件各声明一个构建工具页:侧栏出现“构建工具”文件夹,展开列 6 个和“全部 8 个…”。 +- 八个插件各声明一个构建工具页:侧栏只多一行“构建工具 8”,点开是分栏页,左侧列 8 个页面和各自插件,右侧是第一个页面的设置。 ### 不要这样做 - 不要因为某个设置聚合到了「构建、执行、部署」,就把它从插件详情的「设置」标签里拿掉;聚合入口是额外的,不替代插件自己的位置。 -- 不要在宿主里按插件名或构建工具名加专用页面、专用分组或专用折叠阈值。 +- 不要在宿主里按插件名或构建工具名加专用页面、专用分组或专用阈值。 +- 不要把某一类的插件页逐个列进侧栏;侧栏只放种类行,页面列表在分栏页里。 - 不要在卡片或插件页里放自己的保存按钮。 - 不要把草稿值显示成当前生效值。 @@ -89,13 +97,14 @@ JDK 这类工具会被几个插件各自选一次,用户不知道哪个生效 ## 验证 -- `scripts/desktop/desktop-go.sh test ./internal/settingswindow -count=1`:`toolchains_view_test.go`、`stepping_view_test.go` 和 `build_directory_view_test.go` 覆盖作用域、筛选、分组、信任、草稿与应用、调试器编辑和种类文件夹。 -- `LITHE_VISUAL_OUTPUT_DIR=<目录> scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run 'TestVisualSettings/(32|33|34|m4[4579])' ./internal/settingswindow/`:生成目录页、文件夹页、工具链、调试器和项目信任的深浅色截图,与原型对照。 +- `scripts/desktop/desktop-go.sh test ./internal/settingswindow -count=1`:`toolchains_view_test.go`、`stepping_view_test.go` 和 `build_directory_view_test.go` 覆盖作用域、筛选、分组、信任、草稿与应用、调试器编辑,以及种类行、分栏页、筛选、记住上次页面和搜索命中。 +- `LITHE_VISUAL_OUTPUT_DIR=<目录> scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run 'TestVisualSettings/(32|33|34|m4[4579])' ./internal/settingswindow/`:生成目录页、构建工具分栏页、工具链、调试器和项目信任的深浅色截图,与原型对照。 - 原生窗口与 Windows 实机验收尚未完成,功能矩阵保持 pending。 ## 适用范围 - `desktop/internal/settingswindow/build_directory_view.go` +- `desktop/internal/settingswindow/build_kind_view.go` - `desktop/internal/settingswindow/toolchains_view.go` - `desktop/internal/settingswindow/toolchains_state.go` - `desktop/internal/settingswindow/stepping_view.go` diff --git a/.agents/notes/proposed/feature/2026-11-18-build-settings-remaining-contract-gaps.md b/.agents/notes/proposed/feature/2026-11-18-build-settings-remaining-contract-gaps.md index cdacc483b..02f0e6f2d 100644 --- a/.agents/notes/proposed/feature/2026-11-18-build-settings-remaining-contract-gaps.md +++ b/.agents/notes/proposed/feature/2026-11-18-build-settings-remaining-contract-gaps.md @@ -4,7 +4,7 @@ ## 先说结论 -「构建、执行、部署」的目录页、工具链页、调试器页和插件页文件夹已经实现,见[构建、执行、部署设置页在大量插件注入时的结构](../../implemented/feature/2026-11-18-build-execution-settings-at-scale.md)。剩下的是需要先改插件契约的几项:调试设置额外聚合到调试器下、插件页引用工具、插件页搜索关键词,以及按 5,000 个插件放宽 Core 上限。它们都要先在 Lithe-core-rust 的契约 PR 里补字段。和已实现的部分一样,这些都是额外的聚合入口,插件自己的设置位置(插件详情的「设置」标签和插件声明的页面)保持不变。 +「构建、执行、部署」的目录页、工具链页、调试器页和插件页的分栏页已经实现,见[构建、执行、部署设置页在大量插件注入时的结构](../../implemented/feature/2026-11-18-build-execution-settings-at-scale.md)。剩下的是需要先改插件契约的几项:调试设置额外聚合到调试器下、插件页引用工具、插件页搜索关键词,以及按 5,000 个插件放宽 Core 上限。它们都要先在 Lithe-core-rust 的契约 PR 里补字段。和已实现的部分一样,这些都是额外的聚合入口,插件自己的设置位置(插件详情的「设置」标签和插件声明的页面)保持不变。 ## 问题 diff --git a/desktop/internal/core/settings_surfaces.go b/desktop/internal/core/settings_surfaces.go index 4f6d4f0bb..286624f2c 100644 --- a/desktop/internal/core/settings_surfaces.go +++ b/desktop/internal/core/settings_surfaces.go @@ -36,9 +36,6 @@ type SettingsNavigationItem struct { Group bool `json:"group"` Expanded bool `json:"expanded"` Keywords string `json:"keywords,omitempty"` - // Limit shows at most this many children outside search; the rest fold into - // one overflow row that opens the group's own directory page. Zero shows all. - Limit int `json:"limit,omitempty"` } type SettingsNavigationRow struct { @@ -51,9 +48,6 @@ type SettingsNavigationRow struct { // it; Path holds the ancestor titles so a hit can be listed with its place. Matched bool `json:"matched,omitempty"` Path []string `json:"path,omitempty"` - // Overflow is the group's whole child count on the row that stands for the - // children Limit left out; the row's ID is the group's own. - Overflow int `json:"overflow,omitempty"` } type SettingsDeliveryRequest struct { diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index d4178f947..e67aeda7e 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -200,10 +200,6 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.buildSettings.filterPinned": "Set Manually", "desktop.buildSettings.filterPlaceholder": "Filter by name, version, path or plugin", "desktop.buildSettings.filterProblems": "Needs Attention", - "desktop.buildSettings.folderAll": "All {count}…", - "desktop.buildSettings.folderCount": "{count} pages · provided by plugins", - "desktop.buildSettings.folderEmpty": "No matching pages", - "desktop.buildSettings.folderFilter": "Filter pages or plugins", "desktop.buildSettings.fromSource": "from {source}", "desktop.buildSettings.groupBy": "Group", "desktop.buildSettings.groupCategory": "By Category", @@ -219,6 +215,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.buildSettings.keywordsToolchains": "toolchain sdk jdk version", "desktop.buildSettings.kindBuildSystem": "Build Tools", "desktop.buildSettings.kindCompiler": "Compiler", + "desktop.buildSettings.kindFilter": "Filter pages or plugins", + "desktop.buildSettings.kindNoMatches": "No matching pages", + "desktop.buildSettings.kindPageCount": "{count} pages", "desktop.buildSettings.listCount": "{matched} / {total} tools", "desktop.buildSettings.listSeparator": ", ", "desktop.buildSettings.noMatches": "No matching tools", @@ -3330,10 +3329,6 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.buildSettings.filterPinned": "已手动指定", "desktop.buildSettings.filterPlaceholder": "筛选名称、版本、路径或插件", "desktop.buildSettings.filterProblems": "需要处理", - "desktop.buildSettings.folderAll": "全部 {count} 个…", - "desktop.buildSettings.folderCount": "{count} 个页面 · 由插件提供", - "desktop.buildSettings.folderEmpty": "没有匹配的页面", - "desktop.buildSettings.folderFilter": "筛选页面或插件", "desktop.buildSettings.fromSource": "来自 {source}", "desktop.buildSettings.groupBy": "分组", "desktop.buildSettings.groupCategory": "按类别", @@ -3349,6 +3344,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.buildSettings.keywordsToolchains": "工具链 sdk jdk 版本 toolchain", "desktop.buildSettings.kindBuildSystem": "构建工具", "desktop.buildSettings.kindCompiler": "编译器", + "desktop.buildSettings.kindFilter": "筛选页面或插件", + "desktop.buildSettings.kindNoMatches": "没有匹配的页面", + "desktop.buildSettings.kindPageCount": "{count} 个页面", "desktop.buildSettings.listCount": "{matched} / {total} 个工具", "desktop.buildSettings.listSeparator": "、", "desktop.buildSettings.noMatches": "没有匹配的工具", diff --git a/desktop/internal/settingswindow/build_directory_view.go b/desktop/internal/settingswindow/build_directory_view.go index 78fba7588..d8882a7b6 100644 --- a/desktop/internal/settingswindow/build_directory_view.go +++ b/desktop/internal/settingswindow/build_directory_view.go @@ -1,7 +1,6 @@ package settingswindow import ( - "hash/fnv" "strings" "github.com/1lck/Lithe-IDEA/desktop/internal/core" @@ -11,21 +10,16 @@ import ( "github.com/vivaui/viva/ui" ) -// The Build, Execution, Deployment page and the page of a folder under it follow pgBuild and -// pgFolder of the prototype docs/design/build-execution-settings.html. The Build page lists its -// pages with what each holds in one line, and the tools that need attention above them; it -// shows nothing plugins put on their pages. A folder's page lists the plugin pages of one kind, -// with a filter, for the kinds the sidebar folds. +// The Build, Execution, Deployment page follows pgBuild of the prototype +// docs/design/build-execution-settings.html. It lists its pages with what each holds in one +// line, and the tools that need attention above them; it shows nothing plugins put on their +// pages. const ( // buildPageWidth is the widest the Build page grows, the prototype's max-width. buildPageWidth = 860 // directoryRowGap is the room between a row's tile, words and end, the prototype's .drow. directoryRowGap = 12 - // folderRowHeight is a row of a folder's page, the prototype's 52 points. - folderRowHeight = 52 - // folderFilterWidth is the width of a folder page's filter. - folderFilterWidth = 260 // kindNames is how many of a kind's pages the Build page names before it counts them. kindNames = 3 ) @@ -233,15 +227,12 @@ func (w *window) directoryEntries(language i18n.Language) []directoryEntry { separator := i18n.Shared(language, "desktop.buildSettings.listSeparator") for _, kind := range buildKinds { var names []string - count, first := 0, "" + count := 0 for index := range w.dynamic.pages { page := &w.dynamic.pages[index] if page.Kind != kind { continue } - if count == 0 { - first = page.Key - } if count < kindNames { names = append(names, page.Title) } @@ -258,13 +249,10 @@ func (w *window) directoryEntries(language i18n.Language) []directoryEntry { } else { desc = i18n.SharedFormat(language, "desktop.buildSettings.directoryKind", map[string]string{"names": strings.Join(names, separator)}) } - entry := directoryEntry{key: "kind:" + kind, tile: kindTile, icon: icons.LayoutGrid, title: kindTitle(language, kind), desc: desc} - if count >= folderMin { - entry.open = func() { w.openFolder(kind) } - } else { - entry.open = func() { w.selectSettingsPage(pageBuild, first) } - } - entries = append(entries, entry) + entries = append(entries, directoryEntry{ + key: "kind:" + kind, tile: kindTile, icon: icons.LayoutGrid, title: kindTitle(language, kind), desc: desc, + open: func() { w.openKind(kind) }, + }) } return entries } @@ -284,145 +272,3 @@ func toolchainCounts(scope *toolchainScope) (tools, plugins int) { } return tools, plugins } - -// buildFolderPage is the prototype's pgFolder: the plugin pages of the open folder's kind, -// the ones whose title or plugin the filter matches, each with its plugin and what it holds. -// Choosing one opens it with its folder open in the sidebar. -func (w *window) buildFolderPage(c ui.C) { - b := &w.bp - language := w.marketLanguage() - kind := w.folderPage - pages := w.folderPages(kind) - total := w.dynamic.kindCount(kind) - ui.Column(c).FillWidth().Grow(1).Shrink(1).MinHeight(0).Background(b.surface).Children(func() { - ui.Row(c).FillWidth().Shrink(0).PadSides(10, 14, 6, 14).Gap(8).Items(ui.Center).Children(func() { - ui.Text(c, kindTitle(language, kind)).FontSize(buildHeading).Weight(gfx.WeightBold).Color(b.text).Shrink(0) - ui.Text(c, i18n.SharedFormat(language, "desktop.buildSettings.folderCount", map[string]string{"count": formatCount(total)})). - FontSize(buildSmall).Color(b.sub).Shrink(1).MinWidth(0).Ellipsis() - ui.Spacer(c) - ui.Row(c).Width(folderFilterWidth).Shrink(1).MinWidth(120).Children(func() { - placeholder := i18n.Shared(language, "desktop.buildSettings.folderFilter") - w.filterField(c.Part("filter"), &w.folderQuery, placeholder, placeholder, true) - }) - }) - ui.Row(c).FillWidth().Height(1).Shrink(0).Background(b.line) - if len(pages) == 0 { - ui.Row(c).FillWidth().Shrink(0).PadSides(50, 20, 50, 20).Justify(ui.Center).Children(func() { - ui.Wrap(c, i18n.Shared(language, "desktop.buildSettings.folderEmpty")).FontSize(buildFont).Color(b.faint).TextCenter() - }) - return - } - w.folderList.Key = func(row int) int { - if row < 0 || row >= len(pages) { - return 0 - } - return folderRowKey(pages[row].Key) - } - w.folderList.Label = func(row int) string { - if row < 0 || row >= len(pages) { - return "" - } - return pages[row].Title - } - separator := i18n.Shared(language, "desktop.buildSettings.listSeparator") - ui.List(c, &w.folderList, len(pages), func(r ui.ListRow) { - page := pages[r.Index] - k := r.C - r.Element.Height(folderRowHeight).PadSides(0, 12, 0, 14).Gap(11).Items(ui.Center).Hover(ui.Look{}.Background(b.hover)).Children(func() { - plugin := folderPlugins(page, separator) - w.pluginTile(k, plugin, 28) - ui.Column(k).Grow(1).Shrink(1).MinWidth(0).Children(func() { - ui.Text(k, page.Title).FontSize(buildFont).Weight(gfx.WeightSemibold).Color(b.text).Ellipsis() - ui.Row(k).Height(2).Shrink(0) - line := plugin - if summary := folderSummary(page, separator); summary != "" { - line += " · " + summary - } - ui.Text(k, line).FontSize(11).Color(b.faint).Ellipsis() - }) - ui.Text(k, "›").FontSize(buildFont).Color(b.faint).Shrink(0) - }) - }).Scrollbars().FillWidth().Grow(1).Shrink(1).MinHeight(0).Label(kindTitle(language, kind)) - if row, ok := w.folderList.Submitted(); ok && row >= 0 && row < len(pages) { - w.openFolderPage(pages[row]) - } else if row := w.folderList.Selected(); w.folderList.Changed() && row >= 0 && row < len(pages) { - w.openFolderPage(pages[row]) - } - }) -} - -// folderRowKey is a folder page's row identity, its page's key hashed to the list's -// non-negative 31-bit keys. -func folderRowKey(key string) int { - hash := fnv.New32a() - _, _ = hash.Write([]byte(key)) - return int(hash.Sum32() & 0x7fffffff) -} - -// folderPages are the plugin pages of kind the folder page's filter keeps: the ones whose -// title or a contributing plugin's title holds the filter, ignoring case. -func (w *window) folderPages(kind string) []*core.SettingsPage { - query := strings.ToLower(strings.TrimSpace(w.folderQuery)) - var pages []*core.SettingsPage - for index := range w.dynamic.pages { - page := &w.dynamic.pages[index] - if page.Kind != kind { - continue - } - if query != "" && !folderMatches(page, query) { - continue - } - pages = append(pages, page) - } - return pages -} - -// folderMatches reports whether a lower-case query is in page's title or a contributor's. -func folderMatches(page *core.SettingsPage, query string) bool { - if strings.Contains(strings.ToLower(page.Title), query) { - return true - } - for _, contribution := range page.Contributors { - if strings.Contains(strings.ToLower(contribution.Title), query) { - return true - } - } - return false -} - -// folderPlugins names the plugins that contribute to page. -func folderPlugins(page *core.SettingsPage, separator string) string { - names := make([]string, 0, len(page.Contributors)) - for _, contribution := range page.Contributors { - name := contribution.Title - if name == "" { - name = contribution.PluginID - } - names = append(names, name) - } - return strings.Join(names, separator) -} - -// folderSummary is what a plugin page holds, the titles of its sections. -func folderSummary(page *core.SettingsPage, separator string) string { - titles := make([]string, 0, len(page.Sections)) - for _, section := range page.Sections { - if section.Title != "" { - titles = append(titles, section.Title) - } - } - return strings.Join(titles, separator) -} - -// openFolderPage opens a plugin page from its folder's page, with the folder open in the -// sidebar so the page's row is on the screen. -func (w *window) openFolderPage(page *core.SettingsPage) { - if index := kindIndex(page.Kind); index >= 0 { - w.folders[index] = true - } - // The list forgets the row, so choosing it again the next time the folder shows opens it. - w.folderList.Select(-1) - w.folderPage = "" - w.sess.open[pageBuild] = true - w.selectSettingsPage(pageBuild, page.Key) -} diff --git a/desktop/internal/settingswindow/build_directory_view_test.go b/desktop/internal/settingswindow/build_directory_view_test.go index e3ac4fe52..8d2cbf4d3 100644 --- a/desktop/internal/settingswindow/build_directory_view_test.go +++ b/desktop/internal/settingswindow/build_directory_view_test.go @@ -11,11 +11,13 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/contractfixture" "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginsettings" "github.com/vivaui/viva/app" "github.com/vivaui/viva/gfx" ) -// buildPageContributions are count enabled plugins, each with one setting on a build system +// buildPageContributions are count enabled plugins, each with two settings on a build system // page of its own, bs00, bs01 and so on, so the real Core projects count pages of that kind. func buildPageContributions(t *testing.T, count int) []core.SettingsContribution { t.Helper() @@ -32,7 +34,12 @@ func buildPageContributions(t *testing.T, count int) []core.SettingsContribution id := fmt.Sprintf("bs%02d", index) fixture.Manifest["id"] = "dev.example." + id fixture.Manifest["displayName"] = fmt.Sprintf("Builder %02d", index) - fixture.Manifest["settings"] = []any{map[string]any{"id": "flag", "type": "boolean", "title": "Flag", "default": true, "page": map[string]string{"buildSystemID": id}, "section": "Options"}} + page := map[string]string{"buildSystemID": id} + fixture.Manifest["settings"] = []any{ + map[string]any{"id": "offline", "type": "boolean", "title": "Work offline", "default": false, "page": page, "section": "Options"}, + map[string]any{"id": "jobs", "type": "integer", "title": "Parallel jobs", "default": 4, "minimum": 1, "maximum": 64, "page": page, "section": "Options"}, + } + delete(fixture.Manifest, "settingActions") manifest, err := json.Marshal(fixture.Manifest) if err != nil { t.Fatal(err) @@ -42,6 +49,33 @@ func buildPageContributions(t *testing.T, count int) []core.SettingsContribution return contributions } +// buildFormSource loads each plugin's settings from its own manifest, kept in a store of the +// test's own. +type buildFormSource struct { + store *pluginsettings.Store + manifests map[string]json.RawMessage + workspace string +} + +// newBuildFormSource is the settings of contributions, kept under t's temporary directories. +func newBuildFormSource(t *testing.T, client *core.Client, contributions []core.SettingsContribution) buildFormSource { + t.Helper() + manifests := make(map[string]json.RawMessage, len(contributions)) + for _, contribution := range contributions { + manifests[contribution.Owner.PluginID] = contribution.Manifest + } + return buildFormSource{store: pluginsettings.New(client, t.TempDir()), manifests: manifests, workspace: t.TempDir()} +} + +func (s buildFormSource) Load(ctx context.Context, id string, _ i18n.Language) (pluginservice.SettingsEditor, error) { + snapshot, err := s.store.Load(ctx, s.manifests[id], s.workspace) + return pluginservice.SettingsEditor{Snapshot: snapshot}, err +} + +func (s buildFormSource) Save(ctx context.Context, editor pluginservice.SettingsEditor, scope string, edits []core.PluginSettingEdit) (pluginsettings.SaveResult, error) { + return s.store.Save(ctx, editor.Snapshot, scope, edits, nil) +} + // buildPagesWindow is an English settings window whose plugins put count build system pages // under Build, Execution, Deployment, opened on that page and loaded. func buildPagesWindow(t *testing.T, count int) (*window, *windowDriver) { @@ -50,6 +84,7 @@ func buildPagesWindow(t *testing.T, count int) (*window, *windowDriver) { client := core.NewClient() w := newWindow(NewController(Options{ Text: func() *i18n.Messages { return i18n.For(i18n.English) }, Language: func() i18n.Language { return i18n.English }, + PluginSettings: newBuildFormSource(t, client, contributions), SettingsNavigation: client.SettingsNavigation, SettingsPages: func(ctx context.Context) ([]core.SettingsPage, error) { return client.SettingsPages(ctx, contributions) @@ -61,30 +96,54 @@ func buildPagesWindow(t *testing.T, count int) (*window, *windowDriver) { return w, d } -// buildRows are the plugin rows below Build, Execution, Deployment: folders and their pages. +// buildRows are the rows below Build, Execution, Deployment: the kinds' rows and any plugin +// page a search lists. func buildRows(w *window) []row { var rows []row inside := false for _, r := range w.rows { - if r.level == 0 { - inside = r.page == pageBuild && r.dynamic == "" && r.folder == "" + if r.level == 0 && r.path == "" { + inside = r.page == pageBuild && r.dynamic == "" && r.kind == "" continue } - if inside && (r.dynamic != "" || r.folder != "") { + if (inside || r.path != "") && (r.dynamic != "" || r.kind != "") { rows = append(rows, r) } } return rows } +// kindRow is the sidebar's row of kind, and whether the sidebar has one. +func kindRow(w *window, kind string) (row, bool) { + for _, r := range w.rows { + if r.kind == kind { + return r, true + } + } + return row{}, false +} + // contentHit is the control labeled label furthest right, the page's rather than the // sidebar's when both show the same words. func (d *windowDriver) contentHit(label string) gfx.Hit { + d.t.Helper() + return d.sideHit(label, func(hit, found gfx.Hit) bool { return hit.Bounds.X > found.Bounds.X }) +} + +// sidebarHit is the control labeled label furthest left, the sidebar's rather than the page's +// when both show the same words. +func (d *windowDriver) sidebarHit(label string) gfx.Hit { + d.t.Helper() + return d.sideHit(label, func(hit, found gfx.Hit) bool { return hit.Bounds.X < found.Bounds.X }) +} + +// sideHit is the control labeled label that better prefers over every other one. +func (d *windowDriver) sideHit(label string, better func(hit, found gfx.Hit) bool) gfx.Hit { d.t.Helper() var found gfx.Hit ok := false for _, hit := range d.driver.Snapshot().Hits { - if hit.Label == label && !hit.IsLabel && !hit.Backdrop && !hit.ID.IsZero() && (!ok || hit.Bounds.X > found.Bounds.X) { + if hit.Label == label && !hit.IsLabel && !hit.Backdrop && !hit.ID.IsZero() && (!ok || better(hit, found)) { found, ok = hit, true } } @@ -94,90 +153,51 @@ func (d *windowDriver) contentHit(label string) gfx.Hit { return found } -// TestBuildKindWithFewPagesListsThemDirectly keeps a kind's pages below Build, Execution, -// Deployment while there are fewer than folderMin of them, as the settings hierarchy Note -// says, and the Build page's row for the kind opens its first page. -func TestBuildKindWithFewPagesListsThemDirectly(t *testing.T) { - w, d := buildPagesWindow(t, folderMin-1) - w.sess.open[pageBuild] = true - d.until("the build pages in the sidebar", func() bool { - count := 0 - for _, r := range buildRows(w) { - if r.dynamic != "" { - count++ - } - } - return count == folderMin-1 - }) - for _, r := range buildRows(w) { - if r.folder != "" { - t.Fatalf("row %+v: %d pages of a kind should not fold", r, folderMin-1) - } - if r.dynamic != "" && r.level != 1 { - t.Fatalf("row %+v should be right below Build, Execution, Deployment", r) - } - } - d.clickHit(d.contentHit(kindTitle(i18n.English, "buildSystem"))) - d.pump() - if w.dynamicPage != w.dynamic.pages[0].Key || w.folderPage != "" { - t.Fatalf("the kind's row opened page %q, folder %q; want the first page %q", w.dynamicPage, w.folderPage, w.dynamic.pages[0].Key) - } -} - -// TestBuildKindFoldsIntoAFolderThatListsSix folds folderMin or more pages of a kind into a -// folder: closed, the sidebar shows only the folder; open, it lists folderLimit pages and one -// row for all of them, which opens the folder's page. -func TestBuildKindFoldsIntoAFolderThatListsSix(t *testing.T) { - const count = folderLimit + 2 +// TestBuildKindIsOneRowThatOpensItsPage keeps a kind's pages out of the sidebar however many +// there are: one row below Build, Execution, Deployment stands for them, counts them and does +// not expand, and choosing it opens the kind's page, as the Toolchains and Debuggers pages +// are laid out, on its first page. +func TestBuildKindIsOneRowThatOpensItsPage(t *testing.T) { + const count = 8 w, d := buildPagesWindow(t, count) w.sess.open[pageBuild] = true - d.until("the folder row", func() bool { return len(buildRows(w)) > 0 }) - var folder []row - for _, r := range buildRows(w) { - if r.dynamic != "" { - t.Fatalf("closed folder: page row %+v should be inside the folder", r) - } - if r.folder != "" { - folder = append(folder, r) - } + d.until("the kind's row", func() bool { return len(buildRows(w)) > 0 }) + rows := buildRows(w) + if len(rows) != 1 || rows[0].kind != "buildSystem" || rows[0].group || rows[0].expanded || rows[0].count != count || rows[0].level != 1 { + t.Fatalf("rows below Build = %+v, want one build systems row of %d pages right below it", rows, count) } - if len(folder) != 1 || folder[0].folder != "buildSystem" || !folder[0].group || folder[0].expanded || folder[0].count != count { - t.Fatalf("folder rows = %+v, want one closed build system folder of %d pages", folder, count) + d.clickHit(d.sidebarHit(kindTitle(i18n.English, "buildSystem"))) + d.until("the kind's page", func() bool { return w.shownKind() == "buildSystem" && d.text(w.dynamic.pages[1].Title) }) + if w.dynamicPage != w.dynamic.pages[0].Key { + t.Fatalf("the kind's row opened %q, want the first page %q", w.dynamicPage, w.dynamic.pages[0].Key) } - w.folders[kindIndex("buildSystem")] = true - d.until("the folder's pages", func() bool { - rows := buildRows(w) - return len(rows) > 0 && rows[len(rows)-1].overflow > 0 - }) - rows := buildRows(w) - if len(rows) != folderLimit+2 { - t.Fatalf("rows = %+v, want the folder, %d pages and the row for all of them", rows, folderLimit) + if r, _ := kindRow(w, "buildSystem"); !w.rowSelected(r) { + t.Fatal("the kind's row is not selected while its page shows") } - for _, r := range rows[1 : folderLimit+1] { - if r.dynamic == "" || r.level != 2 { - t.Fatalf("row %+v should be a page inside the folder", r) + first := w.dynamic.pages[0].Contributors[0].PluginID + d.until("the first page's settings", func() bool { + if w.pluginSettings.failed != nil { + t.Fatal(w.pluginSettings.failed) + } + return w.pluginSettings.loaded && w.pluginSettings.id == first && d.wrapped("Parallel jobs") + }) + for index := range w.dynamic.pages { + if title := w.dynamic.pages[index].Title; !d.has(title) { + t.Fatalf("the kind's page does not list %q", title) } } - all := rows[len(rows)-1] - if all.overflow != count || all.folder != "buildSystem" { - t.Fatalf("the last row %+v should stand for all %d pages", all, count) - } - label := i18n.SharedFormat(i18n.English, "desktop.buildSettings.folderAll", map[string]string{"count": formatCount(count)}) - if !d.has(label) { - t.Fatalf("the sidebar does not show %q", label) + if total := i18n.SharedFormat(i18n.English, "desktop.buildSettings.kindPageCount", map[string]string{"count": formatCount(count)}); !d.text(total) { + t.Fatalf("the kind's page does not count its pages as %q", total) } - d.click(label) - d.pump() - if w.folderPage != "buildSystem" { - t.Fatalf("the row for all pages opened folder %q, want the build system folder (%+v)", w.folderPage, all) + if !d.has(i18n.Shared(i18n.English, "desktop.buildSettings.kindFilter")) { + t.Fatal("the kind's page has no filter") } } -// TestBuildPageNamesAKindAndOpensItsFolder checks the Build page's row for a folded kind: it -// names the first pages and counts them, and opens the folder's page, whose filter keeps the -// pages it matches; choosing one opens it with the folder open. -func TestBuildPageNamesAKindAndOpensItsFolder(t *testing.T) { - const count = folderLimit + 2 +// TestBuildPageNamesAKindAndOpensItsPage checks the Build page's row for a kind: it names the +// first pages and counts them, and opens the kind's page on its first page. +func TestBuildPageNamesAKindAndOpensItsPage(t *testing.T) { + const count = kindNames + 2 w, d := buildPagesWindow(t, count) separator := i18n.Shared(i18n.English, "desktop.buildSettings.listSeparator") var names []string @@ -187,28 +207,82 @@ func TestBuildPageNamesAKindAndOpensItsFolder(t *testing.T) { desc := i18n.SharedFormat(i18n.English, "desktop.buildSettings.directoryKindMore", map[string]string{"names": strings.Join(names, separator), "count": formatCount(count)}) d.until("the kind's row", func() bool { return d.text(desc) }) d.clickHit(d.contentHit(kindTitle(i18n.English, "buildSystem"))) - d.pump() - if w.folderPage != "buildSystem" { - t.Fatalf("the kind's row opened folder %q, want the build system folder", w.folderPage) - } - d.pump() - for index := range w.dynamic.pages { - if title := w.dynamic.pages[index].Title; !d.text(title) { - t.Fatalf("the folder's page does not list %q", title) - } + d.until("the kind's page", func() bool { return w.shownKind() == "buildSystem" }) + if w.dynamicPage != w.dynamic.pages[0].Key || !w.sess.open[pageBuild] { + t.Fatalf("the kind's row opened %q, want the first page %q with Build open", w.dynamicPage, w.dynamic.pages[0].Key) } - w.folderQuery = "Builder 05" +} + +// TestBuildKindFilterKeepsThePagesItMatchesAndTheKindRemembersOne filters the kind's list by +// a plugin's name, opens the one page it keeps, and opens that page again when the kind's row +// is chosen after another page. +func TestBuildKindFilterKeepsThePagesItMatchesAndTheKindRemembersOne(t *testing.T) { + const count = 8 + w, d := buildPagesWindow(t, count) + w.openKind("buildSystem") + d.until("the kind's page", func() bool { return w.shownKind() == "buildSystem" && d.has(w.dynamic.pages[1].Title) }) + w.kinds[kindIndex("buildSystem")].query = "Builder 05" // The filter shows once a frame is painted: clicking a row before that would hit a row // the filtered list no longer has. - d.until("the filtered folder", func() bool { return !d.text(w.dynamic.pages[0].Title) }) - pages := w.folderPages("buildSystem") + d.until("the filtered list", func() bool { return !d.has(w.dynamic.pages[1].Title) }) + pages := w.kindPages("buildSystem", "Builder 05") if len(pages) != 1 || pages[0].Contributors[0].PluginID != "dev.example.bs05" { t.Fatalf("the filter kept %d pages, want the one Builder 05 contributes to", len(pages)) } key := pages[0].Key d.click(pages[0].Title) - d.pump() - if w.dynamicPage != key || w.folderPage != "" || !w.folders[kindIndex("buildSystem")] || !w.sess.open[pageBuild] { - t.Fatalf("choosing the page opened %q (folder page %q, folder open %v), want %q with its folder open", w.dynamicPage, w.folderPage, w.folders, key) + d.until("the chosen page", func() bool { return w.dynamicPage == key }) + if w.shownKind() != "buildSystem" { + t.Fatalf("choosing a page in the list left the kind's page for %q", w.dynamicPage) + } + w.selectSettingsPage(pageGeneral, "") + d.until("another page", func() bool { return w.shownKind() == "" && d.has(kindTitle(i18n.English, "buildSystem")) }) + d.clickHit(d.sidebarHit(kindTitle(i18n.English, "buildSystem"))) + d.until("the kind's page again", func() bool { return w.shownKind() == "buildSystem" }) + if w.dynamicPage != key { + t.Fatalf("the kind opened %q again, want the page it showed last, %q", w.dynamicPage, key) + } +} + +// TestSearchListsOnlyTheKindPagesItMatches lists a plugin page under a kind only when the +// search matched it, not because it matched the kind, whose row stands for its pages; choosing +// the page opens it on the kind's page. +func TestSearchListsOnlyTheKindPagesItMatches(t *testing.T) { + const count = 8 + w, d := buildPagesWindow(t, count) + target := w.dynamic.pages[5] + w.searchField.SetText(target.Title) + d.until("the matched page", func() bool { return len(buildRows(w)) > 0 }) + var pages []string + for _, r := range buildRows(w) { + if r.dynamic != "" { + pages = append(pages, r.dynamic) + } + } + if len(pages) != 1 || pages[0] != target.Key { + t.Fatalf("the search for %q listed pages %v, want only %q", target.Title, pages, target.Key) + } + w.searchField.SetText(kindTitle(i18n.English, "buildSystem")) + d.until("the kind's row", func() bool { _, ok := kindRow(w, "buildSystem"); return ok }) + for _, r := range buildRows(w) { + if r.dynamic != "" { + t.Fatalf("matching the kind listed its page %+v", r) + } + } + w.searchField.SetText(target.Title) + // A search's row is named with the path to its page. + label := "" + d.until("the matched page again", func() bool { + for _, r := range buildRows(w) { + if r.dynamic == target.Key { + label = w.rowLabel(r) + } + } + return label != "" && d.has(label) + }) + d.clickHit(d.sidebarHit(label)) + d.until("the page", func() bool { return w.dynamicPage == target.Key }) + if w.shownKind() != "buildSystem" || w.query != "" { + t.Fatalf("choosing the search's row showed kind %q with search %q, want the build systems page with the search ended", w.shownKind(), w.query) } } diff --git a/desktop/internal/settingswindow/build_kind_view.go b/desktop/internal/settingswindow/build_kind_view.go new file mode 100644 index 000000000..c8bf22561 --- /dev/null +++ b/desktop/internal/settingswindow/build_kind_view.go @@ -0,0 +1,239 @@ +package settingswindow + +import ( + "hash/fnv" + "slices" + "strings" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui" +) + +// The page of a kind of plugin pages under Build, Execution, Deployment, build systems or +// compilers, is laid out as the Toolchains and Debuggers pages are: the kind's pages on the +// left, with a filter and their count, and the chosen page's settings on the right. The +// sidebar has one row for the kind however many pages plugins contribute to it, and the list +// shows only the rows on the screen, so thousands of pages cost what a few do. +// +// The page aggregates: a plugin's settings stay on its detail's Settings tab, and the page +// shows the same form with the same drafts, kept to the settings of the chosen page. + +// kindState is the list of one kind's page: its filter, its rows and the page it showed last, +// which opens when the kind's row is chosen again. +type kindState struct { + query string + list ui.ListState + last string +} + +// shownKind is the kind whose page shows: the kind of the open plugin page when it is one of +// buildKinds, empty for any other page. +func (w *window) shownKind() string { + if w.sess.page != pageBuild || w.dynamicPage == "" { + return "" + } + if page := w.dynamic.selected(w.dynamicPage); page != nil && kindIndex(page.Kind) >= 0 { + return page.Kind + } + return "" +} + +// openKind shows the page of kind with Build expanded, on the page it showed last if the +// catalog still lists it, else on the first page of the kind. +func (w *window) openKind(kind string) { + index := kindIndex(kind) + if index < 0 { + return + } + key := "" + if last := w.dynamic.selected(w.kinds[index].last); last != nil && last.Kind == kind { + key = last.Key + } else { + for i := range w.dynamic.pages { + if w.dynamic.pages[i].Kind == kind { + key = w.dynamic.pages[i].Key + break + } + } + } + if key == "" { + return + } + w.sess.open[pageBuild] = true + w.selectSettingsPage(pageBuild, key) +} + +// buildKindPage is the page of kind: the list of its pages beside the chosen page's settings. +func (w *window) buildKindPage(c ui.C, kind string) { + b := &w.bp + language := w.marketLanguage() + state := &w.kinds[kindIndex(kind)] + state.last = w.dynamicPage + width := float32(debuggerListWidth) + if room := w.extent - 1 - toolchainDetailMin; room < width { + width = max(220, room) + } + ui.Row(c).FillWidth().Grow(1).Shrink(1).MinHeight(0).Background(b.surface).Children(func() { + ui.Column(c).Width(width).Shrink(0).FillHeight().MinHeight(0).Children(func() { + ui.Row(c).FillWidth().Shrink(0).PadX(10).PadY(10).Children(func() { + label := i18n.Shared(language, "desktop.buildSettings.kindFilter") + w.filterField(c.Part("filter"), &state.query, label, label, true) + }) + ui.Row(c).FillWidth().Height(1).Shrink(0).Background(b.line) + w.kindList(c.Part("list"), language, kind, state) + ui.Row(c).FillWidth().Height(1).Shrink(0).Background(b.line) + ui.Row(c).FillWidth().Shrink(0).PadX(12).PadY(5).Children(func() { + ui.Text(c, i18n.SharedFormat(language, "desktop.buildSettings.kindPageCount", map[string]string{"count": formatCount(w.dynamic.kindCount(kind))})). + FontSize(11).Color(b.faint).Ellipsis() + }) + }) + ui.Row(c).Width(1).Shrink(0).FillHeight().Background(b.line) + // The detail scrolls, named by the page so it starts at its top each time a page is + // chosen, and grows its content to its height, which the plugin's form fills. + ui.Scroll(c.Key("page:"+w.dynamicPage)).Scrollbars().Grow(1).Shrink(1).MinWidth(0).FillHeight(). + PadSides(buildPagePadTop, buildPagePadX, buildPagePadEnd, buildPagePadX).Gap(10).Children(func() { + if page := w.dynamic.selected(w.dynamicPage); page != nil { + w.kindDetail(c, language, page) + } + }) + }) +} + +// kindList is the pages of kind whose title or plugin holds the filter, each with the plugins +// that contribute to it. Choosing one shows its settings beside the list. +func (w *window) kindList(c ui.C, language i18n.Language, kind string, state *kindState) { + b := &w.bp + pages := w.kindPages(kind, state.query) + if len(pages) == 0 { + ui.Column(c).FillWidth().Grow(1).Shrink(1).MinHeight(0).PadSides(50, 20, 50, 20).Items(ui.Center).Children(func() { + ui.Wrap(c, i18n.Shared(language, "desktop.buildSettings.kindNoMatches")).FontSize(buildSmall).Color(b.faint).TextCenter() + }) + return + } + state.list.Key = func(row int) int { + if row < 0 || row >= len(pages) { + return 0 + } + return kindRowKey(pages[row].Key) + } + state.list.Header = nil + state.list.Label = func(row int) string { + if row < 0 || row >= len(pages) { + return "" + } + return pages[row].Title + } + at := slices.IndexFunc(pages, func(page *core.SettingsPage) bool { return page.Key == w.dynamicPage }) + if state.list.Selected() != at { + state.list.Select(at) + if at >= 0 { + state.list.ScrollIntoView(at) + } + } + separator := i18n.Shared(language, "desktop.buildSettings.listSeparator") + ui.List(c, &state.list, len(pages), func(r ui.ListRow) { + page := pages[r.Index] + k := r.C + plugins := kindPlugins(page, separator) + r.Element.Height(debuggerRow).PadSides(0, 12, 0, 14).Gap(9).Items(ui.Center).Hover(ui.Look{}.Background(b.hover)) + if r.Selected() { + r.Element.Background(b.sel) + } + r.Element.Children(func() { + w.pluginTile(k, plugins, 20) + ui.Column(k).Grow(1).Shrink(1).MinWidth(0).Children(func() { + ui.Text(k, page.Title).FontSize(buildFont).Weight(gfx.WeightSemibold).Color(b.text).Ellipsis() + ui.Row(k).FillWidth().Height(2).Shrink(0) + ui.Text(k, plugins).FontSize(11).Color(b.faint).Ellipsis() + }) + }) + }).Scrollbars().FillWidth().Grow(1).Shrink(1).MinHeight(0).Label(kindTitle(language, kind)) + if state.list.Changed() { + if at := state.list.Selected(); at >= 0 && at < len(pages) && pages[at].Key != w.dynamicPage { + w.selectSettingsPage(pageBuild, pages[at].Key) + } + } +} + +// kindDetail is the chosen page: its title and the plugins that contribute to it, the chooser +// of the contributor when there is more than one, and that contributor's settings of the page. +func (w *window) kindDetail(c ui.C, language i18n.Language, page *core.SettingsPage) { + b := &w.bp + if len(page.Contributors) == 0 { + ui.Wrap(c, i18n.Shared(language, "desktop.pluginSettings.pageUnavailable")).Color(w.pal.muted) + return + } + // A refreshed catalog may no longer list the chosen contributor: the first one stands in. + if w.contributionOf(page) < 0 { + w.contributorID = page.Contributors[0].PluginID + } + plugins := kindPlugins(page, i18n.Shared(language, "desktop.buildSettings.listSeparator")) + ui.Row(c).FillWidth().Shrink(0).Gap(12).Items(ui.Center).Children(func() { + w.pluginTile(c, plugins, 40) + ui.Column(c).Grow(1).Shrink(1).MinWidth(0).Children(func() { + ui.Text(c, page.Title).FontSize(buildHeading).Weight(gfx.WeightBold).Color(b.text).Ellipsis() + ui.Row(c).Height(4).Shrink(0) + ui.Text(c, i18n.SharedFormat(language, "desktop.buildSettings.providedBy", map[string]string{"plugin": plugins})). + FontSize(buildSmall).Color(b.sub).Ellipsis() + }) + }) + if w.dynamic.failed != nil { + ui.Wrap(c, i18n.Shared(language, "desktop.pluginSettings.failed")).Color(w.pal.danger) + } + if len(page.Contributors) > 1 { + ui.Select(c, &w.contributorID, w.dynamic.contributorIDs[page.Key], w.contributorLabel).FillWidth(). + Label(i18n.Shared(language, "desktop.pluginSettings.contributor")) + } + w.pluginSettingsPanel(c, w.contributorID) +} + +// kindRowKey is a row's identity in a kind's list, its page's key hashed to the list's +// non-negative 31-bit keys. +func kindRowKey(key string) int { + hash := fnv.New32a() + _, _ = hash.Write([]byte(key)) + return int(hash.Sum32() & 0x7fffffff) +} + +// kindPages are the plugin pages of kind the filter query keeps: the ones whose title or a +// contributing plugin's title holds it, ignoring case. +func (w *window) kindPages(kind, query string) []*core.SettingsPage { + query = strings.ToLower(strings.TrimSpace(query)) + var pages []*core.SettingsPage + for index := range w.dynamic.pages { + page := &w.dynamic.pages[index] + if page.Kind != kind || (query != "" && !kindMatches(page, query)) { + continue + } + pages = append(pages, page) + } + return pages +} + +// kindMatches reports whether a lower-case query is in page's title or a contributor's. +func kindMatches(page *core.SettingsPage, query string) bool { + if strings.Contains(strings.ToLower(page.Title), query) { + return true + } + for _, contribution := range page.Contributors { + if strings.Contains(strings.ToLower(contribution.Title), query) { + return true + } + } + return false +} + +// kindPlugins names the plugins that contribute to page. +func kindPlugins(page *core.SettingsPage, separator string) string { + names := make([]string, 0, len(page.Contributors)) + for _, contribution := range page.Contributors { + name := contribution.Title + if name == "" { + name = contribution.PluginID + } + names = append(names, name) + } + return strings.Join(names, separator) +} diff --git a/desktop/internal/settingswindow/build_search.go b/desktop/internal/settingswindow/build_search.go index a083cc7bd..90e77450c 100644 --- a/desktop/internal/settingswindow/build_search.go +++ b/desktop/internal/settingswindow/build_search.go @@ -125,7 +125,6 @@ func (w *window) chooseSearchRow(r row) bool { // openBuildChild shows a page under Build, Execution, Deployment with Build expanded, so its // row is on the screen once the search ends. func (w *window) openBuildChild(page pageID) { - w.folderPage = "" w.sess.open[pageBuild] = true w.selectSettingsPage(page, "") } diff --git a/desktop/internal/settingswindow/model.go b/desktop/internal/settingswindow/model.go index 6a12cd251..801eaa221 100644 --- a/desktop/internal/settingswindow/model.go +++ b/desktop/internal/settingswindow/model.go @@ -32,7 +32,8 @@ const ( pageVersionControl // pageBuild is the group "Build, Execution, Deployment", which also has a page of its // own: the directory of its pages and what needs attention. The two pages after it - // belong to it, and so do the build system and compiler pages plugins contribute. + // belong to it, and so does a row for each kind of page plugins contribute to it, build + // systems and compilers, which opens that kind's pages as the two pages list theirs. pageBuild pageToolchains pageDebuggers @@ -153,19 +154,17 @@ type row struct { title string hit int page pageID - // level is 0 on the top level, 1 for a page inside a group and 2 for a page inside - // a folder of a group. + // level is 0 on the top level and 1 for a page inside a group. level uint8 // group says the row is a group, which has a chevron and expands instead of // opening a page; expanded says its pages are listed under it. group, expanded bool - // folder is the kind of plugin pages the row is the folder of, or the folder an - // overflow row opens. A folder row has a chevron and opens the folder's page. - folder string - // overflow is how many pages the folder has when the row stands for the ones the - // sidebar leaves out; choosing it opens the folder's page. count is how many pages a - // folder's row holds. - overflow, count int + // kind is the kind of plugin pages under Build, Execution, Deployment the row opens, and + // count how many pages of it there are. + kind string + count int + // overflow is how many tools the search matched on the row that lists every one of them. + overflow int // path is where a search match lives, its ancestors' titles joined by " › ", // shown after its title. A string keeps a row comparable. path string @@ -198,11 +197,10 @@ const ( // The keys of the rows that are not a page of the table nor a plugin's page. They are past // any count of plugin pages and stay inside the list's non-negative 31-bit keys. const ( - // folderHit is a folder's row; the row after it, folderHit+1, is the folder's row of - // the pages the sidebar leaves out. - folderHit = 1 << 28 + // kindHit is the row of a kind of plugin pages, by the kind's place in buildKinds. + kindHit = 1 << 28 // sectionHit is a section's title; allToolsHit the row listing every matching tool. - sectionHit = folderHit + 64 + sectionHit = kindHit + 64 allToolsHit = sectionHit + 16 // toolHit and adapterHit are the rows of a tool and a debugger, by their place. toolHit = 1 << 29 @@ -260,14 +258,12 @@ func appendVisible(dst []row, messages *i18n.SettingsMessages, open *[pageCount] return dst } -// crumb is one title of the breadcrumb and what choosing it opens: a page, or the page of a -// folder of kind under Build, Execution, Deployment. link is set on a title before the last -// that has a page of its own to open. +// crumb is one title of the breadcrumb and the page choosing it opens. link is set on a title +// before the last that has a page of its own to open. type crumb struct { - title string - page pageID - folder string - link bool + title string + page pageID + link bool } // appendBreadcrumb appends the titles that lead to id to dst and returns it: the group and @@ -291,19 +287,10 @@ func contributedParent(kind string) pageID { } // buildKinds are the kinds of plugin pages under Build, Execution, Deployment, in the -// order the sidebar and the Build page list them. +// order the sidebar and the Build page list them. Each kind has one row in the sidebar, +// whatever the count of its pages, and its page lists them (build_kind_view.go). var buildKinds = [...]string{"buildSystem", "compiler"} -const ( - // folderMin is how many pages of one kind fold into a folder of their own; fewer are - // listed under Build, Execution, Deployment directly, as the settings hierarchy Note - // says. - folderMin = 3 - // folderLimit is how many of a folder's pages the sidebar lists; the rest are on the - // folder's page. - folderLimit = 6 -) - // kindIndex is the place of kind in buildKinds, or -1 for another kind. func kindIndex(kind string) int { for index, k := range buildKinds { @@ -314,7 +301,7 @@ func kindIndex(kind string) int { return -1 } -// kindTitle names a kind of plugin pages: the folder's title and its page's. +// kindTitle names a kind of plugin pages: its row's title and its page's. func kindTitle(language i18n.Language, kind string) string { if kind == "compiler" { return i18n.Shared(language, "desktop.buildSettings.kindCompiler") @@ -571,7 +558,7 @@ func decideKey(key keyKind, ctx keyContext) keyAction { } func (r row) hitIndex() int { - if r.dynamic != "" || r.folder != "" || r.special != rowPage { + if r.dynamic != "" || r.kind != "" || r.special != rowPage { return r.hit } return int(r.page) diff --git a/desktop/internal/settingswindow/settings_surfaces.go b/desktop/internal/settingswindow/settings_surfaces.go index 2c33e47b2..ff2ba6289 100644 --- a/desktop/internal/settingswindow/settings_surfaces.go +++ b/desktop/internal/settingswindow/settings_surfaces.go @@ -151,28 +151,28 @@ func (s *settingsSurfaces) run(parent context.Context) (surfacesResult, error) { items = append(items, core.SettingsNavigationItem{ID: name, Title: titleOf(&key.text.Settings, id), Parent: parent, Group: isGroup(id) || contributed[id], Expanded: key.open[id], Keywords: pageKeywords(job.language, id)}) lookup[name] = row{page: id} } - // The build system and compiler pages of one kind fold into a folder once there are - // folderMin of them: the sidebar lists its first folderLimit and the folder's own page - // lists them all (build_directory_view.go). + // The build system and compiler pages are each under one row of their kind, which opens + // the kind's page that lists them (build_kind_view.go). The row is a group that never + // expands, so its pages are in the sidebar only while a search matches them. kinds := make(map[string]int) for _, page := range result.pages { kinds[page.Kind]++ } buildID := "static:" + strconv.Itoa(int(pageBuild)) for index, kind := range buildKinds { - if kinds[kind] < folderMin { + if kinds[kind] == 0 { continue } - name := "folder:" + kind + name := "kind:" + kind title := kindTitle(job.language, kind) - items = append(items, core.SettingsNavigationItem{ID: name, Title: title, Parent: &buildID, Group: true, Expanded: key.folders[index], Limit: folderLimit}) - lookup[name] = row{page: pageBuild, folder: kind, title: title, hit: folderHit + 2*index, count: kinds[kind]} + items = append(items, core.SettingsNavigationItem{ID: name, Title: title, Parent: &buildID, Group: true}) + lookup[name] = row{page: pageBuild, kind: kind, title: title, hit: kindHit + index, count: kinds[kind]} } for index, page := range result.pages { parent := contributedParent(page.Kind) parentID := "static:" + strconv.Itoa(int(parent)) - if parent == pageBuild && kinds[page.Kind] >= folderMin { - parentID = "folder:" + page.Kind + if kindIndex(page.Kind) >= 0 { + parentID = "kind:" + page.Kind } name := "page:" + page.Key items = append(items, core.SettingsNavigationItem{ID: name, Title: page.Title, Parent: &parentID}) @@ -193,13 +193,10 @@ func (s *settingsSurfaces) run(parent context.Context) (surfacesResult, error) { if !ok { continue } - r.group = item.Group - r.expanded = item.Expanded + // A kind's row opens its page, which lists the pages under it. + r.group = item.Group && r.kind == "" + r.expanded = item.Expanded && r.kind == "" r.level = item.Level - if item.Overflow > 0 { - // The row that stands for the pages the folder leaves out opens the folder. - r.group, r.expanded, r.overflow, r.hit = false, false, item.Overflow, r.hit+1 - } result.rows = append(result.rows, r) } } @@ -208,7 +205,9 @@ func (s *settingsSurfaces) run(parent context.Context) (surfacesResult, error) { // searchRows lists a search's hits flat, as the prototype does: every page the search matched // or that is under a match, with the titles of its ancestors as its path. A group without a -// page of its own is only a path, since its pages are listed. +// page of its own is only a path, since its pages are listed. A plugin's page under a kind is +// listed only when the search matched it: the kind's row stands for the others, which may be +// thousands. func searchRows(projected []core.SettingsNavigationRow, lookup map[string]row) []row { var rows []row var matched []bool @@ -220,10 +219,13 @@ func searchRows(projected []core.SettingsNavigationRow, lookup map[string]row) [ inside = inside || above } r, ok := lookup[item.ID] - if !ok || !inside || item.Overflow > 0 { + if !ok || !inside { + continue + } + if r.dynamic == "" && r.kind == "" && isGroup(r.page) && !ownsPage(r.page) { continue } - if r.dynamic == "" && r.folder == "" && isGroup(r.page) && !ownsPage(r.page) { + if r.dynamic != "" && r.page == pageBuild && !item.Matched { continue } r.path = strings.Join(item.Path, " › ") diff --git a/desktop/internal/settingswindow/visual_capture_test.go b/desktop/internal/settingswindow/visual_capture_test.go index 12ac11ab3..12a4e386e 100644 --- a/desktop/internal/settingswindow/visual_capture_test.go +++ b/desktop/internal/settingswindow/visual_capture_test.go @@ -47,7 +47,7 @@ func TestVisualSettings(t *testing.T) { {"25-settings-process", pageProcessTermination}, {"26-settings-git", pageVersionControl}, {"26-settings-git-console", pageVersionControl}, {"27-settings-terminal", pageTerminal}, {"28-plugins-installed", pagePlugins}, {"29-marketplace-empty", pagePlugins}, - {"32-settings-build", pageBuild}, {"32-settings-build-folder", pageBuild}, {"34-settings-debuggers", pageDebuggers}, + {"32-settings-build", pageBuild}, {"32-settings-build-kind", pageBuild}, {"34-settings-debuggers", pageDebuggers}, {"33-settings-toolchains", pageToolchains}, {"m44-toolchain-directory-menu", pageToolchains}, {"m45-toolchain-custom-directory", pageToolchains}, {"m47-toolchain-project-untrusted", pageToolchains}, {"m48-toolchain-project-trusted", pageToolchains}, {"m49-toolchain-project-trust-click", pageToolchains}, {"m50-toolchain-project-trust-tip", pageToolchains}, @@ -101,9 +101,11 @@ func TestVisualSettings(t *testing.T) { values.SteppingFilters = map[string]core.DebugSteppingFilters{"fixture-jvm": {ClassNameFilters: []string{"java.*", "javax.*", "sun.*", "com.example.generated.*"}, SkipSynthetics: true, SkipStaticInitializers: true}} } if scenario.page == pageBuild { - // Eight plugins each bring a build system page, so the kind folds into a folder. + // Eight plugins each bring a build system page, which the kind's one row and + // page list. contributions := buildPageContributions(t, 8) client := core.NewClient() + opts.PluginSettings = newBuildFormSource(t, client, contributions) opts.SettingsNavigation = client.SettingsNavigation opts.SettingsPages = func(ctx context.Context) ([]core.SettingsPage, error) { return client.SettingsPages(ctx, contributions) @@ -201,8 +203,11 @@ func TestVisualSettings(t *testing.T) { d.click(text("desktop.settings.processTermination.onQuit")) case "m43-process-orphan-policy": d.click(text("desktop.settings.processTermination.leftoverTerminals")) - case "32-settings-build-folder": - w.openFolder("buildSystem") + case "32-settings-build-kind": + w.openKind("buildSystem") + d.until("the first page's settings", func() bool { + return w.shownKind() == "buildSystem" && w.pluginSettings.loaded && w.pluginSettings.id == w.contributorID + }) d.pump() case "m44-toolchain-directory-menu": d.click("Compiler") diff --git a/desktop/internal/settingswindow/window.go b/desktop/internal/settingswindow/window.go index 9f0d6e90d..abe0d809d 100644 --- a/desktop/internal/settingswindow/window.go +++ b/desktop/internal/settingswindow/window.go @@ -42,11 +42,9 @@ const ( tileGap = 8 // childIndent is where the title of a row inside a group starts, under the title of the // group. levelIndent is the Tree's step of a level, which a row's content pads up to where - // its title starts, so a folder's chevron sits in front of the titles beside it; folderStep - // is how much further in a folder's pages start, the prototype's step from l1 to l2. + // its title starts. childIndent = chevronSlot + tileSize + tileGap levelIndent = childIndent / 2 - folderStep = 18 // sectionHeight is the height of a section's title in the search, the prototype's .hd. sectionHeight = 26 // crumbHeight is the height of the breadcrumb, the prototype's .crumb. @@ -126,13 +124,9 @@ type window struct { stepping *steppingState // apply is the footer's write of the Build pages' drafts. apply buildApply - // folders says which folders of plugin pages the sidebar lists the pages of, by their - // kind's place in buildKinds. folderPage is the kind whose folder page shows while the - // Build page is open, empty for the Build page itself; folderQuery filters it. - folders [len(buildKinds)]bool - folderPage string - folderQuery string - folderList ui.ListState + // kinds is the list of each kind of plugin pages under Build, by the kind's place in + // buildKinds: its filter, its rows and the page it last showed. + kinds [len(buildKinds)]kindState pluginSettings *pluginSettingsForm pluginForms map[string]*pluginSettingsForm formLimitReported bool @@ -225,10 +219,9 @@ type window struct { // rowsKey is everything Core's projection of the sidebar is computed from. type rowsKey struct { - text *i18n.Messages - query string - open [pageCount]bool - folders [len(buildKinds)]bool + text *i18n.Messages + query string + open [pageCount]bool } // sidebarKey is everything the sidebar's rows are computed from: Core's projection, and while @@ -534,7 +527,7 @@ func (w *window) declareWork(c ui.C) { // refreshRows rebuilds the sidebar's rows when the language, the search or the expanded // groups have changed since they were built. func (w *window) refreshRows() { - key := rowsKey{text: w.text, query: w.query, open: w.sess.open, folders: w.folders} + key := rowsKey{text: w.text, query: w.query, open: w.sess.open} projected := w.ctrl.opts.SettingsNavigation != nil if projected { w.dynamic.request(key) diff --git a/desktop/internal/settingswindow/window_view.go b/desktop/internal/settingswindow/window_view.go index 7a9b0996e..f3c85323c 100644 --- a/desktop/internal/settingswindow/window_view.go +++ b/desktop/internal/settingswindow/window_view.go @@ -128,24 +128,23 @@ func (w *window) sidebar(c ui.C) { // chooseRow opens what row r stands for. A group without a page of its own folds; one with a // page, which Build is and plugins' pages make any entry they are under, opens it, and Build -// lists its pages as it opens. A folder opens its own page. A search ends once its row is -// chosen, with the rows above the page opened so the page's row is on the screen. +// lists its pages as it opens. A kind's row opens the kind's page. A search ends once its row +// is chosen, with the rows above the page opened so the page's row is on the screen. func (w *window) chooseRow(r row) { if w.chooseSearchRow(r) { return } searching := w.query != "" switch { - case r.folder != "": - w.openFolder(r.folder) + case r.kind != "": + w.openKind(r.kind) case r.group && isGroup(r.page) && !ownsPage(r.page) && r.dynamic == "": w.toggleRow(r) return default: - if r.page == pageBuild && r.dynamic == "" { + if r.page == pageBuild { w.sess.open[pageBuild] = true } - w.folderPage = "" w.selectSettingsPage(r.page, r.dynamic) } if searching { @@ -154,26 +153,13 @@ func (w *window) chooseRow(r row) { } } -// openFolder shows the page of the folder of kind under Build, Execution, Deployment. -func (w *window) openFolder(kind string) { - w.folderPage, w.folderQuery = kind, "" - w.sess.open[pageBuild] = true - w.selectSettingsPage(pageBuild, "") -} - -// revealPage opens every row above the page row r opens, and the folder of a plugin's page -// in one. +// revealPage opens every row above the page row r opens. func (w *window) revealPage(r row) { for page := parents[r.page]; page != noPage; page = parents[page] { w.sess.open[page] = true } if r.dynamic != "" { w.sess.open[r.page] = true - if page := w.dynamic.selected(r.dynamic); page != nil { - if index := kindIndex(page.Kind); index >= 0 && w.dynamic.kindCount(page.Kind) >= folderMin { - w.folders[index] = true - } - } } } @@ -184,15 +170,8 @@ func (w *window) clearSearch() { w.rowsValid = false } -// toggleRow expands or collapses the group of row r, or the folder r is. While searching -// every group is open. +// toggleRow expands or collapses the group of row r. While searching every group is open. func (w *window) toggleRow(r row) { - if r.folder != "" { - if index := kindIndex(r.folder); index >= 0 && w.query == "" { - w.folders[index] = !w.folders[index] - } - return - } toggleGroup(&w.sess.open, r.page, r.group, w.query != "") } @@ -220,18 +199,16 @@ func (w *window) navNode(i int) ui.TreeNode { return ui.TreeNode{Depth: int(r.level), Branch: r.group, Expanded: r.expanded, Selected: w.rowSelected(r)} } -// rowSelected says whether row r stands for the page on the screen. A folder's row is chosen -// while its page shows, Build's while Build's own page does. +// rowSelected says whether row r stands for the page on the screen. A kind's row is chosen +// while its page shows one of its pages, Build's while Build's own page does. func (w *window) rowSelected(r row) bool { switch { - case r.special != rowPage || r.overflow > 0: + case r.special != rowPage: return false - case r.folder != "": - return w.sess.page == pageBuild && w.dynamicPage == "" && w.folderPage == r.folder + case r.kind != "": + return w.shownKind() == r.kind case r.group && isGroup(r.page) && !ownsPage(r.page): return false - case r.page == pageBuild && r.dynamic == "" && w.folderPage != "": - return false } return r.page == w.sess.page && r.dynamic == w.dynamicPage } @@ -253,14 +230,12 @@ func (w *window) navLabel(i int) string { } // rowLabel is the words row r reads as: a search's page after where it lives, the row that -// lists what a folder or a search leaves out by its count, else the row's title. +// lists what a search leaves out by its count, else the row's title. func (w *window) rowLabel(r row) string { language := w.marketLanguage() switch { case r.special == rowAllTools: return i18n.SharedFormat(language, "desktop.buildSettings.searchAllTools", map[string]string{"count": formatCount(r.overflow)}) - case r.overflow > 0: - return i18n.SharedFormat(language, "desktop.buildSettings.folderAll", map[string]string{"count": formatCount(r.overflow)}) case r.special == rowPage && r.path != "": return r.path + " › " + w.rowTitle(r) } @@ -269,7 +244,7 @@ func (w *window) rowLabel(r row) string { // navContent declares what row i holds after its chevron: the page's tile on the top level, // its title, then what the prototype ends it with: a count of problems, a mark of drafts, a -// folder's count of pages or where a search's match lives. +// kind's count of pages or where a search's match lives. func (w *window) navContent(c ui.C, i int) { if i < 0 || i >= len(w.rows) { return @@ -282,12 +257,8 @@ func (w *window) navContent(c ui.C, i int) { ui.Text(c, r.title).FontSize(buildTiny).Weight(gfx.WeightSemibold).Color(b.faint).Ellipsis() }) return - case r.special == rowAllTools || r.overflow > 0: - pad := float32(0) - if w.query == "" { - pad = w.titleStart(r) - float32(r.level)*levelIndent - } - ui.Text(c, w.rowLabel(r)).FontSize(buildSmall).Color(b.accent).PadLeft(pad).Grow(1).Shrink(1).MinWidth(0).Ellipsis() + case r.special == rowAllTools: + ui.Text(c, w.rowLabel(r)).FontSize(buildSmall).Color(b.accent).Grow(1).Shrink(1).MinWidth(0).Ellipsis() return case w.query != "": ui.Row(c).Grow(1).Shrink(1).MinWidth(0).Gap(6).Items(ui.Center).Children(func() { @@ -312,7 +283,7 @@ func (w *window) navContent(c ui.C, i int) { w.navTrailing(c, r) } if r.level != 0 { - pad := w.titleStart(r) - float32(r.level)*levelIndent + pad := childIndent - float32(r.level)*levelIndent if r.group { pad -= chevronSlot } @@ -335,23 +306,14 @@ func (w *window) navContent(c ui.C, i int) { }) } -// titleStart is where the title of a row below the top level starts in the sidebar: under -// the titles of the top level, and a folder's pages a step further in. -func (w *window) titleStart(r row) float32 { - if r.level >= 2 { - return childIndent + folderStep - } - return childIndent -} - // navTrailing ends a row as the prototype does: Build folded and the Toolchains page count the -// tools with a problem, the Debuggers page marks drafts and a folder counts its pages. +// tools with a problem, the Debuggers page marks drafts and a kind counts its pages. func (w *window) navTrailing(c ui.C, r row) { if r.dynamic != "" { return } switch { - case r.folder != "": + case r.kind != "": ui.Text(c, formatCount(r.count)).FontSize(buildTiny).Color(w.bp.faint).Shrink(0) case r.page == pageBuild && !r.expanded, r.page == pageToolchains: if problems := w.toolchainProblems(); problems > 0 { @@ -388,6 +350,10 @@ func (w *window) content(c ui.C) { return } w.breadcrumb(c) + if kind := w.shownKind(); kind != "" { + w.buildKindPage(c.Part("kind"), kind) + return + } if w.dynamicPage != "" { w.dynamicSettingsPage(c) return @@ -399,8 +365,6 @@ func (w *window) content(c ui.C) { w.editorPage(c) case w.sess.page == pageFonts: w.fontsPage(c) - case w.sess.page == pageBuild && w.folderPage != "": - w.buildFolderPage(c.Part("folder")) case w.sess.page == pageBuild: w.buildPage(c.Part("build")) case w.sess.page == pageToolchains: @@ -431,7 +395,7 @@ func (w *window) content(c ui.C) { // breadcrumb is the prototype's .crumb: where the open page is, its group first and the page // last in the weight of the text. A title before the last that has a page of its own opens it: -// Build, Execution, Deployment its directory, a folder its list of pages. +// Build, Execution, Deployment its directory. func (w *window) breadcrumb(c ui.C) { b := &w.bp w.crumbs = w.appendCrumbs(w.crumbs[:0]) @@ -468,40 +432,32 @@ func (w *window) breadcrumb(c ui.C) { } // appendCrumbs appends the titles that lead to the open page to dst: the page's group and the -// page, and for a plugin's page under Build, Execution, Deployment the folder it is in, which -// the sidebar shows once its kind has folderMin pages. +// page. A plugin's page under Build, Execution, Deployment shows on its kind's page, which the +// breadcrumb names as the Toolchains and Debuggers pages are named; one under another entry +// is named after it. func (w *window) appendCrumbs(dst []crumb) []crumb { - language := w.marketLanguage() dst = appendBreadcrumb(dst, &w.text.Settings, w.sess.page) parent := &dst[len(dst)-1] - switch { - case w.dynamicPage != "": - page := w.dynamic.selected(w.dynamicPage) - if page == nil { - break - } - parent.link = ownsPage(parent.page) - if kindIndex(page.Kind) >= 0 && contributedParent(page.Kind) == w.sess.page && w.dynamic.kindCount(page.Kind) >= folderMin { - dst = append(dst, crumb{title: kindTitle(language, page.Kind), page: pageBuild, folder: page.Kind, link: true}) - } - dst = append(dst, crumb{title: page.Title, page: w.sess.page}) - case w.sess.page == pageBuild && w.folderPage != "": - parent.link = true - dst = append(dst, crumb{title: kindTitle(language, w.folderPage), page: pageBuild, folder: w.folderPage}) + if w.dynamicPage == "" { + return dst + } + page := w.dynamic.selected(w.dynamicPage) + if page == nil { + return dst + } + parent.link = ownsPage(parent.page) + title := page.Title + if kind := w.shownKind(); kind != "" { + title = kindTitle(w.marketLanguage(), kind) } - return dst + return append(dst, crumb{title: title, page: w.sess.page}) } -// chooseCrumb opens what a title of the breadcrumb stands for. +// chooseCrumb opens the page a title of the breadcrumb stands for. func (w *window) chooseCrumb(crumb crumb) { - if crumb.folder != "" { - w.openFolder(crumb.folder) - return - } if crumb.page == pageBuild { w.sess.open[pageBuild] = true } - w.folderPage = "" w.selectSettingsPage(crumb.page, "") } diff --git a/docs/assets/build-execution-settings/32-settings-build-dark.png b/docs/assets/build-execution-settings/32-settings-build-dark.png index 3578c558b..452257026 100644 Binary files a/docs/assets/build-execution-settings/32-settings-build-dark.png and b/docs/assets/build-execution-settings/32-settings-build-dark.png differ diff --git a/docs/assets/build-execution-settings/32-settings-build-folder-dark.png b/docs/assets/build-execution-settings/32-settings-build-folder-dark.png deleted file mode 100644 index 9b46707bb..000000000 Binary files a/docs/assets/build-execution-settings/32-settings-build-folder-dark.png and /dev/null differ diff --git a/docs/assets/build-execution-settings/32-settings-build-folder-light.png b/docs/assets/build-execution-settings/32-settings-build-folder-light.png deleted file mode 100644 index cc64fc096..000000000 Binary files a/docs/assets/build-execution-settings/32-settings-build-folder-light.png and /dev/null differ diff --git a/docs/assets/build-execution-settings/32-settings-build-kind-dark.png b/docs/assets/build-execution-settings/32-settings-build-kind-dark.png new file mode 100644 index 000000000..35e5f82ee Binary files /dev/null and b/docs/assets/build-execution-settings/32-settings-build-kind-dark.png differ diff --git a/docs/assets/build-execution-settings/32-settings-build-kind-light.png b/docs/assets/build-execution-settings/32-settings-build-kind-light.png new file mode 100644 index 000000000..f3a3b7b95 Binary files /dev/null and b/docs/assets/build-execution-settings/32-settings-build-kind-light.png differ diff --git a/docs/assets/build-execution-settings/32-settings-build-light.png b/docs/assets/build-execution-settings/32-settings-build-light.png index 8781b9e88..129010119 100644 Binary files a/docs/assets/build-execution-settings/32-settings-build-light.png and b/docs/assets/build-execution-settings/32-settings-build-light.png differ diff --git a/docs/design/build-execution-settings.html b/docs/design/build-execution-settings.html index 5f644dbed..7219dbb47 100644 --- a/docs/design/build-execution-settings.html +++ b/docs/design/build-execution-settings.html @@ -459,10 +459,10 @@ q:"",filter:"all",groupBy:"category",collapsed:{plugin:true},sel:"java.jdk", saved:{global:{"rust.toolchain":"~/.rustup/toolchains/1.100.0-aarch64-apple-darwin"},project:{"java.jdk":"~/.sdkman/candidates/java/21.0.5-tem"}}, draft:{global:{},project:{}},custom:{global:{},project:{}}, - open:{build:true,"k.buildSystem":true,"k.compiler":false}, + open:{build:true},kindLast:{}, navq:"",scroll:{},whyOpen:false,adding:null,addPath:"", dbgSel:"java",dbgSaved:{},dbgDraft:{},dbgAdd:"",dbgQ:"", - folderQ:"",notes:true,notesOpen:true,noteHl:null,toast:null,applying:false,dark:false, + kindQ:"",notes:true,notesOpen:true,noteHl:null,toast:null,applying:false,dark:false, }; /* ================= 生效值(原型里模拟 Core) ================= */ @@ -618,15 +618,11 @@ if(!open)continue; h+=`
2026-10-15-macos-settings-hierarchy.md。"],
+ [2,["*"],"侧栏:宿主自带的“工具链”“调试器”是固定子页;插件声明的页面按种类放。每一种类只占一行并显示页面数,点开是分栏页(见 16),插件再多侧栏也不变长。分组折叠时问题数显示在分组上。需要同步更新 2026-10-15-macos-settings-hierarchy.md。"],
[3,["toolchains"],"作用域放进工具栏,原来常驻的两段说明收进 ⓘ(develop-lithe 第五节)。两个作用域的草稿分开保存,有修改的作用域带蓝点,可以随时切换,不再因为有草稿就禁用切换。"],
[4,["toolchains"],"列表一行一个工具(46px),按需渲染:切到 5,000 个插件看演示栏右侧的“列表渲染”计数,始终只有二十几行。筛选、分组、排序和计数应由 Core 投影,平台只取可见窗口(develop-lithe 第三、四节)。"],
[5,["toolchains"],"筛选:文字筛选(名称、版本、路径、插件)+“需要处理 / 已手动指定 / 未应用”。“需要处理”汇总未找到、版本不满足、检测失败、需要信任和冲突;组内也按问题优先排序。"],
@@ -894,11 +895,11 @@