Skip to content

fix(mobile): Load earlier messages always ends, and says when it can't, in every phone chat - #29137

Closed
brennanb2025 wants to merge 14 commits into
mainfrom
brennanb2025/mobile-older-page-not-lost
Closed

brennanb2025 wants to merge 14 commits into
mainfrom
brennanb2025/mobile-older-page-not-lost

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​104 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​665 $\color{#cf222e}{\Huge{\mathbf{−}}}$​550 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​115

ELI5

On the phone (the app and the over-the-air web page), tapping Load earlier messages in a chat could do nothing at all, could show a spinner for minutes, or could fail without any sign. That happened in both kinds of phone chat: chats that read the agent's transcript file (most agents) and agent-session chats (Claude and Codex chats run through Orca's own session). Now, in every phone chat, one tap either brings in older messages or ends within about 15 seconds. If it failed, it says so, and the button still works for a retry. When older history can never be loaded from there (the chat's saved history is damaged, or a newer Orca saved it), the button is replaced by one short line saying so.

What Changed

What the reader saw before.

  • Transcript chats: a tap made while the phone was reconnecting was thrown away by the reconnect; a refused, failed or timed-out page left the button on its label as if nothing happened; and the page request waited for the connection with no time limit, so the spinner could run for minutes on a phone that couldn't reconnect.
  • Agent-session chats (Claude, Codex): a failed page was written into the chat's read status, which only shows when the chat is empty, so with messages on screen it was invisible; a refusal that means "this history can never be read" swapped the whole chat for the "can't read this chat" card; and one tap could chain up to 24 requests of 15 seconds each.
  • Both: scrolling near the top re-fired a failed request over and over, so the spinner kept coming back and looked permanent.

What the reader sees now (both chat types).

  • Transcript chats: a tap made while reconnecting lands its page once the connection is back.
  • Agent-session chats (Claude, Codex): a tap made while reconnecting ends quietly when the reconnect replaces the chat window, as on main; the reader taps again.
  • One tap gets one 15-second budget, and that budget includes waiting for the connection. The spinner always ends.
  • If a page fails in a way a retry can get past (a timeout, a dropped connection, a refusal or error reply), one muted line appears under the button: "Couldn't load earlier messages. Tap to try again." The button stays tappable. Scrolling at the top no longer re-fires the request while that line shows; only a tap retries.
  • If older history can never be read from here (the host refuses the read because the chat's saved history is damaged or a newer Orca saved it), the button goes away and one line takes its place: "Earlier messages can't be loaded." No "Tap to try again", and the chat stays on screen instead of being replaced by the error card.
  • When the chat window is replaced (a reset, a fresh snapshot, a switch of chat or connection), any read in progress ends quietly and the line clears. An agent-session page answered with a history reset (for any reason) also ends the tap quietly: the desktop's chat subscription then sends a fresh window, which replaces the one the tap was for.

Mechanism. A new hook, use-mobile-older-page-loader.ts, owns the older-page read for both chat types:

  • It holds the one running read's token. A read ends either by settling or by supersede() (the window it was for is gone), and both clear the spinner in the loader, so no path can leave the spinner on. A superseded read's late reply finds a different token and changes nothing. A second trigger in the same moment (tap, scroll, automatic read-back) can't start a second read.
  • It gives each tap one 15-second budget shared by every request in the tap, connect wait included, and starts no request with under one second left. It reads on past pages that draw nothing (for example a page of only a subagent's rows), up to 8 pages.
  • It reports one outcome for the control: idle, loading, failed (retry line) or unavailable (no-retry line, paging off).

Each chat type supplies only its own rules: how to ask for the next page, whether the reply still lands (transcript chats: the same window and the same history byte position; agent-session chats: the same epoch and a window head this tap produced, re-reading from the new head if live output trimmed it), and whether the page drew a row. Agent-session older-page failures no longer touch the chat's read status; only a final read refusal (damaged history, or saved by a newer Orca) gives the no-retry outcome, which stays until the chat's window is replaced (new messages arriving don't bring the spinner back), and every history reset ends the tap quietly.

No wire, host, protocol or saved-data change. The transcript page read now passes the same request budget the agent-session reads already used.

This bounds the Load earlier spinner on both chat types. It does not claim to fix the hang seen in iOS QA. QA's long-running spinner was the Load earlier spinner on a terminal-backed chat (the transcript lane, whose page request had no time limit while the phone waited to reconnect). With this PR it ends within about 16 seconds (the 15-second budget plus settling) and shows the retry line; why it ran past a minute on main is still being traced.

Why

Both chat types had their own copy of one decision (may a page start, does its reply still count, what ends the spinner, what does a failure show), and every bug above was one copy drifting from the other. The common pattern keeps one owner for the older-page request whose settlement and supersession both clear the loading state, decides whether a reply lands by checking that the position it was sent from is still current, shows a short line under the button on failure with the button still usable, and stops automatic re-tries after a failure until the reader asks again. This PR adopts that shape in one loader instead of patching each copy.

Alternatives considered:

  • Fix each chat type in place. Keeps two latches, two invalidation counters and two failure paths that already diverged; the next fix in one would miss the other.
  • Retry automatically after a failure. Hides the failure again and loops on a host that keeps refusing; the reader's tap is the retry.
  • Keep the "can't read this chat" card for a final older-page refusal. Hides a chat that is still readable; the newest messages are fine, only older ones can't be read.

Differences from the common pattern, labelled:

  • Intended: the loader reads on past pages that draw nothing, because these hosts page in raw units (messages, journal items) that can draw nothing on the phone, and older hosts can't change.
  • Intended: one 15-second budget per tap, connect included, rather than a per-request limit; it matches the agent-session reads' existing budget and covers the phone's socket reconnect.
  • Intended: switching away from a chat abandons its older-page read rather than keeping it per chat; the phone shows one chat, and the reader taps again on return.
  • Intended: fixed copy rather than the host's message; host errors here are internal codes a reader can't act on.
  • Intended: a transcript chat on an older host (no history position) and an agent-session snapshot or reset also clear the failure line, because the line described a window that is gone.
  • Intended: an agent-session tap re-reads from a trimmed head within the same tap, where the common pattern ends silently on a moved position; a busy turn trims the head often enough that a silent end would make taps do nothing mid-turn.
  • Intended: a final refusal ends paging with a no-retry line ("Earlier messages can't be loaded.") in the button's place, instead of the retry line or a silent hide.

Merge this before #29043. Without it, #29043 makes the button the only way to page, so a lost page becomes a dead button.

Linked Issue

N/A (maintainer). Found while diagnosing why "Load earlier messages" seemed to stop working on #29043, and from iOS QA's long-running spinner on a terminal-backed chat.

Visual Proof

The phone chat page in Orca's Electron build on Windows, terminal-backed chat, this PR (left) vs main (right). A QA overlay pins the list header into view for the shot.

The desktop returns an error for the page: the retry line appears, vs nothing on main.
Retry line after an error vs main silent

The page request is never answered: the spinner ends with the retry line at 15 s, vs main still spinning at 25 s.
Retry line at 15 s vs main still spinning

A tap made while the phone is reconnecting: the page lands, vs nothing loading on main.
Tap while reconnecting lands vs main nothing

Not shown yet: an iOS screenshot of the retry line, and agent-session (Claude/Codex) chats, which neither QA rig can open without a real agent sign-in.

Testing

  • New: an agent-session chat whose older page fails keeps its status and rows, shows the retry outcome, lands the page on the next tap, and ends in the no-retry outcome when the host refuses the read because the history is damaged.

  • Kept: the transcript tests for a page landing across a same-position reconnect, a refused page flagged until the next tap, and a page dropped when the history position moved; the four agent-session older-history tests (read-on past subagent-only pages, automatic read-back).

  • The page-read assertions and the session.native-chat-page recording goldens now include the read's budget options (goldens hand-updated: only those options change; values re-hashed as the recorder does).

  • CI runs lint, typecheck and the mobile tests.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…ked for

A replayed snapshot cancelled any in-flight "Load earlier messages" page, even
when the replay merged onto the same window and cursor, and every other lost
page (host refusal, error reply, transport drop) was swallowed, so the control
went back to its label as if nothing had been tried.

A page now lands unless its window was replaced or the cursor it was sent from
changed. A page that is lost shows one line under the control,
"Couldn't load earlier messages. Tap to try again.", cleared by the next tap or
a page that lands.
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
…d-on change

# Conflicts:
#	mobile/src/session/MobileNativeChatOverlay.tsx
#	mobile/src/session/use-mobile-native-chat-session.ts
…loader

A failed page now shows the retry line instead of an invisible chat error,
history that can never be read ends paging, and one tap shares one budget.
…r both chat types

A retryable failure keeps the button with the retry line; history that can never
be read swaps the button for one line saying so; scrolling at the top no longer
re-fires a failed read.
…le, retries on a tap, and ends at unreadable history
…he page goldens

Hand-updated: only the nativeChat.readSession options change (absent -> 15 s
budget spanning connect); every value is re-hashed and re-keyed as the recorder does.
@brennanb2025 brennanb2025 changed the title fix(mobile): a reconnect no longer drops the older messages you asked for fix(mobile): Load earlier messages always ends, and says when it can't, in every phone chat Oct 15, 2026
…s the subscription's reload replaces the window

Only a final read refusal (damaged history, or saved by a newer Orca) ends a tap at
'Earlier messages can't be loaded.'; the test now drives that reachable path.
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
# Conflicts:
#	mobile/src/session/MobileNativeChatView.tsx
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
…ge change

# Conflicts:
#	mobile/src/session/MobileNativeChatOverlay.tsx
#	mobile/src/session/use-mobile-native-chat-session.ts
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Superseded by #29271, which carries this change together with the rest of the phone chat scroll work in one PR against main.

@brennanb2025
brennanb2025 deleted the brennanb2025/mobile-older-page-not-lost branch October 19, 2026 20:54
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