You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dbc4ebd
Browse filesBrowse the repository at this point in the historyBrowse files
feat(desktop): key desktop windows by an opaque WindowId
## What Changed
Main mints a random `WindowId` (UUID v4, `node:crypto`) per desktop window and passes it to the renderer as the `--t3code-window-id` preload argument. The registry, preview ownership, Hyprland claims, the snapshot sender check and the update-restore manifest key by it. Project identity stays as data on the window record.
- `WindowRegistry.fork.ts` (new): registry keyed by `WindowId`; identity lookup is a scan; a restored id is reused unless a live window holds it.
- `WindowId.fork.ts` (new): brand, preload argument, validation; package-free for the sandboxed preload.
- `ElectronWindow.ts`, `DesktopWindow.ts`: one-line `multi-window` hooks delegate to the registry; `getOrCreate` passes the reserved id to `create`.
- `WindowPolicy*.ts`, `Manager.ts`: preview owner is `WindowId | "app"`; the bridge exposes `windowId`.
- `HyprlandPlacement.ts`: claims and moves key by `WindowId`.
- `DesktopWindowSession.ts`, `DesktopStartupDrain.fork.ts`, `DesktopUpdates.ts`: the manifest carries an optional `windowId`; restore reopens under the old id. A manifest from before this change still restores.
## Why
A project key cannot name two windows on the same project, or a window whose project changes. An opaque id keys the window itself, so #1342 through #1345 can build on it. None of them is pre-built here.
Closes#1341
### Close conditions
- [x] Registry: keyed by `WindowId`
- `ElectronWindow.fork.test.ts`: "keys each window by a minted WindowId, never by what it shows", "reuses a restored WindowId unless a live window already holds it"
- [x] Previews: ownership keyed by `WindowId`
- `WindowPolicy.fork.test.ts`, `preview.fork.test.ts`: owner routing by `WindowId`; `preview.test.ts` asserts owner `[windowId]`, not the project identity; `DesktopWindow.test.ts` asserts `setWindow` owner `[testWindowId(1)]`
- [x] Hyprland: claim keyed by `WindowId`
- `DesktopWindow.test.ts`: claims and workspace moves carry `[hubId, projectWindowId]` on restore and `testWindowId(1)` on launch
- Unit tests only: the live claim log is debug-level
- [x] Demand, snapshot: keyed by `WindowId`
- Snapshot: `snapShotSender.fork.ts` resolves the sender through `windowIdFor`; `snapShot.fork.test.ts` covers a registered project window and an unregistered one
- Demand: published per window on its own `webContents`; no project key exists on that path
- [x] Reload: id survives a renderer reload
- Live (host, `.dump/evidence/1364-live/`): menu Reload (`22-ctrl-r.txt`), `forcefullyCrashRenderer` (`23-crash.txt`) and update restore (`40-*`, `41-renderer-ids.txt`) all keep the id
- Unit: `DesktopWindow.fork.test.ts` pins the id across `render-process-gone` recovery; `WindowPolicy.fork.test.ts` reads the id from argv and leaves it unset when absent
### Swap proof (each reverted with `git checkout -- <file>`)
```diff
- registry keys by identity key → ElectronWindow.fork.test 2 failed
- id dropped from preload arguments → DesktopWindow.test 3 failed
- drain ignores entry.windowId → DesktopWindow.test 1 failed
- manifest read drops windowId → DesktopWindowSession.test 2 failed
- Hyprland claim keyed by identity → DesktopWindow.test 1 failed
- id dropped (crash recovery test) → DesktopWindow.fork.test 1 failed
- preview owner keyed by identity → DesktopWindow.test 1 failed
```
### Checks
```
vp test run <targeted desktop dirs> → exit 0 (64 files, 700 tests)
vp run fork:ci → exit 0 (scripts 59 files, 648 tests)
vpr typecheck → exit 0
vp run knip:check → exit 0
```
### Note
The crash-recovery case lives in `DesktopWindow.fork.test.ts`: the fork:ci upstream-test rule refuses a new case in `DesktopWindow.test.ts`. `registerMain` now reuses a registered window's id and never mints one the preload cannot see.
## UI Changes
None. Main-process window keying only.
## Checklist
- [x] This PR is small and focused
- [x] I explained what changed and why
- [x] I included before/after screenshots for any UI changes (n/a: no UI change)
- [x] I included a video for animation/interaction changes (n/a: no motion)
Model and harness: Claude Opus 5.5, Claude Code in T3 Code.
## Fork trailers
Squashes:
- ef5a421 feat(desktop): key desktop windows by an opaque WindowId (#1576) (#1588) (#1590)
- ee337a4 fixup! feat(desktop): key desktop windows by an opaque WindowId
- 3ccc7bc fixup! feat(desktop): key desktop windows by an opaque WindowId
- 69a9cc5 fixup! feat(desktop): key desktop windows by an opaque WindowId
- cd0487c feat(desktop): key desktop windows by an opaque WindowId (#1576) (#1588) (#1590)
- faa53bd refactor(multi-window): createWindow seams become marked insertions (#1811) (#1811)
Fork-Domain: multi-window
Fork-Tier: core
Fork-Upstreamable: no
0 commit comments