Skip to content

fix(claude): resume a native chat from its real latest message - #22395

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/claude-resume-point
Sep 24, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/claude-resume-point

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca reopens a native Claude chat, it used to tell Claude "continue from this exact message". The message Orca remembered was often old, and sometimes it was not a message at all. So a reopened chat quietly forgot recent turns, and newer Claude versions refused to start. Claude already knows where its own conversation ends. Now Orca just says "continue this conversation" and lets Claude pick up from its real latest state.

What Changed

Before. A long-running native Claude chat reopened at a point Orca had saved much earlier, sometimes a hook bookkeeping row from the day before. Each reopen branched the conversation off that point. Claude silently lost everything after it, while the chat still showed those turns on screen. With Claude 2.1.280 a point that is not on Claude's current chain fails in about a second with No message found with message.uuid of: …. The chat then showed "The session has no live owner to accept writes" and could not be used.

After. A reopened chat continues from Claude's real latest state, and it never wedges on a bad saved point. The screenshots below show a chat whose saved point was deliberately set back to its first message: after reopening, Claude still lists every earlier turn.

Mechanism

  • A plain reopen resumes by session id only. The launch passes Claude's session id and no --resume-session-at. Claude's own loader decides where the conversation continues, and it follows the end of the file after a crash. The launch identity check now compares the session id only.
  • Orca's saved leaf is bookkeeping, not a resume argument. At every turn's result, the live owner records the leaf of the completed turn in the durable record. It revises the head provider-handle link that this owner minted in place, so the chain does not grow per turn. The update refuses a stale fence, a lease that is not live, and a head minted by another owner or for another provider session. The revised chain must pass the persisted chain validator. A failed write is only logged and retried at the next turn end. A result that arrives after the child's exit is ignored.
  • Close, unexpected exit, and acquisition release no longer read the transcript. They wait for any in-flight turn-end write, then persist the last completed turn. A crash mid-turn therefore never saves a half-turn prompt as the conversation point.
  • Delivery reconciliation reads to the end of the file. When a chat reopens, Orca checks which queued prompts Claude already holds. It now proves the branch from the file's last main-chain transcript row back to the saved anchor, using an explicit tip mode in the transcript branch graph. Before, it stopped at Claude's last-prompt marker. A prompt Claude saved just before a crash now reconciles as delivered instead of being offered for a duplicate resend. The terminal handoff readers keep their existing marker-based behaviour.
  • Claude rewind is reported unsupported. Its proof depended on Claude writing a last-prompt marker at the rewind target right after start-up, which the real binary does not do, so on main it always refused with proof-mismatch. No app screen, mobile client, or CLI command calls it. The rewind launch, proof, and recovery code is removed. A Claude rewind left pending by an older build settles as refused on the next attach, and the chat resumes by session id. A failed settlement is logged and never blocks the chat. Codex rewind is unchanged.

Findings

  1. Claude's last-prompt marker is not the conversation tip. Claude writes it irregularly: at a fresh session's first prompt, next to title rows, and on a graceful exit after a turn. It writes none when a resumed child starts, and none on a kill. In the QA transcript the latest marker trailed the file by two turns. When the file's last row descends from the latest marker, Claude's loader continues from the file's last row. Otherwise it continues from the marker.
  2. Every same-session --resume-session-at creates a side branch in Claude's file. Whether Claude follows that branch later depends on whether a marker happened to be written. So passing a saved point on every reopen, which main does, is itself what produces branched conversations and lost turns.
  3. Real-binary check. A copy of the QA transcript was resumed two ways with Claude 2.1.280. By session id only, Claude continued at the file's last row and answered with both earlier words. At the point an earlier revision of this PR derived from the marker, Claude branched and answered with only the first word.

Why

Claude owns where its conversation continues, and it already follows the end of its own file after a crash. Orca can only guess that point, and every guess it passes as --resume-session-at makes a new branch that the next guess has to account for. Resuming by session id removes the guess and the branch-making together. Orca keeps its own record of the last completed turn because the journal's delivery reconciliation and history window need an anchor. It never feeds that record back to Claude as a resume point.

Alternatives considered:

  • Re-derive the resume point from the transcript at every reopen. An earlier revision of this PR did this. It reads Claude's marker, which lags, so it moved a stale point forward to another stale point and truncated the conversation there. The real-app QA caught it.
  • Keep --resume-session-at but only accept message rows. This fixes the start-up failure, but not the silent context loss or the side branches.
  • Append a chain link at every turn. The provider handle chain is capped at 256 links, so a long chat would overflow it. Revising the owner's head link in place gives the same durability.

Known gaps, left for follow-ups.

  • Claude rewind is off for now. The robust design forks the conversation into a new Claude session at the checkpoint and records it as a forked link. Orca's earlier approach cut the same session back instead. That is a separate change.
  • Transcripts that main already branched. Reconciliation walks the file's end, so for a transcript main already branched it can, once after upgrading, mark a prompt delivered on a branch Claude will not continue. main returned "unknown" in that case. Claude's next write puts the two back in line.
  • Chain growth on reopen. Each reopen still appends one resumed link toward the 256-link cap. This is not new, and this PR removes the extra close-time links main also added.

Linked Issue

Fixes #

Visual Proof

The same test on both sides: a chat answered ALPHA, then BRAVO. Its saved point was then set back to the first message, as happens when an owner dies before saving, and the chat was reopened and asked to list every word so far.

Before (an earlier revision of this PR, which re-derived the point from Claude's marker; main passes the stale point directly and loses the same turns). The screen still shows BRAVO, but Claude answers only ALPHA:

Before: stale point

After (this head). The reopen passes only --resume=<session id>, and Claude answers ALPHA BRAVO CHARLIE:

After: stale point

A saved point on a stop_hook_summary row, the reported wedge, now opens normally and answers with full context:

After: hook-row point

Full Electron QA write-ups, including the launch arguments, record-store values, and the renderer ownership checks for each run:

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Automated tests:

  • Launch. claude-structured-launch-resolution.test.ts: a reopen passes resume and no resumeSessionAt. A different saved leaf under the same session id still launches.
  • Turn-end write. claude-structured-turn-resume-point.test.ts and agent-session-provider-handle-transition.test.ts cover the per-turn write. The durable point advances after each turn, and the chain length and head link id stay the same. The revised record passes isAgentSessionRecord. The update refuses a stale fence, a released lease, a head minted at another fence, and another provider session. A failed write is logged and retried. A result after exit does not write.
  • Close, exit, release. claude-structured-resume-point.test.ts: all three persist the last completed turn without reading the transcript. A reopen followed by a close with no turn keeps the saved leaf. The close cursor lands after an in-flight write.
  • Reconciliation. claude-structured-history-window.test.ts and claude-transcript-branch-graph.test.ts: the history window ends at the last main-chain row and never at a trailing sidechain row. A prompt Claude saved just before a crash reconciles as accepted. File-tail mode proves a transcript that has no marker at all.
  • Pending rewind. structured-claude-pending-rewind.test.ts: a pending rewind from an older build settles as refused and the chat resumes by id, including a failed settlement.
  • Integration. claude-structured-session-integration.test.ts asserts the durable leaf advances during a live session with zero transcript reads at close.

Ablations: each change was removed on its own and the tests that pin it went red. That covers reintroducing resumeSessionAt from the saved leaf, persisting the live leaf at close, walking to the marker instead of the file tail, dropping the file-tail tip mode, and dropping the pending-rewind settlement.

Local runs:

  • pnpm tc:node, pnpm run check:code-quality:changed, and oxlint on every changed file pass.
  • src/main/claude, src/main/native-chat, and the touched src/main/runtime suites pass. The exceptions are the real-binary tests, which already fail on main on this machine.

Manual: Electron QA on macOS in a folder workspace, described under Visual Proof. Not tested: Linux, Windows, SSH (structured Claude only launches on the local host), and a git worktree workspace.

Review

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

  • SSH and remote. Structured Claude sessions only launch on the local host, and the launch resolver refuses any other execution host. The resume no longer reads the transcript at all.
  • Folder workspaces. Behaviour is the same as for git worktrees. The transcript used for reconciliation is found by session id under the account directory, not by working directory.
  • Wire compatibility. No RPC params, stream frames, or src/shared types changed. Claude rewind is reported through the existing unsupported refusal reason on the existing optional support field.
  • Backward compatibility. The record schema is unchanged. Records written by this build carry a real message leaf, so main can still read them after a rollback. Records written by main are only used as an anchor here.
  • Performance. Close, exit, and release no longer read the transcript. A reopen keeps one bounded two-pass read for reconciliation. Each turn end does one serialized record write, which is skipped when the leaf has not moved.

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)

Claude's last-prompt marker names the chain tip, which is often a stop-hook
summary or attachment row that --resume-session-at rejects. The branch proof now
resolves the marker to the latest main-chain message, and a plain resume
re-derives its point from the transcript instead of trusting the stored cursor,
resuming by session id alone when the transcript cannot vouch for one. An
acquisition release now reads the transcript tail like close and exit do.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Completed Claude turns now update the durable provider-handle leaf in place. Claude launches resume by session ID without a leaf cursor, while close and exit persist the last completed-turn leaf. Transcript history proof now targets the last main-chain row. Claude rewind acquisition is removed, and pending Claude rewind records are settled as unsupported during reattachment.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to c5e9d

Restarted chats continue the provider conversation without replaying the prompt. Correct the comment before merging so it does not mislead future changes to resume behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 35 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the user impact, mechanism, rationale, testing, visual proof, compatibility, and known gaps. However, the required Linked Issue section is incomplete because it … Add the valid issue number to the Linked Issue section. Reconcile the checklist with the actual verification results by either running and reporting pnpm lint, pnpm typecheck, pnpm test, and pnpm build, or marking those checks as CI-covered…
✅ 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 clearly and concisely describes the main change: resuming native Claude chats from their latest message.
Full details: Description check

Explanation

The description is detailed and covers the user impact, mechanism, rationale, testing, visual proof, compatibility, and known gaps. However, the required Linked Issue section is incomplete because it contains only "Fixes #", and the checklist claims full lint, typecheck, test, and build success while the testing section reports only targeted suites and partial checks.

Resolution

Add the valid issue number to the Linked Issue section. Reconcile the checklist with the actual verification results by either running and reporting pnpm lint, pnpm typecheck, pnpm test, and pnpm build, or marking those checks as CI-covered and documenting the exceptions.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

  • Transcript leaf is now a message — claude-transcript-branch-graph.ts resolves Claude's last-prompt marker to the latest main-chain user/assistant message (messageAtOrAbove) instead of accepting a hook-summary/attachment tip.
  • A plain reopen re-derives its resume point — new rederiveClaudeResumePoint reads the transcript (readClaudeTranscriptLeafWithReproof) and rewrites --resume-session-at before spawn; a failure falls back to resuming by session id. Skipped for requested rewinds and their recovery.
  • Acquisition release reads the transcript — readTranscriptLeaf is now threaded through releaseClaudeAcquisition, so a release persists a transcript-derived cursor rather than only the in-memory one.
  • Tests — new claude-structured-resume-point.test.ts (13 cases) plus three updated existing suites for the extra read.

Verified locally: pnpm tc:node and oxlint clean; all src/main/claude and session-file-resolver tests pass except four process-exit-proof failures in claude-agent-sdk-exit-proof / claude-stream-json-connection that are unrelated to this diff.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

A completed turn now writes the live main-chain message uuid onto the owner's
head provider-handle link in place, so a host that dies before its close path
runs still resumes from its last completed turn and the chain does not grow per
turn. The write is serialized per session, only logged on failure, and close and
exit persist after it settles.

Co-Authored-By: Claude <[email protected]>

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Durable resume point advances at every turn end — new persistClaudeTurnResumePoint schedules a serialized write of the live leaf whenever a result frame arrives; writes chain on the prior one, and a failure only logs, so a turn is never failed or held up.
  • Head provider-handle link is revised in place — new reviseAgentSessionClaudeResumePoint moves the head link's leafUuid and observedAt without appending, so the chain does not grow per turn. It refuses a stale fence, a non-live lease, and a head minted by another owner or for another provider session, and re-validates the revised chain.
  • Close and exit wait for the in-flight turn-end write — finalizeClaudePublishedSession and persistClaudeSessionHandle now await session.resumePointWrite?.settled before persisting their transcript-derived cursor, so the close/exit cursor lands last (acquisition release reuses the close path).
  • Tests — new claude-structured-turn-resume-point.test.ts (4 cases) covering in-place advance without chain growth, crash recovery via the real launch resolver, close-write ordering, and failed-write tolerance, plus reviseAgentSessionClaudeResumePoint cases and the integration test's live-head assertion updated.

I re-ran the new and touched suites (claude-structured-turn-resume-point, claude-structured-resume-point, agent-session-provider-handle-transition, claude-structured-session-integration, claude-structured-session-recovery, claude-structured-rewind, claude-structured-session-adapter): 91 tests pass. tsc -p config/tsconfig.node.json --noEmit is clean. I also traced every reader of providerHandleChain / provenHandleLinkId / identity.providerHandle in src/main for the in-place head revision: none compares a captured handle against the live head or treats the head leaf as a durable anchor, and renewAgentSessionLease does not bump runtimeFence, so the write's session.fence check stays valid for a live owner.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…after exit

A turn-end write that failed was never retried when the next turn ended at the
same point, because the memo of the last attempted leaf outlived the failure.
A result frame delivered after the child's exit could also start a write that
landed behind the exit path's transcript-derived cursor, moving the durable
point backwards. The failed leaf is now forgotten so the next turn end retries
it, and a turn-end write only runs while the session is still the published
live owner.

The session-id fallback on a plain reopen and a failed durable write on the
unexpected-exit path now log why, instead of leaving no trail.

@pullfrog pullfrog 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.

✅ No new issues found in this delta.

Reviewed changes

  • Turn-end write retries after a failure — persistClaudeTurnResumePoint's rejection handler now clears session.resumePointWrite when it still points at the failed write, so the next result frame retries even when the leaf has not moved.
  • A result trailing the child exit no longer writes — the acquisition message path gates the turn-end write on sessions.get(sessionId) === liveSession; handleExit deletes that entry synchronously, so a late result cannot land behind the exit path's transcript-derived cursor.
  • Failure logging replaces silent drops — the transcript fallback now logs the stored cursor and the reason it could not be vouched for, and the unexpected-exit durable-write failure is logged instead of swallowed.
  • Tests — retry-on-unmoved-leaf, late-result-after-exit, exit-write-failure logging, and the fallback diagnostic are pinned; claude-structured-turn-resume-point, claude-structured-resume-point, and claude-structured-session-adapter pass (57 tests).

I traced the new guard and retry against the close and exit paths: close sets closeFinalization before awaiting resumePointWrite?.settled, so no new turn-end write can be scheduled mid-close, and the failed-write clear is conditional on still being the current write, so a newer in-flight write is never clobbered.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

brennanb2025 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Correction (reviewer). Scenario E is not an independent failure. Scenario D had already continued the conversation from the ALPHA reply, which dropped BRAVO. In E, the reopen correctly continued from that latest branch, so the answer ALPHA was consistent with the conversation at that point. What E does show is that a stored point on a hook-summary row no longer wedges the chat. Scenario D is a real failure of this head and is being addressed: a plain reopen will resume by session id so Claude continues from the actual end of its own conversation.

Electron QA for the native Claude chat resume point. Worktree /Users/brennanbenson/orca/workspaces/orca/claude-resume-point-qa, branch brennanb2025/claude-resume-point-qa, head caff6a8f027ec07aed4d4d317348bbae9045ce63.

Renderer ownership, checked on every attach: http://127.0.0.1:5174/@fs/Users/brennanbenson/orca/workspaces/orca/claude-resume-point-qa/package.json returned 200. The same request for .../claude-resume-point/package.json returned 403.

The chat was the structured lane in a folder workspace (/tmp/qa22395-repo): tab "Claude Chat", composer Send a message….

A. Two turns

Sent Reply with exactly the word ALPHA and nothing else. Assistant text: ALPHA (Worked for 2s).
Sent Reply with exactly the word BRAVO and nothing else. Assistant text: BRAVO (Worked for 2s).

Two turns

B. Durable point after those turns

Store: /tmp/qa22395/agent-sessions/agent-sessions.json. Top-level keys are schemaVersion, hostId, records, operations, retiredClaimKeys, unusableRecords, visibleSessionIds. No checksum or integrity field.

  • accountHome.path: /Users/brennanbenson/.claude
  • chain length: 1 (it did not grow across the two turns)
  • head link: origin created, linkId claude-1-3468a88c-1007-49b5-81a4-d172395ca057-empty, sessionId 3468a88c-1007-49b5-81a4-d172395ca057, leafUuid fea34421-34d5-4d74-86ba-b0c19b6b561a

Transcript: /Users/brennanbenson/.claude/projects/-private-tmp-qa22395-repo/3468a88c-1007-49b5-81a4-d172395ca057.jsonl. The last user/assistant row is the BRAVO assistant, uuid fea34421-34d5-4d74-86ba-b0c19b6b561a. The head leafUuid equals that uuid.

C. SIGKILL, then reopen

The dev runner process group was SIGKILL'd. CDP 9334 and the renderer port were gone. After relaunch on the same profile, the Claude Chat tab was restored with both earlier rows visible.

Sent Which two words did I ask you to reply with, in order? Answer with only the two words.
Reply verbatim: ALPHA BRAVO

Head leaf after that turn: 106be722-fde2-45f6-97f3-6c1b55fcb326, equal to the new assistant uuid. Chain length became 2 (a resumed link was added).

Startup log before the question: transcript branch proof failed (latest marker is on a sibling branch); resume continued by session id, storedLeafUuid still fea34421-34d5-4d74-86ba-b0c19b6b561a.

Reopen after kill

D. Stale leaf set to the first user message

The store has no checksum, so the edit was possible. With the app down, the head link's handle.leafUuid was changed from 106be722-fde2-45f6-97f3-6c1b55fcb326 to 9ebfa53b-f13f-4b5b-b5ac-5ce052d6482c (the ALPHA prompt). 27 bytes differed; the rest of the file was unchanged. The older link's leaf stayed fea34421-34d5-4d74-86ba-b0c19b6b561a.

Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: ALPHA

The rendered history still showed BRAVO and the earlier ALPHA BRAVO answer. The new answer did not include BRAVO.

After the turn, head leaf d9af3497-8f76-48f3-8a1a-5362d96e7830 matches that new assistant row (text ALPHA). Chain length 3. The previous link still holds the stale uuid.

Reopen with stale point

E. Stored point is a system row

The transcript has system rows with subtype stop_hook_summary and uuids that are not init, including 088c3314-59af-4c44-ab7e-874a83442f7c. No user row is a hook attachment. With the app down, the head leaf was set to that system uuid (30 bytes differed).

Startup log: the same sibling-branch proof failure, then resume by session id with storedLeafUuid 088c3314-59af-4c44-ab7e-874a83442f7c. The chat tab opened. The UI did not show No message found.

Sent the same list prompt. Reply verbatim: ALPHA

Head leaf after the turn: 20805f97-664b-4839-8391-7e3c387bb327, matching that assistant row. Chain length 4.

Reopen with system-row point

Not verified

  • A user row that is a hook attachment. This transcript had none, and none was added.
  • A resume where the transcript branch proof succeeds. C and E both logged that the latest marker is on a sibling branch and resumed by session id.
  • Graceful quit. The reopen paths were SIGKILL only.
  • A git worktree workspace. This run used a folder workspace.
  • SSH or any other execution host.
  • Any provider other than this Claude structured chat.

…laude's marker

A plain reopen now passes only the session id, so Claude continues from the
real end of its own conversation. Orca's saved leaf is its own record of the
last completed turn, taken from the live stream at each turn end. It is
bookkeeping (the reconciliation anchor), never a resume argument.

- Launch resolution resumes by id and checks only the session id; the prior
  head leaf is carried into the publication link.
- Remove the launch-time transcript re-derivation.
- Close, unexpected exit, and acquisition release no longer read the
  transcript. They wait for any in-flight turn-end write, then persist the
  last completed turn, so a crash mid-turn never saves a half-turn prompt.
- The delivery-reconciliation window walks from the file's last main-chain
  transcript row to the anchor instead of Claude's lagging marker, so a
  prompt Claude saved just before a crash reconciles as accepted.
- Revert the transcript branch graph to main; the terminal handoff readers
  keep their semantics.
- Report Claude rewind as unsupported. Its marker-based proof can never pass
  on the real binary, and no app screen calls it. Remove the Claude rewind
  launch, proof, and recovery path. A pending Claude rewind left by an older
  build is settled as refused on the next attach, which resumes by id; a
  failed settlement is logged and never blocks the chat.

@pullfrog pullfrog 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.

ℹ️ No critical issues — minor description/cleanup suggestions below.

Reviewed changes

  • Resume by session id only — --resume-session-at and resumeDropsTurn are gone; a resumed Claude launch passes resume alone and the stored leaf is bookkeeping (resumeLeafUuid). The durable-identity guard now compares only the provider session id, so a leaf that moved no longer blocks a launch.
  • Claude rewind removed — the rewind proof stack (ClaudeRewindAttempt, claudeRewindAcquisitionProofs, replaceClaudeRewindOwner, readClaudeTranscriptLeafWithReproof) is deleted; rewindSupport reports unsupported, and a pending prepared/provider-succeeded Claude rewind is settled refused on attach.
  • History window tips at the file's last row — new createTailTipBranchProof synthesizes the marker from the last main-chain transcript row, so a prompt written just before a crash reconciles as accepted rather than not_delivered.
  • Durable point is the last completed turn — ClaudeSession.turnEndLeafUuid advances on result; close and exit persist it via settledClaudeTurnEndLeaf after the in-flight write settles.
  • Tests — a crash-between-prompt-and-echo history-window case, a new structured-claude-pending-rewind.test.ts, and updates across the claude suites.

I ran the touched suites (1242 pass; only the four known sandbox exit-proof failures) and two independent specialists refuted the tail-tip and rewind-removal hypotheses.

ℹ️ PR description still documents the superseded --resume-session-at design

The description's ELI5, Findings, Mechanism, and Testing sections describe resolving the stored leaf to a real message and re-deriving it before spawn via --resume-session-at, and the rewind paragraph says "Rewinds are unchanged." Commit 5cb901c removes --resume-session-at entirely (resume by session id) and reports Claude rewind unsupported, so the description misstates both the mechanism and a user-facing capability change, and its Testing list references deleted tests. Please update it before merge so reviewers and future archaeology do not trust the old model.

Technical details
# Stale PR description after the resume-at pivot

## Affected sites
- PR description (ELI5, Findings, Mechanism, Testing, "Rewinds are unchanged") — still describes `--resume-session-at` re-derivation and claims rewinds are unchanged.
- `src/main/claude/claude-structured-launch-resolution.ts:239-243` — a resumed launch now emits `resume` alone.
- `src/main/claude/claude-structured-session-adapter.ts:63-67` — `rewindSupport` is a constant unsupported.
- `src/main/native-chat/agent-session-wire/structured-rewind-recovery.ts:33-59` — a pending Claude rewind is settled refused, not left pending.

## Required outcome
- The description matches shipped behavior: resume by session id, stored leaf as bookkeeping, Claude rewind unsupported, and the tests that actually exist.

## Open questions for the human (optional)
- Is disabling Claude rewind intended to land in this fix, or should it be split out so the capability change is reviewed on its own?

ℹ️ Nitpicks

  • src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-runner.ts:9-11 still says Claude re-acquires at "resume + resumeSessionAt"; only resume remains.
  • After the rewind removal, intentionalRewindUuid / the intentional-rewind relation in src/main/claude/claude-transcript-branch-graph.ts has no production caller (only claude-transcript-rewind-proof.test.ts and claude-transcript-branch-streaming.test.ts exercise it). Keep it only if the fork-based rewind will reuse it.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…sume note

The restart path resumes Claude by session id alone now; the module comment
still described the old resume-at cursor.

@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: Advanced

Run ID: 900ffc92-00eb-4212-bb80-eb1eb24ebec4

📥 Commits

Reviewing files that changed from the base of the PR and between 5cb901c and c5e9d3a.

📒 Files selected for processing (1)
  • src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-runner.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

Comment on lines +9 to +10
// Codex's thread id — which is native continuation. Nothing re-sends the user's prompt: that is
// what makes an agent redo work it already finished.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,180p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-runner.ts
rg -n 'resume-capable|childless|resumeSessionAt|resume:' src/main/native-chat/agent-session-wire src/main/claude/claude-structured-launch-resolution.ts

Repository: stablyai/orca

Length of output: 8290


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- restart resume host ---'
sed -n '130,190p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-host.ts
printf '%s\n' '--- host lifetime ---'
sed -n '150,215p' src/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.ts
printf '%s\n' '--- Claude launch resolution ---'
sed -n '200,260p' src/main/claude/claude-structured-launch-resolution.ts
printf '%s\n' '--- provider and resume references ---'
rg -n -C 4 'resumeSessionAt|resumeSession|threadId|providerSessionId|structured.*launch|launch.*option|resume:' src/main src/test test 2>/dev/null | head -n 260
printf '%s\n' '--- restart resume tests ---'
sed -n '520,640p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume.test.ts
printf '%s\n' '--- relevant files ---'
git ls-files | rg '(^|/)(codex|claude|structured-agent-session|agent-session-wire).*(launch|resume|adapter|test)|provider'

Repository: stablyai/orca

Length of output: 41746


🏁 Script executed:

printf '%s\n' '--- restart resume host ---'
sed -n '145,185p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-host.ts
printf '%s\n' '--- host lifetime ---'
sed -n '160,210p' src/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.ts
printf '%s\n' '--- Claude launch resolution ---'
sed -n '220,255p' src/main/claude/claude-structured-launch-resolution.ts
printf '%s\n' '--- focused resume tests ---'
sed -n '540,635p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume.test.ts
printf '%s\n' '--- resume option references ---'
rg -n -C 3 'resumeSessionAt|resumeSession|providerSessionId|threadId|resume:' src/main/native-chat src/main/claude src/main/codex 2>/dev/null

Repository: stablyai/orca

Length of output: 45545


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- resumed acquisition implementation ---'
rg -n -C 8 'function resumeHeldStructuredAgentSession|const resumeHeldStructuredAgentSession|resumeHeldStructuredAgentSession' src/main/native-chat/agent-session-wire
printf '%s\n' '--- acquisition options tests ---'
sed -n '1,230p' src/main/native-chat/agent-session-wire/structured-agent-session-acquisition-options.test.ts
sed -n '400,500p' src/main/native-chat/agent-session-wire/structured-agent-session-acquisition-options.test.ts
printf '%s\n' '--- provider launch/resume tests ---'
rg -n -C 6 'resume: providerSessionId|sessionId: providerSessionId|resumed:|resumeLeafUuid|resume.*thread|thread.*resume' src/main --glob '*test.ts' --glob '*test.tsx' | head -n 260

Repository: stablyai/orca

Length of output: 42203


🏁 Script executed:

set -o pipefail
sed -n '1,155p' src/main/native-chat/agent-session-wire/structured-agent-session-hold-resume.ts
printf '%s\n' '--- adapter acquire contract ---'
rg -n -C 8 'interface StructuredAgentSessionAdapter|type StructuredAgentSessionAdapter|acquire:' src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts src/main/native-chat/agent-session-wire/structured-agent-session-attach-flow.ts

Repository: stablyai/orca

Length of output: 6185


Correct the native-continuation rationale.

Native continuation does not resend the user's prompt. It resumes the provider's conversation and prevents the agent from repeating work it already completed.

Suggested comment fix
-// what makes an agent redo work it already finished.
+// what prevents an agent from redoing work it already finished.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Codex's thread id — which is native continuation. Nothing re-sends the user's prompt: that is
// what makes an agent redo work it already finished.
// Codex's thread id — which is native continuation. Nothing re-sends the user's prompt: that is
// what prevents an agent from redoing work it already finished.

The reconciliation readers proved the transcript tip by re-parsing every
line and feeding a synthetic last-prompt row through the graph, doubling
parse cost on every reopen and coupling the tail path to the marker's
JSON shape. The graph now takes tip: 'file-tail' and tracks the last
main-chain row from its own parse; marker mode is unchanged and the
no-eligible-tail fallback keeps the exact marker semantics.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • File-tail branch proof moved into the graph — createBranchProof now takes tip?: 'marker' | 'file-tail'; in file-tail mode the graph tracks the last main-chain row and finish overrides the leaf to it, replacing the createTailTipBranchProof wrapper and the transcriptTailUuid re-parse in claude-transcript-branch-proof.ts.
  • Replay entry points request the tail explicitly — replayClaudeTranscriptBranchAncestry{FromJsonl} pass tip: 'file-tail', and AncestryInput is Omit<BranchProofInput, 'tip'> so a caller cannot override it.
  • Tests — new claude-transcript-branch-graph.test.ts cases pin the file-tail tip when no last-prompt row exists, and that marker mode still requires the marker on the same bytes.

The refactor is behavior-preserving. The old wrapper appended a synthetic last-prompt row at nextIndex and let the unchanged graph resolve it; the new code sets the same leafUuid / leafMarkerLineIndex in place at finish, so the leaf.lineIndex > leafMarkerLineIndex guard, the ancestry walk, and the sibling-branch path all resolve identically. Marker-mode callers (proveClaudeTranscriptBranch, proveClaudeTranscriptBranchFromJsonl) are untouched. I ran the four touched suites (claude-transcript-branch-graph, claude-structured-history-window, claude-transcript-rewind-proof, claude-transcript-branch-streaming): 53 tests pass.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA v2 for native Claude chat resume-by-session-id. Worktree /Users/brennanbenson/orca/workspaces/orca/claude-resume-point-qa, head c5e9d3ac56839131fb0648112ecebe037952b35f.

Renderer ownership on every attach: http://127.0.0.1:5210/@fs/Users/brennanbenson/orca/workspaces/orca/claude-resume-point-qa/package.json returned 200. The same request for .../claude-resume-point/package.json returned 403. Profile /tmp/qa22395v2, folder workspace /tmp/qa22395v2-repo. Structured lane: tab "Claude Chat", composer Send a message….

A. Two turns — PASS

Launch argv (new chat, no --resume, no --resume-session-at):

claude --session-id=abba65f4-106a-42ff-94c1-b2e3e5a444cd --output-format stream-json --verbose --input-format stream-json --permission-prompt-tool stdio --setting-sources=user,project,local --permission-mode default --include-partial-messages --replay-user-messages --dangerously-skip-permissions

Sent Reply with exactly the word ALPHA and nothing else. Reply: ALPHA.
Sent Reply with exactly the word BRAVO and nothing else. Reply: BRAVO.

Store /tmp/qa22395v2/agent-sessions/agent-sessions.json, session claude_21c02aeb_6539_48dc_9610_17935adc04fa. Chain length 1 after both turns. Head leafUuid 6b6d563b-9de8-4232-886a-3c22bf556488, equal to the BRAVO assistant uuid in ~/.claude/projects/-private-tmp-qa22395v2-repo/abba65f4-106a-42ff-94c1-b2e3e5a444cd.jsonl.

Two turns

B. SIGKILL, then reopen — PASS

Reopen argv: claude --resume=abba65f4-106a-42ff-94c1-b2e3e5a444cd with the same stream-json flags. No --resume-session-at.

Sent Which two words did I ask you to reply with, in order? Answer with only the two words.
Reply verbatim: ALPHA BRAVO.

Head leaf after that turn: 654587a6-9a0f-40a4-b4a3-b949de1556e6, equal to the new assistant uuid. Chain length 2.

Reopen after kill

C. Close handshake, then reopen — PASS

window.api.ui.requestClose() emptied the CDP page list and the Claude child exited. The dev process kept the debug port, so that leftover process was stopped only after the window and Claude child were already gone, then the same profile was relaunched.

Reopen argv: claude --resume=abba65f4-106a-42ff-94c1-b2e3e5a444cd. No --resume-session-at.

Sent Reply with exactly the word CHARLIE and nothing else. Reply: CHARLIE.
Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: ALPHA BRAVO CHARLIE.

Head leaf 995b7289-16ff-4a75-81b4-7db876924d62, equal to that assistant uuid. Chain length 3.

Close then reopen

D. Stale but valid stored point — PASS

With the app down, only chat 1's head handle.leafUuid was changed to the first user row, the ALPHA prompt d014d72c-6af7-4460-8ac0-0fe812e21ba7. cmp -l | wc -l was 27. No checksum field. No other field changed.

Reopen argv: claude --resume=abba65f4-106a-42ff-94c1-b2e3e5a444cd. No --resume-session-at.

Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: ALPHA BRAVO CHARLIE.

The edited link still holds d014d72c-6af7-4460-8ac0-0fe812e21ba7. The new head leaf 866b33c8-2018-4bd3-8306-6e42055393ae equals the new assistant uuid. Chain length 4.

Stale point

E. Hook-summary stored point, fresh chat — PASS

Chat 2 session 2714cb55-ca3b-472d-964d-a29a218a145c. Fresh argv used --session-id=2714cb55-ca3b-472d-964d-a29a218a145c and did not use --resume or --resume-session-at.

Sent Reply with exactly the word DELTA and nothing else. Reply: DELTA.
Sent Reply with exactly the word ECHO and nothing else. Reply: ECHO.

A real system row with subtype stop_hook_summary existed (113459d7-2664-4bbe-8a04-57c7bb7d211d, after ECHO). With the app down, only chat 2's head leaf was set to that uuid. cmp -l | wc -l was 28. Chat 1 was unchanged.

Reopen argv: claude --resume=2714cb55-ca3b-472d-964d-a29a218a145c. No --resume-session-at. The chat opened on the DELTA and ECHO rows. No stuck state and no "no live owner" text.

Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: DELTA ECHO.

Head leaf f8059a6e-56a0-400e-b971-a603eb07ade5, equal to that assistant uuid. The previous link still holds the hook uuid.

Hook row point

Not verified

  • SSH or any other execution host.
  • Agents other than this Claude chat.
  • Whether requestClose by itself exits the macOS dev process. The page list went empty and the Claude child exited; the dev process was then stopped so the debug port could be reused.
  • A stored point that is not a real transcript uuid. The hook row used above is a real stop_hook_summary.
  • Windows and Linux.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA v3 on the final head. Worktree /Users/brennanbenson/orca/workspaces/orca/claude-resume-point-qa, head b83a738f1bf52fafc8217fe9d94143e04f3dff6e. Same profile as v2 (/tmp/qa22395v2), CDP 127.0.0.1:9360, renderer 127.0.0.1:5210.

Ownership on every attach: /@fs/.../claude-resume-point-qa/package.json = 200, /@fs/.../claude-resume-point/package.json = 403.

Main rebuild after the fast-forward, from the dev runner log for launch pid 59213: out/main/index.js 8,002.08 kB, ✓ built in 2.29s, then electron main process built successfully.

F. Reopen chat 1 on this head — PASS

Chat 1 argv: claude --resume=abba65f4-106a-42ff-94c1-b2e3e5a444cd with the stream-json flags. It contains --resume=. It does not contain --resume-session-at.

Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: ALPHA BRAVO CHARLIE.

Final head reopen

G. SIGKILL during a chat 2 turn, then reopen — PASS

Sent Count slowly from 1 to 40, one number per line. The process group was SIGKILL'd when the assistant text on screen was 1 and 2 and Worked for was not shown yet. Reopen argv: claude --resume=2714cb55-ca3b-472d-964d-a29a218a145c. No --resume-session-at.

The interrupted prompt is delivered. The chat shows that count prompt and the partial assistant lines 1 and 2. There is no resend offer and no error. An earlier copy of the same prompt is also visible from a kill that happened before any assistant text; that copy has no assistant lines.

Sent List every word I asked you to reply with so far, in order, separated by spaces.
Reply verbatim: DELTA ECHO.

Reopen after mid-turn kill

Not verified

  • SSH or any other execution host.
  • Agents other than these two Claude chats.
  • Windows and Linux.
  • A resend offer for a different interruption point. This reopen showed the partial lines and no resend control.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for human review at b83a738f1b

Every Electron QA scenario passes on the final head. CI is green and the end-of-session readiness checklist found nothing blocking.

What the review changed

  • First two review loops. They kept the original design and fixed four defects in it. A failed turn-end save was never retried. A turn result arriving after the Claude process exited could move the saved point backwards. Two failure paths swallowed errors silently.
  • Electron QA then found a real failure in that design. A chat whose saved point was stale reopened and silently forgot a turn: the screen showed BRAVO, but Claude answered only ALPHA. The cause was Claude's last-prompt marker, which is not written after every turn. Re-deriving the point from it just moved a stale point to another stale point. This was confirmed on the real Claude 2.1.280 binary against a copy of the transcript.
  • Architecture change. A plain reopen now resumes by session id only, and Claude decides where its conversation continues. Orca's saved leaf is kept only as its own record of the last completed turn. Close, exit, and release no longer read the transcript. Delivery reconciliation reads to the end of the file instead of the marker. The PR body describes the mechanism and the alternatives.
  • Loops 3 and 4 came back clean. Loop 3 fixed a stale code comment. Loop 4 replaced a synthetic marker row, and a second full parse of the transcript on every reopen, with an explicit tip option in the branch graph.

Validation

  • Electron QA on macOS in a folder workspace. It covered two turns, reopen after a kill, reopen after a normal close, a stale saved point, a hook-row saved point, and a kill mid-turn. All pass, and every reopen's Claude command line has --resume=<session id> and no --resume-session-at. Details are in the two QA comments above.
  • Readiness checklist at the start and at the final head: no P0 or P1 findings.
  • Local gates. pnpm tc:node, the changed-code quality gate, and oxlint pass. The touched suites pass except two real-binary tests that already fail on main on the test machine. Each new test was checked by removing the code it pins and watching it fail.

Scope note for the reviewer

  • Claude rewind is now reported as unsupported, and its launch, proof, and recovery code is removed. On main it always refused, because it waited for a marker the real binary never writes at that moment. No app screen, mobile client, or CLI command calls it. A rewind left pending by an older build settles as refused, and the chat opens normally. Codex rewind is unchanged.

Follow-ups, not in this PR

  • Restore Claude rewind by forking the conversation into a new Claude session at the checkpoint.
  • Transcripts that main already branched: reconciliation may, once after upgrading, mark a prompt delivered on a branch Claude will not continue.
  • Each reopen still appends one link toward the provider handle chain's 256-link cap. This is not new, and this PR reduces the growth.
  • The terminal handoff readers still read Claude's marker; they need the same audit.

Not tested: Linux, Windows, SSH (structured Claude only launches locally), and a git worktree workspace.

@brennanb2025
brennanb2025 merged commit c4dfd9d into main Sep 24, 2026
32 checks passed
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