Repository navigation
fix(native-chat): never refuse a queued card because 20 were waiting, and keep the queue from covering the chat - #26553
Conversation
Orchestration mail reached a busy chat as ordinary queued message cards, and the queue refused at 20 unsettled cards or 1 MiB with a bare invalid refusal, so automatic notices could fill it and refuse the user's own next queued message. Mail now stays unread while the chat is working, waiting on a prompt or holding unsettled cards, and is coalesced into one delivery when it becomes free; batch identity is recorded so nothing is delivered twice. Human drafts no longer share an aggregate quota, and a failed settled receipt keeps its code, details and message for diagnosis. Co-Authored-By: OpenAI Codex gpt-6.1-sol <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d the queue Drop the 20-card queue limit and the mail-delivery rework; keep only a byte bound on what queued cards publish (it rides every opening frame beside the history page), refused with a reason that says what to do. The desktop queue list now scrolls instead of squeezing the transcript.
… agents fill Other agents' cards stop one maximal message short of the queued-bytes bound, so background work alone can never refuse a person's send. The person's newly queued card scrolls into view, and the refusal's step and host message now name only what the person can do.
Review summaryThe problem. In a busy native chat, every queued card shared one limit of 20. On shipped builds the messages you type don't queue: they go straight into the running turn, because person queueing is still behind an unreleased capability. So the cards come from other agents: one "you have N orchestration messages" notice per mail, plus task hand-offs. When a busy coordinator chat reached 20 cards:
What changes for you.
How the PR changed during review.
Verified.
Seen in QA, not caused by this PR (deferred).
Not verified.
|
📝 WalkthroughWalkthroughThe queue acceptance path replaces its count-and-byte refusal check with a published-byte bound and a reserve for person messages. Oversized queues return a Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A large queue of short messages could disconnect a remote chat session, and a newly queued message can sometimes remain out of view. Account for the full published queue size before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 16 files. (7 skipped: 7 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
eba775b0-00cd-4cbb-85e9-72d06e96d1aa
📒 Files selected for processing (23)
src/main/native-chat/agent-session-journal/queued-message-table.tssrc/main/native-chat/agent-session-wire/structured-agent-session-operation-settlement.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-operation-settlement.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-messages.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-messages.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-published-bytes.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-published-bytes.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-send.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-stop.tssrc/main/runtime/structured-chat-coordinator-mail-queue.test.tssrc/renderer/src/components/native-chat/NativeChatQueuedMessageList.test.tsxsrc/renderer/src/components/native-chat/NativeChatQueuedMessageList.tsxsrc/renderer/src/components/native-chat/agent-session-write-notice-text.tssrc/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-details.tssrc/shared/agent-session-refusal-reason-words.tssrc/shared/agent-session-write-notice-copy.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| export const QUEUED_MESSAGES_PUBLISHED_MAX_BYTES = | ||
| (REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES - AGENT_SESSION_HISTORY_MAX_PAGE_BYTES) / 2 |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the queue projection and the frame/page limits; do not run repository code.
rg -n -C 5 'queuedMessages:|queuedMessages\s*=|REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES|AGENT_SESSION_HISTORY_MAX_PAGE_BYTES' \
src/main/native-chat src/sharedRepository: stablyai/orca
Length of output: 41695
🏁 Script executed:
set -eu
printf '%s\n' '--- target byte-bound module ---'
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-queued-published-bytes.ts
printf '%s\n' '--- queue publication module ---'
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-queued-publication.ts | sed -n '1,240p'
printf '%s\n' '--- queue projection definition ---'
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-queued-publication.ts | sed -n '1,115p'
printf '%s\n' '--- history page bounds ---'
rg -n -C 8 -F -- 'AGENT_SESSION_HISTORY_MAX_PAGE_BYTES' src/main/native-chat/agent-session-wire src/shared
printf '%s\n' '--- byte-refusal call sites ---'
rg -n -C 8 -F -- 'queuedMessagesPublishedBytesRefusal' src/main/native-chat src/shared
printf '%s\n' '--- queued publication consumers ---'
rg -n -C 8 -F -- 'readQueuePublication' src/main/native-chat/agent-session-wireRepository: stablyai/orca
Length of output: 42126
🏁 Script executed:
set -eu
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-queued-published-bytes.ts
printf '%s\n' '--- projection ---'
nl -ba src/main/native-chat/agent-session-wire/structured-agent-session-queued-publication.ts | sed -n '1,180p'
printf '%s\n' '--- refusal callers ---'
rg -n -C 12 -F -- 'queuedMessagesPublishedBytesRefusal' src/main/native-chat
printf '%s\n' '--- history bound declarations and uses ---'
rg -n -C 8 -F -- 'AGENT_SESSION_HISTORY_MAX_PAGE_BYTES' src/main/native-chat/agent-session-wireRepository: stablyai/orca
Length of output: 42399
🏁 Script executed:
set -eu
for f in \
src/main/native-chat/agent-session-wire/structured-agent-session-queued-published-bytes.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-queued-publication.ts; do
echo "--- $f ---"
cat "$f"
done
rg -n -C 10 -F -- 'queuedMessagesPublishedBytesRefusal' src/main/native-chat
rg -n -C 10 -F -- 'serializeRemoteRuntimePayload' src/main/native-chat src/sharedRepository: stablyai/orca
Length of output: 41910
Include card metadata in the published-size bound.
queuedMessagesPublishedBytesRefusal sums only JSON.stringify of each body. The published queue also includes messageId, position, state, pause fields, return fields, queuePause, and nextQueuedMessageId. Since the queue has no card-count limit, metadata can consume the remaining frame budget and push a hydrating frame above REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES, which closes the remote session.
Measure the complete serialized queue publication, using the same projection that readQueuePublication sends, and preserve the existing person-message reserve.
| const listRef = useRef<HTMLUListElement>(null) | ||
| const newestPosition = newest?.position ?? 0 | ||
| const newestIsPersons = newest !== undefined && !newest.from | ||
| const shownPosition = useRef(newestPosition) | ||
| // Before paint, so the new card never shows a frame before the scroll. | ||
| useLayoutEffect(() => { | ||
| // From 0 the queue is loading or holds one card: nothing to scroll to. | ||
| const appended = shownPosition.current > 0 && newestPosition > shownPosition.current | ||
| shownPosition.current = newestPosition | ||
| // The list opens on the next card to send; a card the person just queued is shown instead. | ||
| if (appended && newestIsPersons && listRef.current) { | ||
| listRef.current.scrollTop = listRef.current.scrollHeight | ||
| } | ||
| }, [newestPosition, newestIsPersons]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Check how queued message positions are assigned.
rg -n -C4 'position' src/main/native-chat/agent-session-journal/queued-message-table.tsRepository: stablyai/orca
Length of output: 3160
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- insertQueuedMessage callers ---'
rg -n -C5 --glob '*.{ts,tsx}' 'insertQueuedMessage\(' src || true
printf '%s\n' '--- queued_messages schema and mutations ---'
rg -n -C4 --glob '*.{ts,tsx,sql}' 'queued_messages|DELETE FROM queued_messages|UPDATE queued_messages|position:' src/main src/renderer || true
printf '%s\n' '--- NativeChatQueuedMessageList ---'
sed -n '1,220p' src/renderer/src/components/native-chat/NativeChatQueuedMessageList.tsxRepository: stablyai/orca
Length of output: 45657
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- journal enqueue and move blocks ---'
sed -n '100,235p' src/main/native-chat/agent-session-journal/journal-queued-messages.ts
printf '%s\n' '--- queue table mutation definitions ---'
rg -n -C6 -F -- 'DELETE FROM queued_messages' src/main/native-chat/agent-session-journal || true
rg -n -C6 -F -- 'UPDATE queued_messages' src/main/native-chat/agent-session-journal || true
rg -n -C6 -F -- 'moveQueuedMessages' src/main/native-chat/agent-session-journal || true
printf '%s\n' '--- position-bearing input declarations and uses ---'
rg -n -C5 -F -- 'position?: number' src/main/native-chat/agent-session-journal
rg -n -C5 -F -- 'position:' src/main/native-chat/agent-session-journal/journal-queued-messages.tsRepository: stablyai/orca
Length of output: 29784
Use an immutable enqueue sequence for the scroll trigger.
position is mutable and can be reused. Retention deletes old queue rows, and the next insert assigns MAX(position) + 1 from the remaining rows. If a deleted highest-position card is replaced before an intermediate render, the new person card can have the same newestPosition. The newestPosition > shownPosition.current check is then false, so the list does not scroll.
Track an immutable enqueue sequence or card identity for this comparison instead of relying on position.
ELI5
When an agent is busy, messages sent to its native chat by other agents wait as cards above the box you type in. Each automatic "you have new messages" notice from another agent gets its own card. Orca refused every new card once 20 were waiting. So on a busy coordinator chat, further notices and task hand-offs from other agents were turned away. The card list also had no height limit, so 20 cards could push the conversation and the message box off the screen. This PR removes the 20-card limit and makes the card list scroll inside a fixed height.
What Changed
Before (shipped builds):
After (what you see):
Mechanism:
structured-agent-session-queued-messages.ts: the count limit (QUEUED_MESSAGES_MAX_COUNT = 20) is removed.QUEUED_MESSAGES_PUBLISHED_MAX_BYTES(structured-agent-session-queued-published-bytes.ts). The reason: every waiting card's full text is included each time a phone or paired computer opens the chat, right beside a page of history of up to 2 MiB. Remote connections close the whole session on any single message over 4 MiB. The limit is now derived from those two constants.queueTooLarge), and clients show it in plain words. When a recorded failure is replayed, its message is kept, so the next refusal of this kind can be diagnosed from the record.NativeChatQueuedMessageList: the card list scrolls within a fixed maximum height (max-h-40, the same bound the task and background-task lists next to it use). When you queue a card, the list scrolls to it before the next frame is drawn. A queue that is still loading when the chat opens shows its next card to send first.Why
The 20-card limit was a quota that every sender shared. Hitting it was a bookkeeping state, not a problem with the message: agents' notices and tasks were turned away, and once queueing your own messages ships, your messages would have been too. Removing it fixes the problem at its source. A separate lane or a bigger number could fill up the same way.
Alternatives considered:
Differences from the common pattern:
Linked Issue
Found while investigating a refused send in a busy coordinator chat. That refusal itself came from the separate retry-record limit fixed in #26543; this PR fixes the same class of problem in the message queue. There's no separate issue. Author: @BrennanKB5.
Visual Proof
QA ran on a hidden Electron rig on macOS, using isolated profiles and a test agent that holds its turn open. Other agents' notices were real
orchestration sendcalls, and the UI was driven through the Chrome DevTools Protocol. Full-window screenshots.Before (base
5252884a9c7): 20 notice cards. The list is 979 px tall, and the conversation and message box have been pushed off the screen. Notices 21-25 got no card and no error.After (
9f5fecbd231): 26 notice cards. The list stays 160 px tall and scrolls, and the conversation and message box stay visible and usable.After, the list scrolled to its end, with card 21 accepted and visible:
After the turn ended, all 26 cards drained in order, one turn each, with no notice or error.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
End to end: more than 20 automatic orchestration notices reach a busy coordinator chat through the real notice path and are all queued; a person's queued message is still accepted after them (
structured-chat-coordinator-mail-queue.test.ts).Unit:
Targeted suites pass.
pnpm tc:nodeandpnpm tc:webpass. CI-equivalent static checks pass 22/22. CI passes on the final head.Manual: hidden Electron rig on macOS, before and after builds (see Visual Proof).
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)