[PR #9861] fix(tui): preserve pasted slash commands with arguments #13247

Closed
opened 2026-02-16 18:18:07 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9861

State: closed
Merged: No


Summary

Fixes an issue where pasting a slash command with arguments (e.g., /gcd:plan-phase 2) would cause the text to be deleted.

Root cause: The hide() function in the autocomplete component was too aggressive about cleaning up "abandoned" partial commands. It deleted text when:

  • Autocomplete was in slash command mode
  • Text started with /
  • Text didn't end with a space

This logic incorrectly triggered on pasted commands with arguments.

Fix: Changed the condition to check for any whitespace in the text. If whitespace is present, it means the command has arguments and should be preserved.

Changes

  • Extract shouldClearSlashCommand() into a testable utility function
  • Update hide() to use the new utility
  • Add 17 comprehensive tests covering:
    • Partial commands (should clear)
    • Commands with arguments (should preserve)
    • Pasted commands (should preserve)
    • Edge cases (empty, whitespace, special chars, newlines, tabs)

Testing

bun test test/cli/tui/autocomplete.test.ts
# 17 pass, 0 fail
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9861 **State:** closed **Merged:** No --- ## Summary Fixes an issue where pasting a slash command with arguments (e.g., `/gcd:plan-phase 2`) would cause the text to be deleted. **Root cause:** The `hide()` function in the autocomplete component was too aggressive about cleaning up "abandoned" partial commands. It deleted text when: - Autocomplete was in slash command mode - Text started with `/` - Text didn't end with a space This logic incorrectly triggered on pasted commands with arguments. **Fix:** Changed the condition to check for any whitespace in the text. If whitespace is present, it means the command has arguments and should be preserved. ## Changes - Extract `shouldClearSlashCommand()` into a testable utility function - Update `hide()` to use the new utility - Add 17 comprehensive tests covering: - Partial commands (should clear) - Commands with arguments (should preserve) - Pasted commands (should preserve) - Edge cases (empty, whitespace, special chars, newlines, tabs) ## Testing ```bash bun test test/cli/tui/autocomplete.test.ts # 17 pass, 0 fail ```
yindo added the pull-request label 2026-02-16 18:18:07 -05:00
yindo closed this issue 2026-02-16 18:18:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13247