Skip to content

fix(chat): show bot answers in the project chat that asked - #52517

Merged
nwparker merged 1 commit into
stablyai:mainfrom
lazy9sascha:fix/project-chat-bot-request-card
Nov 29, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
lazy9sascha:fix/project-chat-bot-request-card

Conversation

@lazy9sascha

@lazy9sascha lazy9sascha commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before: a project chat (a structured session that isn't a bot's chat) sends a request to a local bot with 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.
  • After: the project chat gets a bot request card where the request was made, with the outcome and the answer. Reply mail from the bot still shows as its own full "Message from " row, as it does on main.
  • Mechanism:
    • bot-request-owner-card.ts: ownerChatCard only wrote the card when acting.bot was set. readOwnActingSender returns { 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 uses acting.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 has from_bot_id set, 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.
    • Comment-only updates in bot-request-card.ts, native-chat-bot-card-fields.ts, NativeChatBotRequestCard.tsx and MobileBotRequestCard.tsx.

Why

The writer (ownerChatCard) and the agent's instructions (answeredOnCard / answerStaysOnCard in bot-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 to answeredOnCard(asked) but kept the bot gate. This change fixes the writer at the source, so it matches the instructions.

Alternatives considered:

  • Auto-expand the card and draw the answer as markdown, with an expandAnswer flag. 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.
  • Change the agent's wording instead. Rejected. That still leaves project chats with no visible record of the request.

Linked Issue

Fixes #52516

Visual Proof

N/A. No visual proof was captured. The card components already render in every native chat (desktop NativeChatBotCardSurface and mobile MobileBotCardHostProvider wrap 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 no bot-request card is written ([]). It passes here.

  • bots-request-outcome.test.ts: a project chat's outcome has the answer and mailIds: []. Without the from_bot_id gate it fails (['msg_2']).

  • Sender matrix in the new test:

    • A project chat gets a card. A bot chat still gets one.
    • Workers, 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.json is 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.

  • ownerChatCard gate: 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 the replies.map.
  • Renderer fanout: no renderer code changed. Project chats call 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.
  • No sync I/O, polling, timers or subprocesses.

Risk

Level: Low

  • New visible behavior: project chats now show a bot request card where the request was made. A refused send leaves a "Not sent to X" card, the same as in bot chats.
  • Saved data: the card schema is unchanged and no new persisted fields are added. Older clients and older paired phones show the card the way they already do. Downgrade is safe.
  • Bot chats are unchanged. When acting.bot is set, the gate and the fold behave exactly as before.
  • Back out with a plain revert. Cards already written into project chat journals would stay, and render as normal request cards.
  • Known follow-up, not changed here: a terminal (non-structured) agent sender is still told "your owner sees the answer on its card" but has no card (answerStaysOnCard in bot-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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Original fix by @lazy9sascha in #52517. Their authorship is kept with a Co-authored-by trailer.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The automatic answer display should be completed before merging.RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Project answers stay hidden ▶

Summary

Allows ordinary project chats to receive the existing bot-request card.

  • Project chats keep a card linking bot questions to their answers.

Reviews (3) · Last reviewed commit: "fix(chat): show bot answers in the proje..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change updates bot-request card descriptions and adds an optional expandAnswer: true schema field. It changes ownerChatCard eligibility so non-workers can match the target using an optional acting bot ID, and adds tests for card writes and excluded cases. The outcome handler now returns an empty outcome when the request or message is missing, and includes reply mail IDs only when from_bot_id is set.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 250ea

Local bot answers now appear in the project chat that asked the question. No concrete merge-blocking risk was found. Tests were not executed in this review, and platform smoke tests were not run.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(chat): show bot answers in the project chat that asked" matches the main change. The PR writes the existing bot-request card for project sessions, so a bot answer to a project question …
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Fixes #52516), Visual Proof with before/after images, Testing with checkboxes, Performance (None, because…
Linked Issues check Passed Issue #52516 requires that a regular project chat shows one linked answer after a local bot replies. On main, ownerChatCard required acting.bot before writing a card. The change in bot-request-owner-c…
Out of Scope Changes check Passed All changed areas support the objective of showing a project-chat bot answer. The writer change enables the card. The schema change adds the optional expandAnswer flag. The renderers use the flag only…
Full details: Title check

Explanation

The title "fix(chat): show bot answers in the project chat that asked" matches the main change. The PR writes the existing bot-request card for project sessions, so a bot answer to a project question appears in that chat. The title is specific and concise, and it is a single sentence.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Fixes #52516), Visual Proof with before/after images, Testing with checkboxes, Performance (None, because...), Risk with level and rollback, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. The description gives a clear before and after, the mechanism, and the rationale. The Risk section names Low and states the revert effect. Minor gaps: the Risk level is given as bold text without the template's option list, and the Testing section notes that a live multi-peer run, physical mobile device, and Linux, Windows, and SSH tests were not done. Those gaps do not make the description incomplete.

Full details: Linked Issues check

Explanation

Issue #52516 requires that a regular project chat shows one linked answer after a local bot replies. On main, ownerChatCard required acting.bot before writing a card. The change in bot-request-owner-card.ts removes that requirement for non-worker requests that have a session ID. It excludes workers instead. The optional expandAnswer flag in bot-request-card.ts and the desktop and mobile renderers opens the card when a linked answer arrives. Tests in bot-request-owner-card.test.ts cover the project question card, bot-chat cards, and the skipped worker, group-room, connector, status-mail, and missing-session cases. The bots-request-outcome.ts change returns the answer for a desktop caller with null from_bot_id, as its new test shows ("Done." with empty mailIds). This keeps the answer visible on the project card. Mobile behavior rests on code reading and the change summary, not a device run. The issue does not require specific tests, so this does not block the result.

Full details: Out of Scope Changes check

Explanation

All changed areas support the objective of showing a project-chat bot answer. The writer change enables the card. The schema change adds the optional expandAnswer flag. The renderers use the flag only for initial disclosure. The bots-request-outcome.ts change includes reply mail IDs only when from_bot_id is set. It keeps late replies in project chats as their own rows, as the commit message states. This change is connected to the card behavior for project chats, although the PR description's What Changed section does not list it. The remaining edits are comment updates and test fixture changes that match the new behavior. No changed path alters remote forwarding, mailbox delivery, permissions, or credentials. Mobile and schema changes were checked from the summary, not a full diff read, and no unrelated change was found in that evidence.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8874dc25-924e-40a9-b7ed-db01f437b5ce
Commits

Reviewing files that changed from the base of the PR and between dc37832 and 250eab4.

Files selected for processing: 7

  • mobile/src/session/native-chat/transcript/bot-cards/MobileBotRequestCard.tsx
  • src/main/runtime/rpc/methods/bots-request-outcome.test.ts
  • src/main/runtime/rpc/methods/bots-request-outcome.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/bot-request-owner-card.test.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/bot-request-owner-card.ts
  • src/renderer/src/components/native-chat/NativeChatBotRequestCard.tsx
  • src/shared/native-chat/bot-cards/native-chat-bot-card-fields.ts
Files skipped from review as they are similar to previous changes: 3

  • mobile/src/session/native-chat/transcript/bot-cards/MobileBotRequestCard.tsx
  • src/main/runtime/rpc/methods/orchestration/messaging/bot-request-owner-card.ts
  • src/renderer/src/components/native-chat/NativeChatBotRequestCard.tsx

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

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]>
@nwparker
nwparker force-pushed the fix/project-chat-bot-request-card branch from dc37832 to 250eab4 Compare November 29, 2026 14:24
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)) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Project answers stay hidden

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!

@nwparker
nwparker merged commit 775f5bf into stablyai:main Nov 29, 2026
59 checks passed
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.

Local bot answer is missing from the project chat that asked

2 participants