Render launch prompts in native chat and refine initial view #7444
Render launch prompts in native chat and refine initial view #7444AmethystLiang wants to merge 3 commits into
Conversation
- Seed and render the agent launch prompt as a synthetic, pending user message in the native chat view until the transcript catches up. - Refine initial view mode logic so native chat does not auto-open for draft prompt delivery, unsupported agents, or when disabled. - Add delivery failure tracking for the launch prompt, rendering an error status in the message list if pasting into the terminal fails. - Implement corresponding store actions, selectors, cleanup routines, and extensive test coverage.
📝 WalkthroughWalkthroughChangesThis PR introduces a native-chat "launch prompt" mechanism: a new type and terminal-slice state track per-tab prompts seeded when an agent launch submits content, with actions to seed, mark failed, and clear entries, plus cleanup on tab/worktree removal. A new Sequence Diagram(s)Included within the hidden review stack artifact above. Related PRs: None specified. Suggested labels: native-chat, needs-review Suggested reviewers: Not enough information to determine appropriate reviewers. Poem: 🐰 A prompt was launched into the dark, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
⚔️ Resolve 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/lib/launch-agent-in-new-tab.ts (1)
193-204: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHandle followup-path launches as draft-like for chat gating
isFollowupPathstill passes the rawpromptDeliveryintoinitialAgentTabViewModeProps, but this branch only pastes the prompt and does not submit it. SincedecideInitialAgentTabViewModeonly skips chat forpromptDelivery === 'draft', a defaultauto-submitlaunch can still open chat here. Pass a draft-like delivery or special-caseisFollowupPath.
🧹 Nitpick comments (4)
src/renderer/src/components/native-chat/native-chat-availability.ts (1)
3-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: consolidate the duplicate import/re-export of the same module.
Line 3 imports and line 5 re-exports
isNativeChatSupportedAgentfrom the same module specifier; can be combined into one import plus a local re-export.♻️ Optional consolidation
-import { isNativeChatSupportedAgent } from '`@/lib/native-chat-supported-agent`' - -export { isNativeChatSupportedAgent } from '`@/lib/native-chat-supported-agent`' +import { isNativeChatSupportedAgent } from '`@/lib/native-chat-supported-agent`' + +export { isNativeChatSupportedAgent }src/renderer/src/lib/worktree-activation.ts (1)
623-636: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd draft-gating test coverage for the
applyDefaultTerminalTabspath.The
promptDeliveryderivation here mirrors the one inensureWorktreeHasInitialTerminal(lines 559-571), but only the latter path is covered by the newworktree-activation.test.tstest (lines 424-449). Since this path has its own independentisStartupTab && startup?.draftPrompt != nullcondition, a regression here (e.g. an agent added viadefaultTabswith a draft prompt) would not be caught.src/renderer/src/components/native-chat/native-chat-pending.ts (1)
156-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a brief "why" comment on the dedup/prune rationale.
launchPromptAsMessage's text-matching dedup (avoiding a duplicate bubble once the real transcript catches up) andshouldPruneLaunchPrompt's "advanced past" check are non-obvious design choices (matching on normalized text rather than id/turnId). A one-line comment on the "why" would help future maintainers, consistent with the "Why:" comments used elsewhere in this codebase (e.g.native-chat-session-assembler.ts's newcompareMessagescomment, andNativeChatView.tsx's pending-send comments).As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."
Source: Coding guidelines
src/renderer/src/components/native-chat/NativeChatMessageList.tsx (1)
186-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winArbitrary font-size value instead of a design token.
text-[11px]is a Tailwind arbitrary value rather than a documented type-scale token (e.g.text-xs). Please confirm this size is intentionally not covered by an existing STYLEGUIDE.md token before merging; iftext-xs(or another documented caption size) already covers this role, prefer it over the one-off value.♻️ Suggested fix (if `text-xs` matches the documented caption role)
- <div className="max-w-[85%] text-[11px] text-destructive/80"> + <div className="max-w-[85%] text-xs text-destructive/80">As per coding guidelines: "Never invent new color values, font sizes, or shadow tiers when a documented one in STYLEGUIDE.md already covers the role."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9b644bed-dc8b-44b2-8e0c-7b02291dfc0c
📒 Files selected for processing (29)
src/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/native-chat-availability.tssrc/renderer/src/components/native-chat/native-chat-message-grouping.test.tssrc/renderer/src/components/native-chat/native-chat-pending.test.tssrc/renderer/src/components/native-chat/native-chat-pending.tssrc/renderer/src/components/native-chat/native-chat-session-assembler.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-launch-prompt-delivery.test.tssrc/renderer/src/lib/agent-launch-prompt-delivery.tssrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/renderer/src/lib/launch-work-item-direct.test.tssrc/renderer/src/lib/native-chat-initial-view-mode.test.tssrc/renderer/src/lib/native-chat-initial-view-mode.tssrc/renderer/src/lib/native-chat-launch-prompt.tssrc/renderer/src/lib/native-chat-supported-agent.tssrc/renderer/src/lib/worktree-activation.test.tssrc/renderer/src/lib/worktree-activation.tssrc/renderer/src/store/slices/terminal-orphan-helpers.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/worktree-removal-maps-leak.test.tssrc/renderer/src/store/slices/worktrees.ts
…hat-does-not-auto-open
* Treat native draft pre-fills as successful deliveries instead of marking the seeded launch prompts as failed. * Group native chat messages into sorting tiers (real content, streaming preview, optimistic echoes) so optimistic bubbles don't sort past the streaming preview due to finite timestamps.
Summary
Describe the user-visible change.
Screenshots
No visual change.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI Review Report
Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.
Security Audit
Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.
Notes
Call out any platform-specific behavior, risks, or follow-up work.