Files
Brennan Benson a13c51fb3d Let Continue in Chat UI switch when Orca can't prove the terminal stopped, and start unsaved conversations fresh (#40033)
* fix(native-chat): let Continue in Chat UI switch when Orca can't prove the terminal stopped

Continue in Chat UI closed the agent's terminal and then refused the chat
unless the host proved a clean exit, so an idle Claude on a slow or remote
host failed with "couldn't confirm Claude stopped". Any settled exit wait now
lets the chat start; the host's create still refuses a conversation another
terminal holds, using the hook rows and foreground-process checks it already
has. The wait outlasts the host's explicit-close stop.

A conversation the agent never saved (nothing sent yet) has no history to
open, so every Retry failed. After the terminal closes, that chat now restarts
in the same tab as a new conversation instead.

Tracked in #39085.

* fix(native-chat): read a Claude transcript nothing was sent in as empty, and let an unknown writer check switch

A Claude session that never got a message can leave a metadata-only
transcript. Its import found no turns and refused as unreadable, so Continue
in Chat UI still failed. A Claude file with no user or assistant record now
reads as empty, the same refusal a missing transcript gets, which the
handoff answers by starting the chat as a new conversation. Records Orca
can't decode still count as a conversation, so unreadable history keeps
failing.

A host that couldn't say whether it checked other terminals no longer stops
the switch before the close; the create checks them again.

* fix(native-chat): read an empty Claude transcript as empty through adoption, and a broken record as a possible turn

Adoption checks a transcript's identity before using it, and a metadata-only
file carries no working directory, so the empty file still refused as
unreadable. A file with no conversation adopts nothing, so it skips that
check. A record too broken to parse may be a turn, so it keeps the history's
own failure instead of reading as empty.

* fix(native-chat): only a typed record with no message reads as Claude metadata

A record shaped like a turn but missing a known type could read as metadata,
so a transcript holding a real prompt could be taken for one nothing was sent
in. Now only a JSON object with a non-empty type other than user or assistant
and no message counts as metadata; anything else may be a turn and keeps the
history's own failure.

* refactor(native-chat): narrow the Claude record type without a cast

* fix(native-chat): read a Claude meta user record as metadata when it shows nothing

A Claude session where only a local command ran, such as /rename, saves a
user record Claude flags as meta and no turn, so Continue in Chat UI still
failed for it. A meta user record the decoder can't show now counts as
metadata; one it shows, such as a tool result, still counts as a turn.
2026-11-08 17:54:53 -08:00
..