Repository navigation
fix(cli): complete quoted Bash option values - #140034
Conversation
Normalize Bash completion words and insertion prefixes together so quoted, escaped, and mixed prefixes complete to the supported value without evaluating shell input. Preserve existing word-break and cursor behavior. Related: #136557 (deferred quoted-value completion).
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 7:48 AM ET / 11:48 UTC. ClawSweeper reviewWhat this changesThe PR extracts Bash completion generation into a dedicated module and makes quoted or escaped option prefixes complete correctly, with regression coverage and updated documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: current main and the latest release lack quoted-prefix normalization, and the earlier merged repair explicitly deferred it. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw generates shell completion scripts from its registered commands and option choices. The Bash callback interprets the text around the cursor and returns candidates for Readline to insert. flowchart LR
A[Registered commands and choices] --> B[Bash script generator]
B --> C[Installed completion callback]
D[Typed words and cursor position] --> C
C --> E[Normalize quotes and escapes]
E --> F[Match commands and values]
F --> G[Readline completion candidates]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +37, Tests +26, Docs 0. Total +63 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep quote normalization in the Bash generator while preserving existing command metadata, cursor handling, and completion-cache refresh behavior. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source retains the opening quote in a prefix such as Is this the best way to solve the issue? Yes. Normalizing shell words and the insertion prefix at the Bash owner repairs matching without duplicating completion metadata or changing accepted CLI values. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1421c2164075. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '3ed964c8ca6206d26ecc0b6567ccd1389d9948fc': (36 commits) refactor(plugins): unify install config snapshot preparation (openclaw#140081) fix: cloud provisioning stays failed after temporary storage recovers (openclaw#140021) fix(ci): preflight job outputs exceed 1 MiB on full-plan pull requests (openclaw#140018) refactor: consolidate command and provider helpers (openclaw#140072) fix(doctor): replace unavailable TUI cleanup advice (openclaw#140074) fix(plugins): avoid scoped pack failures and missing runtime entries (openclaw#140016) fix: clarify background command timeouts (openclaw#140022) fix(workboard): refresh board navigation while retaining drafts (openclaw#139952) fix: preserve newer chat drafts when rewind completes (openclaw#140066) feat(transcripts): browse and export saved meeting archives (openclaw#139875) fix(cron): complete timeout test observation phase (openclaw#140076) fix(macos): show the full automation count (openclaw#139692) fix: native worker turns fail to load WebSocket transport (openclaw#140071) fix(cli): complete quoted Bash option values (openclaw#140034) fix(chat): show command instructions while pending (openclaw#140041) refactor(cli): use canonical resume result schema (openclaw#140056) fix: restore package acceptance across install runtimes (openclaw#140062) refactor(auto-reply): keep model-selection fixtures in tests (openclaw#140069) fix(plugins): remove owned aliases before uninstalling files (openclaw#140065) fix: completed replies hang when context-engine cleanup stalls (openclaw#140023) ...
Normalize Bash completion words and insertion prefixes together so quoted, escaped, and mixed prefixes complete to the supported value without evaluating shell input. Preserve existing word-break and cursor behavior. Related: openclaw#136557 (deferred quoted-value completion).
Related: #136557 — the earlier Bash option-prefix repair explicitly deferred quoted enum values.
Additional instructions
This branch is in
openclaw/openclaw; maintainers can update it through repository access.What Problem This Solves
Fixes an issue where users pressing Tab on a quoted or escaped Bash option value receive no completion. For example,
openclaw completion --shell fcompletes tofish, but the equivalent prefix after an opening single or double quote stays incomplete. Closed quotes, escaped characters, and mixed quoted words have the same problem.Why This Change Was Made
The Bash generator now prepares semantic words and the Readline replacement prefix in one lexical pass before matching commands or enum values. The existing word-break reconstruction and insertion logic are retained, and the Bash implementation has one owner in
completion-bash.ts; input is never evaluated.Production is +177 / −140 = +37 LOC; tests are +27 / −1 = +26; docs are net neutral. The 140 moved lines are not deletion savings. The added decoder is necessary because the current callback argument alone does not describe closed, escaped, or mixed quoted words, while removing reconstruction would regress equals/colon and cursor behavior.
User Impact
After refreshing cached Bash completion, quoted and escaped prefixes complete to the same supported value as unquoted input. Long options, equals forms, short flags/clusters, aliases, and cursor-position handling retain their existing behavior. Command names, flags, and accepted values keep their public spelling.
Evidence
Real Tab presses used the actual completion-command registration and generated script in fresh Bash 3.2.57 and 5.3.15 PTYs. Each shell ran nine cases. Before the change, the unquoted control passed and all eight quoted/escaped cases failed; afterward, all 18 cases produced the correct parsed
fishargument. Both final native runs exited 0. The recorder used a shell function and did not invoke Gateway or provider operations.src/cli/completion-cli.bash.test.ts.docs:list, and staged diff checks pass.Local proof used Node 24 and the frozen Vitest 4.1.11 dependency installation at
b6a2e5b4eff71070a02e755d55aea0dd53904a20. The directly inspected Bash manual and native callbacks establish quote, escape, and replacement-span behavior. Commander remains pinned to 15.0.0.Read-only preflight against immutable main
7969f4992a8ab53f8fdd003c5ab3dc5cd1163d74confirms the completion owners, callers, and tests retain the reviewed contracts. Commander 15.0.0, tsdown 0.22.14, and their resolved dependency records remain unchanged. Main now names bundled chunks with.mjs; this repair uses the normal source import graph and no hard-coded chunk filenames. Exact-head CI run 34027576277 passed at41a5c7f29b8fdd3162641ead74c86df38774935b: 77 successful jobs and 16 skips, including the artifact build, current-toolchain Node suites, typechecks, lint, docs, and guards. This hosted build is separate from the preserved scoped module build and native Bash proof above.