Skip to content

fix(cli): complete quoted Bash option values - #140034

Merged
steipete merged 2 commits into
mainfrom
codex/qa30-07-bash-quoted-completion-20260905
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa30-07-bash-quoted-completion-20260905

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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 f completes to fish, 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 fish argument. Both final native runs exited 0. The recorder used a shell function and did not invoke Gateway or provider operations.

  • Regression before the production edit: 11 failed, 16 passed in src/cli/completion-cli.bash.test.ts.
  • Focused owner/sibling proof: 89 passed, 0 failed across the four files below. The 107 existing native Fish/PowerShell cases skipped because those binaries are unavailable; no coverage of those binaries is claimed.
  • A scoped tsdown build produced the extracted module and declarations. The compiled generator produced exactly the same bytes as the production caller and the script used for all 18 native cases.
  • Independent managed Codex review is scoped-clean through P2, with no findings. Targeted formatting, docs:list, and staged diff checks pass.
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs \
  src/cli/completion-cli.bash.test.ts \
  src/cli/completion-cli.test.ts \
  src/cli/completion-cli.aliases.test.ts \
  src/cli/completion-cli.visibility.test.ts

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 7969f4992a8ab53f8fdd003c5ab3dc5cd1163d74 confirms 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 at 41a5c7f29b8fdd3162641ead74c86df38774935b: 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.

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).
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 6, 2026 10:29
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 7:48 AM ET / 11:48 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 41a5c7f29b8fdd3162641ead74c86df38774935b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant native Bash observations, regression coverage, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured body records production-generated completion scripts exercised by real Tab presses in Bash 3.2 and 5.3: quoted and escaped prefixes that failed before now produce the parsed fish argument in all 18 cases.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured body records production-generated completion scripts exercised by real Tab presses in Bash 3.2 and 5.3: quoted and escaped prefixes that failed before now produce the parsed fish argument in all 18 cases.
Evidence reviewed 7 items Current main still needs the repair: The fetched main generator reconstructs word breaks and trims the cursor prefix, but passes quoting directly into choice matching without the new lexical normalization.
Latest release has the same missing normalization: Inspection of the supplied v2026.9.2 release commit shows the older Bash generator without quote decoding; no shipped fix was established.
Introduced repair and safety boundary: The decoder normalizes reconstructed words and the retained insertion prefix together. It handles single quotes, double quotes, and escapes through character comparisons without evaluating input; the existing choice quoting and completion dispatch remain in place. This is OpenClaw's shell generator, with no Codex runtime dependency.
Findings None None.
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +37, Tests +26, Docs 0. Total +63 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 177 140 +37
Tests 2 27 1 +26
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 205 142 +63

Review metrics

Metric Value Why it matters
Production versus test growth Production net +37 lines; tests net +26 lines The additional lexical decoder has a concrete correctness purpose; the 140 extracted lines are relocation, not simplification savings.

Technical review

Best 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 openclaw completion --shell "f, preventing it from matching fish; the supplied native before/after observations corroborate that path. This review did not execute it.

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.

Labels

Label justifications:

  • P2: This fixes a bounded Bash completion defect without blocking ordinary CLI execution.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured body records production-generated completion scripts exercised by real Tab presses in Bash 3.2 and 5.3: quoted and escaped prefixes that failed before now produce the parsed fish argument in all 18 cases.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records production-generated completion scripts exercised by real Tab presses in Bash 3.2 and 5.3: quoted and escaped prefixes that failed before now produce the parsed fish argument in all 18 cases.

Evidence

What I checked:

  • Current main still needs the repair: The fetched main generator reconstructs word breaks and trims the cursor prefix, but passes quoting directly into choice matching without the new lexical normalization. (src/cli/completion-cli.ts:400, 1421c2164075)
  • Latest release has the same missing normalization: Inspection of the supplied v2026.9.2 release commit shows the older Bash generator without quote decoding; no shipped fix was established. (src/cli/completion-cli.ts:405, 3928bad9badf)
  • Introduced repair and safety boundary: The decoder normalizes reconstructed words and the retained insertion prefix together. It handles single quotes, double quotes, and escapes through character comparisons without evaluating input; the existing choice quoting and completion dispatch remain in place. This is OpenClaw's shell generator, with no Codex runtime dependency. (src/cli/completion-bash.ts:43, 41a5c7f29b8f)
  • Behavioral regression coverage: The added table cases exercise open and closed quotes, backslash escapes, mixed quoting, equals word breaks, and short options through the generated Bash callback. Existing cursor, profile, literal-choice, and alias coverage remains. These tests were inspected, not executed during this review. (src/cli/completion-cli.bash.test.ts:137, 41a5c7f29b8f)
  • Supplied real Bash proof: The complete captured PR body records actual Tab presses using the production completion registration and generated script in Bash 3.2.57 and 5.3.15 PTYs: eight quoted or escaped cases failed before the change in each shell, while all 18 cases, including controls, produced the parsed fish argument afterward. It also records compiled-generator byte equivalence and 89 passing focused tests. These are supplied observations, not reviewer-executed runs. Captured context sourceRevision: 8fe1a2a563ac47f49daeda466533253598b6cb7af18d1277545632c19560d742. (41a5c7f29b8f)
  • Earlier merged repair is distinct: The supplied GitHub context verifies fix(cli): complete Bash option values without duplicate prefixes #136557 merged at this commit. Its body explicitly leaves quoted enum completion as a separate follow-up, so it does not supersede this PR. (src/cli/completion-cli.ts, 0b23ac4b4268)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-06T10:53:25.555Z sha 41a5c7f :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 46c39bc into main Sep 6, 2026
225 checks passed
@steipete
steipete deleted the codex/qa30-07-bash-quoted-completion-20260905 branch September 6, 2026 11:49
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc pushed a commit to gaoanze888/openclaw that referenced this pull request Sep 6, 2026
* 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)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant