Skip to content

Fix mobile session snapshot freshness after main-side bumps#7409

Open
Fartown wants to merge 1 commit into
stablyai:mainfrom
Fartown:fix/mobile-session-snapshot-freshness
Open

Fix mobile session snapshot freshness after main-side bumps#7409
Fartown wants to merge 1 commit into
stablyai:mainfrom
Fartown:fix/mobile-session-snapshot-freshness

Conversation

@Fartown

@Fartown Fartown commented Jul 5, 2026

Copy link
Copy Markdown

Summary

Fixes #7400.

  • Track renderer-owned mobile session tab snapshot freshness separately from the client-visible delivery snapshotVersion that main can bump for PTY/title/live updates.
  • Preserve monotonic client delivery versions when a fresh renderer structural snapshot arrives after main-side bumps.
  • Reject stale and duplicate same-version renderer snapshots within the same publication epoch so an old one-tab snapshot cannot overwrite newer tab structure.
  • Add regression coverage for the [Bug]: Orca Mobile can show stale one-tab session when main bumps mobile snapshotVersion #7400 stale one-tab mobile session scenario.

Screenshots

No visual change.

Testing

  • pnpm lint
    • Attempted on latest origin/main (17d5eff) and also reproduced on clean origin/main without this PR: src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx:35 fails typescript(switch-exhaustiveness-check) because the switch is already exhaustive. Changed-file oxlint passed.
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Passed on the final branch after rebasing onto origin/main@17d5eff:

pnpm exec oxlint src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.ts
pnpm exec vitest run src/main/runtime/orca-runtime.test.ts --testNamePattern "renderer mobile tab structure|stale renderer mobile tab structure" --reporter dot
pnpm typecheck
pnpm build

Also passed earlier for the complete runtime test file:

pnpm exec vitest run src/main/runtime/orca-runtime.test.ts --reporter dot

Current full-suite notes on the final branch / latest origin/main@17d5eff:

pnpm run lint:switch-exhaustiveness
# Fails on clean origin/main at:
# src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx:35

pnpm test
# 2 failed test files / 3 failed tests, all outside this PR:
# src/main/daemon/node-pty-fd-leak.test.ts
# src/relay/subprocess.test.ts

AI Review Report

A read-only AI review checked the final diff in src/main/runtime/orca-runtime.ts and src/main/runtime/orca-runtime.test.ts for the #7400 failure mode, stale/same-version renderer snapshot handling, client-visible monotonic delivery versions, cross-platform compatibility, SSH/remote/local behavior, provider neutrality, performance, security, and PR scope.

The review found no blocking issues. It confirmed that renderer-owned tab graph freshness is now separate from main-bumped delivery freshness, same-epoch stale and duplicate snapshots are rejected, accepted renderer snapshots remain delivery-monotonic for clients, and the added tests cover stale, duplicate, and fresh-after-main-bump cases. It also explicitly checked macOS/Linux/Windows concerns, shortcuts, labels, paths, shell behavior, and Electron-specific platform differences; this PR does not touch UI, shortcut, accelerator, path, shell, or platform-specific code. The review flagged an unrelated untracked architecture document, which is intentionally excluded from this PR.

Security Audit

This change only adds in-memory runtime bookkeeping for mobile session snapshot freshness. It does not add IPC methods, command execution, filesystem/path handling, network calls, dependencies, auth handling, secrets handling, or new user-controlled parsing. The extra Map is keyed by existing worktree identifiers and bounded by the existing worktree snapshot lifecycle; entries are deleted when snapshots are removed. Security risk is neutral.

Notes

  • No mobile app or protocol change is required; the existing publicationEpoch, snapshotVersion, tab group, and tab payload shape remains intact.
  • Cross-platform / SSH / remote behavior is preserved because the fix is runtime-local snapshot freshness bookkeeping.
  • X handle: not provided.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds renderer mobile session snapshot freshness tracking in the Orca runtime. A per-worktree map records the latest accepted renderer snapshot state, helper functions gate incoming snapshots by publicationEpoch and snapshotVersion and normalize stored snapshotVersion values, and syncMobileSessionTabs now uses that logic before writing to mobileSessionTabsByWorktree. The freshness entry is removed when a worktree’s mobile session tabs are deleted. Tests cover fresh updates and stale updates within the same publicationEpoch.

Changes

Compact metadata:

  • Lines changed: +263/-8
  • Files touched: 2

Sequence Diagram(s)

sequenceDiagram
  participant Renderer
  participant syncMobileSessionTabs
  participant acceptRendererMobileSessionSnapshot
  participant withMonotonicMobileSessionSnapshotVersion
  participant mobileSessionTabsByWorktree

  Renderer->>syncMobileSessionTabs: snapshot (publicationEpoch, snapshotVersion)
  syncMobileSessionTabs->>acceptRendererMobileSessionSnapshot: evaluate freshness
  acceptRendererMobileSessionSnapshot-->>syncMobileSessionTabs: accepted or rejected
  syncMobileSessionTabs->>withMonotonicMobileSessionSnapshotVersion: normalize snapshotVersion
  withMonotonicMobileSessionSnapshotVersion-->>syncMobileSessionTabs: normalized snapshot
  syncMobileSessionTabs->>mobileSessionTabsByWorktree: store snapshot
Loading

Related issues: None provided
Related PRs: None provided
Suggested labels: runtime, mobile-sync
Suggested reviewers: Not specified

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests address #7400 by separating renderer freshness from delivered versions and rejecting stale same-epoch snapshots.
Out of Scope Changes check ✅ Passed The diff stays focused on runtime snapshot freshness logic and regression tests, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main fix: mobile session snapshot freshness after main-side bumps.
Description check ✅ Passed The description follows the required template and covers summary, screenshots, testing, review, security, and notes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Fartown Fartown force-pushed the fix/mobile-session-snapshot-freshness branch from 7ba8960 to 425e15d Compare July 5, 2026 05:57
@Fartown Fartown force-pushed the fix/mobile-session-snapshot-freshness branch from 425e15d to 5c8e95b Compare July 5, 2026 06:05
@AmethystLiang AmethystLiang requested a review from Jinwoo-H July 5, 2026 18:30
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.

[Bug]: Orca Mobile can show stale one-tab session when main bumps mobile snapshotVersion

2 participants