Repository navigation
fix(native-chat): say a refused chat write in plain words, and keep it with the write it describes - #22999
Conversation
…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.
…he live app sees it
…te-refusal-notice
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe 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 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 ReviewSecurity architecture risk: 🔵 Low · up to 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 Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
… 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.
…te-refusal-notice
There was a problem hiding this comment.
ℹ️ 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 hostmessageis passed through only foragent_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 writesnoticeonto the entry instead of a latchederror, 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):writereturnsdone/not-done/dropped;mutatewraps it and toastsnot-done; conversation commands callwriteand report inline.writeError/reportWriteErrorare 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_invalidfor acommandalways ends "Wait for the agent to finish, then run it again." (agent-session-refusal-notice.ts:70-73), butconversationCommandBlockedreturns 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 atstructured-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 usesagentSessionWriteFailureNotice. Refusals are reworded on both clients; failures are not. NativeChatDeliveryRetry.tsx:33renders a notice that already ends "Retry to send it again." directly above a Retry button — mild redundancy, no action required.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ 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 newcomposer-sendwrite 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.phoneWriteKindrewrites onlysend, 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 itssubmissionsarray 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.
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.
There was a problem hiding this comment.
✅ 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) becomeslastFailure, a discriminated fact —refusedwith an optional host message,rejectedwith the provider's reason, orunreachable.parseStructuredAgentSessionAttemptFailureround-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_COPYplusagentSessionWriteNoticeParts(failure, write); the hostmessageis kept only foragent_session_owner_restart_failed, which the host already words for people.parseAgentSessionWriteFailurereads 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_invalidand an unknown newer code drop their next-step sentence;identity_requiredandjournal_unreadableno 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 fromlastFailure(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;phoneWriteKindkeepscomposer-sendso 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 oldnoticestring.
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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues in this commit.
Reviewed changes
- No host refusal message is shown, for any code (
src/shared/agent-session-refusal-notice.ts):AgentSessionWriteFailuredrops itshostMessagefield, soagentSessionRefusalFailureandparseAgentSessionWriteFailurekeep only the code. Theagent_session_owner_restart_failedcase 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
restartFailedsentence 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…te-refusal-notice
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.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 84982f5d-e074-4ea4-9798-43d2ef3b427d
📒 Files selected for processing (15)
mobile/src/session/mobile-structured-send-delivery.test.tsmobile/src/session/mobile-structured-send-delivery.tssrc/renderer/src/components/native-chat/agent-session-write-notice-text.tssrc/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsxsrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/agent-session-refusal-notice.test.tssrc/shared/agent-session-refusal-notice.tssrc/shared/structured-agent-session-send-disposition.test.tssrc/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 }] |
There was a problem hiding this comment.
🎯 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']
}…2025/chat-write-refusal-notice
There was a problem hiding this comment.
ℹ️ 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):structuredAgentSessionRejectionPartsnow 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
agentSessionWriteRetryPartshelper factors the not-done + try-again pair, shared by the ownerUnconfirmed, operation_conflict/expired, and internal-rejection branches. - Dead copy removed:
rejectedUnreachable/rejectedInternalare 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).
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.
There was a problem hiding this comment.
ℹ️ 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.", andoperation_conflict/_expired/_invalid/identity_requiredoffer no next step.owner_restart_failedkeeps "The agent couldn't restart.";capacity,outcomeUnknown,questionChanged,historyUnreadableandunsupportedkeep a cause, each justified by its one emitter in the test'sCAUSESallowlist. - No notice tells you how to try again, except the phone's composer (
agentSessionWriteNotDoneParts): desktop returns only the not-done sentence;composer-sendappends "Send it again.". The per-kindtryAgain*copy keys,ownerUnconfirmed,sessionMissingandmessageNotSentare gone from the shared table, the desktop sentence map,en-runtime-required.jsonand all six locale catalogs. - The
unreachablefailure kind is renamedfailed(AgentSessionWriteFailure): a request can fail as a transport, compatibility or host error, so the generic kind no longer asserts reachability. Theunreachablesentence survives where it is true, in the transport-write-failure branch ofstructuredAgentSessionRejectionParts. - The phone stops showing host and transport text for failures too (
mobile/src/session/mobile-structured-agent-session-rpc.ts): manifest refusals are mapped tounsupported/operation_invalid, and a thrown request to the shared failure copy.mobile-structured-send-delivery.tsandmobile-structured-agent-session-cancel.tsdrop 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).
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.
There was a problem hiding this comment.
ℹ️ 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 newunconfirmedfailure kind andagentSessionRpcErrorFailure(code)map an RPC error tounsupported/operation_invalidonly for the four codes the host rejects before running the method, and tounconfirmedotherwise, 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 itsisRpcDeliveryUnknownpath for transport doubt. - A refused background-task stop names the task (
src/shared/agent-session-refusal-notice.ts):agentSessionWriteKindForMethodnow takes the call fields, soagentSession.cancelwithscope: 'background-tasks'returnsstop-task(with ataskId) orstop-tasks, with new copy keys andNOT_DONEentries; 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ 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_resolvedreturn['questionChanged']for ananswerbut['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 byvalidatePendingPrompt, reached by an answer or a prompt-cancel Stop, so the other kinds are unreachable. - Test:
agent-session-refusal-notice.test.tspins both the stop and answer wording foragent_session_already_resolved.
Verified locally on ce7a1a6: src/shared/agent-session-refusal-notice.test.ts (24 tests) passes.
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.
There was a problem hiding this comment.
✅ 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 forunsupportedand 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_WORKpins the phone resend set: it matches exactly the codes for whichagentSessionWriteNoticeParts(..., 'composer-send')appendstryAgainComposerSend, 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready for review at
|
…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.
|
Follow-up fix in
|
There was a problem hiding this comment.
✅ 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 newstageStructuredAgentSessionOutboxEntryForSendhelper destructureslastFailureout of the entry as it stages it, anddispatchStructuredLaunchPromptnow stages through it. Asource: '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 strippedlastFailureinline; 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, drivessettleStructuredAgentLaunchPromptto acheckpoint_stalerefusal, and asserts the entry survives with nolastFailure. 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Ready to mergeChecked at head
|
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.

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
/compact,/clear) answers inline where you typed it.What the user sees, by error
Where it appears:
/compact,/clear: inline under the composer."What didn't happen" depends on what you were doing:
/compactor/clearHost refusals (the request was turned away before it ran):
agent_session_owner_restart_failedagent_session_checkpoint_staleagent_session_conflictagent_session_ownership_unknownexecution_owner_reconcilingagent_session_operation_capacityagent_session_operation_conflictagent_session_operation_expiredagent_session_operation_invalidagent_session_identity_requiredagent_session_operation_unknownagent_session_item_revision_staleagent_session_already_resolvedagent_session_journal_unreadablestructured_agent_session_unsupportedFor other requests, the same sentences apply with that request's "what didn't happen". For example,
agent_session_operation_capacityon Stop reads "Orca has received too many requests in the last day. The agent wasn't stopped."Requests that failed without a refusal:
structured_agent_session_unsupportedoragent_session_operation_invalidaboveMessages the host accepted and then rejected (these are not refusals):
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_invalidalone 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. Onmain, 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_invalidwith 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
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.tsturns 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).lastFailureonStructuredAgentSessionOutboxEntry). 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.useStructuredAgentSessionMutatereturns a typed outcome (done, not done with a notice, or dropped because the chat moved on) instead of keeping awriteError. Each caller decides where to show it.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 =
mainat the merge base (f6eab381ce), after = this branch (f62350f772; later commits don't change this flow). Each arm started from a fresh profile.After fixing Claude and pressing Retry, the message is answered and nothing is left on screen:
Normal idle stop, return and send on this branch: answered, with no red line, Retry row or toast:
Testing
agent-session-refusal-notice.test.tschecks every refusal code, a failed request, an unconfirmed request and an unknown code, against every kind of request, using five rules: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.use-structured-agent-session-write-refusal.test.tsx: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 onmaintoo, so the test pins the order the live app sees.Runs:
pnpm tc:web,pnpm tc:nodeand the mobile typecheck are clean.oxlint,check:code-quality:changed,check:react-doctor:changedand theverify:localization-*checks pass.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
mainruns 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
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
experimentalStructuredNativeChat) and its phone view. Terminals and the default chat view are unchanged.lastFailurefact is saved with it, never its words. Older saved queues load as before, and a value this build can't read is dropped.Known limits / follow-ups
agent_session_operation_expiredoragent_session_operation_conflict, so it repeats the refusal. The notice no longer promises otherwise.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author X handle: @BrennanKB5