Skip to content

feat(quick-tools): move Quick Tools and the assistant panel to the native desktop - #6707

Closed
ARE404 wants to merge 15 commits into
apache:rust-previewfrom
ARE404:feat/quick-tools-rust
Closed

ARE404 wants to merge 15 commits into
apache:rust-previewfrom
ARE404:feat/quick-tools-rust

Conversation

@ARE404

@ARE404 ARE404 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves Quick Tools and the assistant panel from the Electron app to the native Rust desktop on rust-preview.

  • Panel: the launcher is a nonactivating NSPanel hosting an NSH view. Summoning it gives the panel the keyboard without activating Maka. The app the user was in stays frontmost and keeps its menu bar, as with Spotlight and Raycast. Closing the panel returns to that app.
  • Off by default: a fresh install registers no global shortcut. Turning on "唤起快捷工具" in settings binds Alt+Space, and the user can rebind it.
  • Settings: Quick Tools is managed from the main app's settings. Plugin rows show the manifest description muted after the name. The expanded command list lines up with the plugin name and adds alias and shortcut columns. SettingsRow gains an optional note for this.
  • Plugins: the built-in tools (applications, files, Chrome tabs, Bilibili, clipboard, snippets, notes, calculator, symbols, screenshot, assistant) run on the new runtime. scripts/quick-tools/import-legacy.mjs imports Electron-era data.
  • Settings migration: a fix that moves the retired privacy field out of existing profiles.

Verification

  • node --test products/maka/workbench/tests/quick-tools.test.mjs: 12 passed. This includes reserved host storage IDs and the 64-package registry limit; both new cases fail without the fix.
  • cargo test -p maka-workbench: 37 passed
  • biome format ., cargo fmt --all -- --check, node scripts/rust/dependencies.mjs check and node scripts/rust/notices.mjs check-reviewed: clean
  • plugin-sdk generate.mjs check, UI types example plus tsc, and the bundle tsc: pass
  • Manual checks in the dev app (node scripts/quick-tools/run.mjs --root <temp>):
    • with a fresh data root the launcher toggle is off, and turning it on shows ⌥Space
    • the settings page shows descriptions inline, and the command column aligns with plugin names
  • Not yet checked by hand: with another app frontmost, press ⌥Space and confirm typing and ⌘V work in the panel while that app stays active.
  • After merging current rust-preview: cargo build --locked -p maka-cli -p maka-desktop-shell -p maka-host-shell builds on macOS, and cargo test -p maka-workbench (37) and -p maka-desktop-shell pass. The panel now attaches to each fresh window VM through the shell's new resident-app attach.

AI use

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

Tool(s) and scope: Claude Code and Codex helped with implementation and debugging; the design, review and testing are mine.

Checklist

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

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

GPUI was replaced by the NSH native backends on rust-preview, so the
Quick Tools panel now runs as a nonactivating NSPanel subclass that
hosts an NSH AppView instead of a GPUI window.

- panel.rs: QuickPanel (NSPanel) with becomeKey/resignKey hooks,
  present/dismiss that restore the previous app, and a file picker
  shown as a sheet on the panel so it never activates the app or
  hands key status to the main window.
- appkit.rs: connect the quick-tools control on startup, reconnect on
  follow(), and close panels on quit and barrier.
- Cargo.toml: drop GPUI deps, add objc2 / objc2-app-kit / block2.
- bundle tsconfig: exclude quick-tools runtime/ and tools/, which are
  NSH UI-side sources checked by the ui_types step.
- Remove the leftover MAKA_GPUI env var and GPUI wording in the README.
…cher off

The panel now becomes key as a nonactivating panel without activating
Maka, so the app the user was in keeps its menu bar and focus, as
Spotlight and Raycast do.

A fresh install registers no global shortcut; turning the launcher on in
settings still picks Alt+Space.
…tings

Settings rows take an optional note, shown muted after the label and
truncated first. Plugin rows use it for the manifest description, the
expanded command list lines up with the plugin name and keeps the row
background, and four built-in descriptions are rewritten to fit one line.
@ARE404
ARE404 force-pushed the feat/quick-tools-rust branch from bc465c6 to a17b233 Compare November 8, 2026 16:09
…tools-rust

# Conflicts:
#	plugins/agent/composer/ui/Composer.tsx
#	plugins/agent/conversations/ui/Conversation.tsx
#	plugins/agent/conversations/ui/SessionSurface.tsx
#	products/maka/workbench/app/ComposerDetails.tsx
#	products/maka/workbench/app/MessageRow.tsx
#	products/maka/workbench/app/TurnNavigation.tsx

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed all 130 changed files at 25cd1927f14859900948d2215ee17ffc639e6a81 (+13,989/−576) against current rust-preview cb2cc895896220d8dffea66d16b31329defbbf76. An actual merge succeeds. I found one P1 and three P2 issues, detailed inline: an installed plugin can access retained unsent messages through a host-storage name collision; a 65th package leaves the registry unreadable on restart; the new workbench tests reference a removed environment API; and the new process-wrap dependency is absent from the required notices.

I checked the independent AppKit panel, window/session handoff, foreground/read acknowledgements, composer and message layout, shortcut registration, clipboard/paste/screenshot helpers, native Chrome messaging, declared browser adapters, ranking admission, package lifecycle and storage, built-in tools, contracts and build routing. The extraction of the existing composer in SessionSurface.tsx preserves every existing property modulo whitespace, with two explicit Quick Tools properties added. Neither this inspection nor an issue's acceptance checklist establishes full equivalence with the old application.

Local execution: 11/11 Quick Tools JavaScript tests, 21/21 Bot transcript tests, and the two actual Rust Chrome-bridge tests passed. The Rust checks used the unchanged production chrome.rs in an isolated Linux harness; they cover frame limits and disconnect/session identity, not a live Chrome extension. The actual migration SQL removes both former boolean privacy values while retaining revision/other preferences and leaving two corrupt or unknown shapes for the canonical decoder to reject. I did not run the complete Rust workspace, AppKit, a real browser/model/clipboard, or cross-application typing and paste locally.

For the two storage findings, I executed the actual package/schema/storage modules against real temporary files. The name-collision reproduction additionally executes the actual engine and plugin_worker.js, with a controlled native transport: a plugin declaring permissions: [] reads retained unsent text and attachment names, then overwrites the host file. A distinct plugin ID reads only its own empty data. Adding the missing reserved name blocks installation and preserves the host file. For capacity, 64 packages reopen successfully; the accepted 65th commit writes 65 records and reopening fails. Validating the registry before persistence rejects that commit and preserves a healthy 64-record restart. These repair controls only changed isolated review copies, which I restored byte for byte; no author branch was changed. The transport adaptation does not constitute a native sandbox execution test.

Current CI 42502122122 completed with failure. Its root build reports the new test's Environment.renderer/Renderer errors, and product checks reject missing [email protected] notices. Tooling also fails cargo fmt --all -- --check on newly added code, including the ranking structs and dispatch. The PR body's statement that formatting differs only in pre-existing quick_tools/mod.rs does not describe this run.

Other failures need separate attribution. Linux AppWindow.attributes access and macOS's missing track_menu/native_at type mismatch already fail the current base; I do not report them as new defects here. This PR's NSH job additionally fails the TUI error-display case after 4,600 passing cases, and Windows passes its desktop suite before native-pixels fails to find six rendered turn marks at scale 1 (rail.rs:189, 10.262s). Both base Windows pixel tests passed. The PR changes the turn rail, but these results alone do not establish a user-facing cause; the Windows pixel failure here also differs from #6705's scale-2 preview failure. Native panel, paste, screenshot, and complete unread/session lifecycle acceptance remain unconfirmed.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

.regex(/^[a-z0-9][a-z0-9.-]{0,99}$/)
.refine(
(id) =>
!['host', 'preferences', 'input-history', 'trace', 'shortcuts', 'extensions'].includes(id),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] Reserve the host's retained-send storage namespace

Conversation.tsx now stores retained unsent text and attachment names under quickStorage.update('undelivered', ...), but undelivered passes this manifest-ID check and the native loader's parallel allowlist. An installed plugin with that ID and permissions: [] receives unconditional storage.read/storage.write; the engine maps those calls to storage.read(request.plugin, ...) and storage.write(request.plugin, ...). I reproduced reading another session's retained message and overwriting the actual undelivered.json through the actual installer/engine/worker modules with controlled native transport. A different ID cannot read it; reserving this ID prevents the install. Separate host-owned records from plugin storage, and enforce the same reservation in both manifest validation and the native loader.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

digest: digest(pending.bundle),
previous: current ? { bundle: current.bundle, digest: current.digest } : undefined,
};
await this.save([...this.records.filter((r) => r !== current), next]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Enforce registry capacity before committing an installation

start() parses the entire persisted registry with records.max(64), while this path appends and saves a new record without the same limit. Neither installation UI checks capacity, and installPackage() commits before loading the worker. I reproduced 64 valid packages reopening normally, then a 65th commit succeeding and persisting 65 entries; the next Packages.start() rejects the whole registry and leaves records empty. Because QuickTools.start() awaits it before loading built-ins, the launcher also fails to initialize and the UI cannot list these packages for removal after restart. Validating before persistence makes the same 65th install fail while preserving the 64-record file and a successful restart. Keep updates to existing IDs available at capacity.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

Comment thread products/maka/workbench/src/lib.rs Outdated
super::quick_tools_capabilities(&mut capabilities);
let config=|host,name|nsh_engine::EngineConfig {
ui_sets:sets.clone(),host,data_dir:Some(root.path().join(name)),
environment:Environment{os:Os::MacOs,renderer:Renderer::Native,..Environment::default()},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Update the new tests to the current NSH environment API

This new, unconditional test constructs Environment { renderer: Renderer::Native, ... }, but the synchronized NSH Environment no longer has renderer and Renderer is not in scope. Current-head root-build fails at this exact line with E0560 and E0433 during cargo test --no-run --workspace --locked, preventing all root-test partitions from starting. The macOS-only new test repeats the same obsolete field. Update both fixtures to the current environment fields; this compile failure is introduced by these tests and is separate from the base's Linux/macOS platform compile failures.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

publish.workspace = true

[dependencies]
rmcp = { version = "=3.8.0", default-features = false, features = ["client", "transport-child-process"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Include the new browser transport dependency in release notices

Enabling rmcp's child-process transport adds [email protected] to Cargo.lock, but this PR does not update the Cargo third-party notice inventory. The current-head product job exits with Third-party notices do not cover current component or license data: cargo:[email protected] registry+https://github.com/rust-lang/crates.io-index. Regenerate and check the required inventory/notices for the new feature set so the packaging gate can pass. This is attributable to the new transport dependency, rather than the already-failing NSH base compilation.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

…stry

- Reserve `undelivered` and `launcher-shortcut` as plugin IDs in both the
  manifest schema and the native loader, so an installed plugin cannot
  read or overwrite the host's retained sends or launcher shortcut.
- Reject a new install once 64 packages are installed, and validate the
  registry before writing it, so a restart can always read it back.
  Updating an installed package still works at capacity.
- Drop the removed `Environment::renderer` field from the workbench tests.
- Add `process-wrap` and `zod` to the third-party notices.
- Apply `cargo fmt` to the Rust files this branch changed.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the 35-file increment from 25cd1927f14859900948d2215ee17ffc639e6a81 to 59e9641bf133f9b2107c3900c75b7f95e930b4d3. The complete PR adds configurable Quick Tools and now changes 133 files (+14,389/−624); an actual merge with rust-preview cb2cc895896220d8dffea66d16b31329defbbf76 succeeds. My earlier full review remains the source for the unchanged code. The four previously reported issues are fixed in the checks described below. One confirmed P2 remains: current CI rejects 47 newly added files for missing the required source header.

The manifest schema and Rust loader both reserve undelivered and launcher-shortcut. With the actual engine, package loader, worker preparation and a controlled native transport backed by a real temporary draft file, both reserved IDs are rejected before a worker request and the host draft remains unchanged. The 64-package limit is checked inside the serialized mutation, and saved registries are parsed before writing. Real-file checks covered reopening 64 packages, rejecting a 65th without changing disk, updating/rolling back at capacity, and two concurrent installs from 63 packages: exactly one succeeds and the saved registry reopens with 64. The current 12 Quick Tools Node tests pass; retaining the new tests but restoring the old schema/package modules produces exactly the reserved-ID and capacity failures.

The two obsolete Environment.renderer uses are removed. I ran the actual current maka-workbench Rust test suite on Linux: all 33 tests pass, including the independent panel language/appearance case. This does not execute AppKit or Windows. The added [email protected] and [email protected] notice records match the official record generator and exact locked package contents; the downloaded process-wrap crate also matches Cargo.lock's checksum. The rendered notice document hash matches its manifest. This checks those two additions, not the complete cross-platform release dependency closure.

The subsequent formatting revision matches the output of Biome 2.6.3 on all 20 affected source files, and current CI passes that formatter stage. However, current tooling later fails the source-header check: all 47 reported files are new in this PR. I reproduced that failure with the official checker against the exact current files, then verified that applying its header writer in a separate copy makes the check pass. Please bring these files into the project's header policy, using the appropriate header or a reviewed exclusion for externally owned content.

Other current checks are also not all green. Root build, Linux NSH and packaging fail on the pre-existing private AppWindow.attributes access; macOS fails on the pre-existing missing chrome::track_menu and native_at argument mismatch. Those source sites are unchanged by this PR and are addressed separately by #6709; I am not attributing them to Quick Tools. Windows is still running at this check. The preceding revision's cancelled native jobs are not passes.

I have not accepted the real macOS panel, foreground-application/selection capture, cross-application clipboard paste, populated old session restore, or the full close/reopen and Host-replacement lifecycle. The controlled transport and Linux Workbench tests do not establish those behaviors. No database schema or protocol epoch change is introduced by this increment.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@@ -0,0 +1,111 @@
/* Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Satisfy the source-header check for the new files

The current tooling job fails after formatting and tests because 47 newly added files, including this one, lack the full source header required by the repository checker. I reproduced the failure with the official script on the exact current files; running its header writer in an isolated copy makes the same check pass. This blocks the current PR's CI. Please apply the appropriate headers across the reported files, or use an explicitly reviewed exclusion where ownership requires one.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the 64-file increment from 59e9641bf133f9b2107c3900c75b7f95e930b4d3 to df784be43fb3025ad23884ac3ba66d2acaae29ac. The complete PR is 134 files (+15,497/−624), and an actual merge with rust-preview cb2cc895896220d8dffea66d16b31329defbbf76 succeeds. The source-header P2 in my preceding review is fixed; I found no confirmed new P0–P2 issue in this increment.

I compared each changed file: 63 have identical source after removing only their leading license comments. The one executable change adds an exact exclusion for the unchanged Bilibili SVG, whose sibling provenance document identifies the Simple Icons CC0 origin; it does not exempt the surrounding implementation. The official current checker audits the complete extracted tree successfully: 2,744 covered and 2,949 excluded files. All four checker tests pass. As a control, restoring only the preceding checker on the same current tree fails solely on that SVG, then restoring the exact current checker passes. Thus both the 47 missing headers and the remaining explicit third-party exclusion are accounted for.

No Quick Tools runtime implementation changed in this increment. My earlier reservation/capacity/concurrency, notice-record, 12 Node and 33 Linux Workbench results remain checks of the preceding implementation; I did not rebuild those suites after comment-only changes. Current CI 42553435636 has completed with failure; the platform results are detailed below, and local header success is not an all-CI pass. The prior base Linux/macOS compile failures are separate from this header fix. Real macOS panel/foreground behavior, cross-application paste, populated old sessions and the complete lifecycle still require native acceptance. No database schema or protocol epoch change is introduced.

Current CI log update: tooling job 128954071524 passes the real checkout header check (2,744 covered and 2,949 excluded files), corroborating the local header fix. Root build, Linux NSH and packaging in that run still fail on the old private AppWindow.attributes access; NSH records 4,600 passes, one failure and 29 skips, with the error-display test observing blank output instead of runtime failure after 5.082 seconds. I read those logs but have not established Quick Tools causality. Those checks were started before the base advanced; they do not test a new merge with the current Rust branch. The macOS job has now failed during compilation with the same old-base E0425 (chrome::track_menu) and E0308 (native_at) errors, before executing native tests. The Windows job has now also failed, but after running its tests: 223 platform tests pass with one skipped, and all 22 Desktop tests pass (343.090 seconds). The first pixel test then fails after 10.351 seconds at products/maka/terminal-shell/src/terminal/pixels/tests/rail.rs:189, waiting for six rendered marks at scale 1; the second pixel test is unrun. The test file is identical to the incoming base, but that alone does not exclude an indirect effect of this PR. I have not established the cause or Quick Tools attribution. This is not a test of the freshly merged Rust branch.

Current integration update: rust-preview has since advanced to 75fe3d0e059c58b798782604668f37b56a420255 after #6695 and #6683 were merged by other contributors. I fetched that branch and ran an actual merge of this unchanged PR. There are now four conflicts: products/maka/cli/notices.json, products/maka/desktop-shell/Cargo.toml, products/maka/desktop-shell/src/appkit.rs and products/maka/workbench/app/ModelSettings.tsx. The earlier successful merge against 033e1a50, and the three-conflict count against 9864d521, are historical. These current conflicts need resolution before integration.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 9, 2026
…tools-rust

# Conflicts:
#	products/maka/cli/notices.json
#	products/maka/desktop-shell/Cargo.toml
#	products/maka/desktop-shell/src/appkit.rs
#	products/maka/workbench/app/ModelSettings.tsx

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the merge increment from df784be43fb3025ad23884ac3ba66d2acaae29ac to bfe9f99b8763efe6cdbac2cd6b3c859d4c5fbdf3, including its integration with current rust-preview 75fe3d0e059c58b798782604668f37b56a420255. I found no confirmed new P0–P2 issue in this increment. An actual merge now succeeds, so the four conflicts reported for the preceding head no longer apply to this head.

The two parents are exactly the previously reviewed PR head and that Rust baseline. Of 131 files changed since the preceding PR head, 118 are byte-for-byte identical to the incoming baseline. I inspected the remaining combined changes and compared an automatic merge with the submitted tree: only the four conflict-resolution files differ. In desktop-shell/src/appkit.rs:141, the shared attach helper creates a fresh Host channel and attaches both the shell and Quick Tools; both ordinary resident-window Open and Host replacement call it. I followed quick_tools/panel.rs through its separate panel channel and queued configuration load. In workbench/app/ModelSettings.tsx:101, the merged navigation preserves the incoming unsaved-draft prompt, checks the request again after the prompt, and retains the Quick Tools section filtering. Cargo retains the Quick Tools dependencies alongside the incoming tray dependencies. For cli/notices.json, all 20 changed component records equal the incoming baseline, all preceding records remain, and the notice document's SHA-256 matches the manifest. This is a structural/hash check, not a fresh execution of the complete distribution-notice generator.

On this exact head I installed the locked JavaScript dependencies, applied the repository patches, and ran 12 Quick Tools, nine settings-discard and seven Desktop-close tests: all 28 pass. The real source-header checker also passes (2,754 covered and 2,949 excluded files), and its four tests pass. I did not rerun the full 134-file implementation review or locally compile Rust/macOS. The macOS build and 37 Workbench tests described in the PR are the author's results. Real panel focus while another application remains foreground, cross-application paste, populated old sessions and the full native lifecycle remain outside my executed acceptance scope.

CI 42570244213 has since been cancelled after the PR advanced to 114ff5501787c74c16b2dff3b322dae9522a01f4. I read the cancelled macOS and Windows logs: both stop during compilation without native-test summaries, so they do not establish native acceptance or a test failure. The Ubuntu native job succeeded, but I have not read its raw log here. This review remains a review of bfe9f99b; the subsequent three-file increment is covered by the newer review. This increment introduces no database-schema or protocol-epoch change.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed all three changed files in the increment from bfe9f99b8763efe6cdbac2cd6b3c859d4c5fbdf3 to 114ff5501787c74c16b2dff3b322dae9522a01f4. This review is of the historical 114ff550 head. The subsequent rail fix at 1d63b7ba is covered by the newer review; the P2 below describes the preceding implementation. The hotkey increment passed the bounded checks below. Subsequent CI follow-up confirms a P2 in the PR's existing rail rendering and pixel-test integration, corroborating the rail issue already reported in this comment. An actual merge with current rust-preview 606a11c27658484d52aa43c4f92066e68e6623f2 succeeds.

The change removes the main window's unconditional native-panel opener. workbench/app/App.tsx:92 now registers its local Alt+Space binding only on non-terminal surfaces without native Quick Tools; native panels use the configured global shortcut. desktop-shell/src/quick_tools/panel.rs removes the corresponding quickTools.show handler and Request::Show branch. QuickToolsWindow.tsx:61 drops the settings flag that only that deleted branch supplied. I checked the remaining callers and followed launcher preference changes through runtime/engine.ts, the Rust shortcut bridge and the Carbon registration helper: disabling the launcher removes the toggle binding, while this increment removes the local route around that choice.

I executed the exact App binding block with controlled Host, signal and keymap adapters in six configurations (desktop/terminal, with true/false/absent native capability). All six pass; replacing only that source block with the preceding version fails the native-desktop case (five pass, one fail). This checks which local handler is registered and the fallback's repeated open/close behavior; it does not execute a native global hotkey. All 12 exact current Quick Tools tests pass after installing the locked dependencies and applying the repository patches. The real source-header checker also passes (2,754 covered and 2,949 excluded files).

CI 42572886749 has completed with failure. I read both native logs. Windows passes 226 platform tests with one skipped and all 22 Desktop tests (212.792 seconds), then the first pixel test fails after 10.211 seconds at terminal/pixels/tests/rail.rs:189: six rendered marks are missing at scale 1; the second pixel test is unrun. The fixture imports the actual TurnNavigation component changed by this PR. I executed that component's NavigationMark with controlled native adapters and the exact default dark colors from its ui.tsx: the current inactive stroke is #969ba4 (RGB 150/155/164), while the base stroke is #37393e (55/57/62). The unchanged test only accepts a red channel from 35 through 55, so the changed style no longer satisfies its mark detector; the base component does. The component also returns a 12-point pitch instead of the base's 24 at scale 1. This establishes PR-caused CI breakage (P2); the rendering change needs matching integration coverage that still verifies all six marks are individually clickable at each supported scale. This controlled component check is not a local native raster or mouse replay.

macOS passes all 107 platform library tests and all 10 terminal-native tests, then the sixth Desktop test cannot find a single Pause Goal control after 67.694 seconds. Five Desktop tests pass and 16 are unrun; pixel tests are not reached. The base 75fe3d0e run passes that Goal workflow, while the earlier landed 9864d521 run failed with the same symptom. I have not isolated the cause or established Quick Tools causality for this separate failure. The Rust branch has since advanced through #6714: its two test-file changes remove reserved Cmd+H and add a Goal/Todo control wait. I inspected that diff but have not validated its runtime effect; the new baseline has a separate running CI. The preceding head's run 42570244213 was cancelled; I read its macOS and Windows logs, which stop during compilation without native-test summaries. Those cancellations do not establish a test failure on this head. I did not locally compile Rust or run macOS global shortcuts, foreground preservation, cross-application paste or populated old-session acceptance. Those native boundaries from the earlier review remain open. This increment changes neither a database schema nor a protocol epoch.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@M4n5ter

M4n5ter commented Nov 9, 2026

Copy link
Copy Markdown
Member

@ARE404 (cc @me2seeks re #6695 desktop residency and third-party/nsh alignment)

English

Thanks for the work here. After reviewing 114ff55017 (134 changed files, +15,497 / -624) and checking both failing CI jobs (native-windows and native-macos), please hold off on merging—this needs an architectural redesign onto nsh/desktop & Maka's native runtime and should be split into smaller verifiable PRs.


1. Architectural Alignment with third-party/nsh & #6695 (cc @me2seeks)

Upstream third-party/nsh (323a8663, synced in #6708) already provides native cross-platform primitives in nsh/desktop rendered from the app's single NSH Engine:

  • Launcher / floating popup windows: <Window kind="popup" level="aboveDock" workspaces="all" backdrop="hud" closeOnBlur closeOnEscape sizeToContent> (nsh-core/src/desktop/window.rs:37-40, "A launcher, a tray popover, a command palette: no frame, floats on every workspace, closed by Escape and when it loses the focus, not in the taskbar").
  • System-wide global hotkeys: GlobalShortcut (nsh-platform-{macos,windows,linux}/src/global_shortcut.rs; on macOS this already uses Carbon RegisterEventHotKey + UCKeyTranslate layout resolution without requiring Accessibility permissions).
  • System tray: Tray (nsh-platform-{macos,windows,linux}/src/tray.rs).

Right now, #6707 bypasses nsh/desktop to build a macOS-only second AppView engine + 686-line custom NSPanel (desktop-shell/src/quick_tools/panel.rs) + external Swift Carbon helper (macos.swift), while #6695 (9864d52160) destroys the main NSH engine on window close and resets HostChannel. Merging the two in bfe9f99b87 broke both lifecycles:

  1. Menu-bar resident mode breaks panel::on_main (panel.rs:461-463): on_main calls nsh_platform_macos::with_running_view. When the main window is closed in resident mode (appkit.rs:108), stop_running() sets RUNNING = None, causing with_running_view (nsh-platform-macos/src/app.rs:783-790) to silently drop every closure:
    • Pressing Option+Space sets state.visible = true and drops panel.present(), leaving the launcher dead while closed to the menu bar.
    • If the panel is open when the main window closes, Hide, Resigned, and Resize are all dropped—leaving the POP_UP_LEVEL = 101 floating panel stuck above all apps unable to dismiss.
    • If the Host disconnects while the main window is closed (appkit.rs:205-215), panel::close_all() is dropped and the panel VM + plugin workers outlive the Host connection; conversely, reopening the main window from the menu bar emits Request::Load and unnecessarily destroys/recreates the panel VM.
  2. HostChannel replacement wipes out quickTools.* handlers across all 3 platforms: host::connect (host.rs:62-63) attaches maka_workbench::quick_tools::attach and crate::quick_tools::attach onto Connection.config.host, but appkit.rs:146, linux.rs:186, 273, and direct2d.rs:75, 86-93 replace config.host = HostChannel::new() (or drop first.config on Windows):
    • On Linux and Windows, pressing Alt+Space opens <QuickToolsSurface /> on a channel with zero quickTools.* handlers registered.
    • On macOS, Conversation.tsx quickStorage calls on the main window fail, and "Open in Maka" (Request::Assistant, panel.rs:424-440) sends to a dead HostChannel and resolves true without opening a window when closed to the menu bar.

Coordinating with @me2seeks to move #6695 onto NSH's single-engine Tray + closeOnPress: false / hide() model allows Quick Tools to simply be a <Window kind="popup"> + GlobalShortcut in that same NSH engine on macOS, Windows, and Linux.


2. Blocking Runtime, Packaging & CI Regressions (P0 / P1)

  1. [P0] Unbuilt / unpackaged external sidecars (MAKA_QUICK_NATIVE, MAKA_QUICK_WEB_*):
    • shortcuts.rs:38, workbench/src/lib.rs:91-99, and runtime/native.ts:93-96 require MAKA_QUICK_NATIVE (macos.swift -> maka-quick-native), and web.rs:32-38 requires MAKA_QUICK_WEB_NODE / MAKA_QUICK_WEB_ENTRY (@jackwener/browsermcp, which is only in root devDependencies).
    • Only the developer script scripts/quick-tools/run.mjs builds/sets these. Cargo, scripts/rust/build-cli.mjs (compileCli / stageDesktopBundle), Maka.app bundle signing, products/maka/cli/src/desktop.rs, and CI never compile macos.swift or set those env vars. Launching real maka desktop or Maka.app immediately fails shortcuts::start with "Native shortcut helper is missing", while nativeQuickTools: true disables the in-window Alt+Space fallback—so Quick Tools cannot be summoned at all, and clipboard, paste, screenshot annotation, app icons/pinyin, and web tools all fail.
  2. [P0] Windows native-pixels CI regression (rail.rs:191: six rendered marks missing at scale 1):
    • products/maka/workbench/app/TurnNavigation.tsx:30-65 changed inactive tick color from C.line (#37393e) to C.muted (#969ba4, failing rail.rs:171) and replaced Math.max(24, 16 / nativeHost.uiScaleFactor + 2) with hardcoded 12px—breaking pixel-graphics terminal mode where mouse input rounds to 16px / scale character rows, so adjacent 12px marks collapse into the same cell row and cannot be clicked individually.
    • Moving TurnNavigation to left: 2 (Conversation.tsx:3734) with <Tooltip placement="right"> (TurnNavigation.tsx:92) also pushes tooltips off-screen in the right-aligned rail test harness while leaving stale paddingRight: railInset() (34px) in Conversation.tsx:3253-3254.
  3. [P0] Broken Linux & Windows runtime behavior:
    • On !nativeQuickTools platforms, App.tsx:135-141 eagerly mounts <QuickToolsSurface /> at startup, running engine.start() -> maka.applications throws "应用启动器目前支持 macOS" (red error banner on open) and typing 2+ chars in search errors on every keystroke (mdfind, unregistered quickTools.chrome.list).
    • On Linux, runtime/native.ts:90 implements "Show in Finder" (reveal: true) by ignoring reveal and running xdg-open <file>—opening/executing the target file instead of revealing its parent directory. On Windows, native.open (native.ts:91) throws "此平台暂不支持打开目标" even for https:// URLs.
  4. [P0/P1] Assistant UX, Conversation.tsx & maka.agent defects:
    • Cannot stop a running Assistant response (Composer.tsx:270-276, 933): quickTools hides the entire composer toolbar (display: 'none', hiding the Stop button while keeping hidden ModelSelect / RecentWorkspaces reactive) and escapeComposer intercepts Escape to navigate back before stopAction().
    • Immortal "Not sent" zombie bubbles (Conversation.tsx:2256-2278, 3389-3416): Clicking "Dismiss reminder" (ignoreInline) writes to local undelivered.json and dismisses the Host record, leaving send() undefined and rendering a permanent "Not sent" bubble with zero action buttons and split-brain state from the main window.
    • Hot-path $O(N)$ transcript scan (Conversation.tsx:3051-3060): replyPreviews = computed(...) scans all rows() and rebuilds a Map on every streaming token across all desktop sessions; onContentSizeChange (Conversation.tsx:414-416) unconditionally triggers readExposure.set({}).
    • Settings & mutation guards: QuickToolsWindow.tsx:147-178, 190-196 bypasses #6683's leave() unsaved-changes guard when exiting <ModelSettings> and renders duplicate headers; plugins/agent/native/src/service.rs:257 markBotRead is missing context.operation().ok_or("agent_mutation_required")?.

3. Parallel Plugin Architecture, Resource Churn & Engineering Hygiene

  1. Parallel Electron-era plugin & storage stack in the UI process:
    • workbench/src/quick_tools/* + plugins/application/quick-tools/runtime/* introduces a separate { format: 1, manifest: { apiVersion: 1 }, code } single-file CommonJS plugin format, 1-OS-thread-per-plugin V8 worker pool, V8 -> Rust -> UI-VM -> Rust 4-hop RPC, global-mutex sync_all() flat-JSON storage, per-call node MCP child process spawning in desktop-shell (web.rs:77-95), and a separate Symbol.for('maka.quick-tools.locale.v1') i18n singleton (which drops zh-TW support, violating CONTRIBUTING.md), while inverting dependencies so plugins/agent and packages/plugin-sdk import Quick Tools internals.
    • workbench/src/lib.rs:75-100 grants every workbench UI VM (including TUI) fs.read access to all of ${homeDir} (including ~/.ssh, ~/.aws, ~/.gnupg) and process.execute on whatever path is in MAKA_QUICK_NATIVE.
  2. Background polling & unnecessary fsyncs:
    • macos.swift:243-248 runs a 25 Hz (40ms) repeating timer polling CGEventSource.flagsState forever even when Quick Tools is hidden, waking Swift -> Tokio -> the panel VM on every modifier/arrow keypress system-wide.
    • chrome.rs:151-180 spawns a raw OS thread running a 50ms sleep loop on a non-blocking UnixListener instead of tokio::net::UnixListener.
    • tools/clipboard/index.ts:68 rewrites and fsyncs maka.clipboard.json every 60s even when state.enabled === false; storage.ts:88-106 rewrites and fsyncs trace.json on every launcher execution even though nothing reads trace.json; workbench/src/quick_tools.rs:146 instantiates WordSegmenter::new_auto inside .map() per string (up to 4,096 times per call).
  3. Upgrade migrations, legacy shims, arbitrary truncations & unsafe docs:
    • plugins/settings/store/migrations/0003_retire_privacy_policy.sql (version: 3 in database.rs:43-47) and the 202-line scripts/quick-tools/import-legacy.mjs Electron host.json v2 importer should not be added; schema changes while previewing should fold cleanly into the base schema without accumulating legacy migration/importer layers.
    • Arbitrary destructive limits truncate normal user data: tools/files/index.ts:57 silently slices directory listings to 79 entries (entries.slice(0, 79)); chrome.rs:309-315 disconnects the entire Chrome extension if any open tab has url.len() > 16000 (common for data: / OAuth URLs); macos.swift:279-281 silently drops clipboard PNGs > 4 MiB (routine on Retina displays); plugin_worker.js:79 throws on the 257th crypto.randomUUID() call; packages.ts allows 64 × 16 MiB plugins while quick_tools.rs caps storage files at 42 MiB.
    • unsafe blocks in dismiss.rs:42-67 and panel.rs:486-492 lack // SAFETY: comments documenting pointer/thread/lifetime invariants (AGENTS.md).

Suggested Path Forward

Rather than patching everything inside one 15k-line PR, please split and sequence this cleanly:

  1. PR 1 (Agent & Client APIs): Land plugins/agent markBotRead (with context.operation() check and former-bot read support), rankQuickTools (falling back to local ranking on unconfigured credentials), and products/maka/client control-method tracking with focused unit tests, leaving TurnNavigation.tsx untouched.
  2. PR 2 (Single-Engine NSH Desktop Residency + Launcher Window, coordinated with @me2seeks): Converge #6695 onto nsh/desktop Tray + closeOnPress: false / hide(), and host Quick Tools as a cross-platform nsh/desktop <Window kind="popup"> + GlobalShortcut on the same NSH engine.
  3. PR 3+ (Native Built-in Tools & Assistant View): Build built-in tools directly on Maka's native capabilities, settings store, and tr() (en / zh-CN / zh-TW)—dropping the legacy Electron CJS plugin runtime, import-legacy.mjs, and 0003 migration—with any required OS helper built and signed through Cargo / build-cli.mjs and verified in packaged Maka.app / maka desktop.
中文

感谢投入!完整复核了 114ff55017(134 个文件,+15,497 / -624)以及两个失败的 CI 任务(native-windows、native-macos)后,建议暂不合并——需要基于 nsh/desktop 与 Maka 原生运行时重新收敛架构,并拆分为可独立验证的小 PR 分步合入。


1. 与 third-party/nsh 及 #6695 的桌面宿主架构对齐(cc @me2seeks)

#6708 同步上游 323a8663 后,third-party/nsh 的 nsh/desktop 在单 nsh_engine::Engine 模型下已经原生具备三端能力:

  • 悬浮启动器窗口:<Window kind="popup" level="aboveDock" workspaces="all" backdrop="hud" closeOnBlur closeOnEscape sizeToContent>(nsh-core/src/desktop/window.rs:37-40 专门面向启动器/命令面板设计:无边框、跨所有工作区、Escape/失焦自动收起、不进任务栏);
  • 全局快捷键:GlobalShortcut(nsh-platform-{macos,windows,linux}/src/global_shortcut.rs,macOS 下已通过 Carbon RegisterEventHotKey + UCKeyTranslate 处理键盘布局且无需辅助功能权限);
  • 系统托盘:Tray(nsh-platform-{macos,windows,linux}/src/tray.rs)。

当前 #6707 绕开 nsh/desktop 单独起了 macOS 专属的第二个 AppView 引擎 + 686 行 NSPanel(panel.rs)+ 外部 Swift Carbon 热键进程(macos.swift);而 #6695(9864d52160)又在关主窗口时销毁整个主 NSH 引擎并重置 HostChannel。两者在 bfe9f99b87 合并后直接互撞:

  1. 常驻菜单栏模式下 panel::on_main 全面失效(panel.rs:461-463):on_main 委托给 with_running_view;当用户关闭主窗口驻留菜单栏时,RUNNING 变为 None,with_running_view 会静默丢弃所有闭包:
    • 按 Option+Space 会把 state.visible 置为 true 后丢弃 panel.present(),菜单栏驻留期间全局唤起彻底失灵;
    • 若面板打开时关闭主窗口,Hide / Resigned / Resize 均被丢弃,POP_UP_LEVEL = 101 的置顶窗口会卡死在所有应用最上层无法关闭;
    • 主窗口关闭期间若 Host 断连,panel::close_all() 被丢弃导致面板 VM 与插件线程越界残留;从菜单栏重开主窗口又会无故销毁重建整个面板 VM。
  2. 三端重置/丢弃 HostChannel 清空 quickTools.* 处理器:host::connect(host.rs:62-63)挂在 Connection.config.host 上的处理器,被 appkit.rs:146、linux.rs:186, 273 的 HostChannel::new() 以及 direct2d.rs:75, 86-93 丢弃 first.config 全部抹掉——Linux/Windows 按 Alt+Space 零 quickTools.* handler;macOS 主窗口 Conversation.tsx 的 quickStorage 调用失败;驻留状态下点 "在 Maka 中打开" 往死通道发消息并静默返回 true。

建议与 @me2seeks 协同,先把 #6695 收敛到 NSH 单引擎原生 Tray + closeOnPress: false / hide() 模型,再让 Quick Tools 直接作为同一引擎内的 <Window kind="popup"> + GlobalShortcut 运行,三端统一且零跨 VM 同步开销。


2. 阻塞性运行时、打包与 CI 回归缺陷(P0 / P1)

  1. [P0] 外部辅助进程未纳入构建与打包(脱离 scripts/quick-tools/run.mjs 即不可用):
    • MAKA_QUICK_NATIVE(macos.swift 编译产物)和 MAKA_QUICK_WEB_NODE / MAKA_QUICK_WEB_ENTRY(仅在根 package.json devDependencies 中的 @jackwener/browsermcp)只在开发脚本 scripts/quick-tools/run.mjs 中注入。
    • Cargo、scripts/rust/build-cli.mjs、Maka.app 签名打包、desktop.rs 与 CI 均未编译、打包或设置它们。直接启动真实 maka desktop 或 Maka.app 会立即报 "Native shortcut helper is missing",且 nativeQuickTools: true 关掉了主窗口 Alt+Space 回退,导致快捷工具完全无法唤起,剪贴板、粘贴、截图批注、拼音图标和网页工具全部失效。
  2. [P0] Windows native-pixels CI 必现失败(rail.rs:191: six rendered marks missing at scale 1):
    • TurnNavigation.tsx:30-65 将非激活刻度从 C.line 改为 C.muted,并删掉了 Math.max(24, 16 / nativeHost.uiScaleFactor + 2) 改硬编码为 12px——破坏了像素图形终端按 16px / scale 字符行取整的点击契约(多条刻度落入同一字符行无法单独点击);同时导轨移到 left: 2 后反写了 <Tooltip placement="right">,并在 Conversation.tsx:3253-3254 留下 34px 右侧死留白。
  3. [P0] Linux 与 Windows 默认损坏:
    • 非 macOS 平台启动即挂载 <QuickToolsSurface /> 执行 engine.start(),一打开即弹红字错误 "应用启动器目前支持 macOS",搜索每输入一字都被 mdfind 与未注册的 chrome.list 刷屏报错;
    • Linux 上 "在访达中显示"(native.ts:90)忽略 reveal 直接执行 xdg-open <file>(变成打开/执行目标文件而非打开父目录);Windows 上 native.open 连 https:// 链接都抛错。
  4. [P0/P1] 个人助手、Conversation.tsx 与 maka.agent 回归:
    • 生成中无法停止(Stop):Composer.tsx:270-276, 933 隐藏了整个底栏(含 Stop 按钮),且 escapeComposer 在 stopAction() 之前拦截 Escape 返回列表;
    • 永久僵尸“未发送”气泡:点击 "忽略提醒"(Conversation.tsx:2256-2278)写入本地 undelivered.json 并清掉 Host 记录后,send() 为 undefined,留下无任何操作按钮、永远无法清除的气泡;
    • 流式热路径全量扫描:Conversation.tsx:3051-3060 的 replyPreviews 在每次流式 token 时全量扫描 rows(),onContentSizeChange 无条件重置 readExposure;
    • 漏掉保护与校验:快捷工具模型设置页绕过了 #6683 的 leave() 未保存修改拦截且渲染重复标题;service.rs:257 的 markBotRead 漏掉了 context.operation().ok_or("agent_mutation_required")?。

3. 平行插件栈、后台轮询与工程规范问题

  1. 在 UI 进程内平行移植旧 Electron 插件与存储栈,并扩大沙箱权限面:
    • 引入 { format: 1, apiVersion: 1 } 单文件 CJS 插件包、1 插件 1 OS 线程 V8 Worker、四跳桥接、全局单锁 sync_all() JSON 存储、desktop-shell 内每次请求冷启动 node MCP 进程(web.rs:77-95)以及独立的 Symbol.for i18n 单例(缺失 zh-TW),并反向让 plugins/agent 与 packages/plugin-sdk 依赖快捷工具内部模块;
    • workbench/src/lib.rs:75-100 为所有 workbench UI VM(含 TUI)放开了整个 ${homeDir}(含 ~/.ssh 等)的 fs.read 与环境变量进程执行权限。
  2. 后台常驻轮询与无效 fsync:
    • macos.swift:243-248 以 25 Hz(40ms) 永久轮询全局修饰键,全系统任意应用按修饰键/方向键都会唤醒 Swift -> Tokio -> 面板 VM;chrome.rs:151-180 用裸线程 50ms sleep 循环代替异步 UnixListener;剪贴板禁用时仍每 60s fsync;每次执行重写并 fsync 无人读取的 trace.json;分词在 .map() 内逐词重复构造 WordSegmenter::new_auto。
  3. 升级迁移、旧版导入脚本、硬截断上限与 unsafe 注释:
    • 不应新增 0003_retire_privacy_policy.sql 升级迁移与 scripts/quick-tools/import-legacy.mjs 旧版导入器;
    • 多处无依据限制会截断或中断正常输入:文件浏览 entries.slice(0, 79) 硬截断前 79 项;Chrome 任一标签页 URL > 16KB 直接断开整个扩展;剪贴板 > 4 MiB PNG 静默丢弃;单次调用第 257 次 crypto.randomUUID() 抛错;extensions.json 与 42 MiB 存储上限自相矛盾;
    • dismiss.rs 与 panel.rs 的 unsafe 块缺少 // SAFETY: 安全前提说明。

建议拆分推进路径

  1. PR 1(Agent 与 Client 接口):先单独合入 plugins/agent 的 markBotRead(补齐 context.operation() 校验与历史 Bot 会话支持)、rankQuickTools(无凭据回退本地排序)及 products/maka/client 控制请求追踪,不触碰 TurnNavigation.tsx。
  2. PR 2(单引擎 NSH 常驻托盘 + 悬浮启动器宿主,与 @me2seeks 协同):把 #6695 收敛到 nsh/desktop 原生 Tray + closeOnPress: false / hide(),并在同一 NSH 引擎上用 <Window kind="popup"> + GlobalShortcut 承载三端快捷工具窗口。
  3. PR 3+(原生内置工具与个人助手视图):直接基于 Maka 原生能力、设置存储与统一 tr()(en / zh-CN / zh-TW)实现内置工具,去掉旧 Electron CJS 插件运行时、import-legacy.mjs 与 0003 迁移;确需原生系统桥接的部分纳入 Cargo / build-cli.mjs / Maka.app 正式构建签名并验收打包产物。

Automated review by Antigravity.

The redesigned rail used a 12pt pitch everywhere, but the pixel renderer
still receives mouse input in terminal cells, so marks shared a row and
could not be told apart. Restore the cell-safe pitch, line-coloured marks
and left-side preview there; desktop windows keep the new style.

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed both files changed from 114ff5501787c74c16b2dff3b322dae9522a01f4 to 1d63b7ba7c719fb5ee8c11008187cc254e0b6924. This increment restores the pixel-renderer's rail integration at the component level; I found no confirmed new P0–P2 in these two files. This is a bounded review of the rail fix, not validation of the broader runtime and packaging concerns in the existing comment.

I independently checked the preceding Windows CI failure and its fixture. It imports the actual TurnNavigation changed by this PR: the inactive mark became #969ba4 (150/155/164), whereas the unchanged detector accepts a red channel from 35 through 55. The base component produces #37393e (55/57/62). The actual preceding Windows job fails on six missing marks at scale 1 after 10.211 seconds. That corroborates the reported PR-caused CI regression (P2); the test file being unchanged was not sufficient to exclude PR causality.

The new component uses nativeHost.uiScaleSupported to recognize the pixel-renderer path. I checked the production getter: it is backed by the pixel renderer's UiScale engine context. On that path, the component restores C.line, a pitch of max(24, 16 / scale + 2), right-aligned strokes and left-side tooltips. Ordinary desktop styling retains its 12-point pitch. The test Host now supplies the same capability; its six-mark, four-scale and click assertions remain in place.

I bundled and executed the actual NavigationMark and markPitch with controlled native adapters and the exact default dark colors from ui.tsx. All eight pixel/non-pixel configurations at scales 1, 0.8, 0.5 and 2 pass. Replacing only the component source with the preceding version produces four passes and four failures. Pixel pitches are 24, 24, 34 and 24, with the detector's expected color; non-pixel styling remains 12 points. These checks cover component output and the spacing calculation, not native rasterization, terminal mouse replay or a local Rust build. The real source-header check also passes (2,754 covered and 2,949 excluded files).

The actual merge with rust-preview 606a11c27658484d52aa43c4f92066e68e6623f2 succeeded. CI 42580012761 has now completed successfully. I read both native logs and verified their exact checkout: synthetic merge cfe2cc97ceca70b7af82ae3cf8480c292b026696, with parents 606a11c2 and this PR's 1d63b7ba. Its tree matches my earlier actual merge. macOS passes all 107 library tests, all 10 terminal-native tests, all 22 Desktop tests (283.987 seconds, including Goal in 21.665 seconds), and both pixel tests (2.865 seconds). Windows passes 226 platform tests with one skipped, all 22 Desktop tests (196.253 seconds), and both pixel tests (0.827 seconds). The rail fix therefore now has passing native pixel-regression evidence on both platforms.

The baseline's separate CI 42577427630 also succeeded. Its macOS log passes 107 library, 10 terminal-native, all 22 Desktop (196.573 seconds, Goal 14.948 seconds), and both pixel tests (2.182 seconds); its Windows job also passes 226 platform tests with one skipped, all 22 Desktop tests (323.098 seconds), and both pixel tests (1.510 seconds). These newer results do not isolate the cause of the old Goal timeout. At ee7e906056aa256e584e21e060ae106e6399c094, the separate CI 42586921797 has also completed successfully. I read the native logs: macOS passes 107 platform-library, 10 terminal-native, all 22 Desktop (257.876 seconds), and both pixel tests (3.842 seconds); Windows passes 226 platform tests with one skipped, all 22 Desktop (281.816 seconds), and both pixel tests (1.276 seconds). This is evidence for that Rust baseline, not a new run of this closed PR.

The author closed this PR without merging it on 2026-11-09 at 08:16 UTC. Full native panel behavior, cross-application paste, packaged helpers and populated old-session acceptance were not completed by this review. The successful regression suites do not settle those broader acceptance questions. There is no database-schema or protocol-epoch change in this two-file increment.

Subsequent baseline CI update (2026-11-09): The separate Rust baseline 09ca38c23ae9d46214c2743e182fe018c6544429 now has a successful CI run 42612011937, attempt 1. All 35 jobs have finished, including the final test aggregate; I read its log confirming that all planned work succeeded. The native logs I read for that baseline pass macOS 107 platform-library, 10 terminal-native, 22 Desktop (239.939 seconds) and two pixel tests (2.644 seconds); Windows passes 227 platform tests with one skipped, 22 Desktop (338.712 seconds) and two pixel tests (1.470 seconds). The 22 root-test shards total 2,271 passing tests. This closes the previously pending aggregate, while the original Goal-timeout cause, populated historical-state recovery, real desktop residency and cross-application acceptance limits above remain unresolved. This PR remains closed without merging; the separate baseline result is not acceptance or a rerun of this Qt proposal.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@ARE404

ARE404 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. I checked the main findings against the code and agree with the direction: this shouldn't merge as it stands, and Quick Tools should move onto nsh/desktop in smaller PRs.

What I confirmed

  • Resident mode: once the main window closes, RUNNING is cleared and with_running_view drops the panel's closures.
  • MAKA_QUICK_NATIVE and the web sidecar are only set up by scripts/quick-tools/, so a packaged Maka.app can't summon Quick Tools.
  • linux.rs replaces HostChannel without re-attaching quickTools.*, and the native.ts Linux reveal and Windows open paths are wrong.
  • Escape reaches quickToolsBack before stopAction, and markBotRead is missing the context.operation() check.
  • The 40 ms flag timer, the slice(0, 79) file listing limit, the 16 KB URL check and the ${homeDir} read grant are all as you describe.

I haven't confirmed the Windows first.config path or the macOS quickStorage failure yet, and I couldn't find the left: 2 you mention in the current code.

The TurnNavigation regression is fixed in 1d63b7b: the pixel renderer gets the cell-safe pitch, C.line marks and left-side preview again, and desktop windows keep the new rail. every_visible_turn_mark_can_be_clicked_with_cell_coordinates passes locally on macOS.

Prototype of the single-engine launcher

The behaviour I most wanted to keep is the panel taking the keyboard while the previous app stays frontmost, so I tested that first with a throwaway app: one engine, <Window kind="popup" activate={false}> and GlobalShortcut, on macOS with TextEdit frontmost.

  • The hotkey opens the popup and it becomes key, while TextEdit stays frontmost throughout.
  • Typing (including IME composition), Cmd+V and Escape work, and nothing leaks into TextEdit.
  • It still works with the main window hidden via hide().

It needs two changes in NSH:

  1. InputState::focus_editor checks focus_scope(surface), which falls back to the main window's root outside a window event. Programmatic focus() and autoFocus on an input in a secondary window are therefore refused. Checking against the root of the input's own window fixed it in the prototype, though that local change ignored modal scopes, so it isn't the real fix.
  2. focus() is ignored until the window's first frame. The prototype worked around this with a 200 ms delay; the first frame should honour a pending focus request.

Not covered yet: Windows, Linux, the real close-button path with closeOnPress: false, and tray clicks.

Proposed plan

  1. Agent and client APIs on their own (markBotRead with the operation check, rankQuickTools, control-method tracking), leaving TurnNavigation.tsx alone.
  2. The two NSH focus fixes.
  3. Launcher on <Window kind="popup"> + GlobalShortcut on the single engine, coordinated with @me2seeks on moving #6695 to Tray and hide().
  4. Built-in tools on Maka's native capabilities, settings store and tr(), dropping the CJS plugin runtime, import-legacy.mjs and the 0003 migration. Any OS helper goes through the normal build and signing path.

I'll close this PR and follow up with the split.

One question: should the NSH fixes go into third-party/nsh here or upstream first?

@ARE404 ARE404 closed this Nov 9, 2026
@M4n5ter

M4n5ter commented Nov 9, 2026

Copy link
Copy Markdown
Member

@ARE404 (cc @me2seeks)

English

Great prototype validation—confirming that single-engine <Window kind="popup" activate={false}> + GlobalShortcut + hide() keeps the previous app frontmost on macOS while handling key focus, IME composition, Cmd+V, and Escape retires the biggest UX risk up front.

1. third-party/nsh vs. longbridge/nsh

Please make the changes directly in third-party/nsh here in apache/maka (as a standalone fix(nsh) PR with platform tests). Once everything stabilizes on our side, we'll contribute the reusable fixes upstream to longbridge/nsh so future syncs can drop our local patches.

2. Pointers on the Two NSH Focus Fixes (Step 2)

Checking third-party/nsh across all three desktop backends confirms both of your findings and turns up exact root causes + a Windows counterpart worth fixing in the same PR:

  1. Per-window modal-aware focus_scope (macOS + Windows):

    • macOS: NavState::scope(&self, root: &NshView) (nsh-platform-macos/src/navigation.rs:1158-1171) already tracks modals per window root (self.newest_in(root) checks m.host.as_ref() == Some(root)), and input.rs already has root_in(surface, &window). Adding a focus_scope_for(surface, &window) helper that resolves root_in(surface, &window) -> nav.scope(&root) and using it in InputState::focus_editor (text_input.rs:1742), input::focus_control (input.rs:948), and text_input::tab (text_input.rs:811, via from.window()) will preserve modal focus trapping in both the main window and secondary <Window>s.
    • Windows has the exact same bug: Nav::focus_scope / in_focus_scope (nsh-platform-windows/src/navigation.rs:1300-1307, 1620-1625) uses Self::input_window(surface) (surface.input_root()), which also falls back to surface.root outside an input event. That causes set_focus -> can_hold_focus (text_input.rs:968) to reject programmatic focus in secondary <Window>s, and even causes focused_view (text_input.rs:989) to forcibly blur a secondary window's focused input when queried outside an event. Resolving in_focus_scope(surface, view) against view's owning window root + newest_modal_in fixes Windows at the same root cause.
  2. Pre-first-frame focus has two distinct drop points:

    • Window-level window.focus() (WindowRequest::Focus): On macOS, open_window initializes Showing::Waiting(0) (FIRST_FRAME_MS = 250, which is why the 200 ms delay worked around it). Calling window.focus() while in Showing::Waiting returns early in show(..., focus: true) (nsh-platform-macos/src/window.rs:1045-1051) without recording a pending focus flag, and first_frame (window.rs:1367) computes let key = window.canBecomeKeyWindow() && activate; (false when activate={false}). Recording pending_focus on Showing::Waiting so first_frame passes key = pending_focus || (window.canBecomeKeyWindow() && activate) lets an activate={false} popup become key on its first frame deterministically. (Please also check Linux window.rs:995-1002 and Windows app_window.rs:232-236 so window.focus() before the first frame doesn't flash an unlaid-out window.)
    • Input/control-level autoFocus / ref.focus() (Command::Focus): For <Window><Input autoFocus /></Window>, nsh-core emits the child's Command::Focus before the parent <Window>'s DesktopCommand::OpenWindow (nsh-core/src/core/components.rs:2768-2780), so responder.window() is still None (and editor geometry may not be placed yet) when focus_editor runs (text_input.rs:1736). Retaining a pending focus target until the window attaches and lays out its first frame (similar to FocusState::auto_focus on Windows / focus_requests on TUI) will make autoFocus and same-batch ref.focus() work without timers.

3. Minor Adjustments to the Split Plan

  • Step 1 — Keep markBotRead, drop rankQuickTools: Walking back rankQuickTools from our earlier note—re-checking plugins/agent/native/src/owner/quick_tools.rs, keystroke launcher ranking shouldn't be a journaled SQLite WAL agent Mutation + remote LLM call (CONTROL_METHODS + pending_controls exemption + sending local file/clipboard candidates to a model provider with up to 15s latency), nor should maka.agent depend on Quick Tools types before a caller exists. Let's keep launcher ranking fast and local, and keep PR 1 strictly focused on markBotRead (BotOutbox.read_through, preview, context.operation() check, and markBotRead in CONTROL_METHODS).
  • Step 3 — Land #6695's single-engine Tray + closeOnPress: false / hide() migration first as its own small PR (with @me2seeks) across macOS, Windows, and Linux, then layer the Quick Tools <Window kind="popup"> + GlobalShortcut launcher + Assistant view on top.
  • Step 4 — Slice built-in tools into small PRs by capability rather than one batch, reusing in-process Rust / NSH APIs instead of external helper binaries wherever possible.

(FYI on the three references from the closed diff: Windows dropped first.config via drop(config) in direct2d.rs:75, 86-93; macOS appkit.rs:146 reset HostChannel::new() and only re-ran quick.attach without maka_workbench::quick_tools::attach; and left: 2 was left: props.quickTools ? 0 : 2 at Conversation.tsx:3734. All three go away with the single-engine setup and untouched TurnNavigation.tsx.)

中文

原型验证非常扎实——先在 macOS 上确认单引擎 <Window kind="popup" activate={false}> + GlobalShortcut + hide() 能在保持前序应用前台激活与菜单栏不变的同时,正常接管键盘焦点、中文输入法组合输入、Cmd+V 和 Escape,直接把最大的交互风险提前排除了。

1. 关于 third-party/nsh 还是上游 longbridge/nsh

直接在当前仓库的 third-party/nsh 里修改即可(单独提一个带平台测试的 fix(nsh) 小 PR)。等我们这边整体稳定后,再逐步向上游 longbridge/nsh 贡献以移除本地补丁。

2. 两个 NSH 焦点修复的源码根因补充(Step 2)

对照 third-party/nsh 三端源码核查,你定位的两个问题完全准确,补充两处关键根因和 Windows 同源问题,方便在同一个 PR 里一次修干净:

  1. 按窗口隔离且保留 Modal 约束的 focus_scope(macOS + Windows):

    • macOS:NavState::scope(&self, root: &NshView)(nsh-platform-macos/src/navigation.rs:1158-1171)本身就是按窗口根视图分别查找顶层 Modal 的(self.newest_in(root) 会核对 m.host.as_ref() == Some(root)),且 input.rs 已有 root_in(surface, &window)。只需新增按目标视图所属 NSWindow 解析 root 再调 nav.scope(&root) 的 focus_scope_for(surface, &window),并在 InputState::focus_editor(text_input.rs:1742)、非输入控件 input::focus_control(input.rs:948)及 text_input::tab(text_input.rs:811)中使用,就能同时保留主窗口与子窗口各自的 Modal 焦点隔离。
    • Windows 存在完全相同的同源 Bug:Nav::focus_scope / in_focus_scope(nsh-platform-windows/src/navigation.rs:1300-1307, 1620-1625)同样依赖 Self::input_window(surface)(surface.input_root()),在输入事件外回退到主窗口 surface.root。这不仅会让子窗口内的 set_focus -> can_hold_focus(text_input.rs:968)拒绝编程式聚焦,甚至在事件外查询 focused_view(text_input.rs:989)时还会把子窗口已聚焦的输入框强制 Blur 掉。建议同步将 Windows 的 in_focus_scope(surface, view) 改为按 view 所属窗口根视图 + newest_modal_in 判定。
  2. 首帧前 focus() 被忽略实际包含两处截断:

    • 窗口级 window.focus()(WindowRequest::Focus):macOS open_window 初始处于 Showing::Waiting(0)(FIRST_FRAME_MS = 250,这也是原型里 200ms 延迟能绕过的原因)。首帧前调 window.focus() 会在 show(..., focus: true)(nsh-platform-macos/src/window.rs:1045-1051)遇到 Showing::Waiting 直接提前返回、未记录挂起聚焦状态;而 first_frame(window.rs:1367)计算的是 let key = window.canBecomeKeyWindow() && activate;,在 activate={false} 时为 false。在 Showing::Waiting 上保留 pending_focus 并在 first_frame 中取 key = pending_focus || (window.canBecomeKeyWindow() && activate) 即可让非激活面板在首帧确定性地成为 key window(也请顺带检查 Linux window.rs:995-1002 与 Windows app_window.rs:232-236 首帧前 Focus 的行为一致性)。
    • 控件级 autoFocus / ref.focus()(Command::Focus):在 <Window><Input autoFocus /></Window> 中,nsh-core 会先发出子节点的 Command::Focus,再发出父组件 <Window> 的 DesktopCommand::OpenWindow(nsh-core/src/core/components.rs:2768-2780),因此 focus_editor 执行时 responder.window() 仍为 None(且首帧布局前编辑器可能尚未完成定位)。参考 Windows FocusState::auto_focus / TUI focus_requests,保留挂起的焦点目标并在窗口挂载及首帧布局就绪时兑现,即可无需定时器稳定支持 autoFocus。

3. 拆分顺序微调建议

  • Step 1 —— 只保留 markBotRead,去掉 rankQuickTools:修正一下我们上一条评论顺带提到的 rankQuickTools——复核 plugins/agent/native/src/owner/quick_tools.rs 后,启动器输入排序不应做成写 SQLite Event-Log WAL 的 agent Mutation + 远程大模型调用(占 CONTROL_METHODS、在 pending_controls 特判豁免、附带最高 15s 延迟并把本地文件/剪贴板候选发给模型服务商),也不应在尚无调用方时让 maka.agent 耦合 Quick Tools 类型。启动器排序保持纯本地即时算法即可;PR 1 只专注合入纯粹的 markBotRead(BotOutbox.read_through、preview、context.operation() 校验及 CONTROL_METHODS)。
  • Step 3 —— 先单独把 #6695 收敛到单引擎 Tray + closeOnPress: false / hide() 作为前置小 PR 合入(与 @me2seeks 协同,覆盖 macOS / Windows / Linux),再在其上合入 Quick Tools <Window kind="popup"> + GlobalShortcut 启动器与助手面板。
  • Step 4 —— 内置工具按能力拆成多个小 PR 逐步合入,优先使用进程内 Rust / NSH 原生能力,尽量避免外部辅助子进程。

(附:原 diff 中你提到的三处位置分别是:Windows 在 direct2d.rs:75, 86-93 drop(config) 丢弃了 first.config;macOS 在 appkit.rs:146 重建 HostChannel::new() 后只重挂了 quick.attach 而漏掉了 maka_workbench::quick_tools::attach;left: 2 在原 Conversation.tsx:3734 写作 left: props.quickTools ? 0 : 2。切到单引擎且不改 TurnNavigation.tsx 后这三处都会自然消除。)

@me2seeks

me2seeks commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@ARE404 @M4n5ter Thanks for the review and the prototype. I agree with using NSH's native capabilities first and splitting the work into small, independently verifiable PRs.

For Desktop residency, functionality comes first: closing the main Desktop window must not break Quick Tools, its global shortcut, or its ability to reopen the main window. The design should follow NSH's ownership and lifecycle model; retain the engine, Host connection and services while they are needed, and release resources that are no longer needed as far as possible without impairing functionality. This updates the stricter window-close resource-release requirement from #6695; merely hiding a window is not the same as releasing its engine.

On Linux, if no usable tray is available, please provide a clear prompt that closing Desktop will fully exit it, with an option to keep the window open. Also account for cases where the global shortcut cannot be registered, so we do not leave the app running without a usable way back. Explicit Quit should detach this Desktop client and exit Desktop, without terminating a shared Host or accepted work.

I support reusing the existing permission boundaries and granting only the capabilities actually needed. For validation, I can help accept the Linux and Windows behavior, including close/reopen, tray and shortcut availability, and Quick Tools after the main window closes. The macOS prototype is encouraging, but the real close/tray path and all three platforms still need verification; a fixed delay should not be the production focus fix.

Message drafted with assistance from Maka.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants