Skip to content

Render launch prompts in native chat and refine initial view #7444

Open
AmethystLiang wants to merge 3 commits into
mainfrom
native-chat-does-not-auto-open
Open

Render launch prompts in native chat and refine initial view #7444
AmethystLiang wants to merge 3 commits into
mainfrom
native-chat-does-not-auto-open

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor
  • 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.

Summary

Describe the user-visible change.

Screenshots

  • Add screenshots or a screen recording for any new or changed UI behavior.
  • If there is no visual change, say No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI 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.

- 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.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

This 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 deliverLaunchPromptToAgentTab helper wraps paste delivery and marks failures; call sites in launch-agent and work-item-direct flows now use it. decideInitialAgentTabViewMode/initialAgentTabViewModeProps were refactored to object arguments and gated by agent support and promptDelivery. Session assembly, pending-message pruning helpers, and message sorting were updated to inject/prune launch prompts and pin the streaming message last. The message list UI now shows a "Not delivered" notice, backed by new locale strings across languages. A shared native-chat-supported-agent module replaces a duplicated allowlist.

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,
It waited, hoped, then missed its mark—
"Not delivered," whispered small and clear,
So the rabbit hopped to fix it here.
Now failures fade, prompts prune with grace,
Chat mode gated in the right place.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description mostly repeats the template and leaves Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes unfilled. Fill in each template section with concrete details, especially screenshots or 'No visual change', test results, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main changes to native chat launch prompt rendering and initial view mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch native-chat-does-not-auto-open

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Handle followup-path launches as draft-like for chat gating isFollowupPath still passes the raw promptDelivery into initialAgentTabViewModeProps, but this branch only pastes the prompt and does not submit it. Since decideInitialAgentTabViewMode only skips chat for promptDelivery === 'draft', a default auto-submit launch can still open chat here. Pass a draft-like delivery or special-case isFollowupPath.

🧹 Nitpick comments (4)
src/renderer/src/components/native-chat/native-chat-availability.ts (1)

3-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: consolidate the duplicate import/re-export of the same module.

Line 3 imports and line 5 re-exports isNativeChatSupportedAgent from 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 win

Add draft-gating test coverage for the applyDefaultTerminalTabs path.

The promptDelivery derivation here mirrors the one in ensureWorktreeHasInitialTerminal (lines 559-571), but only the latter path is covered by the new worktree-activation.test.ts test (lines 424-449). Since this path has its own independent isStartupTab && startup?.draftPrompt != null condition, a regression here (e.g. an agent added via defaultTabs with 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 win

Consider a brief "why" comment on the dedup/prune rationale.

launchPromptAsMessage's text-matching dedup (avoiding a duplicate bubble once the real transcript catches up) and shouldPruneLaunchPrompt'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 new compareMessages comment, and NativeChatView.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 win

Arbitrary 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; if text-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

📥 Commits

Reviewing files that changed from the base of the PR and between e5008b1 and 33f5eb1.

📒 Files selected for processing (29)
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-availability.ts
  • src/renderer/src/components/native-chat/native-chat-message-grouping.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/native-chat-session-assembler.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-launch-prompt-delivery.test.ts
  • src/renderer/src/lib/agent-launch-prompt-delivery.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/renderer/src/lib/native-chat-initial-view-mode.test.ts
  • src/renderer/src/lib/native-chat-initial-view-mode.ts
  • src/renderer/src/lib/native-chat-launch-prompt.ts
  • src/renderer/src/lib/native-chat-supported-agent.ts
  • src/renderer/src/lib/worktree-activation.test.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/store/slices/terminal-orphan-helpers.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/store/slices/worktree-removal-maps-leak.test.ts
  • src/renderer/src/store/slices/worktrees.ts

Comment thread src/renderer/src/components/native-chat/native-chat-session-assembler.ts Outdated
Comment thread src/renderer/src/lib/agent-launch-prompt-delivery.ts
* 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.
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.

1 participant