Skip to content

feat(workbench): refactor Settings shell into a full-window inverted-L page - #7238

Merged
M4n5ter merged 2 commits into
apache:mainfrom
YayoiNanoka:feat/settings-page-shell
Nov 26, 2026
Merged

M4n5ter merged 2 commits into
apache:mainfrom
YayoiNanoka:feat/settings-page-shell

Conversation

@YayoiNanoka

@YayoiNanoka YayoiNanoka commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Problem

Settings previously rendered inside a floating <ModalDialog size="page" height={800}> over a dimmed scrim on top of Conversations/Rooms:

  • The floating modal box clashed with Maka's borderless inverted-L window shell (DESIGN.md §Window shell) and TS Maka's page-mode Settings layout, leaving a dimmed background sidebar, a redundant static "Settings" heading, and a modal top-right × close button.
  • At minimum desktop size (640×480), the modal chrome and outer scrim consumed scarce viewport height and squeezed settings rows below the visible viewport.
  • Settings mounted its own second <Toaster> instance instead of using the app's global toast store, and ModalDialog carried a one-off size="page" variant solely for Settings.

Solution

  • Top-level peer WorkspaceSurface routing (products/maka/workbench/app/App.tsx, plugins/agent/conversations/ui/RoomView.tsx, plugins/agent/conversations/ui/SessionSurface.tsx):
    • Gate conversations and rooms surfaces on !settingsOpened() and render settingsViewContract inside a third peer <WorkspaceSurface visible={settingsOpened}>. Conversations and Rooms remain mounted (display: 'none') so streaming turns, scroll positions, composer drafts, side panes, and workspaceMode survive entering and leaving Settings.
    • Update windowTitle to tr('Settings') while open, suppress hidden previewDialog overlays when invisible in both Conversations (App.tsx) and Rooms (RoomView.tsx), and keep both mod+, and empty-draft mod+g (selected() === null) idempotent when Settings is already open.
  • Borderless Inverted-L Settings shell & C.panel / C.card surface ladder (products/maka/workbench/app/ModelSettings.tsx, SettingsPage.tsx, RootUiSettings.tsx, ComposerToolbarSettings.tsx, GeneralSettings.tsx, RemoteAccessSettings.tsx, CommunityPlugins.tsx, ConnectionModel.tsx, DESIGN.md):
    • Replace <ModalDialog> with Maka's inverted-L window shell: a 224pt C.chrome left rail with <TitleBar height={TITLE_BAR_HEIGHT}> clearing macOS traffic lights, a full-width ← Back to app button, and a scrollable category list; plus a borderless rounded 12pt C.panel main panel (PANEL_INSET = 8, windowDrag, controlsRight(true) clearance, no modal × close button).
    • Align SettingsPage.tsx (SettingsSection -> C.card, in-card controls/badges/triggers/buttons -> C.cardRaised with Dark/Light/Terminal hover, active, and quietFocusStyle() focus states, in-card inputs & textarea fade -> C.panel, panel-level SettingsSearch -> C.background) and Settings subpages resting on SettingsSection onto Maka's semantic surface ladder, keeping DESIGN.md in sync.
    • Reuse ui.tsx shared chrome styles (quietFocusStyle, quietActiveStyle, quietHoverStyle, controlHoverStyle), flatten narrow header folding (narrowBackBar()), and snap strictly to the 8×16 grid on terminal (platform.idiom === 'terminal').
  • Toast convergence, shared <WindowDialog>, and desktop-native Escape (products/maka/workbench/app/ModelSettings.tsx, ModalDialog.tsx, WorkspacePicker.tsx, ImageViewer.tsx, Workbench.tsx, plugins/settings/settings/ui.tsx, RoomView.tsx, SessionSurface.tsx):
    • Converge operations.notice() onto the global toast store with toast.dismiss('settings.notice') on clear/unmount and reset operations.notice on Settings close/cleanup when no operations are pending; remove the unused size="page" variant from ModalDialog.
    • Funnel all 6 main-window <Dialog> call sites through one shared <WindowDialog> wrapper in ModalDialog.tsx so hasOpenModalSurface() automatically suspends the Settings Escape binding while any main-window modal dialog is open (without coupling separate <Window>s such as QuickLauncher).
    • Bind Escape with { when: terminal ? 'always' : 'notEditing' } so desktop blurs focused <Input> fields on the first Escape before stepping back through nested subpages / unsaved-draft prompts and returning to the app, while terminal keeps 'always'.
  • 12-locale JSON updates (products/maka/workbench/locales/*.json):
    • Add "Back to app" across all 11 full locale JSONs (zh-HK inherits "返回應用" from zh-TW per overlay rules) and remove the unused "Close settings" key.
点击展开中文

要解决的问题

此前 Rust Maka 的 Settings 以浮动模态框(<ModalDialog size="page" height={800}>)+ 遮罩层的形式叠在 Conversations/Rooms 之上:

  • 与 Maka 无边框的倒 L 形窗口壳层(DESIGN.md §Window shell)以及 TS Maka 的页面模式设置布局不一致,存在遮罩层、冗余静态 "Settings" 标题与右上角 × 关闭按钮。
  • 在桌面最小窗口尺寸(640×480)下,弹窗外边距与遮罩消耗了大量可视高度,挤压设置项。
  • Settings 内部独立挂载了第二个 <Toaster>,且 ModalDialog 仅为 Settings 保留了 size="page" 变体。

当前解决方案

  • 顶层平级 WorkspaceSurface 路由(App.tsx、RoomView.tsx、SessionSurface.tsx):将 Settings 渲染为与 Conversations、Rooms 平级的第三个 <WorkspaceSurface visible={settingsOpened}>,进入/离开 Settings 时保持 Conversations 与 Rooms 挂载以完整保留流式回复、滚动位置、输入框草稿、侧边面板与 workspaceMode;同步抑制 Conversations 与 Rooms 不可见时的 previewDialog,更新窗口标题为 Settings,并保持 mod+, 以及空会话(selected() === null)下 mod+g 的幂等性。
  • 无边框倒 L 形壳层与 C.panel / C.card 色阶对齐(ModelSettings.tsx、SettingsPage.tsx、RootUiSettings.tsx、ComposerToolbarSettings.tsx、GeneralSettings.tsx、RemoteAccessSettings.tsx、CommunityPlugins.tsx、ConnectionModel.tsx、DESIGN.md):移除 <ModalDialog>,采用 224pt C.chrome 左侧栏(<TitleBar> + 全宽 ← Back to app / 返回应用 + 可滚动分类)与右侧无边框 12pt 圆角 C.panel 主面板,并将 SettingsSection 与其内部控件对齐到 C.card / C.cardRaised 色阶(确保深/浅色与终端下的 hover、active 与 quietFocusStyle() 键盘焦点清晰可见),复用 ui.tsx 共享样式,扁平化窄屏头部折叠(narrowBackBar()),并严格对齐终端 8×16 字符网格。
  • Toast 收敛、统一 <WindowDialog> 与原生桌面 Escape 行为(ModelSettings.tsx、ModalDialog.tsx、WorkspacePicker.tsx、ImageViewer.tsx、Workbench.tsx、plugins/settings/settings/ui.tsx、RoomView.tsx、SessionSurface.tsx):将 operations.notice() 收敛到全局 toast store 并在清空/关闭时调用 toast.dismiss('settings.notice') 与清理残留提示;用统一的 <WindowDialog> 封装收口主窗口全部 6 处 <Dialog> 调用,自动协调 hasOpenModalSurface()(不影响独立 <Window> 的 QuickLauncher);Settings 的 Escape 绑定使用 { when: terminal ? 'always' : 'notEditing' },桌面端在聚焦 <Input> 内首次按 Escape 仅退焦而不离页,再次按 Escape 再逐级返回子页、处理未保存草稿或回到应用。
  • 12 语言 JSON 同步(products/maka/workbench/locales/*.json):在全部 11 份完整 locale JSON 中新增自然翻译的 "Back to app"(zh-HK 按 overlay 规则继承 zh-TW 的 "返回應用"),并移除不再使用的 "Close settings"。

验证情况

  • 已通过 cargo fmt --all -- --check、涉及改动目录的 biome format plugins/ products/、ASF 许可证头检查(2,785 个文件)、12 语言 i18n/check.mjs、workbench 单元测试(304/304)、products/maka/bundle 类型检查、maka-workbench 单元测试(3/3,覆盖真实 ModalDialog Escape 隔离、未保存草稿保护、嵌套子页 Escape 逐级返回与终端窄屏折叠)、run product(31 个插件包 + 5/5 产品测试 + notices 检查)以及 macOS AppKit native-desktop 实机集成测试(desktop_settings_page_shell_preserves_state_and_overlays)。
  • 已通过 native-desktop 实机渲染采集 Before(模态框)与 After(无边框 C.chrome -> C.panel -> C.card 倒 L 形页面)的深/浅色、宽屏(1120×900)与窄屏(640×480)对比截图(见下方 Verification 表格)。

Verification

Visual Comparison (macOS AppKit native-desktop captures)

View Before (modal Settings) After (borderless inverted-L C.panel / C.card page)
Wide Dark (1120×900, General) Before Wide Dark General After Wide Dark General
Wide Light (1120×900, General) Before Wide Light General After Wide Light General
Wide Dark (1120×900, Models) Before Wide Dark Models After Wide Dark Models
Narrow Dark (640×480, General) Before Narrow Dark General After Narrow Dark General
Narrow Light (640×480, General) Before Narrow Light General After Narrow Light General

Automated Checks

  • cargo fmt --all -- --check — passed
  • node node_modules/@biomejs/biome/bin/biome format plugins/ products/ — passed (533 files; untouched upstream scripts/ci/suites.mjs currently has a pre-existing formatting diff on origin/main)
  • node scripts/asf-license-headers.mjs check — passed (2785 covered files audited)
  • node scripts/i18n/check.mjs — passed (12 locales, 5 catalogs, 1 doc set)
  • node node_modules/typescript/bin/tsc -p products/maka/bundle/tsconfig.json — passed (note: full node scripts/ci.mjs run contracts also verified packages/plugin-sdk and all products/ & plugins/ against generated ui-types with 0 errors; untouched upstream skills/maka-plugin-authoring/assets/composer-ui/index.tsx currently fails tsc on origin/main after #7310)
  • node --test products/maka/workbench/tests/*.test.mjs — passed (304/304)
  • node scripts/ci.mjs run product — passed (31 plugin packages built, 5/5 product tests, THIRD_PARTY_NOTICES.txt check)
  • cargo test --locked -p maka-workbench --lib -- settings_page_shell models_settings — passed (3/3: settings_page_shell_navigation_and_terminal_folding covering real ModalDialog Escape isolation, dirty-draft Escape & Back to app confirmation, nested subpage Escape stepping, and narrow terminal folding; plus existing models_settings_* tests)
  • cargo test --locked -p maka-cli --features desktop-tests --test native-desktop -- --exact terminal::desktop_new_session::desktop_settings_page_shell_preserves_state_and_overlays — passed (1/1: real macOS AppKit verification of conversation draft preservation, Rooms workspaceMode preservation, idempotent mod+, and empty-draft mod+g, focused <Input> Escape blur before stepping back, Select Escape isolation, clean-root Escape / Back to app return, and narrow 640×480 non-overlap folding)
  • Not run locally: node scripts/ci.mjs check licenses (cargo-deny is not installed in the local toolchain; ASF header verification ran directly via node scripts/asf-license-headers.mjs check).

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Antigravity (Gemini) — implemented the Settings full-window inverted-L shell refactor, WorkspaceSurface routing, C.panel/C.card/C.cardRaised surface alignment, shared <WindowDialog> wrapper, Escape and notice toast handling, 12-locale updates, and headless + native-desktop behavioral tests (Generated-by: Antigravity (Gemini) commit trailer retained).

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a breaking change or persisted-data migration?

  • Yes — describe user/data impact, in-place migration, and upgrade_compat.rs coverage under Summary above
  • No

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Nov 24, 2026
@YayoiNanoka
YayoiNanoka force-pushed the feat/settings-page-shell branch from 63eae10 to a1b18ec Compare November 24, 2026 12:52
@YayoiNanoka
YayoiNanoka marked this pull request as ready for review November 24, 2026 14:19

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

The overall direction looks solid—moving Settings out of ModalDialog into a peer inverted-L WorkspaceSurface, converging notices onto the global toast store, and removing the one-off ModalDialog size="page" variant all make sense. Before merging, there are a few real bugs, some design/cleanliness items (cc @Astro-Han on the DESIGN.md / visual shell trade-offs), and test bloat worth cleaning up.

Correctness & Merge Readiness

  1. Merge conflict against main (12-locale JSON migration)

    • The PR is currently CONFLICTING because products/maka/workbench/app/locale-settings.ts was removed in #7224 (69af2805b2) in favor of products/maka/workbench/locales/*.json.
    • Needs a rebase onto main, adding "Back to app" and removing the unused "Close settings" key across all 12 locale JSON files.
  2. Missed peer previewDialog suppression in RoomView.tsx (plus Escape leak)

    • Where: plugins/agent/conversations/ui/RoomView.tsx:197-205 vs. the change in products/maka/workbench/app/App.tsx:188-191, and products/maka/workbench/app/Workbench.tsx:271-278.
    • Trigger: In a narrow window (< 912pt, where !canDockPreview()), open a Room, click a file/link to open the resource preview dialog (previewDialog), then press mod+, to open Settings.
    • Impact: App.tsx suppresses Conversations' previewDialog when settingsOpened() || workspaceMode() !== 'conversations', but the peer createPreviewDialog in RoomView.tsx still only checks suppressed: () => resources.imageViewer() !== null without !input.visible(). As a result, the Room preview <Dialog> stays open on top of Settings. Because Workbench.tsx:272's <Dialog> does not call trackModalSurface(), pressing Escape closes Settings underneath while the preview dialog remains stuck on screen.
    • Fix: Include !input.visible() in RoomView.tsx's createPreviewDialog suppressed predicate.
  3. Pressing Escape inside any focused Settings <Input> now exits Settings / triggers discard confirmation

    • Where: products/maka/workbench/app/ModelSettings.tsx (keymap.bind('escape', () => back(backAction()), { when: 'always' })).
    • Trigger: Focus any text input inside Settings (e.g., General display name, Models/Skills/MCP search input, Connection API key / Base URL) and press Escape.
    • Impact: Previously, <ModalDialog> relied on NSH's native navigation::key_pressed, where macOS, Windows, and Linux all intentionally blur a focused text field on the first Escape without navigating away from the screen. Binding escape with { when: 'always' } intercepts the key in the platform keymap monitor ahead of field blur, so pressing Escape to leave an input immediately closes Settings or pops up Discard unsaved changes?.
    • Fix: Use when: terminal ? 'always' : 'notEditing' (TUI's handle_field_key does not consume Escape, while desktop blurs the focused input first and then lets a second Escape step back / close Settings).
  4. QuickLauncher.tsx trackModalSurface() is redundant and breaks main-window Settings Escape

    • Where: products/maka/workbench/app/QuickLauncher.tsx:1546-1548 and :1568.
    • Trigger: Have Settings open in the main window -> open QuickLauncher and enter a Quick Tool page (page() !== null, where closeOnBlur={!props.conversing() && page() === null} is false) -> click back to the main window -> press Escape in Settings.
    • Impact: Escape in main-window Settings stops working while QuickLauncher stays open in the background. Moreover, this tracking is unnecessary in the first place: Bootstrap.tsx mounts the main app inside an explicit <Window id="main">, so ModelSettings's keymap.bind is already window-scoped to main in NSH and never fires in <Window id="quick-launcher">.
    • Fix: Remove the trackModalSurface() addition from QuickLauncher.tsx.
  5. SessionSurface.tsx breaks mod+g idempotency when no session is selected (selected() === null)

    • Where: plugins/agent/conversations/ui/SessionSurface.tsx:812-842.
    • Trigger: Start on an empty conversation (selected() === null) -> open Settings, switch to General or make an unsaved form edit -> press mod+g (Models).
    • Impact: The PR moved if (request.kind === 'settings') above if (!(shell()?.visible() ?? false) && !shell()?.dismissRoute()) return;, but left if (request.kind === 'models' && sessionId === null) below it. With Settings open, mod+g hits dismissRoute() first—synchronously setting settingsOpened to false and unmounting ModelSettings (wiping unsaved drafts and page state)—and then calls openSettings() to remount it fresh on the default page.
    • Fix: Keep the original normalization (const target = request.kind === 'models' && sessionId === null ? { kind: 'settings' as const, sessionId } : request;) before the if (target.kind === 'settings') early return. That fixes the bug and keeps open() shorter.
  6. Stale settings.notice toast cleanup when converging onto the global toast store

    • Where: products/maka/workbench/app/ModelSettings.tsx:214-226 and plugins/settings/settings/ui.tsx:303-312.
    • Trigger: Save preferences in General (operations.notice.set('Preferences saved.')) -> close Settings (ModelSettings unmounts, but operations lives at plugin scope so operations.notice() retains the string) -> reopen Settings later.
    • Impact: ModelSettings mounts fresh with lastNotice = '', so the effect immediately re-emits the stale Preferences saved. notice into the global toast store. Also, clearing operations.notice.set('') on category switch doesn't call toast.dismiss('settings.notice') (unlike Composer.tsx and SessionSurface.tsx).
    • Fix: Call toast.dismiss('settings.notice') when message becomes empty, and clear operations.notice on Settings close/cleanup when there are no pending operations.

Design & Cleanliness (cc @Astro-Han)

  1. Global trackModalSurface() ref-count in ModalDialog.tsx is brittle

    • Maintaining a parallel Symbol.for('maka.workbench.openModalSurfaces') counter manually across ModalDialog, WorkspacePicker, ImageViewer, and QuickLauncher duplicates NSH's modal stack and easily misses raw <Dialog> call sites (Workbench.tsx:272, SessionSurface.tsx:3000, RoomView.tsx:235, or future plugin dialogs).
    • If workbench-side tracking is needed while NSH <Dialog> handles Escape after ordinary keymap.bind, it would be much cleaner to funnel all main-window <Dialog> usages through one shared wrapper (and keep separate <Window>s out of it) rather than scattering manual trackModalSurface() calls.
  2. Dark-mode panel surface token vs. DESIGN.md (cc @Astro-Han)

    • DESIGN.md and Workbench.tsx separate sidebar (C.chrome) and main panel (C.panel) via a surface-fill step without a border, with cards on C.card.
    • Here, to avoid touching SettingsPage.tsx (which still uses C.surface / C.background), the dark-mode Settings panel stays on C.background (identical #161719 fill as C.chrome) and compensates with a dark-only 1px C.line hairline border around the entire panel. That leaves dark-mode Settings visually distinct from Conversations and Rooms (visible in after-wide-dark.png).
    • There are only ~15 token references across SettingsPage.tsx and SettingsField.tsx. Would appreciate @Astro-Han's call on whether to align SettingsPage onto C.panel / C.card now or keep the dark hairline as an intentional interim compromise.
  3. Ad-hoc local transitions/scale and deep <If> nesting in ModelSettings.tsx

    • ModelSettings.tsx introduces local navTransition(), iconButtonTransition(), navActiveStyle(), navFocusStyle(), and transform: [{ scale: 0.95 }] on the nested Back icon button. Shared styles already live in ui.tsx (quietFocusStyle, quietActiveStyle, controlHoverStyle), and neither WorkspaceBrowser.tsx nor RoomWorkspace.tsx applies background transitions or press scaling to navigation chrome.
    • The 3-level nested <If> in the narrow header (splitting rail(), ownTitleBar, and !terminal) could also be flattened into a small helper so the layout structure reads cleanly at a glance.

Tests

Test additions currently make up 51.6% of the diff (+360 test lines vs. +338 prod lines), with noticeable duplication and low-signal parts:

  • Pure screenshot harness left in native-desktop (settings.rs): desktop_settings_page_shell_preserves_state_and_overlays launches 4 separate real macOS AppKit windows. Window #2 (light, lines 97–111) has zero assertions—it only opens Settings, clicks General, writes a screenshot artifact, and closes. Windows #3 and #4 repeat the exact same narrow flex-layout checks in both Dark and Light purely to capture screenshots.
  • Verification claim vs. actual coverage gap: The PR description states settings.rs verifies idempotent mod+,, but settings.rs never sends mod+,. Meanwhile, several core behaviors changed by this PR aren't tested anywhere: mod+, idempotency, returning from Settings to Rooms (workspaceMode preservation), hidden previewDialog suppression, and focused-input Escape.
  • Implementation-coupled fake & duplicated geometry checks: models-settings.tsx adds a synthetic TrackedDialog that directly invokes trackModalSurface() (testing the private counter mechanism rather than real WorkspacePicker / ImageViewer modals), and settings.rs + lib.rs duplicate the same hardcoded coordinate checks (<= 224, >= 240, Close settings absent, Select Escape).

Suggested test cleanup: Delete the pure-screenshot windows, the synthetic TrackedDialog, and the duplicated pixel-bound assertions, and rebuild around behavior:

  1. One compact single-window native-desktop test verifying end-to-end host/AppKit behavior: conversation draft + Rooms workspaceMode preservation across Settings entry/exit, idempotent mod+, keeping the current category, focused-input Escape blurring without leaving Settings, Select Escape isolation, and clean-root Escape / Back to app return (plus one narrow non-overlap check if needed).
  2. One compact headless test in lib.rs covering Settings' unsaved-draft confirmation (Escape / Back to app), nested subpage Escape stepping, and terminal folding without locking exact pixel constants.
简体中文

整体方向是对的:把 Settings 从 ModalDialog 移成与 Conversations、Rooms 平级的倒 L 形 WorkspaceSurface,把提示收敛到全局 toast,并顺手删掉只用一次的 ModalDialog size="page",思路很合理。不过合入前有几个真实可达的 bug、一些设计与整洁度问题(涉及 DESIGN.md 和视觉壳层取舍的部分 cc @Astro-Han 一起看下),以及测试信噪比问题需要收拾一下。

正确性与合入阻塞项

  1. 与 main 存在合并冲突(12 语言 JSON 迁移)

    • 当前 PR 状态已是 CONFLICTING:products/maka/workbench/app/locale-settings.ts 已在 #7224(69af2805b2)被移除并迁移至 products/maka/workbench/locales/*.json。
    • 需要 rebase 到最新 main,在全部 12 个 locale JSON 中补齐 "Back to app" 并清理不再使用的 "Close settings"。
  2. 漏修了 RoomView.tsx 对等路径的 previewDialog 抑制(且会叠加 Escape 穿透)

    • 位置:plugins/agent/conversations/ui/RoomView.tsx:197-205 对比 products/maka/workbench/app/App.tsx:188-191,以及 products/maka/workbench/app/Workbench.tsx:271-278。
    • 触发路径:在窄窗口(< 912pt,!canDockPreview())下进入 Rooms -> 点击消息里的文件/链接打开资源预览弹窗(previewDialog)-> 按 mod+, 打开 Settings。
    • 影响:App.tsx 为 Conversations 的 previewDialog 补了 settingsOpened() || workspaceMode() !== 'conversations' 抑制,但对等的 RoomView.tsx 仍只判断 suppressed: () => resources.imageViewer() !== null,漏掉了 !input.visible()。结果 Room 的资源预览 <Dialog> 会一直盖在 Settings 上方;而且 Workbench.tsx:272 的 <Dialog> 未接入 trackModalSurface(),用户按 Escape 想关预览弹窗时,会直接触发底下的 ModelSettings Escape 绑定,把 Settings 关掉而预览弹窗仍留在屏幕上。
    • 修复:在 RoomView.tsx 的 createPreviewDialog 的 suppressed 条件中补上 !input.visible()。
  3. 在 Settings 任意文本框内按 Escape 会直接退页或弹丢弃确认,破坏桌面端编辑习惯

    • 位置:products/maka/workbench/app/ModelSettings.tsx(keymap.bind('escape', () => back(backAction()), { when: 'always' }))。
    • 触发路径:聚焦 Settings 内任意输入框(如 General 的 Display name、Models/Skills/MCP 搜索框、Connection 的 Base URL / API Key 等)并按 Escape。
    • 影响:改造前 <ModalDialog> 走 NSH 原生 navigation::key_pressed,macOS / Windows / Linux 三端桌面都明确约定「聚焦输入框按 Escape 只退焦,绝不直接离开当前页」。改为 { when: 'always' } 后,按键在平台 keymap monitor 阶段就会提前截胡,用户在搜索框或表单里按 Escape 想退出输入,会直接关掉 Settings 或弹出 Discard unsaved changes?。
    • 修复:改为 when: terminal ? 'always' : 'notEditing'(终端 TUI 的 handle_field_key 不消费 Escape,桌面端则先由原生逻辑退焦,第二次 Escape 再返回/关闭 Settings)。
  4. QuickLauncher.tsx 中的 trackModalSurface() 既多余,又会在后台搞死主窗口 Settings 的 Escape

    • 位置:products/maka/workbench/app/QuickLauncher.tsx:1546-1548 及 :1568。
    • 触发路径:主窗口开着 Settings -> 唤起 QuickLauncher 并打开某个 Quick Tool 子页(此时 page() !== null,closeOnBlur={!props.conversing() && page() === null} 为 false,失焦不关闭)-> 点回主窗口 -> 在主窗口 Settings 按 Escape。
    • 影响:只要 QuickLauncher 还停在后台,hasOpenModalSurface() 就一直为 true,主窗口 Settings 的 Escape 彻底失效。而且这段追踪本身就没必要:Bootstrap.tsx 把主应用包在显式 <Window id="main"> 里,ModelSettings 的 keymap.bind 在 NSH 中已经自动 scope 到 main 窗口,本来就不会在独立窗口 <Window id="quick-launcher"> 中触发。
    • 修复:直接移除 QuickLauncher.tsx 里的 trackModalSurface() 改动。
  5. SessionSurface.tsx 拆分 models 后,空会话下在 Settings 里按 mod+g 会拆掉重挂 Settings(丢草稿和当前页)

    • 位置:plugins/agent/conversations/ui/SessionSurface.tsx:812-842。
    • 触发路径:处于空白会话(selected() === null)-> 打开 Settings,切到 General 或修改任意表单产生未保存草稿 -> 按 mod+g(Models)。
    • 影响:PR 只把 if (request.kind === 'settings') 提到了 if (!(shell()?.visible() ?? false) && !shell()?.dismissRoute()) return; 之前,把 if (request.kind === 'models' && sessionId === null) 留在了后面。结果会先执行 dismissRoute() 同步把 settingsOpened 置为 false,立刻卸载 ModelSettings(丢失未保存草稿与页面状态),紧接着再调 openSettings() 重新挂载回默认页。
    • 修复:把原来的归一化逻辑 const target = request.kind === 'models' && sessionId === null ? { kind: 'settings' as const, sessionId } : request; 整体提到 if (target.kind === 'settings') 之前即可,代码还更简洁。
  6. 收敛到全局 toast 后,settings.notice 缺少清理与关闭重置

    • 位置:products/maka/workbench/app/ModelSettings.tsx:214-226 与 plugins/settings/settings/ui.tsx:303-312。
    • 触发路径:在 General 保存偏好(operations.notice.set('Preferences saved.'))-> 关闭 Settings(ModelSettings 卸载,但 operations 挂在插件层,operations.notice() 仍保留旧文案)-> 之后再次打开 Settings。
    • 影响:ModelSettings 重新挂载后 lastNotice 回到 '',effect 会把上一次的 Preferences saved. 再次弹进全局 toast;此外切换分类清空 operations.notice.set('') 时也没有像 Composer.tsx / SessionSurface.tsx 那样调用 toast.dismiss('settings.notice')。
    • 修复:message 变空时调用 toast.dismiss('settings.notice'),并在 Settings 关闭 / cleanup 且无 pending 操作时清空 operations.notice。

设计与整洁度(cc @Astro-Han)

  1. ModalDialog.tsx 里的 trackModalSurface() 全局引用计数过于脆弱

    • 通过 Symbol.for('maka.workbench.openModalSurfaces') 在 ModalDialog、WorkspacePicker、ImageViewer、QuickLauncher 四处手动维护一份平行于 NSH 原生 modal 栈的影子计数,既分散了单一事实来源,又容易漏掉仓库里的裸 <Dialog>(Workbench.tsx:272、SessionSurface.tsx:3000、RoomView.tsx:235)以及后续插件里的弹窗。
    • 如果短期内不改 NSH、仍需要在 workbench 侧协调弹窗与页面级 Escape,更干净的做法是把主窗口内所有 <Dialog> 收口到一个统一封装里自动记账(不要让调用方手动调用隐式协议,也不要把独立 <Window> 混进来)。
  2. 深色模式主面板色阶与 DESIGN.md 不一致(cc @Astro-Han)

    • DESIGN.md 和 Workbench.tsx 规定侧栏(C.chrome)与主面板(C.panel)通过无边框的色阶落差区分,卡片使用 C.card。
    • 本 PR 为了不动 SettingsPage.tsx(内部仍在用 C.surface / C.background),在深色模式下把 Settings 主面板留在与 C.chrome 同色的 C.background(#161719),再额外套一圈深色专属的 1px C.line 框线(在 after-wide-dark.png 里对比 Conversations / Rooms 挺明显)。
    • SettingsPage.tsx 与 SettingsField.tsx 里相关 token 统共约 15 处,方便的话请 @Astro-Han 拍个板:是这次顺手把 SettingsPage 对齐到 C.panel / C.card,还是明确接受深色细线作为阶段性折中。
  3. ModelSettings.tsx 的局部过渡/缩放样式和嵌套 <If>

    • 新增了局部 navTransition()、iconButtonTransition()、navActiveStyle()、navFocusStyle() 以及子页返回按钮的 transform: [{ scale: 0.95 }]。但 ui.tsx 已有共享的 quietFocusStyle / quietActiveStyle / controlHoverStyle,且 WorkspaceBrowser.tsx、RoomWorkspace.tsx 的导航栏 chrome 均未使用背景过渡或按压缩放,这里显得风格跳戏。
    • 窄屏头部为了放置 backToApp 嵌套了三层 <If>(rail() / ownTitleBar / !terminal),抽成扁平分支可读性会好很多。

测试质量

当前新增测试占总新增行数的 51.6%(测试 +360 vs. 生产代码 +338),但信噪比偏低、重复断言较多:

  • native-desktop 里残留了纯截图用例(settings.rs):desktop_settings_page_shell_preserves_state_and_overlays 连续启动了 4 个真实 macOS AppKit 窗口。其中第 2 个窗口(light,97–111 行)没有任何断言,只打开 Settings、点 General、截完图就关;第 3、4 个窗口(narrow Dark/Light 循环)只是为了多截一张图把同一组窄屏坐标断言跑了两遍。
  • PR 描述与实际覆盖不符:PR 正文 Verification 写了 settings.rs 验证了幂等 mod+,,但整份 settings.rs 从未按过 mod+,;同时本次改动里几项关键行为(mod+, 幂等不重置当前页、从 Rooms 进出 Settings 保留 workspaceMode、隐藏的 previewDialog 抑制、聚焦输入框内按 Escape)目前都没有测试覆盖。
  • 测试实现细节 + 跨套重复断言:models-settings.tsx 造了个假组件 TrackedDialog 直接调 trackModalSurface()(测的是私有计数辅助函数本身,而不是真实的 WorkspacePicker / ImageViewer),且 settings.rs 与 lib.rs 重复锁死了相同的像素坐标(<= 224、>= 240)、Close settings 缺失以及 Select Escape。

建议重构测试:删掉纯截图窗口、假 TrackedDialog 和重复的像素坐标断言,围绕真实行为重新精简成两块高价值测试:

  1. 1 个单窗口 native-desktop 行为测试:覆盖需要真实宿主与 AppKit 才能验到的行为——进出 Settings 保留会话草稿与 Rooms workspaceMode、mod+, 幂等停留在当前分类、输入框内按 Escape 只退焦不离页、Select Escape 隔离、clean root 按 Escape / Back to app 返回(如需防窄屏回归,补一次单主题 640×480 不重叠校验即可)。
  2. 1 个紧凑的 lib.rs headless 测试:聚焦 Settings 自身的未保存草稿确认(Escape / Back to app)、嵌套子页逐级 Escape 返回与终端模式折叠行为,避免绑死具体像素常量。

…L page

Move Settings out of ModalDialog into a peer WorkspaceSurface alongside
Conversations and Rooms, preserving background session state (drafts,
scroll positions, side panes, streaming turns, and workspaceMode).

- Route Settings as a peer WorkspaceSurface in App.tsx, suppress hidden
  previewDialog modals in both Conversations (App.tsx) and Rooms
  (RoomView.tsx), update windowTitle, and keep mod+, and empty-draft
  mod+g idempotent when Settings is already open (SessionSurface.tsx).
- Replace ModalDialog in ModelSettings.tsx with Maka's borderless
  inverted-L shell (C.chrome left rail with TitleBar and Back to app,
  rounded C.panel main panel with windowDrag and controlsRight clearance,
  shared ui.tsx chrome states, flat narrow 640x480 folding, and 8x16
  terminal cell layout).
- Align SettingsPage.tsx and Settings subpages inside SettingsSection
  onto Maka's C.panel -> C.card -> C.cardRaised surface ladder with
  clear Dark, Light, and Terminal hover/active/focus states, and update
  DESIGN.md accordingly.
- Converge operations.notice() onto the global toast store with explicit
  dismissal and close/cleanup reset (ModelSettings.tsx, settings/ui.tsx),
  and remove the unused size="page" variant from ModalDialog.
- Centralize main-window modal tracking behind a shared WindowDialog
  wrapper (ModalDialog.tsx) across all 6 main-window Dialog call sites,
  and bind Escape in ModelSettings with when: terminal ? 'always' :
  'notEditing' so desktop inputs blur on first Escape before stepping back.
- Add Back to app and remove unused Close settings across all 12 locale
  JSONs, update existing desktop tests, and add compact behavioral tests
  in settings.rs and lib.rs.

Generated-by: Antigravity (Gemini)
YayoiNanoka added a commit to YayoiNanoka/maka-agent that referenced this pull request Nov 26, 2026
@YayoiNanoka
YayoiNanoka force-pushed the feat/settings-page-shell branch from a1b18ec to e4397cc Compare November 26, 2026 12:22
@YayoiNanoka

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @M4n5ter! I've rebased onto main and addressed all items in e4397cc23:

  • Correctness
    1. Rebased onto main (8290d09df), migrated "Back to app" / removed unused "Close settings" across all 12 locales/*.json files (and updated desktop_new_session.rs), verified with node scripts/i18n/check.mjs.
    2. Added !input.visible() to RoomView.tsx's createPreviewDialog.suppressed.
    3. Changed ModelSettings.tsx Escape binding to { when: terminal ? 'always' : 'notEditing' } so desktop blurs focused inputs first.
    4. Removed trackModalSurface() from QuickLauncher.tsx.
    5. Moved the models (sessionId === null) -> settings normalization in SessionSurface.tsx ahead of dismissRoute() so mod+g stays idempotent.
    6. Dismissed settings.notice on empty/unmount and cleared operations.notice on Settings close when no operations are pending.
  • Design & Cleanliness
    1. Replaced scattered trackModalSurface() calls with a shared <WindowDialog> wrapper across all 6 main-window <Dialog> call sites.
    2. Aligned Settings onto the C.chrome -> C.panel -> C.card / C.cardRaised ladder (ModelSettings.tsx, SettingsPage.tsx, DESIGN.md, and in-card subpage controls) and removed the dark-only 1px border workaround; refreshed Before/After screenshots in the PR description.
    3. Removed ad-hoc local transitions/scale: 0.95 in ModelSettings.tsx in favor of ui.tsx shared chrome styles, and flattened the narrow header into narrowBackBar().
  • Tests
    • Removed the screenshot-only AppKit windows, synthetic TrackedDialog, and duplicated pixel-coordinate checks; rebuilt into one single-window native-desktop behavioral test (settings.rs, covering draft + Rooms workspaceMode preservation, idempotent mod+, / empty-draft mod+g, focused-input Escape blur, Select Escape isolation, clean-root return, and narrow 640×480 non-overlap) and one compact lib.rs headless test.

Ready for another look!

点击展开中文

感谢 @M4n5ter 详尽的 Review!已 rebase 到最新 main 并在 e4397cc23 中逐项修复了所有问题:

  • 正确性与合入阻塞项
    1. Rebase 到最新 main(8290d09df),将 "Back to app" 迁移补齐至全部 12 个 locales/*.json 文件并清理未用的 "Close settings"(同步更新了 desktop_new_session.rs),通过 node scripts/i18n/check.mjs 校验。
    2. 为 RoomView.tsx 的 createPreviewDialog.suppressed 补齐 !input.visible()。
    3. 将 ModelSettings.tsx 的 Escape 绑定改为 { when: terminal ? 'always' : 'notEditing' },保证桌面端在输入框聚焦时首次按 Escape 只退焦。
    4. 移除了 QuickLauncher.tsx 中多余的 trackModalSurface() 改动。
    5. 将 SessionSurface.tsx 中空会话(sessionId === null)的 models -> settings 归一化逻辑提到 dismissRoute() 之前,恢复 mod+g 的幂等性。
    6. 在 settings.notice 为空或卸载时调用 toast.dismiss('settings.notice'),并在 Settings 关闭且无 pending 操作时清空 operations.notice。
  • 设计与整洁度
    1. 用共享的 <WindowDialog> 封装替换零散的手动 trackModalSurface() 调用,覆盖主窗口内全部 6 处 <Dialog> 调用点。
    2. 将 Settings 对齐到 DESIGN.md 的 C.chrome -> C.panel -> C.card / C.cardRaised 色阶(ModelSettings.tsx、SettingsPage.tsx、DESIGN.md 及相关卡片内子页控件),移除了深色专属 1px 框线补丁,并刷新了 PR 正文中的 Before/After 截图。
    3. 移除了 ModelSettings.tsx 中的局部过渡与 scale: 0.95,复用 ui.tsx 的共享导航样式,并将窄屏头部拍平为 narrowBackBar()。
  • 测试精简重构
    • 删除了纯截图 AppKit 窗口、假 TrackedDialog 以及重复的硬编码像素坐标断言;重构为 1 个单窗口 native-desktop 行为测试(settings.rs,覆盖草稿与 Rooms workspaceMode 保留、幂等 mod+, 与空会话 mod+g、聚焦输入框 Escape 退焦、Select Escape 隔离、clean root 返回以及窄屏 640×480 不重叠校验)和 1 个紧凑的 lib.rs headless 测试。

麻烦有空再看一眼!

…aised styles

- Use C.cardRaised hover fill on QuickCommands ShortcutRecorder inside SettingsSection cards.
- Export cardRaisedHoverStyle/cardRaisedActiveStyle from SettingsPage and reuse them in RootUiSettings.
- Drop the duplicate operations.notice reset in plugins/settings/settings/ui.tsx (already handled in ModelSettings cleanup on unmount).

@M4n5ter M4n5ter left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the thorough follow-up — all prior correctness, surface-ladder, modal-tracking, and test-quality items are cleanly addressed.

I pushed a small cleanup commit (1354e2494a) to handle three minor nits directly before merging:

  • Switched QuickCommands's Record shortcut hover fill inside SettingsSection from C.raised to C.cardRaised.
  • Exported cardRaisedHoverStyle / cardRaisedActiveStyle from SettingsPage.tsx and reused them in RootUiSettings.tsx.
  • Dropped the duplicate operations.notice reset in plugins/settings/settings/ui.tsx (already covered by ModelSettings cleanup on unmount).

@M4n5ter
M4n5ter merged commit b55fef7 into apache:main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants