fix(completion): install the right completions for fish users - #1364
Conversation
`openspec completion install` read only $SHELL, the login shell, so users whose interactive shell differs (e.g. fish users on distros where the login shell is bash) got bash completions installed by default (#1197). Detection now consults the parent process via `ps` before falling back to $SHELL. It only trusts a parent that maps to a supported shell, so npx/npm and other non-shell parents still fall back cleanly; Windows is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughShell detection now checks the parent process for supported shells before falling back to ChangesShell Detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant detectShell
participant execFileSync
participant Environment
detectShell->>execFileSync: inspect parent process with ps
execFileSync-->>detectShell: parent shell name or failure
detectShell->>Environment: read SHELL when parent detection fails
Environment-->>detectShell: supported shell value
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/shell-detection.ts`:
- Around line 21-25: Update matchSupportedShell to extract the executable
basename and return a supported shell only when that basename exactly equals
zsh, bash, or fish; do not classify names such as fish-lsp or
bash-language-server. Add a regression test using a fish-lsp parent that
verifies detection falls back to $SHELL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 80812885-299e-4b76-a42d-4aac350c9659
📒 Files selected for processing (3)
.changeset/completion-detect-parent-shell.mdsrc/utils/shell-detection.tstest/utils/shell-detection.test.ts
…ent-process tests Two fixes from CI and review on #1364: - matchSupportedShell now matches the executable basename exactly (stripping a login-shell leading dash) instead of substring matching, so parents like fish-lsp or bash-language-server no longer get mistaken for the shell (CodeRabbit review). - The parent-process tests pin process.platform to linux so they exercise the ps path on Windows CI, where detection otherwise short-circuits and the tests failed. Adds regression tests for -zsh login shells and fish-lsp fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
alfred-openspec
left a comment
There was a problem hiding this comment.
Verified parent-process precedence, exact basename and login-shell handling, POSIX fallback, and the Windows guard. The focused regression matrix and full CI are green.
Closes the problem reported in discussion #1197.
What was wrong
openspec completion installdetected your shell only from$SHELL, which is your login shell. If you run fish interactively but your login shell is bash (the default on Fedora Silverblue and many container/immutable setups), the command installed bash completions and edited.bashrc— silently doing the wrong thing:Fish completions were already fully supported — they just never got selected.
What it does
Detection now looks at the parent process (the shell that actually launched openspec) before falling back to
$SHELL. So running the command from fish installs fish completions.npx, npm scripts, and other non-shell parents fall back to$SHELLexactly as before.ps); Windows/PowerShell detection is untouched.$SHELL, so nothing regresses.Proof it works
New unit tests cover the fish-on-bash case, macOS full-path
psoutput, and every fallback path. Verified end-to-end against the realps(fish isn't installed locally, so these use bash/zsh to prove the parent shell overrides$SHELL— the exact mechanism a fish user needs):$SHELL(login)/usr/bin/fish/bin/bash/bin/bash$SHELL)/bin/bashNotes
patchchangeset.🤖 Generated with Claude Code
Summary by CodeRabbit