fix(tui): insert skill name without wiping existing prompt text#27632
fix(tui): insert skill name without wiping existing prompt text#27632HaleTom wants to merge 5 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one related PR: PR #27160: fix(tui): insert selected skill into prompt This PR is directly related to the current PR (#27632). According to the description in the current PR, #27160 was a prior community PR attempting the same fix using Note: PR #27160 is already mentioned and credited in the current PR's description, indicating the maintainers are aware of this relationship. |
When selecting a skill from the TUI skill picker, the skill name is now inserted at the cursor position using input.insertText() instead of replacing the entire prompt with input.setText(). Previously, typing a question then selecting a skill would destructively wipe the entire prompt. Closes: anomalyco#27578 Closes: anomalyco#27160 Closes: anomalyco#18756 Closes: anomalyco#18755
fc19bb9 to
3c1a384
Compare
There was a problem hiding this comment.
Pull request overview
Updates the TUI prompt skill picker so selecting a skill inserts the skill slash text at the current cursor position instead of replacing the entire prompt, preventing accidental loss of already-typed input.
Changes:
- Replace
input.setText()prompt replacement withinput.insertText()insertion for skill selection. - Sync prompt store input and extmark-backed prompt parts after insertion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Production-readiness review — PR #27632Diff: 1 file, +3/-6 lines Production-ready bar for this PR
Findings1. Correctness & functional completenessNo issues found in this area based on the diff and reviewed context. The handler body (
This matches the established pattern in 2. Architecture & boundary integrityNo issues found in this area based on the diff and reviewed context. The change is scoped to a single event handler within the Prompt component. It does not cross package boundaries, introduce new abstractions, or alter any shared contracts. 3. Code clarity, clean code & maintainabilityNo issues found in this area based on the diff and reviewed context. The 3-line handler body is straightforward. Each line has a clear purpose: mutate textarea, sync store, sync extmarks. No indirection, no speculative generalization. 4. Comments & code documentationNo issues found in this area based on the diff and reviewed context. No comments were added or removed. The code is self-explanatory. 5. Tests & validation[NIT] Regression test mirrors handler logic rather than exercising the real component
The test does correctly assert:
6. PerformanceNo issues found in this area based on the diff and reviewed context.
7. Operational riskNo issues found in this area based on the diff and reviewed context. The change is purely local to the TUI prompt component. No cross-platform concerns, no storage invariants, no migration implications. Revert is a straightforward 3-line diff reversal. 8. Adversarial reviewActively attempting to falsify readiness:
What I could not fully verify
Final verdict✅ Ready to merge — no blocking issues. Full review file: |
…rompt text Added a regression test at packages/opencode/test/cli/tui/prompt-skill-select.test.ts that exercises the skill picker onSelect handler: - 'inserts skill name without wiping existing prompt text' — sets up an input with pre-existing text, simulates onSelect with a skill name, asserts the result is 'some existing text/test-skill ' (append via insertText rather than replacement via setText) - 'inserts skill name into empty prompt' — same assertion on an empty initial text Both pass with the current insertText-based logic and would fail with the old setText-based logic (which replaced the full input content). Addresses review comment: anomalyco#27632 (comment)
|
Committed and pushed as Both tests pass:
|
Updated the mock insertText to track cursorOffset and insert at cursor position rather than always appending. Added two new test cases: - 'inserts skill name at cursor position when cursor is at start' — verifies skill prefix is prepended when cursor is at position 0 - 'inserts skill name at cursor position mid-text' — verifies insertion at arbitrary cursor position Addresses review comment: anomalyco#27632 (comment)
|
guys please merge this, I just lost a prompt after 15 minutes of typing... |
|
@yassine-safraoui Please thumbs up the description -- this registers as a "vote" for the PR. Cheers! |
Issue for this PR
Closes #27578
Closes #27160
Closes #18756
Closes #18755
Type of change
What does this PR do?
When selecting a skill from the TUI skill picker, the skill name is now inserted at the current cursor position using
input.insertText()instead of replacing the entire prompt withinput.setText(). This preserves any text the user has already typed in the prompt box.Previously, typing a question then selecting a skill would destructively wipe the entire prompt — a frustrating UX reported multiple times.
Whitespace note (re: review on #27160)
insertTextdoes not trim surrounding whitespace. This is consistent with every otherinsertTextcall in the same file — file attachments, paste, and history restore all append" "unconditionally. It's a pre-existing cosmetic pattern, not specific to this fix.Replaces #27584
The previous PR (#27584) was closed because a close/reopen trick used to force a diff refresh after a rebase left the PR permanently locked — GitHub refused to reopen it ("no new commits on the branch"). This replacement PR has the same change on the same branch.
Credits
This fix borrows from and improves upon two prior community PRs:
insertText+syncExtmarksWithPromptPartspatternHow did you verify your code works?
Manually verified the logic by inspecting the existing patterns in the codebase:
input.insertText()is already used extensively throughout this file (history restore, paste, file attachments,PromptAppendevent handler)syncExtmarksWithPromptParts()is already called inonContentChangeand during IME submission sync — consistent usagesetStore("prompt", "input", rawText)matches howonContentChangesyncs stateScreenshots / recordings
N/A — 3-line change affecting only the skill picker
onSelecthandler.Checklist