Repository navigation
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
Conversation
…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.
6 of 9 tasks
…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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On a headless
orca servehost, 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 servehost. A Codex terminal pane on the host has finished a turn and Codex is still open and idle.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.
codex(no launch record)zsh, live question)How it works.
conversationrecord: 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.conversationIdentityand an optionalconversationOfferedWithoutStatus: 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).session-tabs.conversation-identity.v1capability 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 itsterminalTitleis the tab's title as the client sees it. No shipped phone reads either for display.Files (main areas).
src/main/agent-hooks/server/server-conversation-facet.ts(new) plus the write sites inserver-status-update.ts,server-ingest-remote.ts,server-ingest-normalization.ts,server-status-retries.ts, persistence, hydration and row comparison.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).src/shared/terminal-conversation-identity.tsandterminal-conversation-model-report.ts(new), tab contracts, the capability constant.web-session-tabs-sync/terminal-build.ts, native chat resolution, gate, availability, options, shortcut, tab menu,pane-agent-session-id.ts, workspace-session sanitizing.Why
How this differs from the common pattern.
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.tsfeeds 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
mainsince 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
docs/reference/agent-skill-sharing-upstream-boundary.mdand 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: Brennan Benson (X: @BrennanKB5)