App: open a chat, the terminal or a diff in a new window

"Open in new window" sits beside Float: the chat pane and chat list row
menus, a floating chat window's title bar, the terminal options menu and
the diff bar, plus Alt+Shift+Y for the chat with the keyboard (listed in
the shortcut help). Once the window opens the item leaves the main window
as Float takes a pane out of the tiling.

The window is its own app instance at /window/chat/<id>,
/window/terminal?tab=<key> or /window/diff/<token>: only that item, named
after it, with "Bring back to main window". It has its own connection and
writes no shared layout (no open-chat workspace, window store or terminal
layout) and posts no notifications, so they stay the main window's.

Web opens a popup window (a blocked popup offers a tab); Linux and macOS
start a second process with --detached (Flutter's multi-window API is still
experimental); Android and iOS hide the action. The capture kit gains a
follow step for windows a page opens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 12:47:42 +00:00
parent c4de1de27b
commit 61c7eee2b0
46 changed files with 3223 additions and 72 deletions
+28
View File
@@ -88,6 +88,7 @@ export async function openBrowser({ cdp, gpu = false, args = [], chromePath = pr
ws.send(JSON.stringify({ id, method, params, ...(session ? { sessionId: session } : {}) }));
});
let targetId;
let main;
try {
({ targetId } = await raw('Target.createTarget', { url: 'about:blank' }));
({ sessionId } = await raw('Target.attachToTarget', { targetId, flatten: true }));
@@ -114,6 +115,33 @@ export async function openBrowser({ cdp, gpu = false, args = [], chromePath = pr
},
/** Brings the kit's own page to the front again (after a scratch page). */
front: () => raw('Target.activateTarget', { targetId }),
/**
* Moves the kit's page session to another page target: the first one
* whose URL contains [match] (a window the page opened with
* `window.open`), waited for up to [timeout] ms; `main` returns to the
* page the kit opened. Resolves to the target's URL.
*/
follow: async (match, timeout = 10000) => {
main ??= { targetId, sessionId };
if (match === 'main') {
({ targetId, sessionId } = main);
await raw('Target.activateTarget', { targetId });
return (await raw('Target.getTargets')).targetInfos.find((t) => t.targetId === targetId)?.url;
}
const end = Date.now() + timeout;
for (;;) {
const hit = (await raw('Target.getTargets')).targetInfos
.find((t) => t.type === 'page' && t.targetId !== main.targetId && t.url.includes(match));
if (hit) {
targetId = hit.targetId;
({ sessionId } = await raw('Target.attachToTarget', { targetId, flatten: true }));
await raw('Target.activateTarget', { targetId });
return hit.url;
}
if (Date.now() > end) throw new Error(`no page whose URL contains ${JSON.stringify(match)} within ${timeout} ms`);
await new Promise((ok) => setTimeout(ok, 100));
}
},
close: async () => {
await raw('Target.closeTarget', { targetId }).catch(() => {});
ws.close();