Skip to content

Resume agent sessions from mobile history - #6969

Merged
brennanb2025 merged 16 commits into
brennanb2025/add-agents-to-mobilefrom
brennanb2025/Agent-Session-History-resume-PR2
Jul 3, 2026
Merged

brennanb2025 merged 16 commits into
brennanb2025/add-agents-to-mobilefrom
brennanb2025/Agent-Session-History-resume-PR2

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Resume to mobile Agent Session History. Tapping Resume resolves the session worktree first, falls back to the active route worktree when desktop would, guards unsupported targets, creates a fresh terminal in the resolved worktree, sends the shared AI Vault resume command with Enter, and navigates mobile to that session.

This PR is intentionally stacked on brennanb2025/add-agents-to-mobile (PR1). It does not add desktop's copy/open/jump overflow actions to mobile; this PR is scoped to user-initiated resume.

Follow-up parity fix: mobile worktree ordering now matches desktop ordering semantics for smart/Agent activity, recent, name, manual, repo collation, pinned overlay behavior, and no-grouping All section behavior.

Design Approach

The implementation follows design-docs/mobile-agent-session-history-resume-pr2.md and desktop's right-sidebar AI Vault resume behavior. Mobile now reuses the shared AI Vault command builder and startup planning path, including command overrides, default args/env, Windows shell family handling, Codex home handling, and POSIX command construction for SSH execution hosts.

For ordering parity, mobile consumes the host/runtime summary fields that desktop owns (sortOrder, manualOrder, lastActivityAt, createdAt, isMainWorktree, hasHostSidebarActivity, status metadata) instead of locally inventing different mobile-only ranking rules.

Review And Completeness

Design-review outcome: the earlier PR2 design ambiguity was resolved in favor of current desktop parity: local and SSH targets are resumable, while runtime/unknown targets are blocked.
Implementation deviations: mobile now fetches settings.get at resume time so command overrides/default launch settings are honored; worktree.ps exposes hostId, terminalPlatform, ordering, and sidebar-activity fields; mobile RPC allows folderWorkspace.list and projectGroup.list for folder workspace target guards.
Completeness verification: headline resume behavior is implemented for local and SSH worktrees; runtime-hosted and unknown workspaces remain intentionally blocked with an explanatory message. Headline ordering behavior is implemented for the data mobile receives from the host; mobile does not independently recompute desktop smart attention from live renderer pane state.
Broad app consistency: compared desktop AI Vault Resume, mobile history browse/preview, mobile terminal launch flows, SSH worktree behavior, folder workspace metadata, desktop sidebar sort comparators, pinned overlay behavior, and grouped/ungrouped workspace sections.

Risks And Non-goals

Non-goals: Copy Resume Command, Copy Session ID, open/reveal/jump actions, and other desktop overflow affordances are not added here.
Accepted risk: mobile depends on the host runtime's tab state after session.tabs.createTerminal, matching existing mobile launch flows.
Accepted gap update: Android emulator QA was refreshed on sdk_gphone64_arm64; the mobile Resume tap-through created a fresh Terminal 2 in demo-project/main and sent the shared-builder Codex resume command, but the seeded disposable fixture used a noncanonical session id so Codex returned No saved session found. A follow-up attempt with a canonical disposable session was blocked by an Android app ANR while selecting Agent Session History from the long-press worktree action sheet, so a fully successful live Codex resume remains unproven.
Ordering caveat: smart/Agent activity parity uses desktop's persisted host sortOrder snapshot. If mobile must recompute live smart attention without that desktop/host snapshot, the runtime contract would need to carry live tab/pane attention inputs that are not part of this PR.

Performance

Perf audit result: the resume hot path only does extra metadata fetches after explicit Resume intent, so history browsing/search remains unchanged. Session-worktree and target resolution are pure in-memory scans over already-loaded worktree/repo summaries. Ordering parity keeps sorting in-memory over the existing mobile list and uses deterministic comparators covered by unit tests.

Validation

Docker recovery: docker info initially reported no daemon while stale Docker Desktop backend PID 67939 was present. I opened Docker, tried bounded docker version/info/status/start/stop probes, interrupted my own stuck docker desktop stop, killed only stale Docker backend PID 67939 with SIGKILL, reopened Docker Desktop, and confirmed docker info reached Server 29.2.1.

SSH/runtime validation: ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/ssh-docker-relay-perf.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1 --grep "keeps an SSH workspace terminal usable" passed. This created a real Linux Docker SSH target, connected Orca to it, added a remote repo/worktree, created an SSH terminal, verified remote output before and after disconnect/reconnect, built the relay bundle, and cleaned up the container.

Android emulator QA follow-up (2026-07-01):

  • Device: emulator-5554, model sdk_gphone64_arm64, boot completed, package com.stably.orca.mobile installed.
  • App loaded and paired to the exact PR worktree desktop: /tmp/orca-pr2-android-1782942367/android-loaded-clean.png, /tmp/orca-pr2-android-1782942367/android-connected-after-pair.png.
  • Real mobile path reached Agent Session History via the worktree long-press action sheet: /tmp/orca-pr2-android-1782942367/android-main-longpress-actions.png, prior ready screen /tmp/orca-pr2-android-1782942367/android-agent-history-ready.png.
  • Tapping Resume opened demo-project/main, created Terminal 2, and sent cd '/Users/thebr/source/repos/Stably/demo-project' && CODEX_HOME=... codex resume ...: /tmp/orca-pr2-android-1782942367/android-after-resume.png, settled command/error screenshot /tmp/orca-pr2-android-1782942367/android-after-resume-settled.png.
  • Backing runtime proof: session.tabs.list showed two terminals for the demo worktree, with Terminal 2 active and launchAgent: codex.
  • Residual gap: canonical-session retest did not complete; after clean app reset/re-pair, selecting Agent Session History from the same long-press action sheet produced Android Orca isn't responding: /tmp/orca-pr2-android-1782942367/android-agent-history-selected-second-tap.png, /tmp/orca-pr2-android-1782942367/android-after-anr-wait.png.

Focused checks run:

  • pnpm --dir mobile test -- src/worktree/workspace-list-sections.test.ts src/worktree/mobile-workspace-lineage.test.ts src/worktree/worktree-list-snapshot.test.ts
  • pnpm --dir mobile test -- src/worktree/workspace-list-sections.test.ts
  • pnpm exec vitest run src/main/runtime/orca-runtime.test.ts -t "builds a compact worktree summary from persisted and live runtime state"
  • pnpm --dir mobile exec vitest run src/session/session-panel-host.test.ts src/agent-history/agent-history-session-card.test.ts src/agent-history/agent-history-resume-target.test.ts
  • pnpm --dir mobile exec tsc --noEmit
  • pnpm run typecheck:node
  • pnpm --dir mobile lint
  • git diff --check

Earlier focused checks:

  • cd mobile && pnpm exec vitest run src/agent-history src/session/ai-vault-resume-launch.test.ts (5 files, 49 tests)
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts (515 tests)
  • pnpm exec oxlint <touched files>
  • pnpm run typecheck
  • cd mobile && pnpm exec tsc --noEmit -p tsconfig.json
  • pnpm exec oxfmt --check <touched files>

Post-PR Stabilization

After the latest push (d46d908a08cd872502202adbed1bc33f11614cad), both GitHub verify checks pass. No CodeRabbit issue or review comments were present in the PR review-comment API at the final sweep; the only PR issue comment is Stage's generated chapter summary.

@ghost

ghost commented Jul 1, 2026 •

Copy link
Copy Markdown

brennanb2025 and others added 15 commits July 1, 2026 18:10
@brennanb2025
brennanb2025 merged commit 1a2b64b into brennanb2025/add-agents-to-mobile Jul 3, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/Agent-Session-History-resume-PR2 branch July 3, 2026 02:20
brennanb2025 added a commit that referenced this pull request Jul 10, 2026
* Show agent session history on mobile

Bring the desktop "Agent Session History" panel to Orca Mobile as a
per-worktree screen: browse past agent transcript sessions across the
host with scope tabs (Workspace/Project/All), search, grouping, session
cards, and tap-to-read message previews.

The transcript scan previously ran only over Electron IPC, so mobile
could not reach it. Expose it over the runtime RPC protocol mobile
already speaks (aiVault.listSessions) so the scan runs on whichever host
owns the transcripts — correct for local and SSH/remote hosts. Both the
desktop IPC handler and the new RPC method share one cache, so opening
the desktop panel and the mobile screen never double-scan.

The pure filter/group/display logic is lifted into /shared (the renderer
re-exports it) so the standalone mobile package can reuse it. Mobile
narrows scoped tabs client-side by cwd path-prefix because the host scan
treats scope paths as a widening union.

Resume-from-mobile is intentionally a follow-up.

* Fix mobile agent history list rendering and RPC authorization

- Authorize aiVault.listSessions in the mobile RPC allowlist so the
  mobile client's call is not rejected before dispatch (without this the
  screen could never load sessions at runtime).
- Name each SectionList section's rows `data` (the field React Native
  reads) instead of `cards`, fixing a type error and silent empty-section
  rendering.

* Address review feedback on agent session history

- Match quoted repo:/path: search operator values so labels and paths
  with spaces match (e.g. path:"/Users/ada/My Project").
- Hold a scoped tab in loading until the worktree list resolves instead
  of firing an unscoped fetch that briefly shows unrelated host history;
  proceed once loaded even if the worktree is absent (no stuck spinner).
- Clear cached host capabilities on disconnect/host-switch and failed
  status.get so a capability-gated action can't linger for a host that
  doesn't support it.
- Cover the real OrcaRuntimeService codex-home forwarding path and the
  quoted-operator parser with tests.

* Hide redundant mobile current worktree badges

Co-authored-by: Orca <[email protected]>

* Resume agent sessions from mobile history (#6969)

Co-authored-by: Orca <[email protected]>

* Adapt merged seams to main's lint and reply-sender hardening

Co-authored-by: Orca <[email protected]>

* Cap mobile project-scope paths to the aiVault RPC bound

Co-authored-by: Orca <[email protected]>

* Share the aiVault scopePaths bound between the RPC schema and mobile

Co-authored-by: Orca <[email protected]>

* Guard shared AI Vault inflight cleanup against concurrent key replacement

The extracted cache module's .finally() cleared inflight tracking
unconditionally, dropping the if (inflightKey === key) guard its sibling
outer cache kept: an older scan resolving after a different-key scan
replaced the tracking would null the newer scan's dedup slot, so a
re-request started a duplicate transcript rescan. Mirrors the sibling
guard; the regression test flushes a macrotask so a reverted guard fails
fast on the call count instead of hanging.

Co-authored-by: Orca <[email protected]>

* Harden aiVault.listSessions contract and gate mobile header entry on capability

- Clamp scopePaths (64) instead of rejecting, cap limit at 2000, and make
  executionHostId optional so mobile can omit it; restamp per caller.
- Retain successful mobile terminal-create mutation ids for 60s so resume
  retries dedupe after transient socket drops.
- Gate the session-header Agent History action on the aiVault.v1 capability
  (mirrors the host-list action) so old hosts never show a dead-end entry.
- Fix stale contract comments (scopePaths clamp semantics; filters move
  includes quoted repo:/path: operator parsing).

* Add subagent field to session test fixtures after #7423 merge

AiVaultSession.subagent became required on main; the five fixtures added on
this branch predate it. Top-level scanned sessions carry null.

---------

Co-authored-by: Orca <[email protected]>
Co-authored-by: Brennan Benson <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Show agent session history on mobile

Bring the desktop "Agent Session History" panel to Orca Mobile as a
per-worktree screen: browse past agent transcript sessions across the
host with scope tabs (Workspace/Project/All), search, grouping, session
cards, and tap-to-read message previews.

The transcript scan previously ran only over Electron IPC, so mobile
could not reach it. Expose it over the runtime RPC protocol mobile
already speaks (aiVault.listSessions) so the scan runs on whichever host
owns the transcripts — correct for local and SSH/remote hosts. Both the
desktop IPC handler and the new RPC method share one cache, so opening
the desktop panel and the mobile screen never double-scan.

The pure filter/group/display logic is lifted into /shared (the renderer
re-exports it) so the standalone mobile package can reuse it. Mobile
narrows scoped tabs client-side by cwd path-prefix because the host scan
treats scope paths as a widening union.

Resume-from-mobile is intentionally a follow-up.

* Fix mobile agent history list rendering and RPC authorization

- Authorize aiVault.listSessions in the mobile RPC allowlist so the
  mobile client's call is not rejected before dispatch (without this the
  screen could never load sessions at runtime).
- Name each SectionList section's rows `data` (the field React Native
  reads) instead of `cards`, fixing a type error and silent empty-section
  rendering.

* Address review feedback on agent session history

- Match quoted repo:/path: search operator values so labels and paths
  with spaces match (e.g. path:"/Users/ada/My Project").
- Hold a scoped tab in loading until the worktree list resolves instead
  of firing an unscoped fetch that briefly shows unrelated host history;
  proceed once loaded even if the worktree is absent (no stuck spinner).
- Clear cached host capabilities on disconnect/host-switch and failed
  status.get so a capability-gated action can't linger for a host that
  doesn't support it.
- Cover the real OrcaRuntimeService codex-home forwarding path and the
  quoted-operator parser with tests.

* Hide redundant mobile current worktree badges

Co-authored-by: Orca <[email protected]>

* Resume agent sessions from mobile history (stablyai#6969)

Co-authored-by: Orca <[email protected]>

* Adapt merged seams to main's lint and reply-sender hardening

Co-authored-by: Orca <[email protected]>

* Cap mobile project-scope paths to the aiVault RPC bound

Co-authored-by: Orca <[email protected]>

* Share the aiVault scopePaths bound between the RPC schema and mobile

Co-authored-by: Orca <[email protected]>

* Guard shared AI Vault inflight cleanup against concurrent key replacement

The extracted cache module's .finally() cleared inflight tracking
unconditionally, dropping the if (inflightKey === key) guard its sibling
outer cache kept: an older scan resolving after a different-key scan
replaced the tracking would null the newer scan's dedup slot, so a
re-request started a duplicate transcript rescan. Mirrors the sibling
guard; the regression test flushes a macrotask so a reverted guard fails
fast on the call count instead of hanging.

Co-authored-by: Orca <[email protected]>

* Harden aiVault.listSessions contract and gate mobile header entry on capability

- Clamp scopePaths (64) instead of rejecting, cap limit at 2000, and make
  executionHostId optional so mobile can omit it; restamp per caller.
- Retain successful mobile terminal-create mutation ids for 60s so resume
  retries dedupe after transient socket drops.
- Gate the session-header Agent History action on the aiVault.v1 capability
  (mirrors the host-list action) so old hosts never show a dead-end entry.
- Fix stale contract comments (scopePaths clamp semantics; filters move
  includes quoted repo:/path: operator parsing).

* Add subagent field to session test fixtures after stablyai#7423 merge

AiVaultSession.subagent became required on main; the five fixtures added on
this branch predate it. Top-level scanned sessions carry null.

---------

Co-authored-by: Orca <[email protected]>
Co-authored-by: Brennan Benson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant