mirror of
https://github.com/stablyai/orca.git
synced 2026-09-27 08:02:35 +00:00
* fix(browser): scope back/forward/reload/zoom/grab shortcuts to the originating split With two browser panes visible in a split, Back, Forward, Reload, Hard Reload, page zoom and Focus Address Bar fired in every visible pane. Main forwarded these guest chords without the page id, and each split's active pane subscribed. The renderer-side listeners for the same chords were also window-wide per pane, so a key pressed in the toolbar (or in a terminal in another split) reached every active browser pane. Guest-forwarded chords now carry the originating browserPageId; preload admits only well-formed payloads and each pane ignores ids that aren't its own. Toolbar-path listeners use the same focused-split scope Find already uses. The streamed remote pane's history chord moves onto that scoped hook. Cmd/Ctrl+C grab (STA-3319) gets the same scope and no longer arms while a text selection exists outside the browser pane, so copying from the native chat transcript works again. * refactor(browser): simplify split shortcut scoping per review Drop the preload payload admission (main and preload ship together), fold the three inline scope checks into browserChromeShortcutOwnsEvent, and replace the outside-overlay selection check with a plain live-selection rule so Cmd+C copies from surfaces that do not move split focus. * refactor(browser): share one zoom command type and tidy shortcut comments BrowserPageZoomEventDetail and BrowserPageZoomCommand were the same shape; keep one in shared/browser-page-zoom.ts and route guest and local zoom through a single handler. * refactor(browser): narrow the zoom event with instanceof instead of a cast * test(e2e): pin split-scoped browser shortcuts Two browser splits (and a terminal beside a browser) now prove that Back, Forward, Reload, Hard Reload, page zoom, Focus Address Bar, and the element grab chord act only on the split that sent them, from both the guest page and the browser toolbar. A native chat selection proves Cmd/Ctrl+C copies instead of arming grab. Split fixtures move to a shared helper so both specs reuse them.
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { createServer } from 'node:http'
|
|
|
|
export type BrowserSplitPageServer = {
|
|
/**
|
|
* `/<pane>/<step>` serves an uncached page titled "<pane> <step>". Chromium shares page zoom
|
|
* per host, so give sibling panes different hosts (127.0.0.1 vs localhost) to keep zoom apart.
|
|
*/
|
|
pageUrl: (pane: string, step: number, host?: '127.0.0.1' | 'localhost') => string
|
|
close: () => Promise<void>
|
|
}
|
|
|
|
export async function startBrowserSplitPageServer(): Promise<BrowserSplitPageServer> {
|
|
const server = createServer((request, response) => {
|
|
const [, pane = 'page', step = '1'] = new URL(request.url ?? '/', 'http://127.0.0.1').pathname
|
|
.split('/')
|
|
.map((segment) => segment.replace(/[^\w-]/g, ''))
|
|
// Why: no-store makes soft and hard reload both reach the network, like a dev server page.
|
|
response.writeHead(200, {
|
|
'Content-Type': 'text/html; charset=utf-8',
|
|
'Cache-Control': 'no-store'
|
|
})
|
|
response.end(
|
|
`<!doctype html><html><head><title>${pane} ${step}</title></head><body><h1>Pane ${pane}, page ${step}</h1><p>Split shortcut fixture.</p></body></html>`
|
|
)
|
|
})
|
|
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
const address = server.address()
|
|
if (!address || typeof address === 'string') {
|
|
throw new Error('Browser split page server has no TCP port')
|
|
}
|
|
const { port } = address
|
|
return {
|
|
pageUrl: (pane, step, host = '127.0.0.1') => `http://${host}:${port}/${pane}/${step}`,
|
|
close: () =>
|
|
new Promise<void>((resolve, reject) =>
|
|
server.close((error) => (error ? reject(error) : resolve()))
|
|
)
|
|
}
|
|
}
|