Skip to content

Improve shell completion docs and avoid full init for completion probes - #25693

Closed
luojiyin1987 wants to merge 8 commits into
anomalyco:devfrom
luojiyin1987:feat/shell-completion-upstream-clean
Closed

luojiyin1987 wants to merge 8 commits into
anomalyco:devfrom
luojiyin1987:feat/shell-completion-upstream-clean

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #25692

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes slow shell completion probes.

opencode completion generates scripts that call opencode --get-yargs-completions ... on every completion request. Before this change, that path still went through the normal CLI startup flow, so completion requests did extra work they do not need.

This PR:

  • adds isShellCompletionInvocation() to detect completion-only invocations
  • skips global CLI middleware for completion invocations
  • skips background models.dev refresh scheduling for completion invocations
  • adds a regression test for the detection helper
  • documents Bash/Zsh shell completion setup in the main README and docs landing pages

The fix works because completion probes now avoid unrelated startup work and stay on a smaller execution path.

How did you verify your code works?

  • Ran bun test test/cli/completion.test.ts
  • Ran bun typecheck
  • Manually verified that a completion invocation in a fresh XDG directory no longer creates runtime DB side effects

Screenshots / recordings

Not a UI change.

Checklist

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

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title Improve shell completion docs and avoid full init for completion probes doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. contributor labels May 4, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

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

Based on my searches, I found one potentially related PR:

PR #23263: feat: add fish shell tab completions
#23263

This PR is related as it also deals with shell completion functionality for the opencode CLI. However, it appears to focus specifically on adding fish shell completions, while the current PR (25693) is about improving documentation and optimizing the completion invocation path for Bash/Zsh. These PRs address different aspects of shell completion functionality and are not duplicates.

No duplicate PRs found

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

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell completion probes run full CLI startup and feel slow

1 participant