Repository navigation
Conversation
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: #27578 Closes: #27160 Closes: #18756 Closes: #18755
…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/opencode#27632 (comment)
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/opencode#27632 (comment)
Address review feedback: guard against undefined or destroyed input before calling insertText in the skill picker onSelect handler.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ported from anomalyco/opencode#27632
Issue for this PR
Closes /skill slash command wipes existing input text instead of preserving it #27578
Closes fix(tui): insert selected skill into prompt #27160
Closes fix: append skills to the prompt instead of replacing #18756
Closes Selecting a skill from the dropdown completely replaces the prompt instead of "appending" to it #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 fix(tui): insert selected skill into prompt #27160](anomalyco/opencode#27160 (review)))
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 fix(tui): insert skill name without wiping existing prompt text #27584
The previous PR ([fix(tui): insert skill name without wiping existing prompt text #27584](anomalyco/opencode#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
Note on force pushes to main
This PR was originally raised as #592 but was auto-closed when the
mainbranch was force-pushed (see #760). Force-pushing to a shared branch breaks PR reopenability and orphans review comments.