Skip to content

feat(app-kit): keep desktop app shortcuts and prefs per machine - #37457

Merged
bolichen97 merged 1 commit into
mainfrom
feat/app-seam-desktop-host-prefs
Nov 15, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
feat/app-seam-desktop-host-prefs

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A desktop app the window host serves keeps the user's own shortcut keys, its per-platform defaults and its per-computer settings, and an adopted built-in brings the user's chosen crew and rebinds along, so Mochi can move onto the host without its users losing anything.

The window host (§35) gives an app fixed manifest accelerators and no per-computer state. Mochi's shell code has four things the host could not express, so an adopted Mochi would regress for its users (owner ruling on #26967, comment 6841699202: "decide directly; users' normal use must not be affected; grant what is needed"):

  • users rebind Mochi's global shortcuts in Settings > Shortcuts, but host shortcuts are fixed;
  • Mochi's defaults differ per platform (CommandOrControl+Shift+M/H/X on macOS, Alt+Shift+M/H/X elsewhere) while the manifest takes one accelerator;
  • reserveMochiShortcuts holds Mochi's chords even while it is disabled, so the host would refuse an adopted Mochi declaring the same chords;
  • the crew the pet shows and the rebinds live in the shell's mochi-machine.json, which a window page cannot read.

#36349 named the shortcut gap under "Not a goal" ("user-rebindable shortcuts"); this is that gap.

Why it matters

Mochi cannot leave core (#26967) while these exist only as Mochi's main-process code. Without them an external Mochi would bind fixed keys its users had moved, use macOS chords on Windows and Linux, be refused its own chords, and forget which crew the pet showed.

Not a goal

  • When built-in shell code steps aside for an app the host serves, and serving an app from a chosen crew while the local copy is off: lane desktop-host-serve (feat(app-kit): let built-in shell code step aside for the window host #37454). This PR only hands over the reservation and seeds the gateway choice that lane reads.
  • Moving Mochi's windows onto the host, adding a desktop block to the built-in manifest, or creating Mochi's repository.
  • Changing what Mochi's shell code does today, or the shell's summon hotkey.
  • A dashboard-level shortcut settings page: the app's own Settings page shows them through the bridge.

What changed (motivation → approach → change)

Goal: the four Mochi-only behaviours as app-agnostic host seams, with the app id as data; Mochi's own state handed over by Mochi's own shell code.

Approach: the shell keeps the user's bindings the way it keeps appWindowGatewayChoices, in a new app-window-prefs.js over its own 0600 app-window-prefs.json; every page call resolves to its sender's own app. Mochi's per-computer settings are the crew the pet shows and its rebinds, so they land in the gateway choice and the bindings; a page gets no second, generic store.

  • Per-platform defaults. desktop.shortcuts[].platformAccelerators (macos/windows/linux), each held to the chord rule, unique per platform; parsed in apps/desktop_manifest.py and app-window-host-rules.js.
  • Rebinding. Bridge level 3 adds shortcuts() and setShortcut(id, accel|""|null): only a declared shortcut, only within 2 s of a press in that window, never a background page, only the manifest's chord rule and no chord another of the app's shortcuts holds; a chord other than the declared default only when the user pressed it in that window (before-input-event, else not-pressed). The new chord is registered before the binding moves, so a refused rebind or reset keeps the chord the app held and never frees it for another app.
  • Hand-over. shell-shortcut-reservations.js: an owner reserving { app: true } under an app id does not block the host serving that app. Mochi keeps its plain reservation until its built-in steps aside (feat(app-kit): let built-in shell code step aside for the window host #37454): opting in earlier would let the built-in and the host register the same chords. One binding is one chord whatever its spelling, so a respelled rebind keeps the chord with its holder.
  • Mochi's choices. mochi/hostHandOff.js, run by initMochi before main.js creates the host, copies the crew and the rebinds from mochi-machine.json into the host's stores for mochi and records what it copied. It copies again only while the host still holds that value, so a change in the built-in before adoption carries over and a choice made through the host (a reset, "self", a new chord) is never overwritten: the rule of Crew Companion's displayHandOff.js. It leaves core with Mochi's shell directory; the host has no import of its own.

Wiring: main.js opens the bindings store before initMochi and hands both stores to it; package.json build.files gains the two modules (no dependency change). Level: platformAccelerators joins unreleased App Kit seam level 8; scripts/adoption_pin.py maps it. Types in desktopWindowTarget.ts. Specs: app-kit-platform §35/§32, mochi.md, manifest reference, electron README.

Backwards compatibility

Compatible: the manifest key is new and optional, the bridge calls are additive behind level, isReserved and desktopDeclarations take only new optional arguments, and only an owner that opts in with { app: true } is handed over. No built-in declares a desktop block, so the host serves none of them and nothing changes for a user until an app adopts. The hand-off only writes the host's entries for mochi, which the host reads only for an installed app of that name declaring those shortcuts (and, for the crew, holding approved gatewayChoice).

Removes nothing: no key, call, record or row is removed or tightened; mochi-machine.json is only read, apart from Mochi's own mochi.hostHandOff record in it.

Tests

  • website/electron/test/app-window-host-prefs.test.js: the per-platform default on darwin, linux and win32; listing; a rebind moving the chord and surviving a restart; unbind and reset; NEGATIVE: no press, a stale press, a second request on one press, a stranger sender and a background page cannot rebind; an undeclared or another app's shortcut, a single-modifier chord, a chord on another of its shortcuts, a reserved chord, another app's chord and another program's chord are refused with every binding unchanged; a refused reset or rebind keeps the app's custom chord from another app declaring it, which takes it only once a move succeeds; respelling a held chord keeps it from an app listed first that declares it; a chord the page picked after a click, another chord, one pressed in another window, a stale, spent, repeated or released press are refused not-pressed, while the pressed chord (by position or character), the default, "" and null pass; the hand-over only to the app named by an { app: true } owner; bindings kept across a listing without the app.
  • mochi/test/hostHandOff.test.js: the adopted declaration's defaults and ids equal shortcuts.js; the crew and the rebinds reach the host (a chord at the built-in's default is no binding) and a second start writes nothing; a change in the built-in before adoption carries over; NEGATIVE: a "self", a reset or a new chord made through the host is never copied over, even when the built-in's value moves later; before any copy, a host value of its own is kept; a rebind the host's rules refuse leaves the host's default; only mochi's entries are written.
  • app-window-host-rules.test.js, test/test_app_manifest_desktop.py: platformAccelerators parses, round-trips, is signed and is refused outside the rules on every platform; a repeated chord is one refusal naming only the platforms it repeats on; a desktop block asking for anything else is refused; pressedChord / keyPressChords per platform.
  • shell-shortcut-reservations.test.js: the hand-over only to the app an { app: true } owner names, never for a plain owner.
  • app-window-preload.test.js: the level 3 calls and their empty answers. test_builtin_adoption_pins.py: platformAccelerators maps to level 8.

Mutation check: dropping the pre-registration in rebindShortcut reds the refused-reset test and the refusal test; comparing a binding by its spelling instead of its chord reds the respelling test; letting the hand-off always copy reds both of its NEGATIVE keep-the-host's-choice tests, and copying over a host value before any record reds the second; dropping the app argument from the host's reservation check reds the hand-over test; serving setShortcut to any sender instead of one the user is acting in reds the no-press test; dropping the pressed-chord check, its spend or its 2 s window reds the not-pressed test.

Determinism: the touched Electron files 3x green; the full Electron suite green in its default order and with the file order reversed, apart from three packaging.test.js cases that need this host's absent node_modules/app-builder-lib; 419 related backend tests green; flake-pattern ratchet green. The new tests use the injected clock or plain Map stores and no sleep.

Local gates: black (pinned 26.10.1) on the changed Python, isort, flake8, mypy on the changed module, comment-history, brand, harness parity, file-line cap, docs-lint. The only website/src/ change is a type declaration with no other reference. Semgrep is not installed on this host; CI's SAST runs it. Local review ran as a self-review against the lanes' contracts: this host has no model-pinned subagent facility.

Manual verification

N/A for a live desktop session: the host was exercised through the injected-Electron tests only, as in #36349. No window, prompt or page renders differently.

Screenshots / video

Why no screenshot: the only file under website/src/ is a type declaration for the bridge, and nothing renders differently.

Related Issues

Part of #26967

Owner ruling: #26967 (comment) (also the 2026-11-07 ruling 6713005850, item 5: the generic window seam). Gap named by #36349.

Same batch, separate lanes: Mochi's reserveMochiShortcuts opts into the hand-over ({ app: true }) together with its step-aside, in #37454 or right after it. desktop-host-serve (#37454) touches app-window-host.js, app-window-host-rules.js (its desktopDeclarations options object composes with this one's platform), the independence gate and the same specs; whichever lands second rebases. app-chat-slot-create shares no file.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 15, 2026 02:12
@bolichen97
bolichen97 requested a review from buluoray November 15, 2026 02:12
@bolichen97

Copy link
Copy Markdown
Contributor Author

Decisions taken under the owner ruling (#26967, comment 6841699202), for the reviewer:

  1. Rebinds obey the manifest's chord rule. A page is app code, so setShortcut accepts only a chord with two different modifier keys, never one another of the app's shortcuts holds, and only within 2 s of a press the shell saw in that window. A legacy Mochi rebind that breaks the rule (a single-modifier chord) is not imported: that shortcut keeps its default, and the shell logs it.
  2. The import is declared, not guessed. desktop.legacyMachinePrefs names which legacy key holds the gateway choice and which holds the bindings. The host names no app and no app-specific key. Shortcut names match ids with case, - and _ ignored, so toggleWindow binds toggle-window.
  3. The import also runs for an app that is off on this computer. A user whose local copy is off but whose pet shows a remote crew keeps that choice for the desktop-host-serve lane (feat(app-kit): let built-in shell code step aside for the window host #37454) to act on.
  4. The hand-over is opt-in per owner ({ app: true }). The summon hotkey and any other owner that is not an app are never handed over, whatever an app is named.
  5. Level. The bridge goes to level 3. The manifest keys join the unreleased App Kit seam level 8 alongside credentialMasks directory entries (§37), with no new bump.
  6. No decoupling-gate row shrinks yet. Mochi's shell directory and main.js requires stay until Mochi is adopted and the serve lane's step-aside lands. This PR moves the built-in's reservation onto the seam, and its mochi-machine.json becomes the import source.

@bolichen97
bolichen97 enabled auto-merge (squash) November 15, 2026 02:13
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of c560438ff0b4809dbcb0f0be52686b824e3aa6af — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: the diff adds no rendered control. It adds manifest parsing, Electron main-process stores and level-3 bridge calls (shortcuts(), setShortcut()), and the rebinding Settings page those calls serve lives in the external app. So the missing screenshots are not a gap.

Notes

  • The setShortcut refusal reasons ('undeclared' | 'refused' | 'not-pressed' | 'in-use' | 'unavailable') are codes, not text a user should see. The manifest reference should tell app authors which sentence to show for each one. For example, not-pressed could read "Press the new shortcut in this window, then save," so the codes never reach the user as they are.

[UX-REVIEWED] c560438

Description read

[DESCRIPTION-READ] be86609548833a9bbe98a681b27a1880f744b9e67dd88bf93827d6bde8583773

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c560438ff0b4809dbcb0f0be52686b824e3aa6af — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the new manifest key, the bridge calls and the reservation hand-over are all additive and app-agnostic, and Mochi's id appears only in the hand-off code under mochi/, which leaves core with it.

Notes

  • hostHandOff.js writes host entries for the id mochi before any app by that name is installed. If an unrelated app named mochi is later installed and approved for gatewayChoice, it inherits the user's crew choice and rebinds. Consider limiting the seed to the official registry's Mochi once feat(app-kit): let built-in shell code step aside for the window host #37454 decides how adoption is identified.

[DESIGN-REVIEWED] c560438

Description read

[DESCRIPTION-READ] 5293d534a7f1d62157e03485ebdd4095f74dd6778e7fe619e0ad52ac50c1c525

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c560438ff0b4809dbcb0f0be52686b824e3aa6af — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

One rider ships ahead of its only caller: the { app: true } reservation hand-over has no production caller in this PR. It is internal to the shell and easy to remove, so it gets a note, not a block.

Notes

What this change ships

Inventory (7 items) — 6 justified

Intent: let an adopted desktop app (Mochi) keep users' rebinds, per-OS default keys and chosen crew once the window host serves it — ADDITION.

  1. Manifest shortcuts can declare a different default chord per OS (platformAccelerators) — justified
  2. An app's own Settings page can list its shortcuts (bridge level 3 shortcuts()) — justified
  3. A user can rebind, unbind or reset an app shortcut by pressing a key in its window (setShortcut) — justified
  4. New 0600 app-window-prefs.json holding per-app bindings on this computer — justified
  5. Shell code tagged { app: true } lets the host serve that app's reserved chords — zero consumers, deferred caller feat(app-kit): let built-in shell code step aside for the window host #37454
  6. Every start copies Mochi's crew and rebinds into the host's stores and records the copy — justified
  7. Two spellings of the same chord now count as one binding when shortcuts are compared — justified

[FIRST-PRINCIPLES-REVIEWED] c560438

Description read

[DESCRIPTION-READ] c1a8e4ee9940c19a502c88e71526df78507e7184b3b80ea3e957aa2b04d5fb97

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c560438ff0b4809dbcb0f0be52686b824e3aa6af — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c560438

Verdict parsed from the review's SHA-scoped output markers for commit c560438ff0b4809dbcb0f0be52686b824e3aa6af.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c560438ff0b4809dbcb0f0be52686b824e3aa6af false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c560438ff0b4809dbcb0f0be52686b824e3aa6af and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c560438

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c560438ff0b4809dbcb0f0be52686b824e3aa6af false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@bolichen97
bolichen97 force-pushed the feat/app-seam-desktop-host-prefs branch from 0baa3e5 to 6154e62 Compare November 15, 2026 04:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: the legacy-store guards had no test that fails without them: fixed in 6154e62

fixed: readLegacyStore now has tests in app-window-host-prefs.test.js that fail without each guard. A symlinked <app>-machine.json reads as absent (the test is skipped only where the host cannot create a link). A file one byte over 256 KiB is absent, and one exactly at the cap is ok. A directory is absent. Non-JSON is absent, a definite nothing that is never retried.
Each of the four mutations named in the finding now fails a test: lstatSync -> statSync, dropping !stat.isFile(), dropping the cap, and returning retry on a parse error.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: never-overwrite was tested only for the gateway choice, and the import order not at all: fixed in 6154e62

fixed: a new NEGATIVE test seeds the host's own prefs and one binding before the import runs. Only the keys the host lacked are added, and the host's own binding is kept. Dropping either hasOwn check fails it.
fixed: a new test gives the importing app an approved gatewayChoice capability and a connected crew. Every window loads from the imported crew on the first tick, so moving importLegacyStores after resolveTargets fails it.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: after any click, a page could move a shortcut onto any chord the rule allows: fixed in 6154e62

fixed: a chord other than the shortcut's declared default is accepted only if the user pressed it in that window within the 2 s press window. Anything else is refused with not-pressed.
The shell reads the press from Electron's before-input-event (keyDown, not a repeat), which is native input a page cannot synthesize. The key is taken from its position or its character, and the modifiers are mapped to the physical keys of this platform (keyPressChords / pressedChord in app-window-host-rules.js). Each press answers one request.
So a page records the user's choice and can no longer pick a chord itself. The only chord the user did not press is the default the publisher signed. "" (unbind) and null (back to the default) still need only the press.
Tests cover: a chord picked after a click, a different chord, a press in another window, and a stale, spent, repeated or released press.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: prefs and bindings are keyed by app name and never pruned: rebutted

rebutted: this store follows the lifecycle core already gives an app's own data. Core's default uninstall keeps data/ (uninstall_app(keep_data=True); the route purges only on an explicit purge_data: true). A reinstall under the same name, from any source, gets data/ back (manager_install: "Reinstalling %s into the folder its uninstall kept"). So after a default uninstall, a same-named app already inherits far more than 64 Ki of prefs. This store is not the weaker boundary.
The alternatives each lose data. Pruning when an app is missing from /api/apps would drop a user's settings whenever list_apps skips a damaged record. Binding to installedAt would drop them on every reinstall, and binding to sourceSigner would drop them on updates, since an update resets it to "".
The spec now states this lifecycle, and a new test pins that prefs and bindings survive a listing that lacks the app.
Residual: an explicit purge removes data/ but not this store (nor the existing gateway-choice store). Closing that needs a signal from core to the shell, which is outside this PR.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: setPref had no gate and does synchronous I/O on every call: fixed in 6154e62

fixed: setPref is refused while the host is suspended. Each app also has a write budget: 32 writes at once, then one every 250 ms. A write past the budget gets {ok: false, reason: "busy"} before any store access.
createMachinePrefs reads each store key once and then keeps it in memory, which is safe because it is the only writer. So prefs(), shortcuts() and refused writes touch no disk. A new test counts the store's get and set calls.
About the suspended mutation in setShortcut: no test can reach that check. suspend() closes every window synchronously, and closeRecord -> onClosed removes each sender from bySender, so no sender resolves while the host is suspended. The check stays as defense in depth, the same as in chooseGateway.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: one duplicate chord was reported three times: fixed in 6154e62

fixed: each shortcut now gets one refusal. When the chord repeats on every platform, the message is the one from before this change: accelerator repeats another shortcut's chord. Otherwise it names only the platforms where it repeats, for example ... on windows, linux. A test is added in test/test_app_manifest_desktop.py.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review finding: the spec cited the wrong ruling, and the prefs API and import are not shown at install: attribution fixed in 6154e62; install line rebutted

fixed: the spec no longer cites 6841699202 for keeping this state in the shell. The shell placement follows from a window's localStorage belonging to its gateway origin. The shortcut half rests on ruling 5 of 6713005850 (the window seam's global shortcuts). The prefs and the import rest on 6841699202 ("users' normal use is not affected; grant what is needed"): an adopted Mochi keeps the crew and the rebinds its users chose.
rebutted: in item 3, "declared in the manifest, shown at install" applies to the capability seams that item lists, and each of those reaches beyond the app's own window. The prefs and the import reach nothing by themselves.
Prefs are the app's own storage, like data/, which has no install line either.
legacyMachinePrefs is declared in the signed manifest. It reads only <app>-machine.json, which only a built-in's own shell code writes (today only Mochi's), so an adopted copy gets data its own built-in already kept.
Whatever the import seeds acts only through things the prompt does show. The gateway choice moves windows only for an app holding the approved gatewayChoice capability (resolveTargets), and the bindings are the app's declared global shortcuts. The spec now records this.
If the owner still wants a trust-prompt line for the import, it is a UI follow-up: one i18n string plus a screenshot.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own.

The PR adds per-platform shortcut defaults, user rebinding of shortcuts through the window host, a hand-over of reserved chords that apps must opt into, and a seeded copy of Mochi's crew choice and rebinds. I checked each part in the code. Rebinding: only within 2 s of the user acting in the window, one request per press, and a chord other than the default must be the one the user actually pressed. The new chord is registered before the old one is released, so a refused rebind keeps the app's chord. Reservation hand-over: only to the owner's own app id, and only when every owner holding the chord agrees. All callers of isReserved were updated. Hand-off: it runs inside a try/catch before the host is created. The crew choice is used only when the app holds the gatewayChoice capability, and the copy-again rule never overwrites a choice made through the host. The Python and JavaScript parsers agree, signing is unchanged for existing manifests, and nothing changes for users today because no built-in declares a desktop block. Tests cover the new behaviour, including the cases that must be refused.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit d1b69b5472 · 1695 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • A retried legacy import overwrites an explicit local gateway choice (span=b9e75ea02a6a)

fixed in 8aacf04: chooseGateway marks the app under appWindowGatewayChosen, and the import seeds the legacy choice only when the app has no such mark and its choice reads as self, so an explicit "self" made while the import was pending is kept.
New test: an unreadable legacy store, then chooseGateway("self"), then a readable store: the import runs, the gateway store stays empty and every window still loads from this computer. Dropping the mark reds it.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 15, 2026
@bolichen97
bolichen97 force-pushed the feat/app-seam-desktop-host-prefs branch from 8aacf04 to 38df4db Compare November 15, 2026 06:50
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
resolution: removed desktop.legacyMachinePrefs, its Python/JS parsers, legacyImportDeclarations, readLegacyStore, importLegacyMachinePrefs, the appWindowGatewayChosen mark and the name normalization

  • Built-in → host hand-off spelled a second time, as a permanent manifest seam (span=735bd7634eb3)

fixed in 38df4db: the manifest key and the host's import are gone; Mochi's own shell code now pushes its state, the displayHandOff.js way.
mochi/hostHandOff.js, called by initMochi before main.js creates the host, copies the crew and rebinds into the host's gateway choice and bindings for mochi, records what it copied, and copies again only while the host still holds that value.
It lives in Mochi's shell directory and leaves with it, so the App Kit contract keeps only platformAccelerators at level 8.

@bolichen97

Copy link
Copy Markdown
Contributor Author

resolution: removed the pending host-side import that could land late

  • A pending legacy import undoes an explicit shortcut reset (span=b9e75ea02a6a)

fixed in 38df4db: the host no longer imports anything, so no late import exists. Mochi's hand-off copies a value only while the host still holds what it last copied (or, before any copy, holds nothing of its own).
A reset, a "self" or a new chord made through the host differs from that record and is never copied over, even when the built-in's value moves later: mochi/test/hostHandOff.test.js NEGATIVE cases; letting the copy always run reds them.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Design note for the reviewer: decisions 2 and 3 in the first comment (the declared legacyMachinePrefs import, and the import running for an app that is off here) no longer apply. Mochi's own shell code now hands its crew choice and rebinds to the host at every start (mochi/hostHandOff.js, before the host is created), whether Mochi is on or off here, and that code leaves core with Mochi's shell directory. The App Kit contract gains only platformAccelerators and the level 3 shortcut calls.

@bolichen97
bolichen97 force-pushed the feat/app-seam-desktop-host-prefs branch from 38df4db to d1b69b5 Compare November 15, 2026 07:05
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Equivalent accelerator spellings transfer a held shortcut (span=425976e6ecb7)

fixed in d1b69b5: sameBinding compares the canonical chord instead of the raw accelerator, so a respelled binding of the chord a holder already has keeps its live registration and no other app declaring the chord can take it.
Class swept: the host's other accelerator uses are register/unregister/isReserved calls (spelling-agnostic or the registered string), not identity checks.
New test: beta holds a chord, alpha listed first declares it, beta rebinds to another spelling: ok, still beta's, registered: true. Comparing by spelling reds it.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Mochi marks its reservation as handed over while the built-in never stands down (span=43250c3b36b1)

fixed in d1b69b5: Mochi's reserveMochiShortcuts is back to a plain reservation (mochi/shortcuts.js and its test equal main), so the host refuses Mochi's chords to every app, an adopted copy included, and the built-in's own register() stays protected.
The generic { app: true } seam stays; Mochi opts in together with its step-aside (#37454), the only point at which a single owner binds the chords. The spec, mochi.md and the PR body say so.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Failed preference writes leave the new shortcut registered (span=425976e6ecb7)

Rebutted (disproportionate, downgraded LOW on adjudication): the state is transient and self-correcting. A throwing setBinding leaves the stored bindings and entry.shortcuts unchanged, so the next tick's apply() -> bindDeclared -> syncShortcuts finds the claimed chord bound to no declared shortcut and releases it (TICK_MS, 5 s).
Until then the extra chord only delivers the app's own declared action to its own window; nothing is persisted and no other app's chord is touched. A store write failing (disk full) already leaves the whole shell's stores degraded; a per-call rollback adds a second release path for that one case.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 6) and Coverage Gate on d1b69b5 are main's red, not this diff: test/metrics/test_kiro_export_destination.py::TestOffOffer::* (3 cases, assert False is True) fails after #37460 and #37463 crossed, tracked by #37546, fix in #37545. This PR touches no metrics code. It rebases onto main once #37545 lands; no rerun or override for that red.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
The desktop window host gave an app fixed manifest accelerators and no
per-machine state, so a desktop pet could not move onto it: its users
rebind its global shortcuts, its defaults differ per platform, its
shell code reserves its chords even while disabled, and the crew it
shows plus the rebinds live in a shell store a window page cannot read
(#36349 left the shortcut gap under "Not a goal").

Generically, with the app id as data:

- desktop.shortcuts[].platformAccelerators: a per-platform default,
  held to the same chord rules (gateway and shell); seam level 8.
- The host binds the user's chord per app per machine, and a page's
  shortcuts() / setShortcut() (bridge level 3) lists and rebinds only
  the app's declared shortcuts, only right after a press in that
  window, and onto a chord other than the declared default only when
  the user pressed that chord there. The new chord is registered
  before the binding moves, so a refused rebind or reset keeps the
  chord the app held and never frees it for another app.
- A shell owner that is an app's own shell code may reserve
  { app: true } so the host serving that app id may bind those chords.
  Mochi keeps a plain reservation until its built-in steps aside
  (#37454), so the two never register the same chords. One binding is
  one chord whatever its spelling, so a respelled rebind keeps the
  chord with its holder.

For Mochi, its own shell code (mochi/hostHandOff.js, called from
initMochi before the host is created) copies the crew the pet shows
and the user's rebinds from mochi-machine.json into the host's gateway
choice and bindings for mochi, recording what it copied. It copies
again only while the host still holds that value, so a change in the
built-in before adoption carries over and a choice made through the
host is never overwritten. It leaves core with Mochi's shell code.

Built-ins behave as before: no built-in declares a desktop block, so
the host serves none of them yet.

Part of #26967
@bolichen97
bolichen97 force-pushed the feat/app-seam-desktop-host-prefs branch from d1b69b5 to c560438 Compare November 15, 2026 08:23
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto 09b0ddc, which carries the main-red fix #37545 for TestOffOffer (the shard 6 / Coverage Gate red on d1b69b5). Diff unchanged; CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 15, 2026
@buluoray

Copy link
Copy Markdown
Contributor

Review passed on this head. Please rebase onto the latest main: the only red tests on this head are main's test/metrics/test_kiro_export_destination.py::TestOffOffer failures (#37546), which #37545 fixed after this run started. The approval will follow once the rebased head is green.

@buluoray buluoray 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.

Approve on c560438. This PR lets a desktop app that the window host serves keep the user's own shortcut keys and a per-platform default on each computer, and it lets Mochi's own shell code copy the crew the pet shows and the user's rebinds into the host's stores ahead of Mochi moving onto the host. Nothing changes for users today, because no built-in declares a desktop block yet. Mochi's existing file is only read, apart from one new record of what was copied, so an upgrade or a downgrade loses nothing. The copy repeats only while the host still holds the value it last copied, so a choice the user makes through the host is never overwritten; tests turn red when the copy is skipped or made unconditional. The new store is written the same way as the shell's existing stores: atomically and owner-only. No app id appears in the host code. This head is rebased onto a main that carries #37545, the fix for main's red metrics tests (#37546), and its CI run is green. Follow-ups: a test that fails when the hand-off is not wired into startup, and a note for #37454 that a Mochi rebind which the host's chord rule refuses falls back to the default after adoption. Decisive lines: website/electron/mochi/hostHandOff.js:56-58 (hostStillSeeded), website/electron/mochi/hostHandOff.js:83-122 (seedHostMachinePrefs reads mochi-machine.json and writes only the new mochi.hostHandOff record there), website/electron/mochi/index.js:1447-1459 (hand-off runs in try/catch), website/electron/main.js:913-931 (prefs store opened 0600 and handed to initMochi before the host is created), website/electron/app-window-host.js:1087-1106 (rebindShortcut registers the new chord before the binding moves), website/electron/shell-shortcut-reservations.js:98-106 (hand-over only for an owner that opted in with { app: true }), docs/system-specs/modules/app-kit-platform.md (§35 updated in the same commit)

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@bolichen97
bolichen97 merged commit d19e0ee into main Nov 15, 2026
100 checks passed
@bolichen97
bolichen97 deleted the feat/app-seam-desktop-host-prefs branch November 15, 2026 09:33
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants