Repository navigation
fix(chat): show bot answers in the project chat that asked - #52517
Conversation
[Medium impact] The change affects local bot questions in project chats and the views that show their answers. The automatic answer display should be completed before merging. Findings
SummaryAllows ordinary project chats to receive the existing bot-request card.
Reviews (3) · Last reviewed commit: "fix(chat): show bot answers in the proje..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
A project chat that asked a bot through `orca orchestration send` never got a request card, because ownerChatCard only wrote one when the sender was a bot. The agent was still told the owner sees the answer on its card, so the answer was lost. Write the card for any structured caller chat, and fold reply mail into the card only for bot chats (from_bot_id set), so a project chat keeps late replies as their own rows like before. Fixes stablyai#52516 Co-authored-by: lazy9sascha <[email protected]>
dc37832 to
250eab4
Compare
| acting.sessionId && | ||
| !acting.sessionId.startsWith('bot-group-member-') && | ||
| (target.id !== acting.bot.id || toOtherChat(receiving, acting.sessionId)) && | ||
| (target.id !== acting.bot?.id || toOtherChat(receiving, acting.sessionId)) && |
There was a problem hiding this comment.
New project cards never open when an answer arrives. Desktop and mobile both put view.answer inside details that start closed, and these cards carry no flag to change that. The retained reply mail also starts folded, with the subject before the answer body. Users can therefore still see only receipt-like rows until they click.
Mark newly eligible project cards and open their answer details when the answer arrives on both platforms, while preserving the user's choice to collapse them.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
ELI5
If you asked a bot a question from a normal project chat, Orca told the agent "the owner can see the answer on a card", but no card was ever drawn. So the answer was lost. Now the project chat gets the same request card a bot's chat gets, so the answer is there. Replies in a project chat still show as their own messages too, so a late answer still turns up at the bottom of the chat.
What Changed
orca orchestration send. The bot answers and the answer reaches the project agent's tool result. That result says "Your owner already sees this answer on its card, so don't repeat it". But no card was written, so the chat only showed the mail receipt notice.bot-request-owner-card.ts:ownerChatCardonly wrote the card whenacting.botwas set.readOwnActingSenderreturns{ sessionId, bot: null }for a project chat, so these chats never got one. The gate now covers any structured caller chat. The self-ask check usesacting.bot?.id, so a bot asking itself still gets no card. Workers, bot group members, connector conversation turns and status mail still get no card.bots-request-outcome.ts:mailIds(the reply mail the card folds away) is returned only when the request hasfrom_bot_idset, meaning a bot's chat sent it. If a project chat folded its replies into a closed card, late answers would be hidden, so project chats keep reply mail as separate rows. The host makes this decision, so older desktop and phone clients pick it up without a client change.bot-request-card.ts,native-chat-bot-card-fields.ts,NativeChatBotRequestCard.tsxandMobileBotRequestCard.tsx.Why
The writer (
ownerChatCard) and the agent's instructions (answeredOnCard/answerStaysOnCardinbot-request-view.ts) disagreed about who gets a card. The instructions never checked for a bot sender. This has been true since the card was added. #46759 moved the writer toansweredOnCard(asked)but kept the bot gate. This change fixes the writer at the source, so it matches the instructions.Alternatives considered:
expandAnswerflag. Rejected. It needs a new field in the persisted schema, which breaks older builds on downgrade. It also causes layout shift on remount, adds markdown cost on every mount, and breaks copying on Android.Linked Issue
Fixes #52516
Visual Proof
N/A. No visual proof was captured. The card components already render in every native chat (desktop
NativeChatBotCardSurfaceand mobileMobileBotCardHostProviderwrap all native chats, not only bot chats), and their render code is unchanged here. The change is the main-process decision about whether a card gets written and whether reply mail is folded. The unit tests below cover both.Testing
Reproduced on main with the new unit test
bot-request-owner-card.test.ts. "leaves the card in a project chat that asked a bot" fails on main, because nobot-requestcard is written ([]). It passes here.bots-request-outcome.test.ts: a project chat's outcome has the answer andmailIds: []. Without thefrom_bot_idgate it fails (['msg_2']).Sender matrix in the new test:
bot-group-member-*, connector conversation turns, status mail and a null session get none.vitest: 6/6 on the two changed suites. During review, 123/123 more across 12 neighbouring suites, including bot-request-card-view, bot-request-record, paired-server-asks, peer-mail, chat-run-takeover-mail, native-chat-activity-rows and journal conversion storage.
oxlint, oxfmt, anti-slop, the native code-quality plugins, ast-grep and the changed-code quality gate are all clean on the 8 files.
tsc -p config/tsconfig.node.jsonis clean.Platforms: macOS (unit level). The change has no platform-specific code.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
Almost none. Both paths run on cold orchestration RPCs, once per bot-request send and once per outcome read.
ownerChatCardgate: under 1 us per call either way (main 0.05/0.18 us, branch 0.18/0.08 us for project/bot chat over 200k calls, which is noise). The only new work is the intended one: one async journal append per project-chat request.bots.request.outcome: one extra property read. Bot chats measured 0.187 vs 0.189 us (1 reply) and 1.859 vs 1.896 us (200 replies). Project chats are slightly faster because they skip thereplies.map.foldBotRequestMail([]), which returns early. That is 0 listener or snapshot calls per card at N=200 mounted rows, the same as main. Each card's cost matches an existing bot-chat card, is virtualized, and grows with the number of request cards, not with mounted tabs.Risk
Level: Low
acting.botis set, the gate and the fold behave exactly as before.answerStaysOnCardinbot-request-view.ts).Review
Reviewed in several rounds, including an independent breakage hunt and verification on fresh main. No blockers left.
Agent skill upstream boundary
Notes
Original fix by @lazy9sascha in #52517. Their authorship is kept with a
Co-authored-bytrailer.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)