Skip to content

Show picker-selected native chat skills as pills - #19616

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/native-chat-skill-invocation
Sep 8, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/native-chat-skill-invocation

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​159
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​434 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​398

ELI5

Selecting a skill from native chat's autocomplete now inserts a rounded lightning-icon pill without an X button. Typing or pasting the same skill name leaves it as ordinary text.

What Changed

  • Replace the composer textarea with a plain-text Tiptap editor and atomic skill nodes, reusing the existing editor dependency and badge primitive.
  • Keep picker, attachment, caret, and transport logic in text coordinates; skill nodes serialize to the original invocation text.
  • Preserve selected nodes in the bounded pane draft cache across chat/terminal switches. Update editor, paste, undo, and IME regression coverage.

Why

A textarea cannot render inline pills, and recognizing skill names from text would incorrectly convert manually typed names. Explicit picker insertion owns pill creation. Plain clipboard text and drafts without node metadata remain plain text; metadata is held in the existing in-memory pane cache, not added to transport messages or persisted across application restarts.

Linked Issue

Fixes #19615

Visual Proof

After: the selected imagegen is a pill, while $imagegen typed later in the same draft stays plain text. No before screenshot was captured; previously both appeared as text.

Native chat with one selected skill pill and one manually typed invocation

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

macOS background Electron/CDP: selected a real autocomplete result with Tab, typed surrounding text including the same invocation, verified one pill and exact serialized text, switched to terminal and back, and removed the pill with Backspace. Screenshot inspected in the full app context.

  • Native-chat suite: 114 files / 1,184 tests passed during implementation.
  • After follow-up changes: 35 focused tests passed; final editor regressions: 8 passed.
  • pnpm tc:web, changed-file oxlint, and commit-hook React lint/format checks passed.
  • Windows, Linux, SSH, and mobile were not exercised locally. Full build and wider checks are left to CI. No live prompt was sent to an agent during UI validation.

Review

Renderer-only change; invocation text still uses the existing send routes. Scope covers the shared composer and unsent draft metadata. The separately reported completed-turn duration bug is outside this PR.

Agent skill upstream boundary

  • Not applicable: this changes invocation presentation, not skill installation or sharing.

Checklist

  • This PR is focused on selected skill pills and supporting editor behavior
  • I explained what changed and why
  • Before/after screenshots attached (after attached; before unavailable)
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Full lint, typecheck, tests, and build pass (scoped local checks above; remaining checks left to CI)

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f03bd9c6-f6ec-47e0-a941-7dbeb9d4c769

📥 Commits

Reviewing files that changed from the base of the PR and between e0f6e8a and 0f3133a.

📒 Files selected for processing (1)
  • src/renderer/src/components/native-chat/NativeChatSkillPill.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The native chat composer now uses a Tiptap-based NativeChatPromptEditor instead of a raw textarea. Selected skills render as atomic pills and serialize to their original invocation text. Typed and pasted invocations remain plain text. Drafts can store structured editor documents by scope. Composer, picker, IME, selection, attachment, dictation, and typed-insertion integrations now use NativeChatComposerInput. Tests cover pill behavior, draft restoration, editing, pasting, and composition flows.

Priority: ➖ Normal

Severity of issue fixed: Low

Merge Risk: 🟡 Moderate · up to 0f313

The chat composer now renders selected skills as pills, but disabled-state presentation, stale picker insertion handling, and required icon styling still need correction. A stale picker selection may interrupt skill insertion, so this is not ready to merge without resolving or explicitly accepting these issues.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the primary change: selected native chat skills appear as pills.
Description check ✅ Passed The description covers the required sections, linked issue, implementation, rationale, testing, and scope. It includes an after image but explains that a before image was unavailable, and it records t…
Linked Issues check ✅ Passed The changes satisfy issue #19615: picker-selected skills render as atomic pills, typed and pasted invocations remain plain text, selected skills serialize to their original text, and draft metadata pe…
Out of Scope Changes check ✅ Passed The production and test changes support the selected-skill pill behavior and its editor, draft, picker, caret, paste, undo, and IME integration. No unrelated code changes are evident.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d75e55e3-4c9a-4315-a88c-f55b047af18b

📥 Commits

Reviewing files that changed from the base of the PR and between bba68b1 and 73f1060.

📒 Files selected for processing (19)
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatComposerField.tsx
  • src/renderer/src/components/native-chat/NativeChatPromptEditor.test.tsx
  • src/renderer/src/components/native-chat/NativeChatPromptEditor.tsx
  • src/renderer/src/components/native-chat/NativeChatSkillPill.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-autogrow.test.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-composition.test.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-input.ts
  • src/renderer/src/components/native-chat/native-chat-draft-cache.ts
  • src/renderer/src/components/native-chat/native-chat-prompt-document.ts
  • src/renderer/src/components/native-chat/native-chat-prompt-editor.test-support.ts
  • src/renderer/src/components/native-chat/native-chat-structured-send-composition-clear.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-app-menu-selection.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-app-menu-selection.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-attachments.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.ts
  • src/renderer/src/components/native-chat/use-native-chat-dictation-actions.ts
  • src/renderer/src/components/native-chat/use-native-chat-picker-state.ts
  • src/renderer/src/components/native-chat/use-native-chat-typed-insertion.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +129 to +131
useLayoutEffect(() => {
editor?.setEditable(!disabled, false)
}, [disabled, editor])

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Convey the disabled state to CSS and assistive technology.

The composer can reach disabled when no PTY exists or canSend is false. Its disabled:* classes apply to the contenteditable div, so :disabled does not match. setEditable(false) prevents editing but does not expose aria-disabled. Set both states on editor.view.dom, then use the data variant for the disabled styles.

🛠️ Proposed fix
   useLayoutEffect(() => {
     editor?.setEditable(!disabled, false)
+    if (editor) {
+      editor.view.dom.setAttribute('aria-disabled', String(disabled))
+      editor.view.dom.toggleAttribute('data-disabled', disabled)
+    }
   }, [disabled, editor])

Then update the class string in src/renderer/src/components/native-chat/NativeChatComposerField.tsx:

-'placeholder:text-muted-foreground/60 disabled:cursor-not-allowed disabled:opacity-50'
+'data-disabled:cursor-not-allowed data-disabled:opacity-50'

editor.view.dispatch(closeHistory(editor.state.tr))
editor
.chain()
.insertContentAt({ from: positions[from], to: positions[to] }, [

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Clamp picker offsets before indexing positions in insertSkill.

completeItem can retain offsets from an earlier draft while a draft update shortens the editor document. Then positions[to] is undefined. Tiptap passes this range to ProseMirror, which throws RangeError: Position undefined out of range. Clamp both offsets to the current map before indexing.

🛠️ Proposed fix
             insertSkill: (from, to, token) => {
               const { positions } = promptTextMap(editor.state.doc)
+              const at = (offset: number): number =>
+                positions[Math.min(Math.max(offset, 0), positions.length - 1)]
               editor.view.dispatch(closeHistory(editor.state.tr))
               editor
                 .chain()
-                .insertContentAt({ from: positions[from], to: positions[to] }, [
+                .insertContentAt({ from: at(from), to: at(to) }, [
                   { type: 'nativeChatSkill', attrs: { token } },
                   { type: 'text', text: ' ' }
                 ])
                 .run()

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

Caution

The composer's IME composition settlement now reads stale text and can silently drop a composed string (see the inline comment on NativeChatComposerField.tsx); the updated composition tests mask the regression rather than catch it.

Reviewed changes
Replaces the native-chat composer <textarea> with a Tiptap/ProseMirror editor so picker-selected skills render as atomic pills, while keeping picker/attachment/transport/caret logic in text coordinates.

  • Tiptap editor replaces the textarea — NativeChatComposerField now renders NativeChatPromptEditor, a minimal-StarterKit EditorContent, behind a NativeChatComposerInput facade that maps text coordinates to document positions.
  • Atomic skill pills — picker skill selection inserts a nativeChatSkill atom rendered as a Badge pill (NativeChatSkillPill); typed or pasted invocation text stays plain.
  • Draft document cache — the bounded pane draft cache now stores the ProseMirror JSON alongside the text so pills survive chat/terminal toggles.
  • Tests — new NativeChatPromptEditor suite plus updated autogrow, composition, structured-send-clear, and app-menu-selection tests.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment on lines +233 to 239
onCompositionEnd={() => {
const compositionWasActive = imeEnterGesture.isComposing()
imeEnterGesture.setComposing(false)
if (compositionWasActive) {
settleImeValue(event.currentTarget)
settleImeValue(textareaRef.current!)
}
}}

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.

settleImeValue now reads textareaRef.current.value, whose getter returns promptTextMap(editor.state.doc).text — ProseMirror's document, not the live DOM. ProseMirror keeps the IME preedit in the DOM and commits it to the doc only asynchronously (a Promise.resolve().then(flush()) / setTimeout(20) from editHandlers.compositionend in prosemirror-view 1.41.8), so this React onCompositionEnd handler runs before the doc is updated and observes the pre-composition text. In the dropped-draft-clear / racing-send path that stale text is then written back through the value setter (setContent(promptTextContent(''))), clearing the browser's live preedit before the deferred commit lands — the user's composed string is permanently lost.

Technical details
# IME settlement reads the stale ProseMirror doc

## Affected sites
- `src/renderer/src/components/native-chat/NativeChatPromptEditor.tsx:138` — `get value()` returns `promptTextMap(editor.state.doc).text`, which during an active composition is the pre-composition text (ProseMirror only updates the DOM, not the doc).
- `src/renderer/src/components/native-chat/NativeChatPromptEditor.tsx:145-147` — the empty-value setter calls `setContent(promptTextContent(''), { emitUpdate: false })`, rewriting the DOM before PM's delayed flush.
- `src/renderer/src/components/native-chat/NativeChatComposerField.tsx:156-162` — `settleImeValue` reads the stale `.value` and, when `droppedDraftClearRef` is set, assigns `imeComposedSegment(base, staleValue)` back through the setter.
- `src/renderer/src/components/native-chat/NativeChatComposerField.tsx:146` — `droppedDraftClearRef.current ||= draft === '' && textarea.value !== ''` now tests the doc (pre-composition base) instead of the browser's live preedit, so a racing clear is detected against the wrong string.

## Why the tests miss it
- `native-chat-prompt-editor.test-support.ts:13-16` (`changePrompt`) writes the preedit via `commands.setContent(...)`, i.e. directly into `editor.state.doc` — a state a real IME never produces (the browser writes only the DOM). Every composition test therefore exercises a world where the doc already holds the preedit, which is exactly the invariant the implementation violates.

## Required outcome
- The compose-settle path must observe the text the user actually composed — either by driving settlement from ProseMirror's own commit (its `onUpdate`/deferred flush), or by reading the live DOM — and must never write a stale, doc-derived value back over the pending preedit.
- Preserve the existing guarantees: a clear confirmed mid-composition keeps only the composed segment, and a rejected/racing send does not eat the draft.

## Suggested approach (optional)
- Defer the settle until PM has committed (e.g. run the clear-replay logic after the deferred flush rather than synchronously in `onCompositionEnd`), or restructure so the racing-clear replay is driven by PM's `onUpdate` where `doc` is already final.
- Note a DOM-read fallback is not trivially correct here: pill DOM text renders `token.slice(1)` (drops the `$`), so `view.dom.textContent` will not round-trip with the text-coordinate draft.

## Open questions for the human (optional)
- None.

)
useImperativeHandle(inputRef, () => input!, [input])

return <EditorContent editor={editor} {...events} />

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.

aria-expanded / aria-controls / aria-activedescendant (passed from NativeChatComposerField) are spread here onto the EditorContent wrapper via {...events} AND injected into editorProps.attributes (the inner role="textbox" contenteditable) by the key.startsWith('aria-') filter. They end up duplicated on two nested elements; consider keeping them only on the role="textbox" element so the combobox/listbox semantics are unambiguous for assistive tech.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Updated the pill visual to use the blue cube icon and title-case labels for Ref OSS (commit f292002c5e). Changed in the existing PR.

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

ℹ️ No new issues in this delta — one minor observation inline.

Reviewed changes
Display refinement for the skill pill since the prior review (delta 73f1060..4886c6a):

  • Title-cased pill label — NativeChatSkillPill now renders skillLabel(token) (e.g. $git-log → Git Log) instead of the raw token.slice(1).
  • Distinct cube icon for the bundled Ref OSS skill — SkillIcon swaps the Zap glyph for Cuboid when the token is ref-oss, otherwise keeps Zap.
  • Assertion updated — the pill test now expects the title-cased label.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 951325f6-fc91-4ab4-9561-3a5804d3f24c

📥 Commits

Reviewing files that changed from the base of the PR and between 4886c6af1d91b953014bcdd08d66b370384ac219 and 022164cedfcf09b251ee92e8d6385d84b04b3b98.

📒 Files selected for processing (1)
  • src/renderer/src/components/native-chat/NativeChatSkillPill.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

data-native-chat-skill={token}
className={`gap-1 border-border px-1.5 py-0 text-sm font-medium text-muted-foreground align-baseline ${selected ? 'ring-1 ring-ring' : ''}`}
>
<Cuboid className="size-4" aria-hidden="true" />

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore the blue cube styling.

Badge applies text-muted-foreground, and this Cuboid has no color override. The icon therefore renders in the muted foreground color instead of blue. Keep the generic Cuboid icon, but restore the intended blue icon class or design token.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-skill-invocation branch from 022164c to fa1fd91 Compare September 8, 2026 20:16
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Too many files changed for review (510 files, 100 file limit).

@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-skill-invocation branch from fa1fd91 to 963fccd Compare September 8, 2026 20:17
@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-skill-invocation branch from 963fccd to e0f6e8a Compare September 8, 2026 20:18
@brennanb2025

brennanb2025 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status: pass / ready to land.

  • Independent review completed; no proven functional, regression, performance, security, SSH/remoting, or compatibility issues found.
  • The icon and styling match existing native chat patterns; no architectural or scope concerns were identified.
  • Focused validation passed: NativeChatPromptEditor.test.tsx (8/8).
  • Readiness checks completed; no proven release-blocking findings. No mobile-facing, SSH, or Windows/WSL surface is touched.
  • The worktree contains a pre-existing unrelated pnpm-lock.yaml modification; it was not changed or included in this review.

Electron screenshot validation through Orca orchestration was attempted, but the current chat session has no orchestration sender terminal (no_active_sender_terminal), so no worker could be launched and no screenshot was attached. This is an infrastructure limitation, not a code finding.

@brennanb2025
brennanb2025 merged commit d7d21b2 into main Sep 8, 2026
26 of 28 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual Electron validation evidence (native chat refactor):

  • Created a real native Codex session via “Continue in New Session”; the rendered app showed the new Working agent tab and toast: “Session context sent to Codex in a new session.”
  • Split the terminal pane with “Split Terminal Right”; app remained rendered with native session state.
  • Opened New tab and created another real Codex native session; app remained rendered with 4 terminal sessions.

Screenshots:

https://github.com/user-attachments/assets/accddced-1fe0-4ff8-81e7-544c225b2899
https://github.com/user-attachments/assets/732a3e5c-2dec-4d2b-bf4f-e1b4a411e976

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.

Render selected native-chat skills as pills

1 participant