Skip to content

fix(native-chat): publish a terminal pane's conversation as its own field so restarted desktops keep Chat history - #25511

Closed
brennanb2025 wants to merge 17 commits into
brennanb2025/mobile-codex-transcript-7370from
brennanb2025/mobile-conversation-identity
Closed

brennanb2025 wants to merge 17 commits into
brennanb2025/mobile-codex-transcript-7370from
brennanb2025/mobile-conversation-identity

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4682 $\color{#cf222e}{\Huge{\mathbf{−}}}$​300 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4382
Prod 55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1385 $\color{#cf222e}{\Huge{\mathbf{−}}}$​296 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1089

Stacked on #25358. The base branch is #25358's branch. Once #25358 merges, this PR is retargeted to main and main is merged in before it leaves draft.

ELI5

On a headless orca serve host, a Codex terminal finishes its turn and sits idle. A desktop app that restarts (or connects for the first time) and opens that pane's Chat sees "Start a chat with Codex" with no history, even though the host still knows exactly which conversation the pane holds. #25358 fixed this for phones only, with a workaround. This PR fixes it for every client by making "which conversation this pane holds" its own fact that the host keeps and sends, instead of something that only travels inside the pane's working/idle status.

What Changed

The problem. A paired desktop is connected to a headless orca serve host. A Codex terminal pane on the host has finished a turn and Codex is still open and idle.

  • A desktop that stayed open keeps showing the conversation in that pane's Chat view, but only because it remembers the last conversation it opened.
  • A desktop that restarts, or connects for the first time, opens that pane's Chat on the empty "Start a chat with Codex" screen. History comes back only after Codex runs another turn.
  • fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358 (STA-7370) fixed the same symptom for phones only, by sending phones a stand-in "finished" status that carries the conversation id. Desktops can't receive that stand-in, because a desktop treats a status from the host as a real turn result (notifications, unread dots, finished times).

Why it happened. The host tells clients which conversation a terminal pane holds only through the pane's status. So any rule that sends "no status" also deletes the conversation address. On a headless host, an idle Codex pane whose title is just the thread name gets no status, so a client that wasn't already watching never learns the address. There was a second, deeper coupling: the host's hook store itself dropped the conversation id when the terminal title reported a new turn starting, until Codex's next hook re-sent it. So even at the source, identity was not independent of status.

What you see now.

Situation Before After
Paired desktop restarts or connects while a headless host's Codex pane is idle Chat opens empty: "Start a chat with Codex" Chat shows the conversation
Same pane, desktop stayed open, a new prompt starts before Codex's next hook Kept only by the desktop's in-memory memory Kept by the host, so a restarted client sees it too
Copy Agent Session ID (terminal menu, Chat pane menu) on that restarted desktop Disabled Enabled; copies the id the Chat shows
Chat menu, header button and shortcut on a restarted desktop for an idle Codex that was started by typing codex (no launch record) Not offered Offered, as on a phone
Model picker on a restarted desktop or phone for an idle pane Often empty Seeded from the conversation's model; a model you pick is never overwritten by an older one
Phone app with this PR Works through #25358's stand-in status Reads the pane's conversation field; no stand-in status
Phone app already in users' hands, new host Works through #25358's stand-in status Still works; the stand-in is built from the same host decision
Spinners, finished times, unread dots, completion notifications, Activity — Unchanged; the status every client receives is byte-identical
A pane the host does not offer today (shell title, renamed to zsh, live question) No conversation on a fresh client Unchanged: no widening in this PR

How it works.

  1. The host keeps the conversation as its own fact. The hook store's existing row for each pane gains a conversation record: agent, provider session (id, key, transcript path), model and the time the address or model last changed. It changes only when an incoming hook event itself reports a session address, and then it takes exactly the address the store's existing admission rules kept for the pane. Title updates, status changes, held rows and copies carried forward never touch it, and a repeated report is a no-op. Close, a certified exit or a terminal reset end it. It is persisted with the row and read back on restart; rows written by older versions fall back to their existing session fields.
  2. The host publishes it on every terminal tab. Each terminal tab in the session-tab list gains an optional conversationIdentity and an optional conversationOfferedWithoutStatus: true. The host includes the conversation only when its agent matches the agent the store currently sees in that pane; otherwise the member is absent, and a client falls back to today's behaviour. So a pane Orca launched as Claude where you then run Codex shows the Codex conversation, and an agent that reports no session never inherits the previous agent's conversation. The second is the host's one decision about whether a pane with no status may offer its conversation; it is the same decision fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358's phone workaround already made, from evidence only the host has (the terminal's own title and live hook signals).
  3. Desktops and phones read it through one shared rule. A tab's real status wins; otherwise the published conversation, but only where the host offers it; otherwise today's behaviour. A conversation the client may not use behaves exactly as if it were absent, so an open Chat keeps its history when a tab is renamed. The desktop mirrors the field per pane (never borrowing a split sibling's), keeps it out of saved workspace state, and feeds the Chat view, its menu, header, shortcut, model picker and Copy Agent Session ID.
  4. Phones already in users' hands keep the fix. A phone that does not advertise the new session-tabs.conversation-identity.v1 capability still gets fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358's stand-in status, now built from the same host record and the same host decision; its tabs do not also carry the new members. The private symbol fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358 used is gone. Differences an old phone can see versus fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358: the stand-in is dated by when the conversation's address or model last changed (so a title repaint no longer re-dates it), and its terminalTitle is the tab's title as the client sees it. No shipped phone reads either for display.

Files (main areas).

  • Store: src/main/agent-hooks/server/server-conversation-facet.ts (new) plus the write sites in server-status-update.ts, server-ingest-remote.ts, server-ingest-normalization.ts, server-status-retries.ts, persistence, hydration and row comparison.
  • Host projection: src/main/runtime/terminal-conversation-identity.ts (new), runtime-mobile-session-projection.ts, runtime-mobile-agent-status-builder.ts, rpc/methods/session-tab-legacy-phone-conversation-fold.ts (new).
  • Shared: src/shared/terminal-conversation-identity.ts and terminal-conversation-model-report.ts (new), tab contracts, the capability constant.
  • Desktop: web-session-tabs-sync/terminal-build.ts, native chat resolution, gate, availability, options, shortcut, tab menu, pane-agent-session-id.ts, workspace-session sanitizing.
  • Phone: native chat eligibility, controller and options, tab equality, owned agent, keyboard dismissal, capability advertisement.

Why

  • Fix the cause, not the phone. The bug class is "identity rides inside status", so every rule that withholds status also withholds the address. Giving identity its own field removes that class for every client, instead of adding a second per-client workaround.
  • Keep it in the host's existing store. The hook store is already the host's single owner of agent facts. The conversation lives on the same row, so it dies with the same close, exit and reset paths, and no second owner or cache is added.
  • Follow the common pattern. The server owns provider identity as a durable fact on its own record; status changes and release never touch it; a newer identity or an explicit clear replaces it; a restarting client re-derives it from the server.
  • Alternatives considered:
    • Sending desktops fix(mobile): keep a Codex pane's chat history after the phone app restarts #25358's stand-in "finished" status: rejected. Desktops would treat it as a real turn result and could raise duplicate completion notifications.
    • Treating a restored idle pane like "no status yet" so every client gets an ordinary finished status: same duplicate-notification risk, and identity would still ride inside status.
    • Letting each client decide from the tab title whether to offer the conversation: rejected. Clients see a different title than the host's terminal title in some cases, so old and new phones would disagree.

How this differs from the common pattern.

Difference Label Why
Identity is a record on the existing per-pane hook row, not a separate record Intended The hook store is the host's single owner; a second record would need its own teardown
Sent per terminal tab on the existing frame Intended Clients read transcripts by id themselves; an optional field needs no new stream or message type
A host-published "offer without status" flag Intended Only the host can tell whether the agent is still in front of a terminal; one decision serves every client
Phones in users' hands still get a stand-in status Temporary Remove once phones without the capability are no longer supported
When one agent runs inside another agent's terminal, the stored conversation follows whatever the store already keeps for the pane today Temporary #24297 fixes which agent owns the pane; this PR follows it automatically in either merge order
A row dismissed in the short window after a new turn starts and before Codex's next hook loses its conversation Temporary Same loss as today; a later change can keep it once older readers are gone
SSH connection loss still removes the row and its conversation Temporary #12070 keeps the binding across a transient disconnect
After a same-agent relaunch, the old conversation shows until the new process reports its session Temporary Same as today; a later change can supersede it when the new launch is observed

Mixed versions (docs/reference/remote-wire-compatibility.md). New optional fields only; no RPC parameter, stream message type or protocol bump. Old desktop + new host: ignores the fields, frames otherwise as with #25358. New desktop + old host: fields absent, today's behaviour. Old phone + new host: stand-in status as with #25358. New phone + #25358 host: falls back to the stand-in status. SSH: the SSH relay is unchanged; the host reads identity from relayed hook rows as today and never treats lost contact as an exit. Folder workspaces and Windows/WSL transcript paths are passed through unchanged. Downgrade: an older host ignores the saved conversation record and may overwrite it on its next save; a newer host that reads a record it does not understand treats it as missing and rebuilds it from the pane's existing session fields, so a later upgrade loses nothing a status would not already show.

Linked Issue

Follow-up to #25358 (Linear STA-7370). Supersedes #22646 for the same bug class; thanks @vesanieminen for the original report and approach.

Visual Proof

Pending: phone QA on the Android emulator and desktop QA run after review. Will be embedded here.

Testing

  • Fail-before: src/renderer/src/runtime/web-session-tabs-conversation-identity-cold-desktop.test.ts feeds a real host frame (statusless idle Codex pane, no launch record) through the real desktop mirror into Chat resolution. It failed on the old code at the session-id assertion and passes now.

  • Store: the conversation record's writers, OSC copies, held rows, SSH relay transcript polls, persistence and restart, and fix(agents): keep terminal resume identity with its provider owner #24297's owner rule emulated in both merge orders.

  • Host: one host decision drives both the phone stand-in and the new fields (real status builder, projection and per-client step); old and new phone readers agree on every title combination.

  • Desktop and phone readers: Chat resolution, gate memory on rename, entry points, Copy Agent Session ID, split panes, and the model picker sequences (status then field, same-millisecond model changes, reconnect gaps).

  • Ablations: removing each piece turns its tests red (17 of 17).

  • Legacy outputs: status snapshots, renderer status and notifications are byte-identical to before.

  • tc:node, tc:web, mobile typecheck, oxlint, anti-slop lint and the changed-lines code-quality gate pass.

  • Platforms: macOS unit tests only so far. Note: two locale test files are red on main since Add translations for terminal shell settings #25418 and are unrelated to this PR.

  • I manually tested these changes locally

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

Review

Pending.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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)

Author: Brennan Benson (X: @BrennanKB5)

…ript-7370' into brennanb2025/mobile-conversation-identity
…ript-7370' into brennanb2025/mobile-conversation-identity
…ript-7370' into brennanb2025/mobile-conversation-identity
…ane's conversation

Red on purpose: the host publishes the identity beside no status, and the
desktop has nowhere to mirror it yet.
… its status

The hook store dropped a pane's conversation address on status edges (an OSC
done->working repaint, a root hook with no session), so identity lived only as
long as a status that carried it. The owner row now holds a conversation facet
that changes only when an incoming event itself reported an address and
admission kept it; a repeat of the facet's address and model is a no-op, so
relayed transcript polls and replays move nothing. Carried-forward writes (OSC,
inference, transcript polls, held permission rows) never touch it. The facet
persists, hydrates (seeded from top-level fields for older rows) and is part of
the semantic row comparison so a facet-only change republishes.
…ield

A restarted paired desktop opened an idle headless Codex pane's chat empty,
because the conversation travelled only inside agentStatus and a neutral idle
title publishes no status. Each terminal tab now carries conversationIdentity
(derived from the store facet, else the status row's address) and, where the
builder's existing neutral-title rule offers it on a statusless tab,
conversationOfferedWithoutStatus. Phones without the new client capability
still get the identity folded into the same completion-neutral done status as
before; the private symbol carrier is gone.
The desktop mirror keeps each leaf's published identity and offer (transient,
never persisted, never merged into agent status). Chat resolution, the gate,
the header/menu/shortcut entry points and Copy Agent Session ID read it through
the shared selector; an offered statusless leaf may name its agent, a genuine
status never borrows it. The model picker treats a field model as a report only
when its report identity changes, so a user's pick survives status/field
switches.
…lded status

Phones advertise session-tabs.conversation-identity.v1 and read the field and
offer through the shared selector for chat eligibility, the transcript address,
the owned agent, attachments, keyboard dismissal and the model picker, so the
host stops synthesizing a done status for them.
…and persistence

Real-store cases: OSC edges, carried writes, inference and held permission rows
never move the facet; kept reports replace or re-model it once; nested
children follow the legacy address; eviction, persistence and facet-only
publication. A real relay forwarding into the host shows a transcript poll and
a cached-row replay leave the facet the same object. Copy Agent Session ID
reads the exact leaf's mirrored field.
…ffer decision

The real headless host publishes the field and offer to runtime clients and
capable phones and folds only for shipped phones; it keeps the field in the
done -> OSC working window, passes Windows paths and folder workspaces, adds no
churn frames, and its frame is byte-equal to the cold-desktop fixture (now
regenerated from that real frame). A parity fixture pins old/capable phone
frames from the real builder, projection and audience fold; the mobile half
runs the real phone readers on it. The desktop half covers entry points, split
leaves, Copy Agent Session ID and a status that lacks an agent.
…ktop and phone

Pickers on both clients keep a user's pick across status/field source switches
and no-evidence frames, take changed field reports and reseed on a new
conversation or clear. The chat gate substitutes its memory only without field
authority. Phones open an offered field and nothing unoffered; tab equality
sees identity- and offer-only changes; the desktop mirror never persists and
leaves completion, unread and notification facts as a field-less frame does.
The OSC path copies the previous row's address into its input; only the
carried classification keeps that copy from replacing a facet that names a
different conversation, or from reviving an explicit null.
…dress and reset

A row whose only change is its facet republishes exactly once; the desktop-host
path publishes the address its status keeps (renderer or hook row, with that
row's model) unless the store holds a facet; a provider generation reset leaves
no field.
…ith a schema

The four original-report call sites now call applyReportedStatus instead of
passing a trailing positional flag, the published identity is parsed with zod
rather than reflective reads, and the phone picker's report bookkeeping lives
beside its per-scope records.
…e host sees there

The conversation field had three wire states: an object, absent, and null.
The host published null for a facet whose agent did not match the pane's
launch-first owner, and every new client read null as "this pane has no
conversation", overriding a genuine status. In a tab Orca launched as
Claude where the user then ran Codex by hand, new desktops and phones lost
Chat history, Copy Agent Session ID and the reported model. A persisted
facet this version could not read also hydrated as a sticky null.

- The field is an object or absent; nothing publishes or reads null. The
  shared selector's authority is address or none, so the gate memory, the
  Copy ID fallback and the picker baseline no longer have a clear branch.
- The store read returns the agent the row names now beside the facet; the
  host publishes the facet only when its agent is compatible with that
  agent (else the launch/foreground owner). A hand-started agent that never
  reports a session no longer inherits the previous agent's conversation
  once its row ages out.
- A null or malformed persisted facet hydrates as absent and is seeded from
  the row's own address, like any row written before facets existed.
- Shipped phones get the folded status without the two conversation
  members they never read.
…gent now in the pane

The host checked a stored conversation against the pane row's agent, even when that
row was the remnant an exited agent leaves behind. After Claude exited and the user ran
a hookless agent such as aider by hand, the remnant still named Claude, so phones and
desktops were offered Claude's conversation for the aider pane.

A conversation is now published only when it matches every piece of current evidence
the host holds: a live (non-remnant) row's agent and the recognized foreground agent.
Only with neither does it fall back to the launch/hook owner. A hand-run Agent Teams
foreground reads as the Claude its hooks report. The published agent names the owner
when compatible, else the current agent, so a pi session under an omp row in a
Claude-launched pane publishes omp, as the status does.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing this stale stacked implementation while preserving the conversation-history problem. A restarted client should learn which conversation an idle pane holds without waiting for the agent to work again.

@zhibisora

Copy link
Copy Markdown

Is there a replacement PR or alternative approach for #25511 and #25358? Is further work planned to fix Chat history not loading after a client restarts while the Codex terminal is idle?

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.

2 participants