+
Date: Tue, 10 Nov 2026 21:53:49 +0000
Subject: [PATCH 6/9] fix(native-chat): stop parsing every chat item's key on
each journal commit (#40874)
---
.../input-order/journal-input-obligations.ts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main/native-chat/agent-session-journal/input-order/journal-input-obligations.ts b/src/main/native-chat/agent-session-journal/input-order/journal-input-obligations.ts
index 87ba94bcabf..e3964f7f6ef 100644
--- a/src/main/native-chat/agent-session-journal/input-order/journal-input-obligations.ts
+++ b/src/main/native-chat/agent-session-journal/input-order/journal-input-obligations.ts
@@ -265,6 +265,10 @@ export function journalInputPresentationMember(
state: JournalReducerState,
itemId: string
): boolean {
+ // Renders ask this of every row on each commit; parsing each key froze main in big chats (#40682).
+ if (state.inputs.rejections.size === 0) {
+ return true
+ }
const identity = parseAgentJournalItemKey(itemId)
return (
identity?.provider !== 'orca' ||
From 6dfb4dc60d78a7b452a5f155fe407a88c73a9e63 Mon Sep 17 00:00:00 2001
From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:02:43 +0000
Subject: [PATCH 7/9] feat(cli): add orca tab annotations so agents can read a
tab's unsent notes (#40873)
Prints the notes the user left on a browser tab and has not sent, the same text the tab's Copy button gives (--json returns them). Reads the saved session, so it works for closed-and-restored tabs; SSH hosts reach it through the desktop browser bridge. A page drawn by a paired desktop reports that its notes stay there.
---
skill-guides/orca-cli/references/browser.md | 1 +
src/cli/browser/browser-format.ts | 9 +++
src/cli/browser/browser-tab.ts | 13 +++-
src/cli/bundled-skill-guides.ts | 1 +
src/cli/root-help-text-primary.ts | 1 +
src/cli/specs/browser-basic.ts | 6 ++
.../desktop-browser-bridge-executor.ts | 19 ------
.../browser/desktop-browser-bridge-wiring.ts | 12 ++--
src/main/orcad/orcad-client-page-commands.ts | 15 +++++
.../commands/browser-command-contracts.ts | 3 +
.../browser/commands/browser-commands.ts | 2 +
.../browser/tabs/browser-tab-annotations.ts | 67 +++++++++++++++++++
.../browser/tabs/browser-tab-queries.ts | 19 ++++++
.../runtime-edge-command-controller.ts | 1 +
.../desktop-browser-bridge-registry.test.ts | 22 ++++++
.../desktop-browser-bridge-registry.ts | 5 ++
.../desktop-browser-bridge-route.ts | 9 +++
.../rpc/methods/browser/browser-core.ts | 6 ++
.../methods/browser/desktop-browser-bridge.ts | 4 ++
.../driver/terminal-driver-resources.ts | 3 +
.../use-browser-page-annotation-send.ts | 2 +-
.../browser-annotation-output.test.ts | 2 +-
.../annotations}/browser-annotation-output.ts | 4 +-
.../runtime/runtime-browser-contracts.ts | 6 ++
src/shared/desktop-browser-bridge-protocol.ts | 23 +++++++
src/shared/orca-browser-cli-commands.ts | 1 +
.../rpc-params-catalog.generated.ts | 1 +
27 files changed, 227 insertions(+), 30 deletions(-)
create mode 100644 src/main/runtime/browser/tabs/browser-tab-annotations.ts
rename src/{renderer/src/components/browser-pane/annotate => shared/browser/annotations}/browser-annotation-output.test.ts (97%)
rename src/{renderer/src/components/browser-pane/annotate => shared/browser/annotations}/browser-annotation-output.ts (98%)
diff --git a/skill-guides/orca-cli/references/browser.md b/skill-guides/orca-cli/references/browser.md
index d10112b75f0..8e9564eab9a 100644
--- a/skill-guides/orca-cli/references/browser.md
+++ b/skill-guides/orca-cli/references/browser.md
@@ -71,6 +71,7 @@ Browser rules:
- Pass `--page ` on every command that acts on one page; `ORCA --help` lists `--page` when it does. `tab list`, `tab current`, `tab create` and `open-url` take no `--page`, and `tab switch`/`tab close` pick a tab by `--index` or `--page`, never both, since `--page` wins. Take the ID from `result.tab.browserPageId` in `ORCA tab current --json` or `result.browserPageId` in `ORCA tab create --json` and keep it for the task; `tab current` shows the routed tab, not the one you pin. When the user means a specific tab, find it by URL or title in `ORCA tab list --json`.
- Without `--page`, a command goes to the worktree's current tab. That stays the agent's tab while it has had a command in the last 20 seconds or so, even after the user picks another (`tab current` reports it too), then moves to the user's pick.
- After `ORCA tab switch`, pass the new page's `browserPageId`.
+- When the user says they left notes or comments on a page, read them with `ORCA tab annotations --page ` (the current tab without `--page`). It prints the notes they haven't sent, the same text the tab's Copy button gives, and `--json` returns them in `result.annotations`. Notes the user already sent arrive in your chat instead.
- A popup window a page opens (sign-in, payment) is listed in `ORCA tab list --json` as a `popup-` page with `openerBrowserPageId`. If a click seems to do nothing, check `tab list`, then drive the popup with `--page popup-`. When it closes, continue on the opener page.
- Browser commands default to the current worktree. `--page` reaches the page in any worktree unless you also pass `--worktree `. Use `--worktree all` only intentionally.
- `tab list` shows every tab in the tab bar. After a restart, tabs the user has not opened report `loaded: false`; `tab switch` or any `--page` command loads one in the background without changing the user's visible tab.
diff --git a/src/cli/browser/browser-format.ts b/src/cli/browser/browser-format.ts
index 63a3d5d814f..ac3e7122022 100644
--- a/src/cli/browser/browser-format.ts
+++ b/src/cli/browser/browser-format.ts
@@ -1,10 +1,12 @@
import { readBrowserActionEffects } from '../../shared/browser-action-effects'
import { writeCliScreenshotTempFile } from '../cli-screenshot-temp-file'
import type { RuntimeRpcSuccess } from '../../shared/runtime-rpc-envelope'
+import { formatBrowserAnnotationsAsMarkdown } from '../../shared/browser/annotations/browser-annotation-output'
import type {
BrowserProfileListResult,
BrowserScreenshotResult,
BrowserSnapshotResult,
+ BrowserTabAnnotationsResult,
BrowserTabCurrentResult,
BrowserTabListResult,
BrowserTabProfileCloneResult,
@@ -132,6 +134,13 @@ export function formatTabShow(result: BrowserTabShowResult | BrowserTabCurrentRe
].join('\n')
}
+// The same text the tab's Copy button gives, so an agent reads what the user would send.
+export function formatTabAnnotations(result: BrowserTabAnnotationsResult): string {
+ return result.annotations.length > 0
+ ? formatBrowserAnnotationsAsMarkdown(result.annotations)
+ : `No unsent notes on tab ${result.tab.browserPageId}`
+}
+
export function formatTabProfileShow(result: BrowserTabProfileShowResult): string {
return [
`page: ${result.browserPageId}`,
diff --git a/src/cli/browser/browser-tab.ts b/src/cli/browser/browser-tab.ts
index 74edfe04e53..7ee72d93664 100644
--- a/src/cli/browser/browser-tab.ts
+++ b/src/cli/browser/browser-tab.ts
@@ -1,11 +1,17 @@
import type {
+ BrowserTabAnnotationsResult,
BrowserTabCurrentResult,
BrowserTabListResult,
BrowserTabShowResult,
BrowserTabSwitchResult
} from '../../shared/browser/runtime/runtime-browser-contracts'
import type { CommandHandler } from '../dispatch'
-import { formatTabList, formatTabListWithProfiles, formatTabShow } from './browser-format'
+import {
+ formatTabAnnotations,
+ formatTabList,
+ formatTabListWithProfiles,
+ formatTabShow
+} from './browser-format'
import { printResult } from '../format'
import {
getOptionalNonNegativeIntegerFlag,
@@ -42,6 +48,11 @@ export const BROWSER_TAB_HANDLERS: Record = {
const result = await client.call('browser.tabShow', target)
printResult(result, json, formatTabShow)
},
+ 'tab annotations': async ({ flags, client, cwd, json }) => {
+ const target = await getBrowserCommandTarget(flags, cwd, client)
+ const result = await client.call('browser.tabAnnotations', target)
+ printResult(result, json, formatTabAnnotations)
+ },
'tab current': async ({ flags, client, cwd, json }) => {
const worktree = await getBrowserWorktreeSelector(flags, cwd, client)
const result = await client.call('browser.tabCurrent', { worktree })
diff --git a/src/cli/bundled-skill-guides.ts b/src/cli/bundled-skill-guides.ts
index 6aaf42ad5c4..f9f46a79606 100644
--- a/src/cli/bundled-skill-guides.ts
+++ b/src/cli/bundled-skill-guides.ts
@@ -740,6 +740,7 @@ const ORCA_CLI_BROWSER_REFERENCE_MARKDOWN = [
"- Pass `--page ` on every command that acts on one page; `ORCA --help` lists `--page` when it does. `tab list`, `tab current`, `tab create` and `open-url` take no `--page`, and `tab switch`/`tab close` pick a tab by `--index` or `--page`, never both, since `--page` wins. Take the ID from `result.tab.browserPageId` in `ORCA tab current --json` or `result.browserPageId` in `ORCA tab create --json` and keep it for the task; `tab current` shows the routed tab, not the one you pin. When the user means a specific tab, find it by URL or title in `ORCA tab list --json`.",
"- Without `--page`, a command goes to the worktree's current tab. That stays the agent's tab while it has had a command in the last 20 seconds or so, even after the user picks another (`tab current` reports it too), then moves to the user's pick.",
"- After `ORCA tab switch`, pass the new page's `browserPageId`.",
+ "- When the user says they left notes or comments on a page, read them with `ORCA tab annotations --page ` (the current tab without `--page`). It prints the notes they haven't sent, the same text the tab's Copy button gives, and `--json` returns them in `result.annotations`. Notes the user already sent arrive in your chat instead.",
"- A popup window a page opens (sign-in, payment) is listed in `ORCA tab list --json` as a `popup-` page with `openerBrowserPageId`. If a click seems to do nothing, check `tab list`, then drive the popup with `--page popup-`. When it closes, continue on the opener page.",
"- Browser commands default to the current worktree. `--page` reaches the page in any worktree unless you also pass `--worktree `. Use `--worktree all` only intentionally.",
"- `tab list` shows every tab in the tab bar. After a restart, tabs the user has not opened report `loaded: false`; `tab switch` or any `--page` command loads one in the background without changing the user's visible tab.",
diff --git a/src/cli/root-help-text-primary.ts b/src/cli/root-help-text-primary.ts
index 10e3f99ae0a..0b0415336b9 100644
--- a/src/cli/root-help-text-primary.ts
+++ b/src/cli/root-help-text-primary.ts
@@ -207,6 +207,7 @@ export const ROOT_HELP_TEXT_PRIMARY = [
' tab create Create a new browser tab (navigates to --url)',
' tab list List open browser tabs',
' tab show Show one browser tab by page id',
+ " tab annotations Show a tab's unsent notes from the user",
' tab current Show the current browser tab',
' tab profile list List browser session profiles',
' tab profile create Create a browser session profile',
diff --git a/src/cli/specs/browser-basic.ts b/src/cli/specs/browser-basic.ts
index 2d9ea0f589e..b25628d9e4a 100644
--- a/src/cli/specs/browser-basic.ts
+++ b/src/cli/specs/browser-basic.ts
@@ -206,6 +206,12 @@ export const BROWSER_BASIC_COMMAND_SPECS: CommandSpec[] = withBrowserPageTarget(
usage: 'orca tab show --page [--worktree ] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'page', 'worktree']
},
+ {
+ path: ['tab', 'annotations'],
+ summary: "Show the notes the user left on a browser tab and hasn't sent yet",
+ usage: 'orca tab annotations [--page ] [--worktree ] [--json]',
+ allowedFlags: [...GLOBAL_FLAGS, 'page', 'worktree']
+ },
{
path: ['tab', 'current'],
summary: 'Show the current browser tab',
diff --git a/src/main/browser/desktop-browser-bridge/desktop-browser-bridge-executor.ts b/src/main/browser/desktop-browser-bridge/desktop-browser-bridge-executor.ts
index abff471a47b..888cdbb736a 100644
--- a/src/main/browser/desktop-browser-bridge/desktop-browser-bridge-executor.ts
+++ b/src/main/browser/desktop-browser-bridge/desktop-browser-bridge-executor.ts
@@ -256,22 +256,3 @@ function urlOrigin(value: unknown): string | null {
return null
}
}
-
-// Routed tabs can still display local files; those remain off-limits to hosts.
-// Allow chrome-error: so hosts can navigate away from failed loads.
-const HOST_REACHABLE_DOCUMENT_PROTOCOLS = new Set([
- 'http:',
- 'https:',
- 'about:',
- 'blob:',
- 'data:',
- 'chrome-error:'
-])
-
-export function isHostReachableDocument(url: string): boolean {
- try {
- return HOST_REACHABLE_DOCUMENT_PROTOCOLS.has(new URL(url).protocol)
- } catch {
- return url === ''
- }
-}
diff --git a/src/main/ipc/browser/desktop-browser-bridge-wiring.ts b/src/main/ipc/browser/desktop-browser-bridge-wiring.ts
index e6f533b851a..cd40d4ad535 100644
--- a/src/main/ipc/browser/desktop-browser-bridge-wiring.ts
+++ b/src/main/ipc/browser/desktop-browser-bridge-wiring.ts
@@ -5,7 +5,9 @@ import {
DESKTOP_BROWSER_BRIDGE_CANCEL_CAPABILITY,
DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY,
DESKTOP_BROWSER_BRIDGE_RUNTIME_CAPABILITY,
- isDesktopBrowserBridgeMethod
+ DESKTOP_BROWSER_BRIDGE_TAB_ANNOTATIONS_CAPABILITY,
+ isDesktopBrowserBridgeMethod,
+ isHostReachableDocument
} from '../../../shared/desktop-browser-bridge-protocol'
import { ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES } from '../../../shared/electron-remote-runtime-client-capabilities'
import '../../../shared/remote-runtime/requests/remote-runtime-request-socket'
@@ -22,10 +24,7 @@ import {
DesktopBrowserBridgeManager,
type DesktopBrowserBridgeCandidate
} from '../../browser/desktop-browser-bridge/desktop-browser-bridge-manager'
-import {
- executeDesktopBrowserBridgeRequest,
- isHostReachableDocument
-} from '../../browser/desktop-browser-bridge/desktop-browser-bridge-executor'
+import { executeDesktopBrowserBridgeRequest } from '../../browser/desktop-browser-bridge/desktop-browser-bridge-executor'
import { rendererResolveRemoteCliWorkspace } from '../../browser/desktop-browser-bridge/desktop-browser-bridge-renderer-scope'
import type { OrcaRuntimeService } from '../../runtime/orca-runtime'
import { RpcDispatcher } from '../../runtime/rpc/dispatcher'
@@ -153,7 +152,8 @@ export function installDesktopBrowserBridge(options: {
...ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
DESKTOP_BROWSER_BRIDGE_RUNTIME_CAPABILITY,
DESKTOP_BROWSER_BRIDGE_CANCEL_CAPABILITY,
- DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY
+ DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY,
+ DESKTOP_BROWSER_BRIDGE_TAB_ANNOTATIONS_CAPABILITY
]
}
)
diff --git a/src/main/orcad/orcad-client-page-commands.ts b/src/main/orcad/orcad-client-page-commands.ts
index 9afc3d95ab7..11e8e8e4a1e 100644
--- a/src/main/orcad/orcad-client-page-commands.ts
+++ b/src/main/orcad/orcad-client-page-commands.ts
@@ -28,6 +28,11 @@ import {
type BrowserEngineTabs
} from '../runtime/browser/client-pages/browser-client-page-queries'
+import {
+ findListedBrowserTab,
+ readBrowserTabAnnotations
+} from '../runtime/browser/tabs/browser-tab-annotations'
+
type Forward = (args: unknown[], name?: string) => unknown
const LOGICAL_TAB_QUERIES = [
@@ -70,6 +75,16 @@ export function orcadClientPageCommand(
: closeBrowserPageWithoutEngine(host, params, browserUnavailableError)
}
}
+ if (name === 'browserTabAnnotations') {
+ return async (...args: Parameters) => {
+ const { page, worktree } = args[0] ?? {}
+ // The engine's active flags are global, so a worktree's current tab needs its own query.
+ const tab = page
+ ? findListedBrowserTab((await logicalTabs().browserTabList({ worktree })).tabs, page)
+ : (await logicalTabs().browserTabCurrent({ worktree })).tab
+ return readBrowserTabAnnotations(host, tab)
+ }
+ }
const query = LOGICAL_TAB_QUERIES.find((candidate) => candidate === name)
if (query) {
return (...args: unknown[]) => {
diff --git a/src/main/runtime/browser/commands/browser-command-contracts.ts b/src/main/runtime/browser/commands/browser-command-contracts.ts
index 9d5367bf3b9..09d04d459ce 100644
--- a/src/main/runtime/browser/commands/browser-command-contracts.ts
+++ b/src/main/runtime/browser/commands/browser-command-contracts.ts
@@ -9,6 +9,7 @@ import type { BrowserBackend } from '../../../browser/browser-backend'
import type { BrowserSessionTabSelectionOptions } from '../tabs/browser-tab-create-publication'
import type { ServeBrowserTabs } from '../headless/serve-browser-tabs'
import type { BrowserTabBarEntry } from '../tabs/browser-tab-listing'
+import type { BrowserPageAnnotation } from '../../../../shared/browser/element-grab/browser-grab-types'
export type BrowserCommandTargetParams = {
worktree?: string
@@ -60,6 +61,8 @@ export type RuntimeBrowserCommandHost = {
options?: BrowserSessionTabSelectionOptions
): void
notifyHeadlessBrowserSessionTabsChanged?(worktreeId: string): void
+ /** A page's unsent notes; see readSavedBrowserPageAnnotations. */
+ readBrowserPageAnnotations?(browserPageId: string): BrowserPageAnnotation[]
/** The tab bar's browser tabs, loaded or not, from the published session snapshot. */
readBrowserTabBar?(worktreeId: string | undefined): BrowserTabBarEntry[]
retireRuntimeOwnedBrowserSessionTab?(worktreeId: string, browserPageId: string): boolean | void
diff --git a/src/main/runtime/browser/commands/browser-commands.ts b/src/main/runtime/browser/commands/browser-commands.ts
index acdda731ff6..4f8e0cb11a8 100644
--- a/src/main/runtime/browser/commands/browser-commands.ts
+++ b/src/main/runtime/browser/commands/browser-commands.ts
@@ -81,6 +81,7 @@ export class RuntimeBrowserCommands {
readonly browserProceedCertificate: RuntimeBrowserTabQueries['browserProceedCertificate']
readonly browserTabShow: RuntimeBrowserTabQueries['browserTabShow']
readonly browserTabCurrent: RuntimeBrowserTabQueries['browserTabCurrent']
+ readonly browserTabAnnotations: RuntimeBrowserTabQueries['browserTabAnnotations']
readonly browserTabSwitch: RuntimeBrowserTabQueries['browserTabSwitch']
readonly browserTabCreate: RuntimeBrowserTabCreation['browserTabCreate']
readonly browserOpenUrlOnClient: RuntimeBrowserTabCreation['browserOpenUrlOnClient']
@@ -187,6 +188,7 @@ export class RuntimeBrowserCommands {
this.browserProceedCertificate = queries.browserProceedCertificate.bind(queries)
this.browserTabShow = queries.browserTabShow.bind(queries)
this.browserTabCurrent = queries.browserTabCurrent.bind(queries)
+ this.browserTabAnnotations = queries.browserTabAnnotations.bind(queries)
this.browserTabSwitch = queries.browserTabSwitch.bind(queries)
this.browserTabCreate = creation.browserTabCreate.bind(creation)
this.browserOpenUrlOnClient = creation.browserOpenUrlOnClient.bind(creation)
diff --git a/src/main/runtime/browser/tabs/browser-tab-annotations.ts b/src/main/runtime/browser/tabs/browser-tab-annotations.ts
new file mode 100644
index 00000000000..c58ceffb5ab
--- /dev/null
+++ b/src/main/runtime/browser/tabs/browser-tab-annotations.ts
@@ -0,0 +1,67 @@
+import type { BrowserPageAnnotation } from '../../../../shared/browser/element-grab/browser-grab-types'
+import type {
+ BrowserTabAnnotationsResult,
+ BrowserTabInfo
+} from '../../../../shared/browser/runtime/runtime-browser-contracts'
+import { isHostReachableDocument } from '../../../../shared/desktop-browser-bridge-protocol'
+import { BrowserError } from '../../../browser/browser-error'
+import type { RuntimeStore } from '../../construction/runtime-store-contract'
+import type { RuntimeBrowserCommandHost } from '../commands/browser-command-contracts'
+import { remoteCliBrowserScopeWorkspaceId } from '../../desktop-browser-bridge/remote-cli-browser-scope'
+
+/** A page's unsent notes from the saved session, which the window keeps current. */
+export function readSavedBrowserPageAnnotations(
+ store:
+ | Pick
+ | null
+ | undefined,
+ browserPageId: string
+): BrowserPageAnnotation[] {
+ // Page ids are unique across hosts, and a bridged SSH page has no worktree row here.
+ for (const hostId of store?.getWorkspaceSessionHostIds?.() ?? []) {
+ const pages = store?.getWorkspaceSession?.(hostId)?.browserPagesByWorkspace ?? {}
+ for (const workspacePages of Object.values(pages)) {
+ const page = workspacePages.find((candidate) => candidate.id === browserPageId)
+ if (page) {
+ return page.annotations ?? []
+ }
+ }
+ }
+ return []
+}
+
+export function findListedBrowserTab(
+ tabs: readonly BrowserTabInfo[],
+ page: string
+): BrowserTabInfo {
+ const tab = tabs.find((candidate) => candidate.browserPageId === page)
+ if (!tab) {
+ throw new BrowserError('browser_tab_not_found', `Browser page ${page} was not found`)
+ }
+ return tab
+}
+
+export function readBrowserTabAnnotations(
+ host: Pick<
+ RuntimeBrowserCommandHost,
+ 'getRuntimeBrowserPageRegistry' | 'readBrowserPageAnnotations'
+ >,
+ tab: BrowserTabInfo
+): BrowserTabAnnotationsResult {
+ // A paired desktop draws this page and keeps its notes; this host would wrongly report none.
+ if (host.getRuntimeBrowserPageRegistry().getPage(tab.browserPageId)) {
+ throw new BrowserError(
+ 'browser_annotations_unavailable',
+ `Tab ${tab.browserPageId} is drawn by a paired desktop, which keeps its unsent notes. Ask the user to send them from that tab.`
+ )
+ }
+ const annotations = host.readBrowserPageAnnotations?.(tab.browserPageId) ?? []
+ return {
+ tab,
+ // An SSH host may not read what a note captured from a desktop-local document.
+ annotations:
+ remoteCliBrowserScopeWorkspaceId() === undefined
+ ? annotations
+ : annotations.filter((note) => isHostReachableDocument(note.payload.page.sanitizedUrl))
+ }
+}
diff --git a/src/main/runtime/browser/tabs/browser-tab-queries.ts b/src/main/runtime/browser/tabs/browser-tab-queries.ts
index 5aaab4a5a66..51f31bdbe76 100644
--- a/src/main/runtime/browser/tabs/browser-tab-queries.ts
+++ b/src/main/runtime/browser/tabs/browser-tab-queries.ts
@@ -1,4 +1,5 @@
import type {
+ BrowserTabAnnotationsResult,
BrowserTabCurrentResult,
BrowserTabListResult,
BrowserTabShowResult,
@@ -17,6 +18,7 @@ import type {
} from '../commands/browser-command-contracts'
import type { RuntimeBrowserCommandTargets } from '../commands/browser-command-targets'
import type { RuntimeBrowserTabCatalog } from './browser-tab-catalog'
+import { findListedBrowserTab, readBrowserTabAnnotations } from './browser-tab-annotations'
export class RuntimeBrowserTabQueries {
constructor(
@@ -27,6 +29,7 @@ export class RuntimeBrowserTabQueries {
| 'getRuntimeBrowserPageRegistry'
| 'markHeadlessBrowserSessionTabActive'
| 'notifyHeadlessBrowserSessionTabsChanged'
+ | 'readBrowserPageAnnotations'
>,
private readonly targets: Pick<
RuntimeBrowserCommandTargets,
@@ -89,6 +92,22 @@ export class RuntimeBrowserTabQueries {
return { tab: this.catalog.describeBrowserTab(params.page, target.worktreeId) }
}
+ async browserTabAnnotations(params: {
+ page?: string
+ worktree?: string
+ }): Promise {
+ if (!params.page) {
+ return readBrowserTabAnnotations(this.host, (await this.browserTabCurrent(params)).tab)
+ }
+ // A named page's notes are saved state: list the tab bar as saved rather than waking a browser.
+ const workspaceId = params.worktree
+ ? (await this.host.resolveBrowserWorkspace(params.worktree)).id
+ : undefined
+ const clientPages = this.host.getRuntimeBrowserPageRegistry().listPages(workspaceId)
+ const tabs = this.catalog.listLogicalBrowserTabs(workspaceId, clientPages)
+ return readBrowserTabAnnotations(this.host, findListedBrowserTab(tabs, params.page))
+ }
+
async browserTabCurrent(params: { worktree?: string }): Promise {
const tab = (await this.browserTabList(params)).tabs.find((candidate) => candidate.active)
if (!tab) {
diff --git a/src/main/runtime/construction/runtime-edge-command-controller.ts b/src/main/runtime/construction/runtime-edge-command-controller.ts
index 933c812272c..6d6b7fac4ec 100644
--- a/src/main/runtime/construction/runtime-edge-command-controller.ts
+++ b/src/main/runtime/construction/runtime-edge-command-controller.ts
@@ -47,6 +47,7 @@ const BROWSER_COMMAND_NAMES = [
'browserProceedCertificate',
'browserTabShow',
'browserTabCurrent',
+ 'browserTabAnnotations',
'browserTabSwitch',
'browserHover',
'browserDrag',
diff --git a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.test.ts b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.test.ts
index cc2170d60e7..4338bf8352b 100644
--- a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.test.ts
+++ b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.test.ts
@@ -6,6 +6,28 @@ import {
} from './desktop-browser-bridge-registry'
import { routeDesktopBrowserBridgeRpc } from './desktop-browser-bridge-route'
+describe('tab annotations through the desktop bridge', () => {
+ it('never sends them to an older desktop, which would drop its whole bridge', async () => {
+ const registry = new DesktopBrowserBridgeRegistry()
+ const emit = vi.fn()
+ registry.attach({ connectionId: 'new', pairedDeviceId: 'd', readsTabAnnotations: true, emit })
+ registry.attach({ connectionId: 'old', pairedDeviceId: 'd', emit })
+
+ await expect(
+ routeDesktopBrowserBridgeRpc({
+ method: 'browser.tabAnnotations',
+ params: { page: 'page-1' },
+ caller: { kind: 'local-cli' },
+ hostEnabled: true,
+ registry,
+ localBrowserAvailable: false,
+ resolveWorkspace: async (selector) => ({ id: selector })
+ })
+ ).rejects.toMatchObject({ code: 'desktop_browser_bridge_not_forwarded' })
+ expect(emit).not.toHaveBeenCalled()
+ })
+})
+
describe('--expect-url through the desktop bridge', () => {
const route = (registry: DesktopBrowserBridgeRegistry) =>
routeDesktopBrowserBridgeRpc({
diff --git a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.ts b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.ts
index b0c561e52ef..b297f8e6d2b 100644
--- a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.ts
+++ b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-registry.ts
@@ -19,6 +19,7 @@ type Attachment = {
pairedDeviceId: string
acceptsCancel?: boolean
enforcesExpectUrl?: boolean
+ readsTabAnnotations?: boolean
emit: (event: DesktopBrowserBridgeEvent) => void
}
@@ -57,6 +58,10 @@ export class DesktopBrowserBridgeRegistry {
return this.attachments.at(-1)?.enforcesExpectUrl === true
}
+ newestAttachmentReadsTabAnnotations(): boolean {
+ return this.attachments.at(-1)?.readsTabAnnotations === true
+ }
+
forward(
request: DesktopBrowserBridgeForward,
options: { timeoutMs: number; signal?: AbortSignal }
diff --git a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-route.ts b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-route.ts
index ae0f6a6aaa5..2f472b5f36e 100644
--- a/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-route.ts
+++ b/src/main/runtime/desktop-browser-bridge/desktop-browser-bridge-route.ts
@@ -75,6 +75,15 @@ export async function routeDesktopBrowserBridgeRpc(options: {
'The Orca desktop sharing its browser cannot check --expect-url. Update Orca on that desktop or drop the flag.'
)
}
+ if (
+ forwardedMethod === 'browser.tabAnnotations' &&
+ !options.registry.newestAttachmentReadsTabAnnotations()
+ ) {
+ throw new BrowserError(
+ DESKTOP_BROWSER_BRIDGE_NOT_FORWARDED_CODE,
+ 'The Orca desktop sharing its browser cannot read tab notes. Update Orca on that desktop.'
+ )
+ }
const result = await options.registry.forward(
{ method: forwardedMethod, params, ...(workspaceId ? { workspaceId } : {}) },
{ timeoutMs: forwardTimeoutMs(forwardedMethod, params), signal: options.signal }
diff --git a/src/main/runtime/rpc/methods/browser/browser-core.ts b/src/main/runtime/rpc/methods/browser/browser-core.ts
index d9d6d14ed1f..6edf1f772ba 100644
--- a/src/main/runtime/rpc/methods/browser/browser-core.ts
+++ b/src/main/runtime/rpc/methods/browser/browser-core.ts
@@ -118,6 +118,12 @@ export const BROWSER_CORE_METHODS = [
params: TabCurrent,
handler: async (params, { runtime }) => runtime.browserTabCurrent(params)
}),
+ defineMethod({
+ name: 'browser.tabAnnotations',
+ permission: 'workspace',
+ params: BrowserTarget,
+ handler: async (params, { runtime }) => runtime.browserTabAnnotations(params)
+ }),
defineMethod({
name: 'browser.tabSwitch',
permission: 'workspace',
diff --git a/src/main/runtime/rpc/methods/browser/desktop-browser-bridge.ts b/src/main/runtime/rpc/methods/browser/desktop-browser-bridge.ts
index eac4e3e6047..8780e8f932b 100644
--- a/src/main/runtime/rpc/methods/browser/desktop-browser-bridge.ts
+++ b/src/main/runtime/rpc/methods/browser/desktop-browser-bridge.ts
@@ -2,6 +2,7 @@ import {
DESKTOP_BROWSER_BRIDGE_CANCEL_CAPABILITY,
DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY,
DESKTOP_BROWSER_BRIDGE_RUNTIME_CAPABILITY,
+ DESKTOP_BROWSER_BRIDGE_TAB_ANNOTATIONS_CAPABILITY,
DesktopBrowserBridgeAttachParams,
DesktopBrowserBridgeResultParams
} from '../../../../../shared/desktop-browser-bridge-protocol'
@@ -45,6 +46,9 @@ export const DESKTOP_BROWSER_BRIDGE_RPC_METHODS = [
enforcesExpectUrl:
context.clientCapabilities?.includes(DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY) ??
false,
+ readsTabAnnotations:
+ context.clientCapabilities?.includes(DESKTOP_BROWSER_BRIDGE_TAB_ANNOTATIONS_CAPABILITY) ??
+ false,
emit
})
let release = (): void => {}
diff --git a/src/main/runtime/terminal/driver/terminal-driver-resources.ts b/src/main/runtime/terminal/driver/terminal-driver-resources.ts
index c9655ef980e..3cbe25f462c 100644
--- a/src/main/runtime/terminal/driver/terminal-driver-resources.ts
+++ b/src/main/runtime/terminal/driver/terminal-driver-resources.ts
@@ -43,6 +43,7 @@ import { RuntimeWorktreeBaseReconciliation } from '../../workspaces/metadata/run
import { RuntimeWorktreeRemovalInFlight } from '../../workspaces/removal/runtime-worktree-removal-in-flight'
import { ServeBrowserTabs } from '../../browser/headless/serve-browser-tabs'
import { readBrowserTabBar } from '../../browser/tabs/browser-tab-listing'
+import { readSavedBrowserPageAnnotations } from '../../browser/tabs/browser-tab-annotations'
import { parseWorkspaceKey } from '../../../../shared/workspace-scope'
import { getRepoIdFromWorktreeId } from '../../../../shared/worktree/id'
import type { ServeBrowserPageState } from '../../browser/headless/serve-browser-tab-layout'
@@ -201,6 +202,8 @@ export abstract class OrcaRuntimeWithTerminalDrivers extends OrcaRuntimeWithFitO
markHeadlessBrowserSessionTabActive: this.markHeadlessBrowserSessionTabActive.bind(this),
notifyHeadlessBrowserSessionTabsChanged: (worktreeId) =>
this.notifyMobileSessionTabsChanged(worktreeId),
+ readBrowserPageAnnotations: (browserPageId) =>
+ readSavedBrowserPageAnnotations(this.store, browserPageId),
readBrowserTabBar: (worktreeId) =>
readBrowserTabBar(this.mobileSessionTabsByWorktree, worktreeId, (id) => {
// Why: an SSH host's bridged workspace may have no row here, yet its pages render in this window.
diff --git a/src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-send.ts b/src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-send.ts
index bb26b30562e..70374e1457c 100644
--- a/src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-send.ts
+++ b/src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-send.ts
@@ -5,7 +5,7 @@ import type {
BrowserAnnotationIntent,
BrowserPageAnnotation
} from '../../../../../shared/browser/element-grab/browser-grab-types'
-import { formatBrowserAnnotationsAsMarkdown } from './browser-annotation-output'
+import { formatBrowserAnnotationsAsMarkdown } from '../../../../../shared/browser/annotations/browser-annotation-output'
import { EMPTY_BROWSER_ANNOTATIONS } from '../describe-page/browser-annotation-geometry'
import {
holdNotesForSend,
diff --git a/src/renderer/src/components/browser-pane/annotate/browser-annotation-output.test.ts b/src/shared/browser/annotations/browser-annotation-output.test.ts
similarity index 97%
rename from src/renderer/src/components/browser-pane/annotate/browser-annotation-output.test.ts
rename to src/shared/browser/annotations/browser-annotation-output.test.ts
index 9dd29c59aed..6f1fd29ef65 100644
--- a/src/renderer/src/components/browser-pane/annotate/browser-annotation-output.test.ts
+++ b/src/shared/browser/annotations/browser-annotation-output.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import type { BrowserPageAnnotation } from '../../../../../shared/browser/element-grab/browser-grab-types'
+import type { BrowserPageAnnotation } from '../element-grab/browser-grab-types'
import {
BROWSER_ANNOTATION_INLINE_TEXT_MAX_LENGTH,
formatBrowserAnnotationsAsMarkdown
diff --git a/src/renderer/src/components/browser-pane/annotate/browser-annotation-output.ts b/src/shared/browser/annotations/browser-annotation-output.ts
similarity index 98%
rename from src/renderer/src/components/browser-pane/annotate/browser-annotation-output.ts
rename to src/shared/browser/annotations/browser-annotation-output.ts
index 1285f4acd11..742943aa1f5 100644
--- a/src/renderer/src/components/browser-pane/annotate/browser-annotation-output.ts
+++ b/src/shared/browser/annotations/browser-annotation-output.ts
@@ -2,8 +2,8 @@ import type {
BrowserGrabComputedStyles,
BrowserGrabPayload,
BrowserPageAnnotation
-} from '../../../../../shared/browser/element-grab/browser-grab-types'
-import { isWindowsAbsolutePathLike } from '../../../../../shared/cross-platform-path'
+} from '../element-grab/browser-grab-types'
+import { isWindowsAbsolutePathLike } from '../../cross-platform-path'
function formatPageHeading(payload: BrowserGrabPayload): string {
// Document previews report a file path; `C:\` would otherwise parse as a URL scheme.
diff --git a/src/shared/browser/runtime/runtime-browser-contracts.ts b/src/shared/browser/runtime/runtime-browser-contracts.ts
index 81cb593fdb5..41851575b65 100644
--- a/src/shared/browser/runtime/runtime-browser-contracts.ts
+++ b/src/shared/browser/runtime/runtime-browser-contracts.ts
@@ -1,3 +1,4 @@
+import type { BrowserPageAnnotation } from '../element-grab/browser-grab-types'
import type {
BrowserCertificateFailure,
BrowserCookieImportResult,
@@ -122,6 +123,11 @@ export type BrowserTabSetProfileResult = {
}
export type BrowserTabShowResult = { tab: BrowserTabInfo }
+/** The notes the user left on a tab's page and has not sent yet. */
+export type BrowserTabAnnotationsResult = {
+ tab: BrowserTabInfo
+ annotations: BrowserPageAnnotation[]
+}
export type BrowserTabCurrentResult = { tab: BrowserTabInfo }
export type BrowserTabProfileShowResult = {
diff --git a/src/shared/desktop-browser-bridge-protocol.ts b/src/shared/desktop-browser-bridge-protocol.ts
index dfc1c615647..86b595a8027 100644
--- a/src/shared/desktop-browser-bridge-protocol.ts
+++ b/src/shared/desktop-browser-bridge-protocol.ts
@@ -6,6 +6,9 @@ export const DESKTOP_BROWSER_BRIDGE_RUNTIME_CAPABILITY = 'browser.desktopBridge.
export const DESKTOP_BROWSER_BRIDGE_CANCEL_CAPABILITY = 'browser.desktopBridge.cancel.v1'
/** Older desktops re-parse params and would drop expectUrl, so commands carrying it need this. */
export const DESKTOP_BROWSER_BRIDGE_EXPECT_URL_CAPABILITY = 'browser.desktopBridge.expect-url.v1'
+/** Older desktops drop the whole attachment on a method they don't allow, so tab annotations need this. */
+export const DESKTOP_BROWSER_BRIDGE_TAB_ANNOTATIONS_CAPABILITY =
+ 'browser.desktopBridge.tab-annotations.v1'
export const DESKTOP_BROWSER_BRIDGE_UNAVAILABLE_CODE = 'desktop_browser_bridge_unavailable'
export const DESKTOP_BROWSER_BRIDGE_NOT_FORWARDED_CODE = 'desktop_browser_bridge_not_forwarded'
@@ -27,6 +30,7 @@ export const DESKTOP_BROWSER_BRIDGE_METHODS: ReadonlySet = new Set([
'browser.tabList',
'browser.tabCurrent',
'browser.tabShow',
+ 'browser.tabAnnotations',
'browser.tabSwitch',
'browser.tabCreate',
'browser.tabClose',
@@ -144,3 +148,22 @@ export const DesktopBrowserBridgeResultParams = z.discriminatedUnion('ok', [
})
])
export type DesktopBrowserBridgeResultParams = z.infer
+
+// Routed tabs can still display local files; those remain off-limits to hosts.
+// Allow chrome-error: so hosts can navigate away from failed loads.
+const HOST_REACHABLE_DOCUMENT_PROTOCOLS = new Set([
+ 'http:',
+ 'https:',
+ 'about:',
+ 'blob:',
+ 'data:',
+ 'chrome-error:'
+])
+
+export function isHostReachableDocument(url: string): boolean {
+ try {
+ return HOST_REACHABLE_DOCUMENT_PROTOCOLS.has(new URL(url).protocol)
+ } catch {
+ return url === ''
+ }
+}
diff --git a/src/shared/orca-browser-cli-commands.ts b/src/shared/orca-browser-cli-commands.ts
index 24b933a00e5..b1a76e6255d 100644
--- a/src/shared/orca-browser-cli-commands.ts
+++ b/src/shared/orca-browser-cli-commands.ts
@@ -49,6 +49,7 @@ export const ORCA_BROWSER_CLI_COMMAND_KEYS = {
'open-url',
'tab list',
'tab show',
+ 'tab annotations',
'tab current',
'tab switch',
'tab create',
diff --git a/src/shared/rpc-contract/rpc-params-catalog.generated.ts b/src/shared/rpc-contract/rpc-params-catalog.generated.ts
index 60356b6a064..bd26cbe5fec 100644
--- a/src/shared/rpc-contract/rpc-params-catalog.generated.ts
+++ b/src/shared/rpc-contract/rpc-params-catalog.generated.ts
@@ -985,6 +985,7 @@ export const RPC_PARAMS_BY_METHOD = {
'browser.storage.session.clear': ExpectUrlBrowserTarget,
'browser.storage.session.get': StorageKey,
'browser.storage.session.set': StorageKeyValue,
+ 'browser.tabAnnotations': BrowserTarget,
'browser.tabClose': TabClose,
'browser.tabCreate': BrowserTabCreateParams,
'browser.tabCurrent': TabCurrent,
From 557d588e697263beea3c757dd83bee765ec8ec89 Mon Sep 17 00:00:00 2001
From: Neil <4138956+nwparker@users.noreply.github.com>
Date: Tue, 10 Nov 2026 14:08:25 -0800
Subject: [PATCH 8/9] relay edge: tag auth-expiry closes and control opens with
keepalive use and host silence (#40882)
Desktop closes for expired relay authorization rose after the keepalive release (3/day to ~35/day
on the edge cohort). The close metric now carries whether the control took the keepalive offer and
how long the host had been silent, and control_active carries keepalive use, so the cause can be
told apart (stalled desktop timers vs a control whose refresh stopped while it stayed live).
---
cloud/apps/relay-edge/src/host-relay-handshake.ts | 2 +-
cloud/apps/relay-edge/src/host-relay.ts | 3 ++-
cloud/apps/relay-edge/src/metrics.ts | 2 ++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/cloud/apps/relay-edge/src/host-relay-handshake.ts b/cloud/apps/relay-edge/src/host-relay-handshake.ts
index bc153be8a0c..22614a1fe85 100644
--- a/cloud/apps/relay-edge/src/host-relay-handshake.ts
+++ b/cloud/apps/relay-edge/src/host-relay-handshake.ts
@@ -191,7 +191,7 @@ export abstract class HostRelayHandshake extends HostRelayBase {
})
// After the ack, which strict shipped parsers must see unchanged; only hosts that asked get it.
if (a.clientKeepalive) { this.send(ws, { type: 'keepalive-offer', v: 1, intervalMs: this.config.pingIntervalMs }) }
- metric(this.env, 'control_active', 1, rebind ? 'rebind' : 'new', [], '', a.place)
+ metric(this.env, 'control_active', 1, rebind ? 'rebind' : 'new', [], a.clientKeepalive ? 'keepalive' : 'legacy', a.place)
await this.reschedule()
}
}
diff --git a/cloud/apps/relay-edge/src/host-relay.ts b/cloud/apps/relay-edge/src/host-relay.ts
index 958232f8ff4..14f5a0f544f 100644
--- a/cloud/apps/relay-edge/src/host-relay.ts
+++ b/cloud/apps/relay-edge/src/host-relay.ts
@@ -187,7 +187,8 @@ export class HostRelay extends HostRelayPhones {
// Same order as the cells' heartbeat: expired auth past its grace, then the 6 h lease.
if (now > a.claims.exp + CONTROL_CONTINUITY_LIMITS.expiredAuthExistingSpliceGraceMs) {
const sinceRefreshS = a.lastRefreshAt === undefined ? -1 : Math.round((now - a.lastRefreshAt) / 1000)
- metric(this.env, 'auth_expired_close', sinceRefreshS, a.lastRefreshAt === undefined ? 'never' : 'refreshed', [], '', a.place)
+ const seenAgoS = Math.round((now - seen) / 1000)
+ metric(this.env, 'auth_expired_close', sinceRefreshS, a.lastRefreshAt === undefined ? 'never' : 'refreshed', [seenAgoS], this.keepalive(a) ? 'keepalive' : 'legacy', a.place)
this.close(ws, RELAY_CLOSE_CODE.BAD_OUTER_CREDENTIAL, 'relay authorization expired')
await this.onSocketGone(ws, RELAY_CLOSE_CODE.BAD_OUTER_CREDENTIAL, '')
continue
diff --git a/cloud/apps/relay-edge/src/metrics.ts b/cloud/apps/relay-edge/src/metrics.ts
index 7d87b759e4d..febc2bab77c 100644
--- a/cloud/apps/relay-edge/src/metrics.ts
+++ b/cloud/apps/relay-edge/src/metrics.ts
@@ -2,6 +2,7 @@
import type { Env } from './env'
export type MetricEvent =
+ // label 'new' | 'rebind'; reason 'keepalive' | 'legacy' (took the keepalive offer or not).
| 'control_active'
| 'control_close'
| 'phone_open'
@@ -26,6 +27,7 @@ export type MetricEvent =
| 'control_upgrade'
// Control closed 4401 for expired authorization: value = seconds since its last extending
// refresh, label 'refreshed'; -1 and label 'never' when this socket never extended its token.
+ // double2 = seconds since the host's last inbound frame or keepalive; reason 'keepalive' | 'legacy'.
| 'auth_expired_close'
// Pre-auth socket refused by the per-source limiter: label 'phone' | 'data' | 'health'. Unpushed-host phones: 'not_on_edge'.
| 'preauth_limited'
From e319da9cef18bcadc8e440fc172a140a9cb9fad6 Mon Sep 17 00:00:00 2001
From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:13:18 +0000
Subject: [PATCH 9/9] fix(mobile): save the downloaded desktop page on Android
7 (#40878)
* fix(mobile): save the downloaded desktop page on Android 7
Below API 26, expo-file-system 55 moves a directory with File.copyTo, which
creates an empty directory, so committing a downloaded page build always
failed with cache-write-failed. Copy the tree recursively and delete the
source there instead.
* fix(mobile): remove a partial copy when an Android 7 page move fails
---
.../generation-store-file-system.test.ts | 3 ++-
.../generation-store-file-system.ts | 19 ++++++++++++++++++-
.../src/mobile-web-shell/generation-store.ts | 4 ++--
.../mobile-web-shell-session-effects.test.ts | 1 +
4 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/mobile/src/mobile-web-shell/generation-store-file-system.test.ts b/mobile/src/mobile-web-shell/generation-store-file-system.test.ts
index 7b170ea268f..644f2c83d96 100644
--- a/mobile/src/mobile-web-shell/generation-store-file-system.test.ts
+++ b/mobile/src/mobile-web-shell/generation-store-file-system.test.ts
@@ -1,11 +1,12 @@
import { describe, expect, it, vi } from 'vitest'
-// Mock the import-time native module to test only the URI converter.
+// Mock the import-time native modules to test only the URI converter.
vi.mock('expo-file-system', () => ({
Directory: class {},
File: class {},
Paths: { cache: '' }
}))
+vi.mock('react-native', () => ({ Platform: { OS: 'ios' } }))
import { generationDirectoryPath } from './generation-store-file-system'
diff --git a/mobile/src/mobile-web-shell/generation-store-file-system.ts b/mobile/src/mobile-web-shell/generation-store-file-system.ts
index 74189aeb408..06aa62f880e 100644
--- a/mobile/src/mobile-web-shell/generation-store-file-system.ts
+++ b/mobile/src/mobile-web-shell/generation-store-file-system.ts
@@ -1,4 +1,5 @@
import { Directory, File } from 'expo-file-system'
+import { Platform } from 'react-native'
export type GenerationDirectoryEntry = {
readonly name: string
@@ -127,7 +128,23 @@ export function createExpoGenerationFileSystem(rootUri: string): GenerationFileS
}
},
async moveDirectory(fromUri, toUri) {
- new Directory(fromUri).move(new Directory(toUri))
+ const from = new Directory(fromUri)
+ // Below API 26, Expo 55's move copies a directory without its contents; its copy is recursive.
+ if (Platform.OS === 'android' && Number(Platform.Version) < 26) {
+ const to = new Directory(toUri)
+ try {
+ from.copy(to)
+ } catch (error) {
+ // Readers trust a generation by its manifest, so a failed copy must leave no partial tree.
+ if (to.exists) {
+ to.delete()
+ }
+ throw error
+ }
+ from.delete()
+ return
+ }
+ from.move(new Directory(toUri))
},
async moveFile(fromUri, toUri) {
new File(fromUri).move(new File(toUri))
diff --git a/mobile/src/mobile-web-shell/generation-store.ts b/mobile/src/mobile-web-shell/generation-store.ts
index 0e78ad2a2d6..45f54c2772b 100644
--- a/mobile/src/mobile-web-shell/generation-store.ts
+++ b/mobile/src/mobile-web-shell/generation-store.ts
@@ -216,7 +216,7 @@ export function createGenerationStore(options: {
manifest: staged.manifest
}
const entries = await fs.list(generations)
- // A build-id directory alone proves nothing: pre-API-26 Android moves can leave it empty. Require its activation manifest before reusing it.
+ // A build-id directory alone proves nothing; require its activation manifest before reusing it.
const existing = entries.find((entry) => entry.name === staged.buildId)
if (
existing?.isDirectory === true &&
@@ -238,7 +238,7 @@ export function createGenerationStore(options: {
}
await fs.createDirectory(generations)
await fs.moveDirectory(staged.directory, target)
- // Below API 26, Expo Android FileSystemPath.kt moves directories via non-recursive copy/delete and can leave an empty target; failed source deletion leaves tmp for sweeping.
+ // Never activate a target without its manifest; a source left in tmp is swept.
if (!(await fs.fileExists(joinUri(target, MANIFEST_FILE_NAME)))) {
await fs.delete(target)
throw new Error(`generation ${staged.buildId} did not carry its manifest through the rename`)
diff --git a/mobile/src/mobile-web-shell/mobile-web-shell-session-effects.test.ts b/mobile/src/mobile-web-shell/mobile-web-shell-session-effects.test.ts
index b023ae70955..f5b1619252e 100644
--- a/mobile/src/mobile-web-shell/mobile-web-shell-session-effects.test.ts
+++ b/mobile/src/mobile-web-shell/mobile-web-shell-session-effects.test.ts
@@ -7,6 +7,7 @@ const doubles = vi.hoisted(() => ({
}))
vi.mock('expo-file-system', () => ({ Directory: class {}, File: class {}, Paths: { cache: '' } }))
+vi.mock('react-native', () => ({ Platform: { OS: 'ios' } }))
// The runner's deadlines live in the runtime module, whose foreground timer reads React Native's AppState.
vi.mock('./foreground-timer', () => ({ setForegroundTimer: () => () => {} }))
vi.mock('../transport/rpc/rpc-operation', () => ({