Repository navigation
Commit e95355d
feat(desktop): window requests target the sender or the most recent window
## What Changed
Every "main" window lookup in main now resolves by one rule.
| Request | Target |
| --- | --- |
| From a renderer (IPC) | The sender window |
| App-wide (menu, dock, `t3 app`, capture) | Most recently focused app window |
Only windows that main registered can be targets, so the splash, DevTools, and popups never are.
The upstream fallback runs only while no window is registered yet.
| File | Change |
| --- | --- |
| `WindowTargets.fork.ts` (new) | `IpcRequester` reference; `DesktopIpc` provides the sender around every invoke and sync handler |
| `WindowRegistry.fork.ts` | Focus recency per `WindowId`, dropped on close; `requestTarget` is the sender if registered, else the most recent window; `windowsByRecency` lists windows newest first |
| `ElectronWindow.ts` | `main`, `currentMainOrFirst`, `focusedMainOrFirst` return `requestTarget` first |
| `DesktopWindow.ts` | `activate` and `prepareCaptureReveal` use the capture's pinned window while a capture is acquiring, else the target; hub creation stays hub-only |
| `SnapShotTarget.fork.ts` (new) | A capture pins its window on `requested`; later events, the reveal, the post-capture activation, and the Linux destination window follow the pin. The pin is released on `ready`, `failed`, or when the capture fiber ends, interruption included |
| `DesktopAppActivationRenderers.fork.ts` (new) | Readiness per sender window; a request walks the ready windows in focus-recency order; an unregistered sender is ignored and never clears readiness; losing a window fails only the request it was handling |
### Audit
| Consumer | Resolves to |
| --- | --- |
| `ElectronWindow.main`, `currentMainOrFirst`, `focusedMainOrFirst` | Sender, else most recent (hooked once here) |
| `getWindowFullscreenState` (sync IPC) | Sender |
| `pickFolder`, `pickProjectFavicon`, `pickThemeFiles` owner | Sender |
| `showContextMenu` | Sender |
| `pasteAsText` main check | Sender: project windows can now paste as text |
| `ensureTrustedSnapShotSender` | Sender; the registered-window fallback is now redundant but kept |
| `DesktopSshPasswordPrompts.request` | Requester inside IPC, else most recent |
| `DesktopAppActivation.setRendererReady` | Per registered sender; an unregistered sender is ignored |
| `DesktopWindow.activate` (dock, `t3 app`) | Most recent |
| `DesktopWindow.activate` (post-capture) | Window pinned at `requested` |
| `prepareCaptureReveal` | Window pinned at `requested` |
| `dispatchMenuAction`, `zoomMain` | Most recent |
| `dispatchSnapShotEvent` | Window pinned at `requested` |
| `DesktopSnapShot` `destinationWindow` | Window pinned at `requested` |
| `openSystemSettings`, snapshot permission and setup owners | Kept: on macOS the focused window is the sender |
| `notificationBadge` | Kept: app-wide badge |
| `sendAll`, `destroyAll`, `syncAllAppearance` | Kept: broadcast |
| Preview `setMainWindow` owner | Kept: `"app"` owner from #1341 |
| `mainWindowBounds`, `flushMainWindowBounds` | Kept: hub bounds, #1345 |
| `ensureMain`, `createMain`, `revealOrCreateMain`, `createMainIfBackendReady`, `showConnectingSplash` | Kept: hub creation, #1343 |
## Why
Upstream binds IPC answers, dialogs, captures, and activation to the single hub window.
| Flow | Before, with project windows |
| --- | --- |
| Dialog from a project window | Parented to the hub |
| Fullscreen state | Read from the hub |
| One window's cleanup | Cleared `t3 app` activation for all |
Closes #1342
### Close conditions
- [x] Audit: every `main`-style consumer resolved
- [x] Fullscreen: targets the sender
- [x] Async: dialog, capture return to requester
- [x] Activation: readiness is per sender
- [x] Close one: others keep activation
- [x] Exclusions: no splash, DevTools, or popup
| Condition | Evidence in `apps/desktop/src/electron/WindowTargets.fork.test.ts` |
| --- | --- |
| Audit | Audit table above; "an IPC request resolves every main-style lookup to the sending window" |
| Fullscreen | "fullscreen state is read from the sender, not the hub", through `DesktopIpc.handleSync` |
| Async | "a dialog opened from a window is owned by that window while another has focus"; "every event of one capture reaches the window its request pinned"; "the capture reveals and activates the window it pinned"; "an interrupted capture releases its pinned window" |
| Activation | "a request goes to the most recently focused ready window"; "with the focused window not ready, a request walks focus recency"; "a renderer main did not register cannot clear the app windows" |
| Close one | "closing one ready window leaves the others activated"; "losing the window handling a request fails only that request" |
| Exclusions | "an app-wide request resolves to the most recently focused app window only": a focused unregistered window and an unregistered sender both resolve to the last app window |
### Live checks (host, not run here)
| Check | Steps and expectation |
| --- | --- |
| Fullscreen | Fullscreen a project window and reload it; its chrome reads fullscreen and the hub's does not |
| Dialog | Focus the hub, then pick a folder from a project window; the sheet parents to the project window |
| Capture | Snap shot with a project window last focused; the animation and result land there |
| Activation | Open the hub and a project, close the project, run `t3 app`; the request still completes |
| Exclusions | Focus detached DevTools, then use a menu action; it reaches the last app window |
### Swap proof
Temporary reverts at `f38334a280`, not committed:
| Reverted | `WindowTargets.fork.test.ts` |
| --- | --- |
| `ElectronWindow.ts` and `DesktopIpc.ts` hooks | 6 of 8 fail |
| `setRendererReady` hook | 3 of 8 fail (every activation case) |
### Checks
```text
vp test run <12 desktop files> → exit 0 (12 files, 156 tests)
vp run fork:ci → exit 0 (scripts: 59 files, 648 tests)
vpr typecheck → exit 0
vp run knip:check → exit 0
```
**Note:** `activate` now reveals the most recent window, not the hub, which also affects the dock behaviour in #1343.
## UI Changes
None: this changes which window main targets and adds no UI.
## Checklist
- [x] Small and focused
- [x] Explains what and why
- [x] Screenshots: n/a, no UI change
- [x] Video: n/a, no motion
Model and harness: Claude Opus 5.5, Claude Code in T3 Code.
## Fork trailers
Squashes:
- c3c9d16 feat(desktop): window requests target the sender or the most recent window
- 14073c5 fixup! feat(desktop): window requests target the sender or the most recent window
- c74e5dc feat(desktop): window requests target the sender or the most recent window
- faa53bd refactor(multi-window): createWindow seams become marked insertions (#1811) (#1811)
Fork-Domain: multi-window
Fork-Tier: core1 parent 2e5c1a7 commit e95355d
14 files changed
Lines changed: 736 additions & 11 deletions
File tree
- apps/desktop/src
- app
- electron
- ipc
- snapShot
- ssh
- updates
- window
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| 324 | + | |
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
| |||
352 | 354 | | |
353 | 355 | | |
354 | 356 | | |
| 357 | + | |
355 | 358 | | |
356 | 359 | | |
357 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 120 | + | |
124 | 121 | | |
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
128 | | - | |
129 | 125 | | |
| 126 | + | |
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
| |||
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
160 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
187 | | - | |
188 | | - | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| 215 | + | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| |||
263 | 266 | | |
264 | 267 | | |
265 | 268 | | |
266 | | - | |
267 | | - | |
| 269 | + | |
268 | 270 | | |
269 | 271 | | |
270 | 272 | | |
| |||
0 commit comments