feat(opencode): dynamic session ID completion for --session, export, and session delete#27001
Open
wakamori wants to merge 2 commits into
Open
feat(opencode): dynamic session ID completion for --session, export, and session delete#27001wakamori wants to merge 2 commits into
wakamori wants to merge 2 commits into
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…etion Add a custom completion callback to suggest session IDs from the local database when completing --session/-s, 'session delete', and 'export' commands. Uses yargs FallbackCompletionFunction to preserve default completions for all other contexts. Ref: anomalyco#1515
…used param - Escape colons in session titles to prevent zsh completion format breakage - Wrap DB query in try-catch and fall back to default completions on failure - Rename unused 'current' parameter to '_current'
5d17a62 to
7d03450
Compare
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.
Issue for this PR
Contributes to #1515
Type of change
What does this PR do?
Adds dynamic value completion for session IDs. When a user presses
<TAB>after flags or commands that accept a session ID, the shell now suggests actual session IDs (with titles) from the local database.This applies to:
opencode --session <TAB>/opencode -s <TAB>opencode session delete <TAB>opencode export <TAB>The implementation adds a
FallbackCompletionFunctionto the existing.completion()call inindex.ts. It checks the previous token to determine whether a session ID is expected, queries thesessiontable via drizzle, and returns the results. For all other contexts it falls back to yargs default completions.How did you verify your code works?
Ran
--get-yargs-completionsdirectly to confirm session IDs are returned in the right contexts and default completions still work elsewhere. All 260 existing CLI tests pass.Screenshots / recordings
N/A — CLI only change.
Checklist