Repository navigation
Show picker-selected native chat skills as pills - #19616
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe native chat composer now uses a Tiptap-based Priority: ➖ Normal Severity of issue fixed: Low Merge Risk: 🟡 Moderate · up to 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d75e55e3-4c9a-4315-a88c-f55b047af18b
📒 Files selected for processing (19)
src/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/NativeChatComposerField.tsxsrc/renderer/src/components/native-chat/NativeChatPromptEditor.test.tsxsrc/renderer/src/components/native-chat/NativeChatPromptEditor.tsxsrc/renderer/src/components/native-chat/NativeChatSkillPill.tsxsrc/renderer/src/components/native-chat/native-chat-composer-autogrow.test.tsxsrc/renderer/src/components/native-chat/native-chat-composer-composition.test.tsxsrc/renderer/src/components/native-chat/native-chat-composer-input.tssrc/renderer/src/components/native-chat/native-chat-draft-cache.tssrc/renderer/src/components/native-chat/native-chat-prompt-document.tssrc/renderer/src/components/native-chat/native-chat-prompt-editor.test-support.tssrc/renderer/src/components/native-chat/native-chat-structured-send-composition-clear.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-app-menu-selection.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-app-menu-selection.tssrc/renderer/src/components/native-chat/use-native-chat-composer-attachments.tssrc/renderer/src/components/native-chat/use-native-chat-composer-keydown.tssrc/renderer/src/components/native-chat/use-native-chat-dictation-actions.tssrc/renderer/src/components/native-chat/use-native-chat-picker-state.tssrc/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.
| useLayoutEffect(() => { | ||
| editor?.setEditable(!disabled, false) | ||
| }, [disabled, editor]) |
There was a problem hiding this comment.
🎯 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] }, [ |
There was a problem hiding this comment.
🩺 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()There was a problem hiding this comment.
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 —
NativeChatComposerFieldnow rendersNativeChatPromptEditor, a minimal-StarterKitEditorContent, behind aNativeChatComposerInputfacade that maps text coordinates to document positions. - Atomic skill pills — picker skill selection inserts a
nativeChatSkillatom rendered as aBadgepill (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
NativeChatPromptEditorsuite plus updated autogrow, composition, structured-send-clear, and app-menu-selection tests.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| onCompositionEnd={() => { | ||
| const compositionWasActive = imeEnterGesture.isComposing() | ||
| imeEnterGesture.setComposing(false) | ||
| if (compositionWasActive) { | ||
| settleImeValue(event.currentTarget) | ||
| settleImeValue(textareaRef.current!) | ||
| } | ||
| }} |
There was a problem hiding this comment.
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} /> |
There was a problem hiding this comment.
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.
|
Updated the pill visual to use the blue cube icon and title-case labels for Ref OSS (commit f292002c5e). Changed in the existing PR. |
There was a problem hiding this comment.
ℹ️ 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 —
NativeChatSkillPillnow rendersskillLabel(token)(e.g.$git-log→Git Log) instead of the rawtoken.slice(1). - Distinct cube icon for the bundled Ref OSS skill —
SkillIconswaps theZapglyph forCuboidwhen the token isref-oss, otherwise keepsZap. - Assertion updated — the pill test now expects the title-cased label.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
🎯 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.
022164c to
fa1fd91
Compare
|
Too many files changed for review (510 files, 100 file limit). |
fa1fd91 to
963fccd
Compare
963fccd to
e0f6e8a
Compare
|
Review status: pass / ready to land.
Electron screenshot validation through Orca orchestration was attempted, but the current chat session has no orchestration sender terminal ( |
|
Manual Electron validation evidence (native chat refactor):
Screenshots: https://github.com/user-attachments/assets/accddced-1fe0-4ff8-81e7-544c225b2899 |

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
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
imagegenis a pill, while$imagegentyped later in the same draft stays plain text. No before screenshot was captured; previously both appeared as text.Testing
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.
pnpm tc:web, changed-file oxlint, and commit-hook React lint/format checks passed.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
Checklist