Skip to content

fix(native-chat): a send with no live owner restarts it once - #22359

Merged
brennanb2025 merged 78 commits into
brennanb2025/claude-init-deadlinefrom
structured-send-recovery
Sep 24, 2026
Merged

brennanb2025 merged 78 commits into
brennanb2025/claude-init-deadlinefrom
structured-send-recovery

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 231 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14535 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4532 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10003
Prod 1167 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11531 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4960 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6571

ELI5

If a chat's agent process stopped (for example, Claude took too long to start and was shut down), every message you sent after that was told "not ready yet, try again" — forever. Retry just resent the same message into the same dead end. Now sending a message first checks that the chat has a running agent, and starts one again if it doesn't, then delivers the message — all as one step, so nothing else can slip in between. If the agent is still starting when you send, the message is held for it and delivered the moment it is ready; if the agent dies while starting, the message is marked as failed with the reason, the chat shows that reason, and nothing keeps retrying on its own. Separately, an agent nobody is looking at now stays up for 30 minutes of quiet instead of 15 seconds, so returning to a chat or sending to one in the background rarely has to restart it.

What Changed

Before:

  • When the agent's startup timed out or the agent exited, the host released the chat's ownership.
  • From then on, every send came back with agent_session_ownership_unknown. Clients treat that code as "not admitted yet", so Retry resent the message forever.
  • The only thing that could restart the agent was the chat view's "hold". It ran once when the view opened and silently ignored its own failure.
  • Any agent no view was holding was stopped 15 seconds after its last view left or its turn ended. So nearly every send to an unviewed chat, and every worktree switch away and back after 15 seconds, paid for a restart.

After:

  • A send makes sure the chat has an owner as a step of its own admission. Every mutation to a session already runs on that session's queue, one at a time. The send's admission is now two-phase inside that step: the operation ledger answers first and places nothing; a send the ledger will admit then restarts the owner if the lease was handed back cleanly; only after that is the ledger row placed and the lease and fence checked, against the lease as it stands once the owner is there.
    • A released, reconciled lease with no handoff in progress uses the existing resume-eligibility rule.
    • This replaces the simpler restart-before-send on the branch this PR is stacked on (fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364). That version restarted the owner and then refused the send as stale, so the client had to resend under the new fence. This one restarts inside the send's own serialized step and admits it once.
    • Anything else goes straight to the normal lease check and gets its usual refusal. That covers a live owner, an owner the host cannot verify, one still being reserved, and one mid-handoff. A send the session would refuse anyway (a cleared conversation, an unconfirmed rewind or command) does not restart an owner just to be refused.
    • Nothing reacts to a refusal any more: the old "send, get refused, restart, resend" path is gone.
  • A child that is still starting owns the send. A Claude agent is published the moment its process spawns, before the CLI has answered initialize, so the restart above — and the first start of a freshly opened chat — can hand the send a child that has proven nothing yet. That child is the owner: the send is admitted against it at once, and the adapter holds the message until the child proves its start, then writes it. This is the held-prompt model from fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364; this PR adds nothing beside it. If the child exits before it proves its start, the adapter rejects the held message with the child's own exit diagnostic, so the message ends as failed rather than as a delivery nobody can confirm, and the host's exit settlement writes that diagnostic into the chat as one status row. The settlement now reads "this was a start that failed" off the host's own phase as well as the provider's flag, so a provider that omits the flag still gets the row and still does not auto-resume into the same failure. The release clock already counts a message held for a start as work owed, so a starting session holding one is not evicted from under it. One spawn per user action holds throughout: a send that already restarted the owner does not restart it again, and a send that meets a starting child restarts nothing.
  • One spawn attempt per user action, and callers take turns. The chat view's hold, a send, and the host's own restart after an unexpected exit all restart through the same function, inside the session's queue. The attach itself is now callable from inside that queue (attachStructuredAgentSessionUnderSerialize); the client-facing attach is the same body wrapped in the queue. So a hold and a send that both find the owner gone run one after the other: the first attaches, the second finds the child and attaches nothing. If the first attempt fails, the second makes its own attempt against the lease as it now stands. There is no shared in-flight resume, no "is a resume running" flag, and no way for two attaches to race against the same released fence. The host's own restart after an exit is the same call, so when the surface that held the chat leaves while that restart is still spawning, the new child goes on the idle clock instead of living until quit. A queued restart counts as in flight from the moment it is asked for, so a quit drains one waiting behind a close before it decides what to evict.
    • A second surface that opens the chat while the host is already restarting its agent keeps its holder. Before, that hold lost the race, dropped its holder, and the child went on the release clock under an open surface.
  • The fence is bookkeeping, not a guess. When a child is resumed into a lease that was handed back cleanly, the session remembers the fence of the owner it replaced. A send whose expected fence is that one is admitted at the new fence, because the restart is the only thing that moved it — whether the send ran the restart itself or arrived just behind it. A send that was stale before the restart is refused stale, as always. A handoff back to native moves the fence too, and clears that memory: only a restart may rebase a writer.
  • A replay never spawns. A send the operation ledger already holds a row for is answered from that row, whoever owns the session now. If the session was closed, its journal is made readable for the answer and no child is started. Without this a child that dies at startup moves the fence, the client automatically resends the same message, and every replay would spawn another child that dies the same way.
  • A restart answers with a typed refusal, and the send classifies it. The resume returns the attach's own refusal — its message and, when the failed attach proved its child gone, its ownerVerdict — instead of throwing a bare code. A restart that fails after the attach already recorded the failure in the ledger is read back off that row, so a durably failed restart is a refusal, not a fault. The send classifies every wire code as transient, failed or unresumable through a table that must name every code, so a new refusal code does not compile until it is placed.
    • Transient (reconciling, conflict, a stale checkpoint, an owner the host cannot verify, ledger capacity): the send runs as the lease stands and gets the ordinary refusal, which the client keeps as retryable.
    • Failed or unresumable: the send is refused agent_session_owner_restart_failed. Its message names the agent and carries the restart's own cause — "Codex couldn't restart: Not signed in. Run codex login." — and, only when this host has nothing to restart the chat from (no record, or one its adapter cannot run), adds "Start a new chat to continue." The ownerVerdict is forwarded when the attach had one. The same text is written into the chat as a status row, the way a start that failed already leaves one, so the reason is still there after the error strip is gone. The row is keyed by the send's own id, so a client that resends the same id and fails again adds no second row. The refusal happens before admission, so the ledger holds no row for it, and nothing about the failure is remembered: a resend under the same id, a Retry under a new one, and a later send once the cause clears are each a fresh attempt.
    • When the failed restart proved its child exited during startup, the chat row uses the same wording as any start that died ("The provider stopped before it finished starting: …"), so one failed attempt always reads the same whichever path noticed it. The error strip under the composer keeps " couldn't restart: ."
    • This refusal is for a restart that produced no child at all. A restart whose child was published and then died while starting is the held-prompt case above: the send was admitted, and the rejection and the status row come from the exit, not from the send.
    • A fault thrown by the restart's own bookkeeping is reported to the host log and the send runs as the lease stands; bookkeeping never blocks a user's action.
    • The code is classified as settled-rejected, so the outbox stops resending on its own, shows the host's message, and offers Retry under a new message id. The chat view's hold still raises the code for its RPC caller.
  • Unheld owners idle for 30 minutes.
    • The release clock still starts when the last view lets go, or when a restart — a send's, or the host's own after an exit — finishes with no view holding the chat: the one function that restarts it tells the holds that a child now exists with no holder.
    • Every journal write while the clock is pending starts the window over: a send, streamed output, the turn ending. A start that lands and reaches the message it was holding goes through the same renewal.
    • A running turn still defers the release, as before, and so does a message held for a start that has not landed.
    • Held chats are unaffected, and quitting the app still stops every agent at once.
  • Renderer. The hold no longer swallows its failure; it logs it. Sends now recover by themselves, so the hold is no longer the only way back.
  • What the user sees when a start fails is complete and consistent.
    • A send admitted against a starting child that then dies is settled rejected, not "delivery unconfirmed": a child that never proved its start has accepted nothing. The message shows "Message was not sent." with Retry, and the red line names the cause instead of the generic "Couldn't reach the agent". Before, it read "unconfirmed", and pressing Retry removed Retry.
    • Each failed attempt writes exactly one status row, and it is always visible. A rejected send has no turn, so it no longer gets a "Worked for 0s" disclosure that folded the row explaining the failure out of sight until the next Retry.
    • A cause that arrives after the child's exit was already processed still names the CLI's diagnostic, never an internal session id.
  • Starting Claude never waits on an option write the CLI does not answer. Restoring a saved model, effort or permission mode during start skips a write the CLI leaves unanswered instead of failing the whole start at the SDK's 30-second request deadline. The saved choice stays the user's wanted value, is shown as not confirmed, survives later option changes and /clear, and is tried again on the next start. Only an option the CLI refuses, or one the user changes, replaces it. /clear now starts the new chat from the saved options as they are.
  • A message queued as startup finished is written. A prompt that joined the startup queue after its last drain (the continuation sent after an app restart could) sat as "sending" forever; it now starts the drain itself.

Why

The bug was a lifecycle gap. After the owner died, nothing tied to the user's own action could bring it back, and the refusal code told clients to keep waiting.

  • A client-side retry cap, or a renderer that keeps re-holding, would only add another guard around that gap.
  • The host already owns the lease, the fences, the operation ledger and the per-session queue, so recovery lives there, ahead of admission, on that queue.
  • Putting the restart inside the send's serialized step, rather than in front of it, is what removes the race class: the "is there a child" check and the attach are one step, so no second caller can act on a stale answer. The earlier shape shared a single in-flight resume between callers and rebased fences from the resume's memory; that was a coordinator beside the queue rather than the queue itself.
  • A send that meets a starting child is admitted against it rather than made to wait for the start. An earlier revision of this PR parked such a send off the queue until the child's startup verdict and re-ran its admission; that was a second owner of the message beside the adapter's own hold, with its own settle-once bookkeeping and teardown phase. fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364 already holds the message in the adapter, rejects it with the exit diagnostic, and writes the cause into the chat, so the wait was removed and the send goes straight to admission.
  • Checking first rather than reacting to a refusal keeps a single admission per send. It also means the refusal code keeps a single meaning.
  • Doing it on the host also covers SSH and remote clients and mobile, with no client changes needed to get the fix.

What the 15 seconds was protecting, and why 30 minutes is safe:

  • The release clock was added so that closed chats stop keeping an agent process until the app quits. At the same time, startup stopped respawning every chat the profile had ever opened.
  • Neither goal depends on the number 15. Startup still spawns nothing until a view holds a chat or a send arrives. Quit and update still stop every agent, and the timer never keeps the process alive. A closed chat's agent is still stopped, just after 30 quiet minutes instead of 15 seconds.
  • The ownership lease is renewed about every 10 seconds (a third of its 30-second lifetime) for every live owner, whether or not a view holds it. So a long idle window just means more renewals of a healthy lease; no lease runs out underneath an idle agent.
  • The cost is memory and process count: every chat touched in the last 30 minutes can keep one agent process.

Backward compatibility: older clients don't know the new code. They hold it as a blocked send that shows the host's message, keeping the same message id. Mobile treats an unknown code as rejected and shows the message. Neither retries forever. Folder workspaces and SSH hosts take the same path, because recovery is keyed only on the session record held by the execution host.

Differences from the common pattern

  • The chat view's hold is a second route. Opening a chat still starts its agent through the hold. It does not wait for the first send. Both routes are the same serialized restart and share one idle clock.
  • Recovery is narrower. The host restarts an owner only where it can prove the old one is gone, meaning the lease was handed back cleanly and reconciled. An owner it cannot verify is never replaced; that send keeps its retryable refusal until the lease is settled. A hold re-derives a lease the host has not adjudicated, or one a failed attempt left latched in recovery, before it reads it.

Linked Issue

N/A — reported internally (structured Claude chat stuck retrying after an init timeout).

Visual Proof

No layout or styling changed. The visible change is that a stuck send now either goes through or shows a failure message with its cause, in the error strip and in the chat. Screenshots from a hidden Electron build of this branch, with a Claude CLI that fails to start and then recovers, are in the validation comments on this PR; the latest covers the head after merging current main: a failed start, a send while it is still broken, Retry, recovery once the CLI works, an idle hidden chat keeping its agent, /clear keeping the chosen model, and quit and reopen resuming the same conversation.

Testing

  • I manually tested these changes locally (a hidden Electron build of this branch, with a controllable Claude CLI, across nine validation passes; results and screenshots are in this PR's comments)

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

  • src/main/native-chat/agent-session-wire/structured-agent-session-send-preparation.test.ts runs against the real host. It covers:

    • the restart happens before the send is admitted (the adapter's acquire runs before the store's admission), and the send is admitted once
    • a live owner is left alone
    • a send the session refuses anyway does not restart anything
    • restarting once and delivering, including after an unexpected exit
    • concurrent sends take turns behind one restart: one spawn, each delivered; a hold and a send that arrive in the same gap: one spawn, both succeed, the child is held
    • a send that arrives after the restart has already claimed the lease is admitted at the new fence
    • a replayed operation does not re-run, and a replay into a closed session makes it readable and spawns nothing — including after a child that exited during startup, and including a row with no journal entry behind it
    • the restart-failed refusal: it names the agent, carries the exact cause and ownerVerdict: 'exited', leaves no ledger row, and the chat gets the same status row; a resend of the same id and a Retry under a new id each get another attempt but no second row; a later send once the cause clears restarts and is delivered; "Start a new chat" is suggested only when the host cannot resume the record at all
    • a transient resume refusal, and a fault thrown by the restart itself, both run the send as the lease stands
    • a second surface's hold during the host's own restart after an exit keeps its holder and spawns nothing; the only surface leaving during that restart puts the new child on the idle clock
    • a hold queued behind a close counts as in flight before its turn, so a quit's drain waits for it
    • a hold reads its lease only after this host has reconciled it and exited a latched recovery stage
    • the idle clock runs only when no view holds the chat, and journal activity restarts the window
    • a lease the host can't verify is left alone
  • src/main/native-chat/agent-session-wire/structured-agent-session-send-restarts-failed-start.test.ts, against the real host with an adapter that publishes a starting child: a session that published and then lost its child before startup takes the next send by restarting once and admitting the message against the new child before it has proven its start, with no stale round trip; when that child exits before proving its start, the exit retires the held message, exactly one status row names the cause, the fence moved by exactly two, nothing spawned a second time, and a Retry restarts once and is admitted. A send during the first start is admitted against the starting child and restarts nothing; one whose child dies first is retired with the cause and restarts nothing; a send against a proven child is left alone.

  • src/main/runtime/claude-structured-send-held-for-startup.test.ts, against the production runtime, adapter, record store and host with only the CLI process scripted: a chat whose CLI keeps dying at initialize — the first start dies, the send restarts once, that start dies too — ends with the message rejected with the CLI's own diagnostic, one status row per failed start, no submission left in doubt, the lease released, the fence moved by two and no second spawn; once the CLI is healthy the next send restarts once and is written to the CLI. A send while the first start is still answering initialize is held and written once the CLI answers; one whose CLI dies first is rejected with the diagnostic, leaves one row, and restarts nothing.

  • src/main/native-chat/agent-session-wire/structured-agent-session-startup-failure-exit.test.ts pins that a start that failed is read off the host's own phase when the provider omits the flag, and still writes the cause row and does not auto-resume.

  • src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.test.ts shows a handoff back to native clears the remembered restart fence.

  • src/main/native-chat/agent-session-wire/structured-agent-session-holds.test.ts and structured-agent-session-hold-resume-race.test.ts pin the 30-minute window and show that activity restarts it; that a writer's restart and a hold in the same gap run one resume, with the child held; that a writer's restart with no surface goes on the idle clock; and that a re-hold queued behind a failing attempt makes its own attempt and keeps the holder it re-took.

  • src/main/runtime/rpc/methods/structured-agent-session-hold.test.ts covers the same over RPC: a same-ID re-hold that arrives while the first hold is still attaching waits for it and finds the child (one attach, both succeed, the child is held); a re-hold behind a first hold whose acquisition failed makes its own attempt; and the connection sweep still releases the child in both cases.

  • src/main/runtime/claude-structured-send-restart-dies-before-dispatch.test.ts, against the production runtime at a subscriber: a send whose restarted child dies before starting settles rejected with the cause, one row per failed attempt with the same wording, the row reaches a client that was subscribed throughout, and Retry is one new attempt. structured-agent-session-turn-timing.test.ts and native-chat-transcript-slots.test.ts pin that a rejected send opens no turn and its row is not folded; use-structured-agent-session-outbox-rejection-cause.test.tsx pins the cause in the red line.

  • src/main/runtime/claude-structured-startup-unanswered-control-request.test.ts and claude-structured-options.test.ts: an unanswered option write skips instead of failing the start, the saved choice survives a turn that reports another model, a change to a different option, and /clear, and an explicit user choice replaces it. claude-structured-session-startup.test.ts pins that a prompt queued after the last drain is written.

  • src/main/native-chat/agent-session-wire/structured-agent-session-refusal-retry.test.ts (the refusal-classification oracle), src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx and use-structured-agent-session-hold.test.tsx cover the new code and the logged hold failure.

  • Each test was checked by deleting the code it covers, and each went red against the deletion: the hold not serialized, the fence bookkeeping, the ensure-owner step, the replay's readable restore, the ledger-first order, the unserialized exit recovery, the resume's reconcile-before-read, the verdict, the status row, the transient and thrown classifications, the settled-row read, the cause in the message, and the host-phase read in the exit settlement.

  • pnpm tc passes. Vitest over src/main/native-chat, src/shared, src/main/runtime, src/main/claude and the affected renderer folders passes, apart from cases that fail identically on the branch this PR is stacked on: an order-dependent worktree-scan case in orca-runtime.test.ts, the real-binary Claude tests, a Sidebar hydration case, and a real-process posix-lsof-probe case that passes alone. Oxlint and the changed-lines quality gate pass.

AI Disclosure

Implemented with Claude (Anthropic).

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

Author X: @BrennanKB5

Checklist

  • This PR is small and focused (it is not: it carries the send-recovery mechanism plus the start-failure presentation fixes found while validating it)
  • 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)

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 24266c9b-46e5-43a5-a195-6d2af0ec6356

📥 Commits

Reviewing files that changed from the base of the PR and between e16d9ca and c127d0336e7df15f6949ef81a90a9e5e65968ac5.

📒 Files selected for processing (12)
  • src/main/native-chat/agent-session-wire/structured-agent-session-holds.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-refusal-retry.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-send-recovery.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-send-recovery.ts
  • src/main/native-chat/agent-session-wire/structured-conversation-command-controller.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-hold.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-hold.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/shared/agent-session-refusal-retry.ts
  • src/shared/agent-session-wire-refusals.ts

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 — one classification question inline.

Reviewed changes

  • Host-side send recovery — a send refused agent_session_ownership_unknown now resumes the owner once (single-flight per session) and re-runs the send, only where the existing resume-eligibility rule already allows it, rebasing expectedRuntimeFence only when the client's fence matched the pre-resume fence.
  • resumeUnheld extraction — hold()'s resume block moved to a public resumedUnheld on the holds class, exposed through the mutation context and wired to holds.resumeUnheld; the unheld path arms the same release clock a departed surface would.
  • New refusal agent_session_owner_unrecoverable — added to the shared wire codes and classified settled-rejected, so the outbox blocks the entry, rotates the operation id, and shows the host's message instead of retrying. Transient resume refusals keep the original retryable code.
  • Renderer hold — no longer swallows a failed agentSession.hold; it logs the failure. The session still reads, and sends recover on their own.
  • Tests — new send-recovery suite against the real host (restart, unexpected exit, concurrent share, replay, unrecoverable, unverifiable lease, release clock), plus the refusal-oracle, outbox, and hold tests. I ran src/main/native-chat (1402 tests) and the two renderer suites locally; all pass.

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

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

ℹ️ Delta reviewed — no new issues. The prior inline note on the resume-error classification remains open (untouched by this commit), so this incremental review is non-approving.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5a2d4895 → c127d033), one commit:

  • Type alignment in send recovery — StructuredAgentSessionSendRecovery's getRecord dependency now declares AgentSessionRecord | null, matching AgentSessionRecordStore.getRecord (agent-session-record-store.ts:119). Every call site already guards with ?./!record, so this is a type-only change with no runtime behavior difference.

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

@brennanb2025
brennanb2025 force-pushed the structured-send-recovery branch from c127d03 to 63f4a97 Compare September 23, 2026 00:26
@brennanb2025
brennanb2025 changed the base branch from main to brennanb2025/claude-init-deadline September 23, 2026 00:26

@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 in the delta — one stale comment left behind by the widened idle window.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (c127d033 → d1c899c), one commit that reworks send recovery from refusal-driven to ensure-before-admission:

  • A send now ensures an owner before it is admitted — StructuredAgentSessionSendRecovery.send reads the persisted lease first; where it is resumable and not refused by the record, it single-flights a resumeUnheld ahead of admission, and only rebases expectedRuntimeFence when the client's fence matched the pre-resume fence. Live, unverifiable, reserved, handed-off and would-be-refused leases still run unchanged and meet the ordinary lease check.
  • The record's send-block moved to one exported function — structuredAgentSessionSendBlock (rewind prepared/provider-succeeded, or an unconfirmed/cleared conversation command) is now shared by the recovery gate and the send's own run step, replacing the inline copy in sendStructuredAgentSessionTurn.
  • The release window widened to 30 minutes and became activity-aware — STRUCTURED_AGENT_SESSION_RELEASE_GRACE_MS is now 30 * 60_000, and every journal publication for an unheld session re-arms the clock through a new onJournalActivity hook on StructuredAgentSessionClientDelivery.
  • resumeUnheld extraction is retained and exposed through the mutation context; the renderer hold now logs a failed agentSession.hold instead of swallowing it.
  • Tests — the send-recovery suite was rewritten against the new mechanism (ensure-before-admission ordering, live-owner no-op, refused-send no-op, activity re-arm, unexpected-exit restart, concurrent share, replay, unrecoverable, unverifiable lease); the release clock gained 30-minute and renew cases; the refusal oracle and the renderer outbox/hold tests cover the new code.

ℹ️ Nitpicks

  • src/renderer/src/components/native-chat/use-structured-agent-session-transport.ts:24 still reads "the host evicts the session 15s after the last turn and then refuses the send outright." Both halves are now wrong — the idle window is 30 minutes, and a send restarts a lost owner rather than being refused — which is exactly the fix this PR makes. The equivalent comments in structured-agent-session-release-clock.ts, structured-agent-session-holds.ts and visible-worktree-activity-inputs.ts were updated here, but this one and the mobile test comment at mobile/src/session/use-mobile-structured-agent-session.test.tsx:331 were missed.

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

A provider child that timed out or exited hands its lease back, and every
later send was refused agent_session_ownership_unknown. Clients read that
code as "not admitted yet" and resend forever, while only a surface hold
could make a new child, once per mount, with its failure swallowed.

The send now routes to a live owner, otherwise restarts one from the
persisted resume state where resume eligibility allows it (single-flight
per session), otherwise refuses with the new settled
agent_session_owner_unrecoverable. Unverifiable, reserved and handed-off
leases are left alone. The desktop hold now logs its failure.
@brennanb2025
brennanb2025 force-pushed the structured-send-recovery branch from d1c899c to 509c688 Compare September 23, 2026 04:43

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

ℹ️ Delta reviewed — no new issues. The prior inline note on the resume-error classification is untouched by this commit, so this incremental review is non-approving.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (46f4d76 → 3156821), one commit:

  • The ledger now outranks the lease in the recovery gate — StructuredAgentSessionSendRecovery takes a new hasJournaledSend dependency; when the loaded journal already carries the send's operation id, send runs it straight through admission instead of restarting an owner, so a client auto-resend after a startup death is replayed rather than spawning another doomed child. The controller wires it to sessions.get(sessionId)?.journal.submissions(). This requires the session to be loaded, so a closed session still reopens once before the replay is served — pinned by the renamed "reopens a closed session once for a replay" test.
  • A send joining an in-flight restart now rebases from the fence the restart replaced — the in-flight map holds { fromFence, recovery } rather than the bare promise, so a second send that arrives after the restart has already claimed the lease compares against the lost fence it read before the claim, not the post-claim fence, and gets rebased and admitted. Previously it compared against the already-moved fence and was refused.
  • Tests — two new cases: "restarts nothing for a resend the journal already answers" (child exits during startup, resend against the new fence replays, no acquire, one dispatch, lease stays released) and "rebases a send that arrives after the restart has already claimed the lease" (one acquire, two dispatches). I confirmed both can fail: disabling the journal gate trips the first on acquire being called, and reverting the rebase to read the live fence trips the joiner case. Focused vitest for the send-recovery and holds suites passes (28 tests).

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

…e restart, and a send the ledger already holds restarts nothing

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

ℹ️ Delta reviewed — no new issues. The prior inline note on the resume-error classification is untouched by this commit, so this incremental review is non-approving.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (3156821 → 49c6c03), one commit that folds send recovery into the holds' single-flight resume:

  • One restart is now shared by a hold and a send — the per-session single-flight moved from StructuredAgentSessionSendRecovery into StructuredAgentSessionHolds (resumes map): resumeUnheld returns { fromFence }, joins an in-flight resume, and exposes isResuming. The recovery dropped its private inFlight/Restart map and delegates to it, and resumeHeldStructuredAgentSession returns the pre-attach fence so joiners rebase from the owner the resume replaced.
  • The ledger row replaces the journal as the "already answered" gate — the first guard is now isAttached(sessionId) && hasLedgerRow(clientOperationId), backed by a new findAgentSessionGlobalOperationRow shared with global admission. This catches a send the ledger holds but the journal never saw (claimed, then the host died before its journal write), while a closed session still reopens once before replay.
  • The record gate is skipped while a resume is in flight — a send arriving during a hold's resume joins it and rebases from that resume's replaced fence instead of re-adjudicating the already-moved record.
  • User-facing copy — the agent_session_owner_unrecoverable message now reads "Retry, or start a new chat."
  • Tests — the hold/resume race suite was rewritten around the shared single-flight (a holder that leaves and returns joins the pending resume; a failed one settles before a fresh resume starts); the send-recovery suite gained the ledger-row-without-journal replay case and the Retry-rotates-id case; the refusal oracle pins agentSession.setOption:agent_session_owner_unrecoverable as unreachable. The four touched suites pass locally (43 tests).

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Validated 49c6c03ae3391cdb8381f8de862807064eb55223 on origin/structured-send-recovery.

Dev build from this worktree, fresh profile, structured chat flags already on disk.
Hidden window (ORCA_BACKGROUND_LAUNCH=1, mock keychain). Screenshots are Playwright over CDP of that renderer.

A. PASS. Structured Claude chat (textbox "Send a message…", tab "Claude Chat") answered Reply with exactly: OK with OK. Claude child pid 93197, parent Electron pid 49849 on CDP 9361, working directory the scratch repo.

A baseline reply

B. FAIL. After kill -9 93197 the transcript showed no exit row within 20s. Reply with exactly: BACK stayed on "Working" for more than 2 minutes, with "Message delivery is unconfirmed." and Retry. No BACK reply, and no new Claude child of this app.

B unconfirmed delivery

C. SKIPPED. No live Claude child remained after B, so a 25s hide could not be checked against an unchanged pid.

D. SKIPPED. A second hidden instance put a claude shim that exits 1 ahead of ~/.local/bin on PATH. The chat still started /Users/brennanbenson/.local/bin/claude and answered. Making that binary unlaunchable would change a file outside the validation artifacts, so this arm was not completed.

Unexpected on screen: the composer shows Fable / High while the sidebar row says sonnet, and a notice says macOS is blocking Orca notifications.

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

ℹ️ Delta reviewed — no new issues. The prior inline note on the resume-error classification remains open (untouched by these commits), so this incremental review is non-approving.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (49c6c03 → fe21434), two test-only commits. No production code changed.

  • Wire-level hold tests rewritten around the shared single-flight — the old refusal-driven "late child released after its same-ID replacement refuses the stale fence" test is gone, replaced by a same-ID replacement arriving mid-resume that joins the one attach (both succeed, the child is held), and a shared resume failure that fails both requests with the next hold starting a fresh resume.
  • A resume spy now proves the join — the hold/resume race harness exposes its resume mock; "joins a pending resume for a holder that left and came back" asserts resume ran exactly once, and a new case proves a failed resume leaves an already-child-backed replacement holder in place.
  • Replay-reopen idle-clock pin — the send-recovery replay test now asserts the reopened child is unheld and on the idle release clock.

I verified the new assertions can fail: removing the resumes join in StructuredAgentSessionHolds.resumeUnheld turns all three red, and the focused suites pass as-is (39 tests).

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

…-recovery

The base restarted a childless session before a send with a resume that swallowed its own
failure and answered the send stale. This branch's send recovery already covers that through
the holds' single-flight resume, the ledger guard, and the fence rebase, so the base's
resume-before-send is dropped and its test is kept against this branch's delivered result.

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

ℹ️ Delta reviewed — no new issues. This delta is a merge of the base branch; the prior inline note on the resume-error classification is untouched by it, so this incremental review is non-approving.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (fe21434 → f4ef3db), one merge commit that integrates brennanb2025/claude-init-deadline into the branch:

  • Base branch merged in — f4ef3db merges the PR base tip (4fd2c30) into the branch. The merged product content (Claude start-positive learning, one failed-create refusal shape, base's own send-after-failed-start retry) is base-owned and therefore not part of this PR's diff against base; the PR diff continues to show the branch's single-flight recovery superseding base's resumeBeforeSend / resumeForWrite, and no dangling references to those removed symbols remain.
  • Base test adapted to branch semantics — base's structured-agent-session-send-after-failed-start.test.ts (added on base) is carried into the branch with its assertion rewritten from a stale-fence refusal to the branch's rebase-and-deliver outcome (ok: true, replayed: false). The suite passes against the merged host.
  • Ledger accessor union — AgentSessionRecordStore now carries both findGlobalOperationRow (the branch's admission gate) and getOperationRow / agentSessionOperationKey (base's failed-create path), so both call sites resolve.

I verified the merged head: pnpm tc passes, pnpm run check:code-quality:changed reports 0 new findings, the six main-process native-chat suites (58 tests) and the two renderer suites (26 tests, run via pnpm test so the @/ alias resolves) all pass.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Validated f4ef3dbfe79d5ac85a825093dccfb8d7c94bbe24 on origin/structured-send-recovery.

Dev build from this worktree, fresh profile, hidden window (ORCA_BACKGROUND_LAUNCH=1, mock keychain). Screenshots are Playwright over CDP of that renderer.
Claude was a shim selected through a fake login shell: while a flag file existed it exited 1 with claude: not signed in (rig); with the flag removed it ran the real Claude CLI.

E. FAIL. With the flag file present, the open chat showed "The provider stopped before it finished starting: claude stream-json exited (code 1): claude: not signed in (rig)." and the composer stayed usable. After the flag was removed, Reply with exactly: BACK showed "Message was not sent." and "This chat's agent stopped and could not be restarted. Retry, or start a new chat." Pressing Retry left that text for 90s and did not start another child.

E startup failure

E send after the flag was removed

D. BLOCKED. A later live chat (pid 30067) was closed with the flag file present. After 5s the projects sidebar and the activity list had no row for that chat, and selecting the workspace opened Terminal 1 instead, so the reopen-and-fail send could not be run. The child was gone.

D after closing the chat

C. PASS. With that same child still alive, the other workspace hid the chat for 25s. Coming back and sending Reply with exactly: STILL got STILL in about 2s, and pid 30067 was unchanged (parent Electron 86584, session 0164cc2e-05d4-4fc6-a381-7bbd03df8691).

C reply after hiding the chat

The earlier "B FAIL" was a different, pre-existing failure mode (a killed child after a proven start) and is not what this PR changes.

Terminal 1 in this run printed zsh: string expected after -c. That comes from the fake login shell rewriting a normal interactive shell start, not from the chat under test. A notice also said macOS is blocking Orca notifications.

A send that found the owner gone restarted it OUTSIDE the host's per-session
serialize, through a single-flight resume map shared with the surface hold, then
rebased its fence by heuristic. The attach body is now callable from inside
`serialize` (`attachStructuredAgentSessionUnderSerialize`), and every restart
runs there: a hold, a send's ensure-owner step, provider-exit recovery and the
rewind owner replacement take turns on one queue, so the first to run attaches
and the next finds its child. The single-flight map and `isResuming` are gone.

Admission is two-phase for a send: the ledger's answer comes first and places
nothing; a send it will admit gives the session an owner, and only then are the
row placed and the lease and fence checked. A send it will replay into a closed
session makes the journal readable and spawns nothing. The session entry
records the released fence the child replaced (`resumedFromFence`), so a writer
current as of that owner is admitted at the new fence by bookkeeping, whether it
ran the restart or arrived behind it.

The resume reads its record only after this host has reconciled it and exited
any recovery stage a failed attempt latched, so a hold behind a failed attempt
makes its own attempt against the lease as it now stands.
…conciled it and exited a latched recovery stage
… classifies

`resumeHeldStructuredAgentSession` and the holds' `ensureProviderChild` answer
`{ ok: true } | { ok: false, refusal }` instead of throwing the refusal code.
The refusal is the attach's own, with its message and, when the failed attach
proved its child gone, its `ownerVerdict`. An attach that settles a failed
acquisition in the ledger and then rethrows the cause is read back off that row,
so a durably failed restart is a refusal and only an unrecorded error is a fault.

The send classifies the refusal through a `Record` over every wire code — a new
code does not compile until it is placed — into transient (the lease is someone
else's to settle; the send runs as the lease stands) or terminal. A terminal
one answers `agent_session_owner_unrecoverable` carrying the cause, forwards the
verdict, and writes the same status row into the chat that a start that failed
leaves, so the user sees why after the error strip is gone. Nothing about the
failure is remembered; a Retry is a fresh attempt. A fault thrown by the restart
itself is reported and the send runs as the lease stands, since bookkeeping
never gates a user's action.

`hold()` still raises the refusal code for its RPC caller.
…-recovery

The base reverted its own restart-before-send now that this branch owns restarting on send, and
merged main. The adapted test keeps its new name here; the thread-goal mutation from main is
wired through the serialized send path unchanged.

@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

This run re-reviewed the delta since the prior pullfrog review (f4ef3db → a666d88), three commits that rework send recovery into a serialized admission step and replace the prior classification denylist.

  • Ensure-owner is a step of the send's own serialized admission — StructuredAgentSessionSendRecovery and its recovery gate are gone. prepareStructuredAgentSessionSend runs inside the send's serialize: the ledger's answer comes first (placing nothing), a send it will admit may then restart the owner, and only after that are the row and the lease/fence checked. So a hold and a send still share one attach, and a send is admitted exactly once.
  • A resume answers with a typed refusal the send classifies — this retires the earlier inline concern. TRANSIENT_RESUME_REFUSALS (a denylist over an open error space) is replaced by RESUME_REFUSAL_OUTCOME: Record<AgentSessionWireRefusalCode, 'transient' | 'terminal'>, which must name every wire code to compile. A terminal failed restart refuses agent_session_owner_unrecoverable carrying the cause and ownerVerdict, and writes the same status row a failed start leaves; a thrown restart fault is reported and treated as transient rather than terminal.
  • Holds drop their single-flight — resumeUnheld / isResuming / resumeForWrite are removed; ensureProviderChild runs inside the session's serialize and arms the idle clock when unheld. A failed attempt releases only the holder this call added, at the incarnation it added.
  • Fence bookkeeping is explicit — session.resumedFromFence records the fence of the cleanly released owner a child replaced; a send whose expected fence equals it is rebased to the new fence, whether it ran the restart or arrived behind it. A rewind/handoff does not set it (the record is not resumable in those states).
  • Ledger evaluate/admit split — evaluateAgentSessionOperationRow / evaluateAgentSessionMutationOperation place nothing, so preparation can run between the ledger's answer and the transactional admission; findAgentSessionGlobalOperationRow is extracted to shared.
  • Tests — the send-preparation suite (20 tests, real host) replaces the send-recovery suite and covers ordering (['acquire','admit']), replay-into-closed with no spawn, shared restarts, rebased joiners, the terminal refusal with its status row and fresh Retry, transient/thrown handling, and the second-surface holder during an auto-restart. The hold/race, RPC hold, and refusal-oracle suites were rewritten around one-attempt-per-holder. I ran the focused main-process suites (49 + 106 tests) and pnpm tc:node; all pass.

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

… never answered

Clearing a chat seeded the replacement from the values the child reported,
so a saved model or effort whose restore write the CLI never answered was
replaced by the CLI's own value in the new chat, even though the retired
record kept it. The replacement now keeps those saved values too, and its
start retries them.
…he exit settles during the close

The diagnostic was dropped when the close began, but closing over an exit
that was still settling finishes that settlement, which kept it again, so a
closed or deleted chat held it until its next acquire. It is now dropped once
the close finishes. Pins that an acquire and a close each retire it.

@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

This run re-reviewed the delta since the prior pullfrog review (6349aee → f2d5c85), four commits that refine the Claude unanswered-option and settled-exit paths.

  • A saved option the CLI never answered survives a later change to a different option — claudeRestoreUnansweredOptions(session) derives the still-unanswered keys by filtering session.restoreUnansweredOptions against what the child has since applied (session.options). The extracted withUnansweredSavedOptions helper is now called from the send-mutation persistOptions write as well as nativeSessionOptionsFromReport, fed by a new routed readOptionRestoreUnanswered adapter method. Persisting an applied option no longer silently drops a saved choice still awaiting its restore, while a user write of that same key clears it.
  • A send that meets an already-settled exit names that exit's cause — the Claude adapter keeps the last settled exit's Error in a settledExitErrors map, cleared by acquire/closeSession; session() falls back to it after this.exits, so a dispatch admitted before the host processed the exit reports The provider stopped before it finished starting: <diagnostic>. rather than a generic "no live session" error.
  • Tests — new cases pin the unanswered choice surviving a different-option change, a user write clearing the unanswered state, the exit-settlement wording (dispatchRejectionReasonIsInternal false), and the settled-exit diagnostic reaching a send, plus a two-row spawn/start-time-read restart case.

Both prior inline threads (stale unknown→rejected assertions) are resolved. I ran the four delta test files (46 tests) and pnpm tc:node; all green.

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

brennanb2025 and others added 2 commits September 23, 2026 20:00
* fix(claude): resume a native chat from its real latest message

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]>

* fix(claude): advance the durable resume point at every turn end

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]>

* fix(claude): retry a failed turn-end resume write and ignore results 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.

* fix(claude): resume a native chat by session id and stop predicting Claude'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.

* fix(claude): drop the stale resume-cursor wording from the restart-resume note

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

* refactor(claude): prove the file-tail resume tip inside the branch graph

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.

---------

Co-authored-by: Claude <[email protected]>
…taking over the pane (#22444)

OpenCode 2's plugin adapter unwraps a single-property `{ data }` success schema,
so `ctx.session.get` resolves to the bare session record. The shared lineage
lookup only accepts `result?.data?.id === sessionID`, and OpenCode 2 has no
`session.list` fallback, so `resolveRootSessionID` returned null for every
session and `childState` was permanently null.

With unknown lineage `canFailOpen` is true for attention events, so a subagent's
`permission.asked`/`question.asked` fell through and pinned an un-evictable
blocker keyed to the child's own session id — publishing a subagent as if it
were a root. Observed in hook posts: SessionBusy for a child session id whose
`session_v2` row carries a parent.

Envelope the result in the OC2 client shim so the shared lineage module works
unchanged; OpenCode 1 already receives enveloped results and is untouched.

Also adds `opencode2` to the double-Escape interrupt list, extracted into one
shared helper so the server inference and renderer gate cannot drift. A single
Escape was inferring an interrupt, and Escape is how the Subagents dock closes.

7 of 11 new lineage tests fail without the shim.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Validated 17b41b5eaa0c57f347c5a0e283a943cfae5528a4 on origin/structured-send-recovery. This is a re-proof on the final head after the diagnostic-retention and option-persistence fixes.

Dev build from this worktree, fresh profile, hidden window (ORCA_BACKGROUND_LAUNCH=1, mock keychain). Screenshots are Playwright over CDP of that renderer.
Claude was a shim selected through a fake login shell: while a flag file existed it waited 1s and exited 1 with claude: not signed in (rig); with the flag removed it ran the real Claude CLI.

D. PASS. With the flag still present, the open chat showed one gray row, "The provider stopped before it finished starting: claude stream-json exited (code 1): claude: not signed in (rig).", and a usable composer; sending Reply with exactly: DEAD added exactly one new gray row of that sentence in about 8s with no further click, showed "Message was not sent." with Retry, and put that same sentence in red under the composer, with no "Worked for" disclosure and with neither "no live claude stream-json session" nor a claude_ id in the red line; one Retry, flag still present, added exactly one more gray row, left the message unsent, left Retry in place, and kept the same red line.

D after one Retry while the shim still failed

E. PASS. After the flag was removed, Retry on that message returned DEAD in about 3s ("Worked for 1s") from child pid 28165 (parent Electron 91965, Claude session 920d503a-c80e-4ba6-83d2-60e102223b8d). runtimeFence on the record was 7, from the open, the failed send, the failed Retry, and this recovery.

E reply after the flag was removed

C. PASS. Hiding that chat on the other workspace for 25s, then sending Reply with exactly: STILL, returned STILL in about 2s ("Worked for 1s") and pid 28165 was unchanged. runtimeFence stayed 7.

C reply after hiding the chat

nwparker and others added 3 commits September 23, 2026 20:08
…ng ORCA_OPENCODE_AGENT (#22547)

* test(opencode): pin per-major OpenCode overlay selection on WSL and the relay

OpenCode 2 dies with "Duplicate plugin ID" when two plugin files share an id,
so which overlay a guest or remote pane is pointed at decides whether the agent
starts. Nothing failed if that selection regressed:

- the WSL spawn path never asserted which major it asks the guest relay for,
  and the shared pty-ipc mock had no openCode2HookService at all, so no test
  could reach the opencode2 branch of buildPtyHostEnv;
- requestGuestOpenCodeOverlayDir had no coverage for the v2 guest dir;
- PluginOverlayManager had no case for a remote config root that still holds
  the other major's stale Orca plugin.

Tests only; no behavior change. Each new case was mutation-checked against the
production line it guards.

* test(opencode): stop the plugin contract test inheriting ORCA_OPENCODE_AGENT

The generated plugin self-disables when ORCA_OPENCODE_AGENT names a different
major, and the contract test saved and restored that variable without ever
setting it. Run from a shell that has it — which is any shell inside an Orca
OpenCode pane, i.e. how this repo is usually developed — the plugin returned an
empty hook set and the contract failed for the wrong reason.

Delete it in beforeEach, the way the opencode2 setup test already pins it.
Verified the file passes with the variable set to either major and unset;
before this it failed for two of the three.
* fix(rate-limits): read OpenCode Go usage with the account API key

Since OpenCode's console migration (upstream fe51b0b19a, "fix(console):
restrict legacy access to Black"), an account with no Black subscription
is redirected from the legacy console to /console/login, so Orca's
cookie-based workspace lookup returns nothing and the Go bar stays empty.

Fetch usage from GET https://opencode.ai/zen/go/v1/usage instead, which
authenticates with `Authorization: Bearer <key>` and needs no console
session. The key resolves in order: Orca settings override,
OPENCODE_API_KEY, then whatever OpenCode itself stored on /connect --
auth.json for 1.x, the credential table for 2.x. The cookie path stays
as the fallback so Black/legacy accounts keep working.

A 403 EntitlementError now reads as "no OpenCode Go subscription" in the
status bar instead of a generic refresh failure (#22257's reporter was
misled by exactly that).

* fix(rate-limits): prefer OpenCode's stored Go key over OPENCODE_API_KEY

OpenCode applies the key saved on /connect after the environment, so the
stored key is the one its own Go requests use. OPENCODE_API_KEY is also
the Zen provider's variable, so ranking it first could read a key that
OpenCode itself is not using for Go.

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

* fix(rate-limits): name the API key when OpenCode Go usage lands on sign-in

A redirected usage request arrives as a 200 sign-in page because Electron
follows redirects; report it as a rejected key instead of a parse failure.
The cookie path's empty workspace lookup is what non-Black accounts now
hit after the console migration, so its message points at the API key
rather than only the workspace override.

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

* chore(i18n): add the OpenCode Go API key strings to the English catalog

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

* docs(rate-limits): stop calling the credential table an OpenCode 2 marker

Verified on two real Windows hosts running OpenCode 1.18.16: the `credential`
table exists there too (empty, same columns), so its presence does not identify
a 2.x install. Neither host had an `auth.json` at all.

The resolution already probes both stores on every version, so only the comments
were wrong. Says so now, and records that a 2.x install which never ran the
legacy import has no `auth.json` either — which is why both tiers exist.

* refactor(shared): move GhosttyImportPreview out of global-settings-types

Adding `opencodeGoApiKey` pushed global-settings-types.ts one line past the
300-line ceiling, failing `oxlint` in CI. AGENTS.md forbids a max-lines
suppression, so split instead: the Ghostty import preview is a distinct concern
that never belonged in the settings-shape file.

Re-exported from the original module so no importer changes. 293 code lines now.

---------

Co-authored-by: Jinwoo-H <[email protected]>
Co-authored-by: Claude <[email protected]>
…anted value, not a list beside it

A restore cleared the session's wanted options and added back only the writes
the CLI answered, so an unanswered one lost the user's value and every later
writer had to be told to put it back: the start report, each option change and
/clear each carried a list of unanswered keys. The restore now keeps the saved
value as wanted and unconfirmed, so what the session reports and persists
already carries it, and the list, its adapter method and the started-event
field are gone. A refused option is still dropped.

/clear now starts the replacement from the record's options instead of reading
the child's live values, which can be a model the CLI fell back to.

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

Important

One test added by a88d95b is red at HEAD: its wait predicate matches before the agent has proven its start, so setOption is refused and the case can never pass. Details inline.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (f2d5c85 → a88d95b), three commits.

  • A cleared chat starts from the options the user chose — /clear builds the replacement attach from record.options directly, deleting the live readOptions + withUnansweredSavedOptions block and the source-record persistOptions; the premise is that the child's live model can be a fallback the CLI chose rather than the user's pick.
  • A close forgets its settled exit diagnostic even when the exit settles during the close — closeSession now deletes settledExitErrors in a .finally after closeSessionProcess, so a close that releases a still-settling exit no longer re-retains the error until the next acquire.
  • An option the CLI never answered is kept wanted-but-unconfirmed — restoreUnansweredOptions, claudeRestoreUnansweredOptions, the adapter's readOptionRestoreUnanswered and the started event's restoreUnansweredOptions field are gone; a timed-out restore now leaves the saved value in session.options and clears confirmedOptions, so the picker reports the wanted value with confirmed excluding it and the record keeps it without a side list. nativeSessionOptionsFromReport drops its restoreUnanswered input.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Validated a88d95b709964bdd9a126952bd427f2447fcde8b on origin/structured-send-recovery. This is a re-proof on the final head after the option-persistence refactor, plus the /clear check in F.

Dev build from this worktree, fresh profile, hidden window (ORCA_BACKGROUND_LAUNCH=1, mock keychain). Screenshots are Playwright over CDP of that renderer.
Claude was a shim selected through a fake login shell: while a flag file existed it waited 1s and exited 1 with claude: not signed in (rig); with the flag removed it ran the real Claude CLI.

D. PASS. With the flag still present, the open chat showed one gray row, "The provider stopped before it finished starting: claude stream-json exited (code 1): claude: not signed in (rig).", and a usable composer; sending Reply with exactly: DEAD added exactly one new gray row of that sentence in about 8s with no further click, showed "Message was not sent." with Retry, and put that same sentence in red under the composer, with no "Worked for" disclosure and with neither "no live claude stream-json session" nor a claude_ id in the red line; one Retry, flag still present, added exactly one more gray row, left the message unsent, left Retry in place, and kept the same red line.

D after one Retry while the shim still failed

E. PASS. After the flag was removed, Retry on that message returned DEAD in about 4s ("Worked for 2s") from child pid 32151 (parent Electron 75681, Claude session 87917116-3f0c-4135-a6ec-3ae0ee08bcdf). runtimeFence on the record was 7, from the open, the failed send, the failed Retry, and this recovery.

E reply after the flag was removed

C. PASS. Hiding that chat on the other workspace for 25s, then sending Reply with exactly: STILL, returned STILL in about 2s ("Worked for 1s") and pid 32151 was unchanged. runtimeFence stayed 7.

C reply after hiding the chat

F. PASS. The composer model picker was changed from Opus (1M context) to Sonnet; Reply with exactly: PICKED returned in about 3s ("Worked for 2s"). /clear replaced the transcript with an empty chat in under a second and the picker still showed Sonnet. Reply with exactly: AFTER returned in about 3s ("Worked for 2s"). The new session clear-b9bf0f69acd3effdf2006266a2c040c693e22553 recorded options model=sonnet, effort=high, fastMode=false.

F Sonnet still selected after /clear

brennanb2025 and others added 9 commits September 23, 2026 20:26
…st loaded ones (#22558)

* fix(native-chat): show every user message on the message rail, not just loaded ones

The message rail was built only from transcript rows the renderer had
loaded, so any prompt above the loaded page had no tick, and the rail lost
ticks when a long live session trimmed its retained window.

The host now answers `agentSession.conversationOutline`: every user message
in a structured session's journal (item id, creation sequence, a preview
cut to 200 characters, image count) plus the journal position it is current
through. It is derived from the reduced journal on each request with the
same projection the transcript runs, so an entry's id and preview are what
the loaded row shows. The reply is bounded like a history page: previews
shorten, then drop, and only then do the oldest entries go.

The renderer asks only while the pane is visible and older history is
unloaded, uses outline entries only for messages older than its loaded
window (the window is authoritative for the rest), and falls back to loaded
messages while the outline is stale (epoch change, or the window trimmed
past what it covers). Selecting a tick with no row pages older history in
until the row exists, then uses the existing rail jump.

The method is negotiated with `agent-session.conversation-outline.v1`; a
client never calls a host that does not advertise it, and any failure
leaves the rail on loaded messages.

* fix(native-chat): keep a rail jump from the bottom from re-arming follow and cancelling itself

A rail jump started by a reader following the end stopped a few pixels
above the bottom instead of reaching the message. Paging older history in
for a jump always leaves the reader following at the very end, so jumps to
unloaded messages hit it every time; a jump to a loaded message from the
end did too.

The jump scrolls smoothly, and only its landing is marked as the
application's own scroll. Its first frames move a pixel or two, still
inside the band where a reader event re-arms follow, so the list read the
jump leaving the end as the reader arriving at it. The next frame, just
outside the band, then read as the reader taking over and rebased the view
with an instant write, which cancels the smooth scroll.

Re-arming follow now needs the reader to be arriving at the end: an
unmarked event that moved the view up never reattaches a detached reader.

* test(native-chat): check a rail jump left the end before reading where it landed

* fix(native-chat): keep the rail's message list still while a press selects an item

With the whole conversation in the rail, its hover list overflows and opens
scrolled to the message being read. Clicking an older item did nothing:
pressing it focuses it, which turns the hover preview interactive, and that
switch re-ran the effect that scrolls the lit row into view and focuses it.
The list moved under the pointer between press and release, so the click
landed on the list instead of the item, and focus jumped to the lit row.

Revealing the lit row now follows the list opening (and its rows shifting),
not the switch between hover and interactive. Entering interactive moves
focus into the list only when focus is not already on one of its items.

* perf(native-chat): keep the rail's outline entries stable while a trimmed window slides

A long live session holds a head-trimmed window, so every new row moved the
oldest-loaded edge and rebuilt the outline view even when no user message
crossed it. The rail then re-merged, re-rendered and re-read the scroll
geometry on each new row. The view is now reused while the set of entries
older than the edge is unchanged.

* fix(native-chat): let a rail jump wait out an older page already loading

Scrolling to the top of the loaded window asks for the next older page. A rail
jump made while that page was in flight asked again, got the lane's immediate
no-op return, read it as a page with no progress, and dropped the click. The
jump now waits for the in-flight page to land before deciding.

* fix(native-chat): reattach follow when content shrinking clamps a reader onto the end

The rule that stops a smooth scroll leaving the end from re-arming follow
compared offsets, so it also refused a reader whose offset dropped because
settled content folded away beneath them and the browser clamped them onto
the end. They sat at the bottom without following, and the next reply grew
out of view. Re-arming now requires closing on the end rather than moving
down, which still rejects a scroll leaving it.

* fix(native-chat): keep the rail hooks' ref writes out of render

Both hooks wrote a ref while rendering, which React may replay or discard.
The rail's structural-sharing baseline is now recorded after commit, and the
history jump calls the lane's page loader from its effect instead of through
a render-updated ref.

* fix(native-chat): let the latest rail pick win over a jump still paging

A jump to an unloaded message keeps paging older history until it lands. A
pick made meanwhile lost to it: a loaded message scrolled into view, then the
earlier jump finished and pulled the reader away; another unloaded message was
ignored. Picking a loaded message now cancels the paging jump, and picking an
unloaded one retargets it without asking for a second page.

* fix(native-chat): step a rail history jump with a functional update

The step that requests the next page wrote the pending jump from the value
its effect closed over, so a pick or cancel queued since that commit would
be overwritten.

* refactor(native-chat): run a rail history jump as one abortable awaited loop

The jump through unloaded history was an effect-driven state machine that
guessed "no progress" from the message list's identity and could not be
cancelled by anything but another rail pick. A diff reveal, "Jump to latest"
or the reader scrolling left it paging, and when its page landed it pulled
the reader away; a history read that kept failing during a live turn could
repeat back to back.

Loading an older page now reports how it ended, and a second request while
a page is in flight joins it instead of being refused. The jump is an
awaited loop that reads the rail from a commit after each page, stops on
anything but a page that moved the window, and is aborted by any other
navigation, reader input (wheel, touch, scroll keys, scrollbar), a session
switch or unmount. The latest pick wins.

* fix(native-chat): derive the rail outline from the transcript's own projection

The host built the outline from user items alone, while the transcript
orders every message by when it was observed, folds tool results into the
turn above and then drops harness turns. An imported user row carrying a
tool result beside harness text therefore got a rail tick previewing the
harness text, and clicking it paged history for a row that never draws.

The transcript's order-fold-strip projection now lives in one shared
function. The renderer's list projection wraps it with its own tail-row
order, and the host runs it over the whole journal and keeps the user rows
that draw content, so the outline lists the same messages in the same order.

* fix(native-chat): retry a failed rail outline read a few times

A failed outline read left the rail on loaded messages until a new gap
opened, the pane was shown again or the epoch changed. The client now
rejects a failed read (a host without the outline still resolves to
nothing, without being called), and the rail retries up to three times
with doubling backoff.

* test(native-chat): give the rendered-transcript fixture the older-page result contract

* perf(native-chat): sort the shared transcript projection without a spread copy

* fix(native-chat): let a wheel over the rail cancel a rail jump still paging

The rail forwards its wheel to the transcript, so a reader scrolling there is
scrolling the transcript. That wheel never reached the scroller's reader-input
handlers, so the jump kept paging and later pulled the reader to its target.

* fix(native-chat): keep the rail's list open while a picked message pages in

Picking a message that is not loaded yet can take several pages of older
history. The list closed on the pick, so its busy item was never seen and
the click looked ignored. The list now stays open with that item pulsing
until the jump lands or is abandoned, and stops revealing the lit row
meanwhile so the rows do not move under the pointer.

* fix(native-chat): keep the shared transcript projection loadable on mobile

The projection moved to src/shared, which mobile's Hermes engine also loads,
and switching its sort to toSorted broke the Hermes compatibility guard.
Sort a copy made with Array.from instead, as other shared code does.
…le (#22593)

The comment merged with #22546 claimed ConPTY never forwards DECSET 2004 and
that the signal therefore cannot fire on Windows. Verification on two real
Windows hosts refuted that: the sequence arrives in order on both ConPTY
backends, and the readiness signal fired in every run.

The budget was the actual problem — opencode does not enable bracketed paste
until ~4.8s and its composer is not ready until ~10s, so the 8s default expired
first and the draft was pasted blind. Same fix, accurate reason.

Note the claim that seeded this: terminal-agent-paste-bracketing.ts says 2004
"can be lost by remote replay or ConPTY", which is careful and not contradicted
here; the absolutism was mine.
* fix(relay): drain a same-cap cell over 5 minutes, not 2

The 2026-09-23 c27 roll drained 2,145 hosts over the 2-minute window,
about 18 re-dials/s, while the director re-places roughly 8/s through
its single-slot sticky lane. The overflow queued behind slow
re-placements and timed out, so /v1/assign returned 503 fleet-wide for
about 5 minutes. 5 minutes is the cell's maximum pace window and keeps
the remaining 2,650-host cells near lane capacity. The transition wait
already outlasts a 5-minute window (17 min).

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010

* test(relay): pin the same-cap drain window contract at 5 minutes

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010

* fix(relay): keep the drain wait at lease plus the 5-minute window

The transition wait after a drain was set to the 15-minute migration
lease plus the pace window. Widening the window to 5 minutes without
moving the wait left 12 minutes for a migration that can hold for 15,
so a late-window migration would time the wave out into rollback.

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
* feat(ipynb): run notebook cells in a persistent Jupyter kernel

Replaces the fresh-process runner (which silently re-ran every earlier cell)
with the user's own ipykernel, driven by a small bundled Python bridge over
line-framed JSON. One kernel per open notebook: started on first Run, shut
down when its tab closes or Orca exits (stdin EOF), and the kernel's own
parent poller reaps it if the bridge dies.

The header gains a kernel pill (workspace .venv/.conda recommended, PATH
interpreters, Browse), Interrupt/Restart/Run all/Clear all, and a one-time
missing-ipykernel dialog with Install. Outputs stream live per cell and are
written into the document when the run finishes.

* test(ipynb): cover the stalled-interrupt restart offer

* refactor(ipynb): disable the kernel pill while settling; merge its classes with cn

* refactor(ipynb): tie kernels to their renderer document and simplify the run flow

- Main keys kernels per renderer, so a reload, renderer crash or closed
  window shuts them down, and two windows never share one notebook kernel.
  One close-driven cleanup replaces the separate exit and start-failure
  deletions.
- The first run uses the nearest workspace env, else the first Python on
  PATH; the picker no longer opens itself, so its open state stays in the
  toolbar. Closing the picker brings the missing-ipykernel dialog back
  instead of dropping the queue, which also keeps a Browse pick's run.
- Discovery marks the kernel starting, so a second run during it queues
  instead of starting a second kernel, and a tab closed mid-discovery no
  longer leaks one.
- Running an nbformat 4.4 notebook gives its cells ids (upgrading to 4.5),
  so moving a cell mid-run cannot misroute its output.
- The death notice drops stderr from before the kernel was ready (the
  unencrypted-TCP warning).
- SSH and non-Python runs toast instead of writing a notice into the cell.
- Windows conda envs are named after their folder.

* fix(ipynb): install ipykernel into envs without pip

uv-created venvs ship without pip, so Install failed with 'No module named
pip' there. When pip is missing, bootstrap it with the stdlib's ensurepip
and retry. The install moves beside the other interpreter probes, and the
copyable install command comes from one helper.

* fix(ipynb): address PR review comments on stream errors, old jupyter_client and the Windows venv hint

- Swallow stdout/stderr stream errors on the bridge child, as spawnProcess
  requires, so a broken pipe cannot crash main.
- The bridge exits (reporting the death) even when cleanup_resources is
  missing (jupyter_client < 6.1.5) or raises.
- The install-failure hint suggests `py -m venv .venv` on Windows.

* feat(ipynb): add Cancel to the missing-ipykernel dialog

It does what Esc does: drops the cells waiting on the kernel.

* fix(ipynb): recover from a rejected kernel start; quote the install command per shell

- Discovery moves into start, so one catch turns a rejected
  listPythonEnvironments or startKernel into the usual failed start: the
  session returns to off with the error in the cell, instead of sticking
  at starting.
- The copyable ipykernel command quotes the interpreter only when its path
  has whitespace, prefixing PowerShell's call operator on Windows. Install
  itself still spawns without a shell.

* fix(ipynb): always shell-quote the copyable ipykernel install command

Quote the interpreter path for every path, not only ones with whitespace,
so paths with shell metacharacters like & copy as a working command.
Single quotes are literal in POSIX shells and PowerShell; embedded quotes
are escaped per shell, and PowerShell keeps its & call operator.
…and say what to do (#22448)

* fix(native-chat): keep chats that failed to resume in the status bar and say what to do

After a restart, a chat whose resume did not carry on was reported only by a
four-second toast that named nothing, and the status bar entry vanished because
the reattach had already spent the offer.

The host now files the outcome as a durable `failed` entry in the recovery
capsule, with the refusal code and the prompt the offer quoted, and returns it
from the restart-resume RPCs. The renderer shows a "N chats failed to resume"
status bar entry, a count-only toast with Show and Dismiss, and keeps the resume
dialog open with a status icon per row and a "To resume" line whose action is
chosen from the reason. A failure dies on dismiss, on a successful retry, on the
user's own send in that chat, or with the marker's 24h expiry.

* fix(native-chat): keep the resume dialog unchanged and add failed chats as rows

The failure view had replaced the resume dialog's title, checkboxes, preference
box, and footer. The dialog is back to main's layout. A chat an earlier resume
could not carry on is now an ordinary selectable row there, plus a status icon
whose tooltip carries the reason, a dismiss control, and a "To resume" line.
Selecting it and pressing Resume retries it; it is pre-selected only when a
retry can succeed. Resumed chats leave the list as before.

Also stubs the new failure listing on the cross-version wire host fixture, which
the restart-resume RPC now reaches.

* refactor(native-chat): release a failed-resume record where a send is admitted

Keeps the host file at main's size, and only releases the record for a send the
controller actually lets through.

* fix(native-chat): note a failed restart resume in the chat and derive when it is settled

The chat itself now says when Orca could not continue it after a restart,
with an error (refused) or warning (unconfirmed) status row, so the failure
survives the toast, a dismissed record, and another restart.

A recorded failure is current only while the chat's newest user message is
the one it had when the failure was filed. Listing re-derives that from the
journal and prunes superseded records, replacing the in-memory set and the
hook on every send.

Failures move to their own optional top-level key in the recovery file, so an
older build that rejects unknown entry states keeps reading its offers. A
retried failure stays a failure through a rollback or a lapsed lease instead
of returning as a pending offer, and the toast's Dismiss names only the chats
the host listed as failed.

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

* test(native-chat): check the older reader against a filed failure before any retry

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

* fix(native-chat): file a failed restart resume against the chat as its attempt ended

A failure was filed against the chat's newest user message read at settlement, after every chat in
the action had finished. The chat's note asks the user to send a message, and one sent while other
chats were still being continued became part of the filed state, so the failure stayed listed after
the user had done what it asked. Each chat's newest message is now observed as its own attempt ends.

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

* fix(native-chat): let a reply that made a chat ineligible retire its failure

When a restart resume reached a chat the user had already replied in, the
attempt was refused as no longer eligible, but the failure was filed against
that very reply. It then stayed listed as "finished on its own" until the user
sent yet another message. An ineligible chat is no longer observed at the
attempt, so its failure falls back to the reserved marker and the reply that
made it ineligible supersedes it at the next listing.

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

* fix(native-chat): offer Retry on a failed resume only when a retry would run

When the agent refused Orca's "continue" message with its own reason, the
failed row fell to the generic guidance, which offers Retry and pre-selects
the chat in the resume dialog. The refused message is already the chat's
newest user message, so a retry is never eligible: it did nothing and the
same "couldn't be resumed" toast came back.

The host now reports whether a retry would run, derived at list time from
the same predicate the retry applies to the failure's marker. Where it would
not, the row offers Open chat and Dismiss and is not pre-selected. An older
host omits the flag and the reason alone decides, as before.

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

* fix(native-chat): file only restart failures the user must act on

A chat that stopped being resumable between listing and acting (it
finished on its own or is waiting on the user) was filed as a failure
with no note in the chat. It now just spends the offer.

A failed reattach now writes the same in-chat note as a refused
continuation, so every filed failure explains itself in the chat.

An unconfirmed continuation's failure retires once the chat shows the
continuation's own message opened the newest turn.

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

* fix(native-chat): clear a failed resume from the status bar once its chat moves on

While a failed resume is listed, the restart store watches the host's
status feed; when a failed chat's status or latest prompt changes after
the list was read, it re-reads the host once. The host still decides
whether the failure stands. Nothing is watched while nothing failed.

The failure toast now counts only the requested chats the host still
lists as failed, keeping the old count for a host that sends no list.

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

* test(native-chat): pin that an unjournaled continuation never retires its unconfirmed failure

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

* fix(native-chat): stop telling the user to send a message into a chat Orca couldn't reconnect

A failed reattach, or a continuation refused because another window or terminal owns the
session, now leaves a note saying Orca couldn't reconnect the chat instead of advising a send
that would meet the same refusal. The restart list keeps the reason-specific advice.

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

* fix(native-chat): keep the failed-chat re-read from undoing an action or missing a reply

The status-bar re-read no longer runs while a resume or dismiss is in flight, and its answer is
dropped if one settled meanwhile, so a dismissed failure cannot come back. A change to a failed
chat already seen always triggers it, whatever the host's timestamp says. A chat whose unconfirmed
continuation the host already retired is now reported as resumed instead of saying nothing.

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

* test(native-chat): pin that no failed-chat re-read runs under a resume in flight

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

* test(native-chat): typecheck the unjournaled-continuation case against a nullable marker

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

* docs(native-chat): drop the stale "no arguments" note on the restart-offer params

The dismiss call now names sessions, so the older comment contradicted the schema below it.

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

* fix(native-chat): count unconfirmed resumes apart from refused ones in the action toast

The post-action toast said "N chats couldn't be resumed" for chats whose
continuation may well have gone out, while the list and the chat itself say
Orca couldn't confirm it. That wording invites a duplicate "continue" send.
Unconfirmed chats now get their own count, classified by the outcome the
host filed, so the toast matches the row it points to.

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

* fix(native-chat): stop offering Resume on a failure the host says cannot retry

A failed row the host marks unretryable could still be ticked, sending a resume
that could only fail again; its checkbox is now disabled and it never joins the
action. An older host that omits the flag keeps today's selectable row.

The status bar no longer calls a chat "failed to resume" when the host only
couldn't confirm the resume, matching the dialog's own wording, and the mixed
toast's second line now says "other" so it cannot read as the same chat.

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

* fix(native-chat): skip unreadable failure records instead of rejecting the capsule

A failure record this build cannot parse (a newer outcome, say) made the
whole recovery file unreadable, so a downgraded build listed no restart
offers and could not record new teardowns. Failures are advisory: parse
each one on its own and drop what does not parse.

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

* test(native-chat): pin that a failure record with an unreadable marker is skipped

The skip-unreadable-failure test only covered an unknown outcome, so going back to the throwing
marker parser for failure records still passed. A failure record usually outlives its offer
entry, so a newer marker shape can appear only there.

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

---------

Co-authored-by: Claude <[email protected]>
Main resumes a Claude chat by session id alone and removes Claude rewind; the
stack publishes a Claude start at spawn and resumes a chat whose first start
failed as the same conversation. Both hold in the result:

- claude-structured-launch-resolution.ts: keep the stack's transcript check; a resume passes only the session id (no resumeSessionAt), and the inherited env drops CLAUDE_CONFIG_DIR.
- claude-structured-session-acquisition.ts: drop the rewind observer and proof-before-publish path; every start publishes at spawn and reads its facts after publish; publication carries main's turn-end leaf.
- claude-structured-session-publication.ts: keep the stack's providerSessionId input; drop claudeConfigDir, which the session no longer holds.
- claude-structured-session-test-support.ts: keep the stack's requestTimeoutMs; drop the removed readTranscriptLeaf parameter.
- claude-structured-rewind.ts and its test: deleted as on main; the stack's resumed -> resumesTranscript rename there is moot.
- structured-rewind-claude-owner.ts: deleted as on main; the stack's serialized-attach call there is moot.
- structured-agent-session-acquisition.ts: keep the stack's providerChildPhase result; drop the rewind proofs.
- structured-agent-session-attach-flow.ts: keep the stack's failed-create refusal; drop its rewind-refusal branch.
- structured-agent-session-attach-orchestration.ts: keep the stack's serialized attach; drop the rewind option so a pending rewind is always settled on attach.

Main's new tests use the stack's launch fields and runtime lifecycle hook; the
pending-rewind test seeds the transcript a resume continues.
…model

The record holds the saved model from creation, so waiting for it returned at
once and the option write could reach Claude while it was still starting,
which refuses it. Wait for the effort the finished start reports instead.
The notice that a structured chat is still starting was only in English.

@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

This run re-reviewed the delta since the prior pullfrog review (a88d95b → e9e7707): two authored commits plus two merges of origin/main.

  • The previously red startup test now gates on the start proving itself — the "replaces the unanswered saved model" case in claude-structured-startup-unanswered-control-request.test.ts now waits on toEqual({ model: 'sonnet', effort: 'high' }) instead of toMatchObject({ model: 'sonnet' }), which the attach reservation already satisfied before startup proved. The suite is green at head (5/5), closing the prior review's finding.
  • The still-starting notice is translated — auto.components.native.chat.NativeChatStructuredSessionStatus.starting gains es/fr/ja/ko/zh copy, each carrying the {{value0}} agent-label placeholder. verify:localization-catalog exits 0 and the src/renderer/src/i18n suite (173 tests) passes.
  • Two merges of origin/main — integrate main's recent claude/native-chat work (#22395, #22448, and others). The PR's core recovery files (send-preparation.ts, holds.ts, mutation-admission.ts, hold-resume.ts) are unchanged by them; pnpm run typecheck:node exits 0 and the focused recovery suites (76 tests) pass.

The prior blocking thread is resolved. Verified locally: pnpm run typecheck:node exit 0; claude-structured-startup-unanswered-control-request.test.ts 5/5; focused suites 76/76; i18n 173/173.

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

The merge re-pointed this test at a child that exits after publish, where the
exit path also releases the binding, so it passed with the acquisition's release
deleted. A child that exits before publish leaves only that release. Also drops
the create 'init' phase, which lost its last producer when rewind stopped
proving before publish.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Validated e9e77073e0f47e075e51f6984a102158848d1895 on origin/structured-send-recovery. This is a re-proof after merging current main, plus the reopen check in G.

Dev build from this worktree, fresh profile, hidden window (ORCA_BACKGROUND_LAUNCH=1, mock keychain). Screenshots are Playwright over CDP of that renderer.
Claude was a shim selected through a fake login shell: while a flag file existed it waited 1s and exited 1 with claude: not signed in (rig); with the flag removed it ran the real Claude CLI.

D. PASS. With the flag still present, the open chat showed one gray row, "The provider stopped before it finished starting: claude stream-json exited (code 1): claude: not signed in (rig).", and a usable composer; sending Reply with exactly: DEAD added exactly one new gray row of that sentence in about 8s with no further click, showed "Message was not sent." with Retry, and put that same sentence in red under the composer, with no "Worked for" disclosure; one Retry, flag still present, added exactly one more gray row, left the message unsent, left Retry in place, and kept the same red line.

D after one Retry while the shim still failed

E. PASS. After the flag was removed, Retry on that message returned DEAD in about 3s ("Worked for 2s") from child pid 45486 (parent Electron 24149, Claude session 386c83ee-db96-4009-bfea-0bf8f796201d). runtimeFence on the record was 7, from the open, the failed send, the failed Retry, and this recovery.

E reply after the flag was removed

C. PASS. Hiding that chat on the other workspace for 25s, then sending Reply with exactly: STILL, returned STILL in about 2s ("Worked for 1s") and pid 45486 was unchanged. runtimeFence stayed 7.

C reply after hiding the chat

F. PASS. The composer model picker was changed from Opus (1M context) to Sonnet; Reply with exactly: PICKED returned in about 3s ("Worked for 2s"). /clear replaced the transcript with an empty chat in about 0.5s and the picker still showed Sonnet. Reply with exactly: AFTER returned in about 3s ("Worked for 2s"). The new session clear-1366b0d38514d4f114a98696a1fad670ae764500 recorded options model=sonnet, effort=high, fastMode=false.

F Sonnet still selected after /clear

G. PASS. After that AFTER reply, asking the chat to remember PELICAN returned OK in about 3s. Quitting and relaunching the same profile resumed Claude session 0c3c53c2-6d79-4e6a-8541-b746191b71cc (child pid 26763, parent Electron 25756), and asking for the word returned PELICAN in about 3s with no startup-failure row.

G reopen answered PELICAN

…reebuff agent) (#22601)

This reverts commit 0677271.

#18790 was merged as one squash commit that carried two unrelated changes:
a process-incarnation fallback for reaping leaked orchestration worker
terminals, and an unannounced "Freebuff" third-party agent (catalog entry,
icon, locale strings, README rows). The Freebuff agent was never meant to
ship, so the whole PR is reverted; the reap fix should be re-submitted on
its own.

Until that re-land, a worker whose durable terminal handle goes stale is
again reported missing on release/stop instead of being re-found through
its process incarnation, so its terminal can leak on Remote Server.

The mobile session page closure pin moves 4218 -> 4219: the revert drops
the freebuff icon #22119 pinned (-1), and #22452 had already added two
src/shared modules without re-pinning (+2).
Brings main's re-pin of the mobile session route closure (4219) with its
revert of #18790; no conflicts.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status

Ready to merge, pending two decisions below. Head e81f02cbd2 includes current main, merges cleanly into it, and fast-forwards #22364's branch. CI: all 36 checks that ran pass, including Mobile Checks; locally, pnpm tc, oxlint, the changed-lines quality gate, React Doctor and the localization catalog checks pass, and vitest passes apart from real-Claude-binary tests that fail the same way on main on the test machine.

What the review changed

Several review passes ran over this PR and the branch it is stacked on. Each pass fixed what it found, and the next pass checked those fixes. Two independent architecture reviews replaced mechanisms rather than patching them:

  • The restart moved inside the send's own serialized step. It had been a pre-check running outside the session's queue, which needed its own in-flight map, a copy of the ledger rule and a guessed fence. Those were the source of most defects the early passes found. Now a hold, a send and the host's own restart after an exit take turns on one queue, so there is one spawn per user action.
  • A saved option the CLI never answers is kept as the user's wanted value, where it was lost. A four-commit chain had been re-adding it at every place options are saved. The fix moves to the one place the value was dropped, and the plumbing is deleted.

Defects fixed along the way, each pinned by a test that goes red without its fix:

  • A message sent while Claude was still starting, then rejected, left "Message delivery is unconfirmed" and removed Retry. It now says the message was not sent, names the cause and keeps Retry.
  • The row explaining a failed start was folded away under a fake "Worked for 0s" until the next Retry. A rejected send now opens no turn.
  • A saved option write the CLI never answered failed the whole start at a hidden 30-second deadline.
  • A prompt queued just as startup finished could sit as "sending" forever.
  • An internal session id could appear as the failure cause.

Manual validation

A hidden Electron build of this branch ran nine times with a Claude CLI that can be made to fail at startup. The latest pass, on the head after merging main, passed every scenario:

  • A failed start shows its cause.
  • A send while the CLI is still broken is not sent, names the cause and keeps Retry, with one row per attempt and nothing hidden.
  • Retry once the CLI works delivers exactly once.
  • A hidden, idle chat keeps its agent.
  • /clear keeps the chosen model.
  • Quit and reopen resumes the same conversation.

Screenshots are in the validation comments above.

Decisions before merge

  1. Merge order. This PR should land in fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364's branch first (a fast-forward), then fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364 goes to main carrying both. Together they are about 140 files.
  2. Send-as-Retry for a chat that never opened. fix(claude): open structured chat without a startup deadline, and make Retry start fresh #22364 makes typing into a chat whose first open failed start a fresh open, the same as pressing Retry. That is a product change beyond the reported bug, and a second recovery route next to this PR's host-side one. Keep it, or limit recovery to Retry?

Known limits, not changed here

  • A Claude CLI that hangs during startup without exiting holds its message until the chat is closed, because there is no startup deadline by design. Mobile does not show the "still starting" line yet.
  • An agent nobody is viewing now stays up for 30 minutes of quiet, with no cap on how many.
  • Separately, and already true on main: if a Claude process that already started is killed outright, Orca is never told it exited, so the next send stays unconfirmed. That needs its own fix in how the exit is reported.

@brennanb2025
brennanb2025 merged commit e81f02c into brennanb2025/claude-init-deadline Sep 24, 2026
50 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Folded into #22364. This branch's head was fast-forwarded onto brennanb2025/claude-init-deadline, so #22364 now carries both halves as one change (150 files against main). Neither half was safe to merge to main on its own, because several commits here fix startup behavior that #22364 introduced. Review and merge #22364.

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.

4 participants