Skip to content

fix(native-chat): say a refused chat write in plain words, and keep it with the write it describes - #22999

Merged
brennanb2025 merged 17 commits into
mainfrom
brennanb2025/chat-write-refusal-notice
Sep 27, 2026
Merged

brennanb2025 merged 17 commits into
mainfrom
brennanb2025/chat-write-refusal-notice

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​943 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​894
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​661 $\color{#cf222e}{\Huge{\mathbf{−}}}$​98 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​563

ELI5

When Orca couldn't do something you asked for in a chat, it showed Orca's own debugging text, like "Expected runtime fence 1; the session is at 3." That tells a person nothing. The text could also stay on screen after your message had gone through. Now each kind of error is shown in plain words, and the explanation goes away as soon as the thing it describes is resolved.

What this PR does

  1. Plain words for every host refusal. The host's refusal text is never shown. Each refusal code maps to a fixed sentence, chosen by the code and by what you were doing (sending, stopping, answering a question, changing a setting, running a command). The full mapping is in the table below.
  2. A message's error lives on that message. A refused message keeps the reason in its own Retry row, once. Sending it again clears the reason, and delivery removes the row. There is no separate red line under the composer to go stale, which is what left "Expected runtime fence 1…" on screen after the message was delivered.
  3. Other requests report once and move on. A refused Stop, question answer, setting change or goal change shows one toast. The button you pressed is still there to try again. A conversation command (/compact, /clear) answers inline where you typed it.
  4. It doesn't claim a failure it can't prove. If a request timed out or lost its connection, the host may already have carried it out. The notice then says "Orca couldn't confirm what happened. Check the chat." rather than "not done".
  5. Desktop and phone use the same words. Desktop translates each sentence. The phone shows the English and, where sending again can work, adds "Send it again.", because it puts the message back in the composer instead of showing Retry.

What the user sees, by error

Where it appears:

  • A message you sent: its Retry row.
  • Stop, answer, setting, goal, or stopping background tasks: a toast.
  • /compact, /clear: inline under the composer.
  • Phone: the composer's error line.

"What didn't happen" depends on what you were doing:

You were… "What didn't happen"
Sending a message Your message was not sent.
Pressing Stop The agent wasn't stopped.
Stopping one / all background tasks The background task wasn't stopped. / The background tasks weren't stopped.
Answering a question Your answer was not sent.
Changing the model, effort or another setting The setting wasn't changed.
Running /compact or /clear The command didn't run.
Changing the goal The goal wasn't changed.

Host refusals (the request was turned away before it ran):

Refusal code What the user sees (example when sending) Phone adds "Send it again."
agent_session_owner_restart_failed The agent couldn't restart. Your message was not sent. No
agent_session_checkpoint_stale Your message was not sent. Yes
agent_session_conflict Your message was not sent. Yes
agent_session_ownership_unknown Your message was not sent. Yes
execution_owner_reconciling Your message was not sent. Yes
agent_session_operation_capacity Orca has received too many requests in the last day. Your message was not sent. No
agent_session_operation_conflict Your message was not sent. No
agent_session_operation_expired Your message was not sent. No
agent_session_operation_invalid Your message was not sent. (for a command: The command didn't run.) No
agent_session_identity_required Your message was not sent. No
agent_session_operation_unknown Orca couldn't confirm what happened. Check the chat. No
agent_session_item_revision_stale When answering: This question was already answered or has changed. When stopping: … The agent wasn't stopped. No
agent_session_already_resolved Same as above. No
agent_session_journal_unreadable Orca couldn't read this chat's saved history. Your message was not sent. No
structured_agent_session_unsupported The Orca running this chat doesn't support this. Update Orca, then try again. No
A code this client doesn't know (from a newer host) Your message was not sent. No

For other requests, the same sentences apply with that request's "what didn't happen". For example, agent_session_operation_capacity on Stop reads "Orca has received too many requests in the last day. The agent wasn't stopped."

Requests that failed without a refusal:

What happened What the user sees
A message's send failed before it reached the host Your message was not sent.
The host turned a request away before running it (method not supported, or invalid request) Treated as structured_agent_session_unsupported or agent_session_operation_invalid above
A message's send timed out or lost its connection Message delivery is unconfirmed. (unchanged)
Any other request timed out or lost its connection Orca couldn't confirm what happened. Check the chat.

Messages the host accepted and then rejected (these are not refusals):

Rejection reason What the user sees
The provider's own explanation, e.g. "Claude messages support at most 20 images" The provider's words, as they are
The agent's process couldn't be written to Orca couldn't reach the agent. Your message was not sent.
An Orca-internal reason (dispatch queue full, …) Your message was not sent.
No reason Your message was not sent.
The host's start-failure sentence, e.g. "The provider stopped before it finished starting: claude stream-json exited (code 1): …" Still shown as the host wrote it. Rewording it at the source is #23116.

Why these words, and what comes next

The refusal text is written for whoever debugs the host. A client showing it verbatim was the bug, so the client owns the words, and it covers every refusal code.

Several codes each stand for more than one situation. agent_session_operation_invalid alone has about 21 host paths, including a cleared conversation, a running turn, a pending question and a provider's own rejection. The code alone can't say which, so those rows say only what didn't happen. On main, some of those cases showed a host sentence written for people (for example "This conversation has been cleared. Open the current conversation to continue."), so they are less specific here until the host sends the reason.

That's the next step: #23116 gives every refusal a typed reason that belongs to its code (for example agent_session_operation_invalid with the reason "conversation cleared"). A follow-up then grows this table so each reason gets its own sentence and next step. The plan is for a reason with no wording to fail the typecheck. This table stays as the fallback for older hosts that send no reason.

The lingering red line came from keeping the error in a place nothing tied back to the write it described. Clearing that string in one more place would add a second guard and leave the next ordering to find. Storing the reason on the message removes the separate copy, so nothing is left to go stale.

Alternatives considered

  • One error banner per chat that clears on the next successful send or on dismiss. Rejected, because an error that outlives its cause is the reported bug.
  • A "try again" sentence per code, such as "Press Stop again." Rejected, because for some codes trying again repeats the same refusal. The button you pressed is the next step.
  • Show the host's text for the codes whose text is written for people. Rejected: every code has at least one host path whose text is written for a log or carries an internal marker. The census is listed in agent-session-refusal-notice.test.ts.

How it compares with the common pattern: a closed list of error codes mapped to copy the client owns, and a failure reported once rather than kept on screen. This PR matches both. Deviation: the host doesn't yet send a typed reason within each code, so the copy depends only on the code and the kind of request. #23116 closes that.

How it works

  • src/shared/agent-session-refusal-notice.ts turns a failed write into whole sentences, from the refusal code and the kind of request. Desktop translates each sentence (agent-session-write-notice-text.ts). The phone shows the English (mobile-structured-agent-session-rpc.ts).
  • A queued message saves why its last attempt failed, as a fact rather than words (lastFailure on StructuredAgentSessionOutboxEntry). Staging the message for another attempt clears it, on both the normal path and the new-chat launch path. The Retry row picks the words when it renders.
  • useStructuredAgentSessionMutate returns a typed outcome (done, not done with a notice, or dropped because the chat moved on) instead of keeping a writeError. Each caller decides where to show it.
  • The live bug: when a restart is slow, the host's record of the resend reaches the client before the reply to the send. The outbox then drops that reply, and the reply was the only thing that cleared the old error string. With the reason on the message, no separate string is left to clear.

Linked Issue

No separate issue. Reported during live QA of #22918: after an idle stop and restart, the composer showed "Expected runtime fence 1; the session is at 3." after the message had been delivered.

#22812 (merged) stops the host from refusing that send in the first place. This PR makes every other refusal readable and keeps any reason from outliving its message. #23116, stacked on #22821, is the host half that builds on it.

Visual Proof

Live desktop app on a separate Mac: an isolated dev instance with a hidden window, driven over CDP, running a structured Claude chat with real Claude Code. The idle window was shortened to 45 s in the QA build only. After the idle stop, Claude was made unable to start, a message was sent, then Claude was fixed and Retry pressed. Before = main at the merge base (f6eab381ce), after = this branch (f62350f772; later commits don't change this flow). Each arm started from a fresh profile.

Before: send after the idle stop, restart fails After: same
before after

After fixing Claude and pressing Retry, the message is answered and nothing is left on screen:

after retry

Normal idle stop, return and send on this branch: answered, with no red line, Retry row or toast:

after idle return

Testing

  • agent-session-refusal-notice.test.ts checks every refusal code, a failed request, an unconfirmed request and an unknown code, against every kind of request, using five rules:
    • a certain refusal says the request didn't happen, once;
    • a request that may have run never says it didn't;
    • only "Update Orca" and the phone's "Send it again." tell you to try again;
    • a cause is named only for codes whose every host path means it;
    • no notice is empty or shows host text.
  • use-structured-agent-session-outbox-rejection-cause.test.tsx: a send refused at the old fence, sent again after the pane learns the new fence, with the journal answering before the reply, ends with no error and no blocked message.
  • The disposition, outbox storage, Retry row, launch-path and notice-text tests cover a failure saved as a fact, cleared on resend by both paths, read back after a reload, and translated a whole sentence at a time.
  • use-structured-agent-session-write-refusal.test.tsx:
    • a refused Stop shows one toast and leaves nothing latched;
    • a timed-out Stop says Orca couldn't confirm;
    • a refused command answers inline.
  • The mobile tests check that the phone shows the same words and never shows transport or host text.

Ablations

  • main's send path with the journal-first order leaves "Expected runtime fence 1; the session is at 3." on screen; this branch clears it. The reply-first order passes on main too, so the test pins the order the live app sees.
  • Removing "clear the failure when the message is sent again" fails the outbox test (normal path) and the launch-path test.
  • Restoring the old desktop write-error handling fails the timed-out Stop test.

Runs:

  • The desktop, shared and mobile suites for these areas pass on the current head.
  • pnpm tc:web, pnpm tc:node and the mobile typecheck are clean.
  • oxlint, check:code-quality:changed, check:react-doctor:changed and the verify:localization-* checks pass.
  • CI is green.

Live QA (separate Mac, macOS)

  • Restart failure after the idle stop, and a normal idle stop, return and send, before and after as shown above.

  • Not reproduced live: the host's fence refusal itself. Thirteen main runs with three timings never produced it, because the host accepts a send across one restart. The unit test and the ablation cover that race.

  • Not run by hand: the toast for a refused Stop or answer, mobile, and paired web. They share the tested code.

  • I manually tested these changes locally

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

AI Disclosure

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

  • Scope: only the experimental structured chat (experimentalStructuredNativeChat) and its phone view. Terminals and the default chat view are unchanged.
  • Mixed versions: no wire change. The client picks the words from the refusal code it already receives. An older client with a newer host keeps showing the host's text as before. A code the client doesn't know gets "what didn't happen".
  • Saved queue: the queued message's new optional lastFailure fact is saved with it, never its words. Older saved queues load as before, and a value this build can't read is dropped.
  • SSH and remote hosts: the change is client-side only. Refusals are produced on the execution host exactly as before.
  • Overlap: fix(native-chat): a message is accepted, then delivered #22821 edits the same outbox files, so whichever lands second takes a merge.

Known limits / follow-ups

  • The codes that stand for several situations name no cause until the host sends a typed reason (fix(native-chat): the host writes chat failures for a person, with a typed fact beside them #23116 and its follow-up).
  • The host's start-failure sentence in a rejected message is shown as written. fix(native-chat): the host writes chat failures for a person, with a typed fact beside them #23116 rewords it at the source.
  • The first message of a new chat is sent by the launch path, which doesn't save the failure fact yet, so its Retry row shows the generic "Message was not sent.".
  • Pre-existing: Retry keeps the same operation id after agent_session_operation_expired or agent_session_operation_conflict, so it repeats the refusal. The notice no longer promises otherwise.
  • Pre-existing: on desktop, a send that failed with an error other than a timeout or lost connection is classed as not sent.
  • Launch and create refusals still show the host's text. That's a separate surface.
  • Pre-existing, seen in QA: the Retry button's label is missing from the Spanish catalog.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Author X handle: @BrennanKB5

…t with the write it describes

A send's refusal now lives on the queued message and goes when that message is sent again or delivered, so a resend that succeeds after an agent restart no longer leaves a red line under the composer. Stop, answers, option and goal changes report a refusal once as a toast; a conversation command answers inline. One shared table turns every refusal code into copy with a next step, on desktop and mobile, instead of showing the host's diagnostic text.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change adds shared, write-specific notices for agent-session refusals and request failures. Renderer write handling now distinguishes completed, refused, and dropped outcomes. Send failure details are stored on outbox entries and displayed with retryable messages. Mobile mutation results and launch-option updates also use formatted notices instead of exposing most host diagnostics.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to a4f73

A rejected message can appear without an explanation when its reason is empty. This is a bounded issue, but the fallback should be used before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a4f73

The reviewed paths replace diagnostic refusal text with plain-language notices and keep send failures with the affected message. No new material security weakness was established, but coverage is incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A failure originating at the agent-session boundary can affect notices in both native-chat renderer and mobile. The inspected change affects presentation and outbox failure state, not the authority carried by a send request.

Trust Boundaries and Controls

  • observed — Wire refusal text is not interpolated into the shared refusal notice. Provider rejection reasons follow a separate path that can preserve a literal reason for display; the inspected evidence does not establish a new or worsened exposure from that path.

Resilience and Maintainability Implications

  • observed — Accepted sends remove their outbox entry; unknown delivery remains unconfirmed. This distinction avoids presenting an uncertain send as either delivered or safely repeatable.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 28 files. (7 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: user-friendly handling of refused native-chat writes and associating failures with the relevant write. It is specific despite being somewhat long.
Description check ✅ Passed The description is mostly complete. It explains the user impact, implementation, rationale, alternatives, linked issue context, visual proof, testing, scope, compatibility, known limits, and checklist…
Full details: Docstring Coverage

Explanation

Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 28 files. (7 skipped: 7 unsupported.)

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… to press Retry

The phone puts a refused message back in the composer and has no Retry
control, so "Retry to send it again." named something that is not there. A
phone send now reads "Your message was not sent. Send it again."

Also types the rejection-cause test's empty submissions without a cast.

@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 gap in the new notice invariant and a few copy nits.

Reviewed changes

  • New refusal-to-copy table (src/shared/agent-session-refusal-notice.ts): agentSessionRefusalNotice(code, writeKind) maps every wire refusal code plus the write kind to plain copy; the host message is passed through only for agent_session_owner_restart_failed, and an unknown code falls back to generic copy.
  • Reason moves onto the outbox message (structured-agent-session-outbox.ts, structured-agent-session-send-disposition.ts): a refused/failed/rejected send writes notice onto the entry instead of a latched error, strips any stale notice when state is replaced, and drops it with the entry on delivery.
  • Typed write outcome (use-structured-agent-session-mutate.ts): write returns done / not-done / dropped; mutate wraps it and toasts not-done; conversation commands call write and report inline. writeError / reportWriteError are gone.
  • Callers rerouted: options, thread goal, Stop and answers toast; launch picks and the mobile RPC use the same table.

ℹ️ The launch-prompt dispatch path neither clears nor sets the new notice

The outbox's own dispatch strips notice when staging a re-send (structured-agent-session-outbox-dispatch.ts:80), which is what makes "sending it again clears the reason" true. The launch settlement's parallel send path was not updated to match: dispatchStructuredLaunchPrompt spreads the stored entry ({...current, state: 'dispatching'}) without dropping a prior notice, and on refusal requeues without recording the new plain copy. The outbox's own notice invariant therefore does not hold for a source: 'launch' entry that the launch path re-sends.

Technical details
# Launch-prompt dispatch bypasses the notice invariant

## Affected sites
- `src/renderer/src/lib/structured-agent-session-launch-prompt.ts:94-102` — stages `{...current, state: 'dispatching', lastAttemptAt}`; a persisted `notice` rides through.
- `src/renderer/src/lib/structured-agent-session-launch-prompt.ts:111-121` — refusal branch calls `requeueStructuredAgentSessionSendRefusal` (a spread) and never calls `agentSessionRefusalNotice`, so the entry keeps whatever notice it already had.
- `src/renderer/src/lib/structured-agent-session-launch-prompt.ts:137-140` — thrown-request branch sets `unconfirmed` with no notice.
- Contrast `src/renderer/src/components/native-chat/structured-agent-session-outbox-dispatch.ts:80`, which destructures `notice` out on staging.

## Required outcome
A launch-source entry obeys the same rule as every other outbox entry: a re-send clears any prior `notice`, and a refusal records the new copy for the write kind (`send`).

## Reachability (traced, not executed)
The two dispatch paths share a promise only while it is in flight; `shareStructuredAgentLaunchPromptDispatch` deletes the key on settle (`structured-agent-session-launch-prompt.ts:74-79`). If the pane's own dispatch refuses and settles before `settleStructuredAgentLaunchPrompt` shares, the launch path starts a fresh `dispatchStructuredLaunchPrompt` on the notice-bearing entry. A test that seeds a launch-source entry with a `notice` and drives `settleStructuredAgentLaunchPrompt` would pin whichever ordering is real.

## Open question for the human
Is the launch prompt intentionally outside the new "reason lives with its message" rule, or should it share the strip/set helpers?

ℹ️ Nitpicks

  • agent_session_operation_invalid for a command always ends "Wait for the agent to finish, then run it again." (agent-session-refusal-notice.ts:70-73), but conversationCommandBlocked returns the same code for causes where retrying will keep failing, e.g. "This conversation has been cleared. Open the current conversation to continue." and "Resolve the pending question or approval before using this command." (structured-conversation-command-admission.ts:13-56, surfaced at structured-conversation-command.ts:92-97).
  • On the phone, a transport failure still shows the raw host/JS text (mobile/src/session/mobile-structured-agent-session-rpc.ts:180,191) where the desktop catch now uses agentSessionWriteFailureNotice. Refusals are reworded on both clients; failures are not.
  • NativeChatDeliveryRetry.tsx:33 renders a notice that already ends "Retry to send it again." directly above a Retry button — mild redundancy, no action required.

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.

ℹ️ The incremental changes are clean — no new issues. The earlier review's open items still stand.

Reviewed changes (since 7c35108)

  • Phone-specific send wording (src/shared/agent-session-refusal-notice.ts, mobile/src/session/mobile-structured-agent-session-rpc.ts): a new composer-send write kind maps a refused phone send to "Send it again." instead of "Retry to send it again.", because the phone returns the message to the composer and offers no Retry control. phoneWriteKind rewrites only send, so Stop, answer, option, command and goal copy is unchanged.
  • Tests: the notice suite now iterates composer-send, the mobile refusal test pins "Send it again.", and the outbox rejection test stabilises its submissions array identity with a module constant.

Verified locally: agent-session-refusal-notice.test.ts, use-structured-agent-session-outbox-rejection-cause.test.tsx, use-structured-agent-session-write-refusal.test.tsx and mobile-structured-operation-id-retirement.test.ts all pass.

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

…hat is true

A queued message saved the words of its failure to local storage, so the copy
lived in users' data. It now saves the fact: the refusal code (with the host's
words only for a failed restart, which the host writes for people), the
provider's rejection reason, or that the host could not be reached. The Retry
row chooses the words when it shows the message. A saved failure this build
cannot read is dropped, and the row says only that the message was not sent.

The words are true for every host path behind each code:
- A refusal whose code does not say why (a cleared conversation, a pending
  question, a provider's own rejection) says only what did not happen, with no
  next step that could repeat the refusal.
- An unsettled owner no longer claims the agent was restarting; it says Orca
  could not confirm which agent process owns the chat.
- A code from a newer host says only what did not happen.

Desktop translates each sentence whole, with the shared English as the
fallback the phone shows as is, so the two never say it differently. The phone
no longer shows transport or host text when a request fails without a
refusal.
…ed restart's

Every refusal code has at least one host path that writes its message for a
log or carries a marker. A replayed refusal, for one, says "Operation <id> was
already refused: <code>." because the ledger stores no message. A failed
restart's message also embeds the resume's own refusal text, which can be the
ledger's. So no code's message is safe to show, and the failed-restart
exception goes. The Retry row now says "The agent couldn't restart. Your
message was not sent." with no next step, because some restarts need a new
chat. The cause is still in the chat's own status row. The saved failure keeps
only the code.

The test lists one such emitter per code, so a code that later becomes safe to
show has to be argued against that list.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found in this commit. It is a clean refactor, its new tests pass locally, and the copy table covers every wire refusal code.

Reviewed changes

  • Failure is stored as a fact, not as copy (src/shared/structured-agent-session-outbox.ts, structured-agent-session-send-disposition.ts): StructuredAgentSessionOutboxEntry.notice (a rendered string, previously persisted to users' local storage) becomes lastFailure, a discriminated fact — refused with an optional host message, rejected with the provider's reason, or unreachable. parseStructuredAgentSessionAttemptFailure round-trips it and drops anything malformed, so a row with an unreadable failure says only "Message was not sent.".
  • One copy table composed of whole sentences (src/shared/agent-session-refusal-notice.ts): AGENT_SESSION_WRITE_NOTICE_COPY plus agentSessionWriteNoticeParts(failure, write); the host message is kept only for agent_session_owner_restart_failed, which the host already words for people. parseAgentSessionWriteFailure reads a saved fact back.
  • Copy made truthful for each code: an unsettled owner (checkpoint stale, conflict, ownership unknown, owner reconciling) no longer claims the agent was restarting; agent_session_operation_invalid and an unknown newer code drop their next-step sentence; identity_required and journal_unreadable no longer offer a retry that cannot work.
  • Desktop translates each sentence whole (agent-session-write-notice-text.ts) with the shared English as fallback, and the Retry row chooses its words from lastFailure (NativeChatDeliveryRetry.tsx).
  • Phone stops showing host or transport text (mobile/src/session/mobile-structured-agent-session-rpc.ts): pre-handler refusals and plain request failures are reworded through the same table; phoneWriteKind keeps composer-send so a refused send goes back to the composer.
  • Tests: new NativeChatDeliveryRetry.test.tsx, agent-session-write-notice-text.test.ts, and outbox-storage round-trip cases; existing suites updated to assert the saved fact instead of the old notice string.

Verified locally: the changed shared and renderer suites pass (80 tests across 10 files), tsc for the web and node projects is clean, and all six shipped locale catalogs carry the 23 writeNotice keys in parity with the shared table.

The earlier open note about the prompt-cancel copy (agent_session_item_revision_stale / agent_session_already_resolved for a Stop) is unchanged by this commit, so this review is not an approval.

Pullfrog  | Fix it ➔ | 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.

✅ No new issues in this commit.

Reviewed changes

  • No host refusal message is shown, for any code (src/shared/agent-session-refusal-notice.ts): AgentSessionWriteFailure drops its hostMessage field, so agentSessionRefusalFailure and parseAgentSessionWriteFailure keep only the code. The agent_session_owner_restart_failed case now returns ['restartFailed', notDone] — "The agent couldn't restart. Your message was not sent." — with no next-step sentence, because the code does not say whether a retry can work; the cause stays in the chat's status row.
  • New restartFailed sentence in the shared copy table, the desktop sentence map (agent-session-write-notice-text.ts), en-runtime-required.json, and all six locale catalogs.
  • Tests: the refusal suite gains a census comment naming one log-only or marker-carrying host emitter per code and asserts no code × write ever surfaces the host text; the saved-failure round-trip cases drop the failed-restart host message; the outbox suite asserts a failed restart keeps only its code.

Verified locally: the affected shared and renderer suites pass (69 tests across 7 files), including agent-session-refusal-notice, agent-session-write-notice-text, structured-agent-session-send-disposition, structured-agent-session-outbox-storage, use-structured-agent-session-outbox, and NativeChatDeliveryRetry.

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

A message the agent turned away on the phone said "Retry to send it again", but the phone has no Retry control; it now says "Send it again." like every other refused phone message, built from the same sentences as the other notices.

The capacity refusal said Orca was handling too many requests "for this chat" and offered a retry. The limit is counted across every chat over a day, so an immediate retry would likely be refused again. It now says so, with no next step.
A local install rewrote it and it was committed by mistake.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 84982f5d-e074-4ea4-9798-43d2ef3b427d

📥 Commits

Reviewing files that changed from the base of the PR and between f1de911 and a4f731a.

📒 Files selected for processing (15)
  • mobile/src/session/mobile-structured-send-delivery.test.ts
  • mobile/src/session/mobile-structured-send-delivery.ts
  • src/renderer/src/components/native-chat/agent-session-write-notice-text.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsx
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-refusal-notice.test.ts
  • src/shared/agent-session-refusal-notice.ts
  • src/shared/structured-agent-session-send-disposition.test.ts
  • src/shared/structured-agent-session-send-disposition.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/en-runtime-required.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

? 'Orca could not send your message — Retry to send it again.'
: reason
? agentSessionWriteRetryParts(write)
: [{ text: reason }]

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the fallback notice for an empty rejection reason.

If submission.reason is '', this branch returns { text: '' }. The renderer and mobile formatters then show no explanation for the rejected message. Treat empty or whitespace-only reasons like null, while preserving nonempty provider explanations.

Proposed change
-  if (reason === null) {
+  if (reason === null || reason.trim() === '') {
     return ['messageNotSent']
   }

@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 this delta — the phone now reuses the desktop refusal copy, and the capacity wording no longer claims a per-chat limit or offers a retry that cannot work. The earlier open items still stand, so this is not an approval.

Reviewed changes (since f1de911, commit 23acb30)

  • Phone shares the desktop rejection copy (src/shared/structured-agent-session-send-disposition.ts, mobile/src/session/mobile-structured-send-delivery.ts): structuredAgentSessionRejectionParts now returns parts and takes a 'send' | 'composer-send' kind, so a refused phone send says "Send it again." where desktop says "Retry to send it again.".
  • Capacity copy corrected (src/shared/agent-session-refusal-notice.ts, desktop sentence map, en-runtime-required.json, all six locale catalogs): "Orca has received too many requests in the last day." replaces "for this chat", and the capacity branch drops its next-step sentence. The ledger limit is per-client/global over a 24h row window (agent-session-host-authority.ts:38, agent-session-operation-ledger.ts:173), so the new wording is accurate and the old per-chat claim was not.
  • New agentSessionWriteRetryParts helper factors the not-done + try-again pair, shared by the ownerUnconfirmed, operation_conflict/expired, and internal-rejection branches.
  • Dead copy removed: rejectedUnreachable / rejectedInternal are gone from the shared table, the desktop sentence map, and every locale catalog.
  • Tests updated: the phone refusal test now pins a code that carries a next step, the send-disposition transport-rejection assertion matches the new wording, and the options toast test asserts the capacity copy without a retry sentence.

Verified locally on a4f731a: agent-session-refusal-notice, structured-agent-session-send-disposition, agent-session-write-notice-text, NativeChatDeliveryRetry, and use-structured-agent-session-options (52 tests) pass with config/vitest.config.ts; the writeNotice keys are in parity across all six catalogs. Mobile suites could not run here (expo deps absent).

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

…refusal

No refusal notice says how to try again any more: the control that sent
the write already does that, and a sentence per code was false for some
of the host situations the code covers. The phone keeps "Send it again."
where a resend under the same operation id can go through, and an older
host still gets "Update Orca, then try again."

A cause is named only for codes whose every emitter means it. The owner
codes and identity_required now say only what did not happen, the
outcome-unknown sentence no longer claims the write itself is in doubt
(a send behind an unconfirmed rewind is refused outright), and a request
that failed without a refusal is recorded as `failed` rather than
`unreachable`, since most such failures are host or compatibility errors.
The census test now pins the cause allowlist and the absence of retry
sentences, and the unused sentences leave every catalog.

@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 this delta — the changes since the last review tighten the refusal copy so it is true for every host path behind a code, and the phone only offers "Send it again." where a resend can work. The earlier open items still stand, so this is not an approval.

Reviewed changes (since a4f731a, commit f62350f)

  • A cause is named only where every host emitter of the code means it (src/shared/agent-session-refusal-notice.ts): an owner-state code (checkpoint_stale, conflict, ownership_unknown, execution_owner_reconciling) now says only "…was not sent.", and operation_conflict/_expired/_invalid/identity_required offer no next step. owner_restart_failed keeps "The agent couldn't restart."; capacity, outcomeUnknown, questionChanged, historyUnreadable and unsupported keep a cause, each justified by its one emitter in the test's CAUSES allowlist.
  • No notice tells you how to try again, except the phone's composer (agentSessionWriteNotDoneParts): desktop returns only the not-done sentence; composer-send appends "Send it again.". The per-kind tryAgain* copy keys, ownerUnconfirmed, sessionMissing and messageNotSent are gone from the shared table, the desktop sentence map, en-runtime-required.json and all six locale catalogs.
  • The unreachable failure kind is renamed failed (AgentSessionWriteFailure): a request can fail as a transport, compatibility or host error, so the generic kind no longer asserts reachability. The unreachable sentence survives where it is true, in the transport-write-failure branch of structuredAgentSessionRejectionParts.
  • The phone stops showing host and transport text for failures too (mobile/src/session/mobile-structured-agent-session-rpc.ts): manifest refusals are mapped to unsupported/operation_invalid, and a thrown request to the shared failure copy. mobile-structured-send-delivery.ts and mobile-structured-agent-session-cancel.ts drop their 'Request not sent' / 'Stop not sent' remaps because the message now comes from the table.
  • Tests: the refusal suite pins the cause allowlist, the no-try-again rule, the per-code phone copy and the failed-request copy; new desktop and phone cases assert no transport or host text survives; the outbox rejection case keeps the refusal as a fact and the journal-first re-send race.

Verified locally on f62350f: the 15 changed shared/renderer test files (175 tests) pass, pnpm tc:web and pnpm tc:node are clean, all four verify:localization-* checks pass, and the six locale writeNotice key sets are in parity (14 keys). Mobile suites could not run here (expo deps absent).

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

…have run

A desktop Stop, answer, option, goal or conversation command whose request threw
said the write did not happen, for every error. A timeout or a lost connection can
come after the host ran the write, so a timed-out /compact said "The command didn't
run." while it ran. Only an RPC error the host answers before running the method
proves that; any other failure now says Orca couldn't confirm what happened.

The phone already drew this line; both clients now read it from one shared rule.
…k, not the agent

A background-task stop goes through agentSession.cancel, so a refusal of it
said "The agent wasn't stopped." although the agent was never asked to stop.
The write kind now reads the cancel's scope and names the task or tasks.
… stop the agent

A Stop pressed while a question or approval is pending names that prompt, so the host can refuse it
as already resolved or stale. The notice then spoke only about the question and never said the agent
kept running.

@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 this delta — the two new commits make the copy honest about what a thrown request proves and about what a background-task stop stops. The earlier open item still stands, so this is not an approval.

Reviewed changes (since f62350f, commits 788539e and d7bc1a1)

  • A thrown request no longer claims the write did not happen (src/shared/agent-session-refusal-notice.ts, use-structured-agent-session-mutate.ts, mobile/src/session/mobile-structured-agent-session-rpc.ts, structured-agent-session-launch-options.ts): a new unconfirmed failure kind and agentSessionRpcErrorFailure(code) map an RPC error to unsupported/operation_invalid only for the four codes the host rejects before running the method, and to unconfirmed otherwise, whose notice is "Orca couldn't confirm what happened. Check the chat." The phone keeps its own {status:'unknown'} path for a response error and its isRpcDeliveryUnknown path for transport doubt.
  • A refused background-task stop names the task (src/shared/agent-session-refusal-notice.ts): agentSessionWriteKindForMethod now takes the call fields, so agentSession.cancel with scope: 'background-tasks' returns stop-task (with a taskId) or stop-tasks, with new copy keys and NOT_DONE entries; desktop and mobile pass their fields through.
  • Tests: the shared suite pins the unconfirmed copy for every write kind and the pre-handler mapping, plus the task-vs-agent stop copy; the desktop refusal suite adds a timed-out Stop that says Orca couldn't confirm; the options test now expects the unconfirmed copy for a thrown transport error.

Verified locally on d7bc1a1: the four changed shared/renderer test files (48 tests) pass, pnpm tc:web and pnpm tc:node are clean, and verify:localization-catalog and verify:localization-runtime-catalog pass.

Pullfrog  | Fix it ➔ | 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.

✅ No new issues found. The commit since the last review fixes the one open thread, and its test pins both wordings.

Reviewed changes (since d7bc1a1, commit ce7a1a6)

  • A Stop refused over a moved-on prompt now names what did not happen (src/shared/agent-session-refusal-notice.ts): agent_session_item_revision_stale/agent_session_already_resolved return ['questionChanged'] for an answer but ['questionChanged', notDone] for any other write kind, so a prompt-cancel Stop says "This question was already answered or has changed. The agent wasn't stopped." instead of dropping the stop sentence. These codes are only emitted by validatePendingPrompt, reached by an answer or a prompt-cancel Stop, so the other kinds are unreachable.
  • Test: agent-session-refusal-notice.test.ts pins both the stop and answer wording for agent_session_already_resolved.

Verified locally on ce7a1a6: src/shared/agent-session-refusal-notice.test.ts (24 tests) passes.

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

Replaces the per-rule loops with one table of every failure (each refusal
code, a failed or unconfirmed request, and a code from a newer host) by
every write kind, and five rules each cell must keep: a certain refusal
says that write did not happen, once; a write that may have run never
says it did not; only "Update Orca" and the phone's resend where it can
work say to try again; a cause is named only for allowlisted codes; no
cell is empty or shows the host's text.

@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. This commit only rewrites the refusal-notice suite into one spec table; the production copy table is untouched, and the new rules fail on a mutation of the code they cover.

Reviewed changes (since ce7a1a6, commit a34e8a7)

  • One spec table replaces the per-rule loops (src/shared/agent-session-refusal-notice.test.ts): the suite builds every failure — each wire refusal code, a failed request, an unconfirmed request, and a synthetic code from a newer host — crossed with every write kind, then checks five invariants: a certain refusal says that write did not happen exactly once; a write that may have run never claims it did not; "try again" appears only for unsupported and the phone's resendable cases; a cause is named only for allowlisted codes; and no cell is empty or leaks the host text.
  • RESEND_CAN_WORK pins the phone resend set: it matches exactly the codes for which agentSessionWriteNoticeParts(..., 'composer-send') appends tryAgainComposerSend, so a change to which codes offer a resend fails the table.

Verified locally on a34e8a7: agent-session-refusal-notice.test.ts (26 tests) passes. Reverting agent_session_operation_unknown to [notDone] fails two of the new rules, confirming the table can fail rather than restating the implementation.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for review at a34e8a7784

Verdict: the code review has converged, CI is green (30 pass, 11 skipped, none pending), and the closing readiness check passed with no P0 or P1 findings. The PR stays client-only, inside the agreed scope: the refusal copy table, the failure fact stored on each message, toasts, desktop translation, and phone copy. It makes no host or wire change.

Review loops (7 in total)

  • Loops 1–6 each found real problems and fixed them. Loop 7 was clean: it added one test and found no false sentence.
  • Main changes since the first version:
    • A queued message now stores why it failed as a fact (the refusal code, the provider's reason, or that the request failed) instead of finished English. The words are chosen when the row is shown.
    • The copy is built from whole sentences, translated on desktop into every language Orca ships.
    • A notice names a cause only when that cause is true for every place the host can send the code. No notice says how to try again, except "Update Orca" and the phone's "Send it again." where a resend can work. The control that sent the request (Retry, Stop and so on) is how you try again.
    • A request that timed out or lost its connection says "Orca couldn't confirm what happened" instead of claiming it did not happen. Desktop and phone share that rule.
    • A refused background-task stop no longer blames the agent. A refused Stop over an already-answered question says the agent kept running.
    • The phone no longer mentions a Retry button it doesn't have.
  • Because several loops each found one more wrong sentence, an architecture review was run. It kept the design and replaced per-case next-step advice with the rules above. One test checks all 162 combinations of failure and kind of request against those rules.

Live QA (separate Mac, real Claude Code, main vs this branch)

  • A plain idle stop, return and send is answered, with nothing left on screen.
  • Claude failing to restart after the idle stop: the red line under the composer is gone, and the reason is said once in the Retry row. After Claude is fixed, Retry delivers and nothing is left on screen.
  • The host's own wording is still shown in that case, because it is a rejection the host recorded, not a refusal. The PR body now says so explicitly and uses the new screenshots.

Findings routed elsewhere

  1. Host wording of the failed-restart rejection (for example "The provider stopped before it finished starting: claude stream-json exited (code 1): …"), shown in the Retry row and the chat row, and untranslated in Spanish. This is owned by fix(native-chat): the host writes chat failures for a person, with a typed fact beside them #23116: it rewrites that writer and every stored failure row and rejection reason for people, with a typed fact beside them, and adds a typed cause to refusals. A desktop follow-up then grows this PR's table to read those facts. That follow-up is also where to decide whether the Retry row should repeat the chat row.
  2. Send while "Claude is still starting" never answered. Seen on main in the before arm: after 6 minutes the chat still said "Working for 6m 20s". It is not caused by this PR, which makes no host change. It has been routed to fix(native-chat): a message is accepted, then delivered #22821's merge-resolution review, since fix(native-chat): a message is accepted, then delivered #22821 replaces the send-while-starting path.

Known limits, all listed in the body

  • agent_session_operation_invalid and the owner-related codes name no cause until fix(native-chat): the host writes chat failures for a person, with a typed fact beside them #23116's typed cause lands.
  • Retry keeps the same operation id after an expired or conflicting refusal, so it repeats that refusal. This predates the PR and is outbox id handling.
  • The first message of a new chat goes through the launch path, which doesn't record the failure fact yet, so it shows the generic "Message was not sent."
  • Launch and create refusals are a separate surface.

Merge order: this PR targets main. #22821 and #23116 are stacked and edit the same outbox files, so whichever lands second takes a merge.

…it sends it again

The first message of a new chat is sent by the launch path, which staged it
without removing the failure saved by an earlier attempt. A message that failed
through the outbox and was then refused again through the launch path showed the
earlier reason in its Retry row. Both paths now stage through one shared step
that removes it.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up fix in 3d1ad9915a9. The closing readiness check found a case where the Retry row could show an old reason.

  • Before: the first message of a new chat is sent by the launch path. That path staged the message for sending without removing the failure saved by an earlier attempt. So a message that failed through the regular send path, and was then refused again through the launch path, showed the earlier reason in its Retry row.
  • After: both send paths now stage a message through one shared step (stageStructuredAgentSessionOutboxEntryForSend in src/shared/structured-agent-session-outbox.ts), which removes the saved failure. The hook file use-structured-agent-session-outbox.ts is unchanged.
  • Test: structured-agent-session-launch-prompt.test.ts saves a failure, refuses the launch path's resend, and checks that the old failure is gone. With the fix removed, the test fails.
  • Checks:
    • The native-chat and shared suites pass: 1023 files, 11435 tests.
    • One unrelated test, repo-ref-maintenance.test.ts, failed under load and passes when run alone (19/19). It is not touched by this PR.
    • pnpm tc:web, check:code-quality:changed and oxlint on the changed files pass.
  • Still a known limit: the launch path does not record a new failure fact of its own yet, so that first message's Retry row still says the generic "Message was not sent."

@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 (since a34e8a7, commit 3d1ad99)

  • A launch re-send drops the previous attempt's failure (src/renderer/src/lib/structured-agent-session-launch-prompt.ts, src/shared/structured-agent-session-outbox.ts): a new stageStructuredAgentSessionOutboxEntryForSend helper destructures lastFailure out of the entry as it stages it, and dispatchStructuredLaunchPrompt now stages through it. A source: 'launch' entry the launch path re-sends no longer carries the reason from its earlier attempt, which closes the gap the first review raised against the launch prompt.
  • The outbox dispatch path is a behavior-neutral refactor (structured-agent-session-outbox-dispatch.ts:81): that path already stripped lastFailure inline; the commit moves the identical logic into the shared helper so both dispatch paths clear the fact the same way.
  • Test (structured-agent-session-launch-prompt.test.ts): seeds a launch entry with a capacity failure, drives settleStructuredAgentLaunchPrompt to a checkpoint_stale refusal, and asserts the entry survives with no lastFailure. I confirmed it fails against the old spread staging, so it pins the fix rather than restating it.

The other half of the earlier launch-prompt concern — the launch path recording a new failure fact on refusal — is still absent, but the PR body scopes it as a follow-up and the launch first-message Retry row keeps its main copy ("Message was not sent."), so it is not a regression.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Ready to merge

Checked at head 3d1ad9915a: mergeable with a clean merge state, all required checks passing. The one package (windows) failure was a timeout in the Windows installer process-probe test, which this PR doesn't touch, and it passed on re-run.

@brennanb2025
brennanb2025 merged commit da57f47 into main Sep 27, 2026
67 of 69 checks passed
brennanb2025 added a commit that referenced this pull request Sep 28, 2026
Brings in #22999's refusal notice table and per-message outbox failure. The one conflict, the send
rejection copy, keeps #22999's sentence parts and reads the rejection through the single dispatch
rejection classifier: a transport failure says Orca couldn't reach the agent, a legacy marker says
only that the message was not sent, and any other reason is a sentence written to be read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant