Skip to content

fix(cli): complete Bash option values without duplicate prefixes - #136557

Merged
steipete merged 2 commits into
mainfrom
codex/qa30b-bash-completion-equals
Sep 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa30b-bash-completion-equals

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #136556.

What Problem This Solves

Fixes an issue where users completing Bash options after = would receive no choices or a duplicated option prefix. A named profile such as --profile=gateway could also send completion into the wrong command context.

Why This Change Was Made

The generator now reconstructs adjacent equals/colon fragments once and uses those same logical words for command selection and option choices. Returned text respects the fragment Readline actually replaces. Whitespace and shell redirections remain separate. Shared short-option scanning and command-context dispatch replace duplicated paths.

Production +54 / −61 = −7 LOC; tests/support +217 / −43 = +174; docs +1. Generated Bash output is 149,561 bytes versus 144,723 before; this is a correctness repair and source simplification, with no generated-size or speed claim.

User Impact

Both --flag value and --flag=value complete correctly across the tested native Bash versions, including named profiles before nested commands. Attached short values continue to work. The unusable -s=fish suggestion is removed: the real Commander parser treats its value as =fish and already rejects it.

Other shell generators emit byte-identical output. No installation, configuration, storage, dependency or global COMP_WORDBREAKS change is introduced.

Evidence

The original and rebuilt compiled CLI generated scripts inside isolated synthetic state. Real interactive Tab presses exercised those scripts:

Native case Before After
Bash 5.3: completion --shell= No choices All four supported shells
Bash 5.3: --profile=gateway completion --shell f No choices fish
Bash 3.2: completion --shell=f Whole option returned for the f replacement span fish, without a duplicate prefix
  • Three original regression failures are retained. All 173 focused owner/sibling tests pass.
  • Sixty-two interactive cases pass across Bash 3.2.57 and 5.3.15, covering redirections, quotes, colon/repeated-equals fragments and short clusters. Bash 5.3 insertion buffers are checked exactly, including cursor-in-middle cases; Bash 3.2 callbacks and transcripts verify candidates and prefix behavior. Proof never executes the typed command.
  • Fish and PowerShell executables are unavailable locally: 107 native cases skip. Their unchanged output hashes and static sibling checks are verified.
  • The complete required changed-file gate and canonical runtime build, including 53 built-module checks, pass. Independent Codex review is clean through P2. Two regressions caught in earlier candidates were fixed and reproduced before the final review; neither is counted as another original issue.
  • Root directly inspected the complete generator/command-tree owners, actual native results, installed Commander 15 parser and GNU Bash manual. The affected Bash owner is present in stable v2026.8.2 and unchanged on current main; no unverified introduction attribution is made.

Review finding and native cursor proof

The September 2 ClawSweeper P2 finding and its rank-up request are addressed. Reconstructed words retain the complete command-line token; matching now trims that token to the actual cursor before deriving Readline replacement text. Real Tab presses with the cursor after f in --shell=fish formerly returned an empty candidate on the first candidate; both Bash 3.2 and 5.3 now return fish. This keeps the existing right-of-cursor suffix under native Readline's skip-completed-text=off setting. No shell editing setting is changed.

The final 62 native cases preserve the preceding 40 cases and add 22 cursor/UTF-8 controls; all 62 restore the caller's locale. GNU release source confirms the offset unit changes at Bash 4.3: pcomplete.c in Bash 4.2 binds the byte index directly, while Bash 4.3 converts the prefix through MB_STRLEN. The generated function uses local byte semantics only for those older versions. A real Bash 3.2 UTF-8 regression failed before that correction and passes afterward. Bash 4.2/4.3 themselves were source-inspected, not executed.

The dependency-inspection gap is also closed: root personally inspected Commander 15.0.0 lib/command.js:1760–1907 (parseOptions) and lib/option.js choice validation. Actual parser proof rejects -s=fish because the attached short value is literally =fish; -sfish and -ysfish remain covered.

The final canonical runtime build, all 29 required changed-file checks, and one cumulative independent Codex review through P2 pass with frozen inputs. Bash 3.2 lacks READLINE_LINE, so its evidence is the real callback plus PTY transcript. Quoted enum completion such as --shell="fish" with the cursor inside the quotes remains a named pre-existing follow-up; no repair of that separate behavior is claimed.

Final review disposition

The latest ClawSweeper review reports no actionable defect. Its remaining Commander source-inspection gap is resolved by the direct installed-source and actual parser checks above. Its maintainer decision is covered by the explicit request to land this repair. Required exact-head CI is green.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 5:10 PM ET / 21:10 UTC.

ClawSweeper review

What this changes

The PR rebuilds Bash completion’s logical command words around = and : fragments so option values receive correctly scoped, non-duplicated suggestions.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned PR open: current main still contains the reported Bash completion behavior, while the prior cursor-span finding is addressed and no new blocking defect was found.

Priority: P2
Reviewed head: 3f447d7f24c215c08518858f8d8b5732bfa0c904
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The focused repair has strong native-shell evidence and addressed the prior cursor-span finding without a remaining actionable defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied PR body reports real interactive Bash 3.2 and 5.3 Tab runs against scripts emitted by the compiled CLI, covering the changed generated-script owner and showing corrected candidates for equals values and cursor spans.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied PR body reports real interactive Bash 3.2 and 5.3 Tab runs against scripts emitted by the compiled CLI, covering the changed generated-script owner and showing corrected candidates for equals values and cursor spans.
Evidence reviewed 6 items Introduced completion repair: The generated Bash function reconstructs adjacent word-break fragments, trims to the cursor span, and strips only the replacement prefix before returning candidates.
Boundary regression coverage: The new native-Bash cases cover split and unsplit equals values, profile values before nested commands, cursor-in-middle behavior, redirections, colon/repeated-equals fragments, and short clusters.
Existing owner-boundary tests: The CLI test shard includes all colocated src/cli tests, including the new Bash boundary suite and existing cross-shell coverage.
Findings None None.
Security None None.

How this fits together

The CLI generates a Bash completion script from the Commander command tree. Bash supplies token and cursor metadata to that script, which resolves the active command and returns the text Readline should insert.

flowchart LR
  A[Typed CLI line] --> B[Bash completion metadata]
  B --> C[Generated completion script]
  C --> D[Reassembled command words]
  D --> E[Command and option lookup]
  E --> F[Readline replacement candidates]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned CLI completion repair be approved once its exact-head required checks are green? Approve after exact-head checks: Accept the focused Bash completion repair after required checks confirm the reviewed head.

Why: Repository policy prevents automated cleanup of MEMBER-authored or maintainer-labeled work even when the implementation review is clean.

Before merge

  • Resolve merge risk (P1) - The read-only worktree lacks Commander 15 source and DNS prevented fetching it, so this review could not independently inspect the parser contract behind the narrow -s=fish behavior claim.
Agent review details

Security

None.

PR surface

Source -7, Tests +174, Docs +1. Total +168 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 54 61 -7
Tests 3 217 43 +174
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 272 104 +168

Review metrics

Metric Value Why it matters
Production versus test delta production −7, tests/test support +174, docs +1 The bug fix simplifies the production generator while adding boundary coverage for Bash word and cursor behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136556
Summary: This PR is the active candidate repair for the linked Bash completion defect; current main does not yet contain it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land this focused generator repair once the designated maintainer accepts it and the exact-head merge gates are green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land this focused generator repair once the designated maintainer accepts it and the exact-head merge gates are green.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked report and PR body provide concrete native Bash 3.2 and 5.3 scenarios, and current main still has the raw-token path that those scenarios exercise.

Is this the best way to solve the issue?

Yes. Repairing the generated Bash owner at the point where Bash word fragments and Readline’s replacement span are interpreted avoids changing configuration or other shell generators.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5b15291868b9.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied PR body reports real interactive Bash 3.2 and 5.3 Tab runs against scripts emitted by the compiled CLI, covering the changed generated-script owner and showing corrected candidates for equals values and cursor spans.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a user-facing CLI completion defect with limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied PR body reports real interactive Bash 3.2 and 5.3 Tab runs against scripts emitted by the compiled CLI, covering the changed generated-script owner and showing corrected candidates for equals values and cursor spans.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR body reports real interactive Bash 3.2 and 5.3 Tab runs against scripts emitted by the compiled CLI, covering the changed generated-script owner and showing corrected candidates for equals values and cursor spans.

Evidence

What I checked:

  • Introduced completion repair: The generated Bash function reconstructs adjacent word-break fragments, trims to the cursor span, and strips only the replacement prefix before returning candidates. (src/cli/completion-cli.ts:407, 3f447d7f24c2)
  • Boundary regression coverage: The new native-Bash cases cover split and unsplit equals values, profile values before nested commands, cursor-in-middle behavior, redirections, colon/repeated-equals fragments, and short clusters. (src/cli/completion-cli.bash.test.ts:26, 3f447d7f24c2)
  • Existing owner-boundary tests: The CLI test shard includes all colocated src/cli tests, including the new Bash boundary suite and existing cross-shell coverage. (test/vitest/vitest.cli.config.ts:5, 3f447d7f24c2)
  • Current main still has the defect path: Current main and the PR base have the same completion-cli blob, whose Bash generator still uses the raw current COMP_WORDS entry without the PR’s reassembly or cursor-prefix handling. (src/cli/completion-cli.ts:404, 5b15291868b9)
  • PR remains unmerged and necessary: The PR head is not an ancestor of current main, and main made no completion-cli change after the pinned PR base. (src/cli/completion-cli.ts:392, 3f447d7f24c2)
  • Codex boundary check: The sibling Codex CLI defines and emits its own Clap-generated completion scripts, confirming this OpenClaw Bash generator is a separate implementation boundary. (codex-rs/cli/src/main.rs:2856, 5adb68a49933ae446bf11935662c83dba55a0804)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: 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-02T19:49:09.399Z sha 6d584bc :: needs changes before merge. :: [P2] Preserve the suffix when completion starts mid-value

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@steipete
steipete merged commit 0b23ac4 into main Sep 2, 2026
172 of 174 checks passed
@steipete
steipete deleted the codex/qa30b-bash-completion-equals branch September 2, 2026 22:04
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…nclaw#136557)

* fix(cli): complete Bash option values without duplicate prefixes

* fix(cli): preserve Bash completion cursor spans
steipete added a commit that referenced this pull request Sep 6, 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: #136557 (deferred quoted-value completion).
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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

Bash completion loses choices or duplicates option prefixes after equals

1 participant