Skip to content

perf(mobile): trust healthy session tab streams - #10134

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-session-tabs-stream-health
Jul 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-session-tabs-stream-health

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Description

  • Certify session.tabs.subscribe only after an accepted full updated frame or a
    list request physically begun after the subscription snapshot.
  • Stop the focused route's two-second session.tabs.list fallback while that
    stream is certified and no close/browser recovery is pending.
  • Fence results by client generation, subscription cycle, stream barrier,
    requirement, route lifetime, and accepted-application revision; coalesce one
    physical request cohort while preserving a required post-mutation trailing list.
  • Run browser-focus and markdown-stale effects only for accepted,
    tombstone-filtered snapshots.
  • Give relay subscriptions the same exactly-once error frame as direct transport.
    Keep terminal.list, unsubscribe behavior, and terminal lifetime handling
    unchanged.

ELI5

The phone used to ask the desktop for the whole tab list every two seconds even
while the desktop was already sending every tab change live. It now stops the
duplicate question only after proving the live feed is trustworthy. If the feed
ends, reconnects, or local close/focus work is unfinished, the old safety poll
automatically resumes.

Proof of zero regression

  • Independent final correctness, performance/transport, and
    platform/integration reviews found no remaining issues.
  • Post-rebase focused D-003 behavior: 8 files, 61/61 tests passed.
  • Post-rebase full mobile suite: 320 files; 2,330 tests passed and 2 skipped.
  • Mobile TypeScript, full oxlint, and the 952-file format check passed.
  • Root Node/CLI/web TypeScript, max-lines ratchet, and git diff --check passed.
  • Normal bootstrap proves a pre-snapshot list cannot certify the stream: the
    initial snapshot creates a new barrier, the old result is discarded, and a
    distinct post-snapshot list must apply. An accepted full updated frame may
    certify immediately.
  • Old client generations, canceled subscriptions, stale barriers, late lists,
    rejected snapshots, and results superseded by any accepted application cannot
    mutate current UI state.
  • Concurrent same-barrier callers receive one exact promise. If a newer
    mutation requirement arrives during the request, that promise remains pending
    until its one trailing physical list settles; failures wait for the next tick
    rather than spinning.
  • Backgrounded or blurred routes perform zero tab and terminal polls. Focus,
    foreground resume, reconnect, and stable connected-to-connected generation
    cutover invalidate prior health and reconcile immediately or on the current
    generation's next frame/tick.
  • Close tombstones keep the tab fallback active through expiry. Pending browser
    focus resolves from either list or stream effective tabs. Rejected snapshots
    perform no browser, markdown, tombstone, or reconciliation side effects.
  • Direct and relay subscription failures emit one compatible
    { type: 'error', message, error } frame and fence late callbacks. Existing
    unsubscribe behavior is unchanged for mixed-version compatibility.
  • Local, daemon, WSL, SSH, and relay hosts share the same session-tab RPC
    contract. The change adds no host path, process, Git, shell, or native-module
    assumptions.
  • Full post-rebase root suite: 3,272 files and 34,817 tests passed; 8 files and
    60 tests skipped by the existing suite.
  • Full root lint reaches the known pre-existing released orca-cli revision-9
    append-only manifest blocker after oxlint, switch-exhaustiveness, reliability,
    max-lines, and bundled-guide checks pass. Direct localization catalog and
    coverage checks also pass. This diff changes no skill files.

Proof of performance improvement

  • Deterministic fake-clock route budget, one focused certified session for
    60 seconds:
    • Before: 30 session.tabs.list + 30 terminal.list RPCs.
    • After: 0 session.tabs.list + exactly 30 terminal.list RPCs.
  • That removes 30 redundant tab inventory RPCs and 30 host
    listMobileSessionTabs executions per focused idle minute.
  • Safety fallback remains bounded exactly as designed:
    • PROBING or DEGRADED for 10 seconds: one immediate + five interval tab lists.
    • Backgrounded or blurred for 60 seconds: 0 tab / 0 terminal lists.
    • A close tombstone through 10 seconds: tab lists at 2/4/6/8/10 seconds, then
      none after accepted expiry processing.
  • Same-barrier requests coalesce to one physical list; one newer ordinary
    requirement creates one trailing physical list instead of parallel duplicates.
  • This PR does not claim fewer mobile radio wakes or fewer terminal
    inventories: the justified terminal.list request intentionally remains every
    two seconds.
  • A physical-device battery trace was not used; the improvement proof is the
    deterministic production-hook request budget plus transport/controller tests.

@nwparker
nwparker marked this pull request as draft July 23, 2026 08:35
@nwparker
nwparker marked this pull request as ready for review July 23, 2026 08:35
@nwparker
nwparker force-pushed the nwparker/perf-session-tabs-stream-health branch from b1123ed to 2dd97f7 Compare July 23, 2026 08:52
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a mobile session-tab reconciliation controller and React hook for stream subscriptions, list polling, recovery, generation fencing, and application-revision handling. Session screens now use the hook and shared accepted-result effects for browser focus and markdown staleness. Tests cover reconciliation, lifecycle transitions, recovery, and subscription stability. Relay RPC streams now deliver connection and RPC failures to listeners and prevent late callbacks after cancellation or cleanup, with corresponding tests.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description does not follow the repository template and is missing required Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections. Reformat the PR description to the required template and add the missing sections, especially Screenshots, Testing, AI Review Report, Security Audit, and Notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and matches the main change: mobile session tab stream trust and certification.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b5b9857e-bd4d-4cba-84b7-d8f9921893c9

📥 Commits

Reviewing files that changed from the base of the PR and between 1648251 and b1123ed.

📒 Files selected for processing (10)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/src/session/mobile-session-tabs-accepted-effects.test.ts
  • mobile/src/session/mobile-session-tabs-accepted-effects.ts
  • mobile/src/session/mobile-session-tabs-stream-health.test.ts
  • mobile/src/session/mobile-session-tabs-stream-health.ts
  • mobile/src/session/use-mobile-session-tabs-reconciliation.test.ts
  • mobile/src/session/use-mobile-session-tabs-reconciliation.ts
  • mobile/src/transport/mobile-relay-rpc-streams.test.ts
  • mobile/src/transport/mobile-relay-rpc-streams.ts

@nwparker
nwparker merged commit a2b1185 into main Jul 24, 2026
5 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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