Skip to content

feat: bash-like Tab completion for shell mode (! commands) in CLI TUI#26065

Open
LycanW wants to merge 2 commits intoanomalyco:devfrom
LycanW:dev
Open

feat: bash-like Tab completion for shell mode (! commands) in CLI TUI#26065
LycanW wants to merge 2 commits intoanomalyco:devfrom
LycanW:dev

Conversation

@LycanW
Copy link
Copy Markdown

@LycanW LycanW commented May 6, 2026

Issue for this PR

Closes #7755

Type of change

  • New feature

What does this PR do?

Pressing Tab while typing a ! shell command now triggers bash-like path/file completion. Added a useKeyboard handler in the CLI TUI Prompt component that intercepts Tab before the agent_cycle keybind, runs readdirSync (cross-platform file completion) or compgen -c (command name fallback).

  • Single match → auto-completes (directories get / suffix)
  • Multiple matches → shown in a toast without path prefix
  • Common prefix auto-expansion
  • Works on Linux, macOS, and Windows

How did you verify your code works?

Built the binary on Linux Mint (x86_64) with bun run script/build.ts --single --skip-embed-web-ui. Test cases:

  • ls /u<Tab> → auto-completes to ls /usr/ (single match, directory gets / suffix)
  • ls /usr/<Tab> → shows candidates in toast: bin games include lib lib64 ...
  • ls /usr/l<Tab> → auto-completes to ls /usr/local/ (prefix narrowing)
  • echo<Tab> → command name completion via compgen
  • Re-Tab on same partial → re-shows same candidate list
  • Tab in normal mode or with modifiers → does NOT trigger completion

To reproduce: bun install && bun run --cwd packages/opencode script/build.ts --single --skip-embed-web-ui, run binary, enter shell mode with !.

Screenshots / recordings

2026-05-07 07-52-38屏幕截图 2026-05-07 07-52-23屏幕截图

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

The following comment was made by an LLM, it may be inaccurate:

The search found one related PR:

Related PR:

This PR addresses shell completion features, though it appears to focus on fish shell completions rather than bash-like completion for the CLI TUI's shell mode (! commands). The current PR (#26065) is specifically about Tab completion within the TUI itself, so while related in theme, they target different scopes.

No exact duplicate PRs found addressing the same feature (Tab completion for ! shell commands in CLI TUI).

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

LycanW added 2 commits May 7, 2026 14:39
- Single match auto-completes, directories get / suffix
- Multiple matches shown without path prefix
- Common prefix auto-expansion
- File completion via readdirSync (cross-platform)
- Command name completion via compgen fallback (first word only)
- Works on Linux, macOS, and Windows
- Autocomplete popover for multi-match completions (up/down navigation)
- File/path completion via readdirSync (cross-platform)
- Bash/zsh programmable completion for subcommands (git, systemctl, etc.)
- Command name completion via compgen fallback
- Common prefix auto-expansion
- Tilde (~) path expansion
- Single match auto-complete with / suffix for directories
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.

[FEATURE] Tab completion support in shell mode (! command)

1 participant