Skip to content

[0.0.28] fix(cli): PowerShell operand completion, profile budget, Lua ledger fixtures - #2613

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1486/fix-pwsh-completion
Oct 24, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1486/fix-pwsh-completion

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: cli | Labels: fix,P1,area:cli,area:plugin | Milestone: v0.0.28 | RFC: OQ-017 | Task: CTX-1486

Follow-up to merged #2610 (cd1ccc26). Refs #2575. Final head rebased onto main 7628cc64; duplicate changes already on main (candidates Lua fixture via #2614, CHANGELOG consolidation via #2617) were dropped.

Defects fixed

Blocker: PowerShell operand completion was unreachable

$paths only carries grammar-node keys (plugin, config profile, ...), so the operand branches nested inside elseif ($paths.Contains($path)) never ran for plugin enable|disable or config profile show|use|path.

Fix: compute $isOperandPath from the resolved path and evaluate the dynamic operand branches before the static lookup. Flags still fall through to the static path (empty for operand slots).

Minor: config profile list counted unrelated files against the profile budget

run_list passed PROFILE_LIST_CAP (256) as both the entry limit and the name limit, so 300 unrelated files plus profiles could print stopped at 256 entries and omit profiles. Fix: scan up to PROFILE_SCAN_CAP (1024) entries while capping emitted names at PROFILE_LIST_CAP. scan_names was split into collect_names so the entry/name limits are testable with a deterministic ordering.

Tests

  • pwsh_completes_plugin_and_profile_operands_from_local_state: loads the generated PowerShell script (.ps1), invokes $global:_BittyCompletionScript for plugin enable, plugin disable a, config profile show, and config profile path w over isolated XDG state, and asserts exact candidate text. The harness prints diagnostics to stderr (PATH, Get-Command bitty, raw helper output, per-case path/word/element count/results, exceptions) so a future CI failure is actionable. Skips locally when pwsh is absent; Windows/macOS/Linux CI all run it.
  • bash_completes_plugin_and_profile_operands_from_local_state: sources the Bash script and calls _bitty_complete with COMP_WORDS for the same four contexts.
  • candidates: bounded sorted/deduped state+store union, legacy TOML fallback (with the one-time migration), malformed Lua -> empty set (no legacy fallback). Main's write_state Lua-render fixture is kept unchanged.
  • profile::tests::entry_budget_does_not_count_unrelated_files: 300 unrelated files before three profiles.
  • PowerShell unit assertion that operand branches precede $paths.Contains.

Evidence (head 1b9eff66)

  • cargo fmt --all -- --check — clean
  • RUSTFLAGS="-D warnings" cargo clippy -p bitty-terminal -p bitty-config --all-targets --locked — clean
  • RUSTFLAGS="-D warnings" cargo clippy -p bitty-terminal --features dev-tools --all-targets --locked — clean
  • cargo test -p bitty-terminal --test cli_completion — 15 passed (local pwsh skipped: pwsh unavailable; Bash functional test ran)
  • cargo test -p bitty-terminal --bin bitty candidates — 21 passed (includes plugins_union_state_and_store_sorted)
  • cargo test -p bitty-terminal --bin bitty profile:: — 3 passed
  • cargo test -p bitty-terminal --bin bitty — 1234+ passed on the prior base; rerun pieces above after the final rebase
  • Remote CI on 1b9eff66: 17 success, 0 failure, 2 skipped — Quality gates (1/2), Windows, macOS ARM64, Linux X11/Wayland + compat matrices, MSRV, CodeQL, supply chain, VM tier PR, extension pin drift, M1/compat aggregates all green.

Earlier red-run evidence (fixed)

The first pwsh run returned four separators only. Diagnostics then showed correct paths/helpers:

profiles=alpha|work
plugins=alpha.plugin|zeta.plugin
case='bitty plugin enable ' word='' path='plugin enable' previous='enable' elements=3 type=CommandAst
results=2

Root causes fixed: the completion file was dot-sourced without a .ps1 extension; the expected string missed the leading case separator; Windows stdout is CRLF (now normalized before comparison).

Notes

  • just ci-local remains blocked on this host by the act-runner Nix installer download through the proxy (DNS/HTTP2 failures); the equivalent Rust gates above were run locally. Remote CI is authoritative.
  • No merge performed.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e477e87d-800b-42ad-be02-ca9dadb929c3
Commits

Reviewing files that changed from the base of the PR and between d9e4c9f and 1b9eff6.

Files selected for processing: 5
  • crates/bitty-terminal/src/candidates.rs
  • crates/bitty-terminal/src/completion.rs
  • crates/bitty-terminal/src/profile.rs
  • crates/bitty-terminal/tests/cli_completion.rs
  • crates/bitty-terminal/tests/fixtures/completion/powershell.txt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The changes add tests for plugin candidate sorting and ledger migration, separate profile scan and output limits, and update PowerShell completion for plugin and profile operands. Bash and PowerShell integration tests exercise operand completion against isolated state.

Changes: Plugin and profile completion

Layer / File(s) Summary
Plugin candidate ledger and test setup
crates/bitty-terminal/src/candidates.rs, crates/bitty-terminal/tests/cli_completion.rs
Tests cover sorted, de-duplicated, capped plugin candidates; legacy TOML migration when the Lua ledger is absent; and malformed Lua ledger handling. The CLI test fixtures use Lua for managed state and TOML for legacy state.
Profile-name scanning and listing
crates/bitty-terminal/src/profile.rs
Profile listing scans up to PROFILE_SCAN_CAP entries and returns at most PROFILE_LIST_CAP names. The truncation message reports both limits. A test checks that unrelated files do not prevent later profiles from being collected within the scan bound.
Plugin and profile operand completion
crates/bitty-terminal/src/completion.rs, crates/bitty-terminal/tests/fixtures/completion/powershell.txt, crates/bitty-terminal/tests/cli_completion.rs
PowerShell completion checks plugin and profile operand paths before static grammar lookup. Tests cover plugin enable/disable and profile show/use/path operands, including Bash and PowerShell integration tests. The test harness isolates command state and writes shell-specific completion scripts.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • bitty-terminal/bitty#2449: The changes cover completion for config profile show, use, and path, and adjust profile-list scanning.

Possibly related PRs

  • bitty-terminal/bitty#2600: This PR introduces the Lua plugin ledger and TOML migration behavior covered by the candidate tests and fixtures.
  • bitty-terminal/bitty#2616: This PR reports a pre-existing failure in the plugin candidate union test that this PR updates and reports passing.

Suggested labels: bug, area:config

Merge Risk: Minimal · up to 1b9ef

No actionable merge-blocking issue remains in the reviewed changes; merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 24.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the pull request's main changes: PowerShell operand completion, profile scan budgeting, and Lua ledger test fixtures.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 24.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Xuepoo Xuepoo added area:cli Area: command-line interface area:plugin Area: plugin host fix Bug fix P1 Priority: high labels Oct 24, 2026
@Xuepoo Xuepoo added this to the v0.0.28 milestone Oct 24, 2026
@Xuepoo
Xuepoo force-pushed the ctx-1486/fix-pwsh-completion branch 3 times, most recently from c4e0189 to 140662d Compare October 24, 2026 05:27
…ixtures (#2575)

PowerShell now evaluates plugin/profile operand paths before the grammar-node lookup, so `plugin enable|disable` and `config profile show|use|path` return local candidates; a pwsh-driven integration test invokes the completion scriptblock against isolated XDG state. Bash gains the same functional operand test. `config profile list` scans the 1024-entry budget while capping output at 256 profiles, so unrelated files cannot hide profiles. Candidate fixtures now write the Lua bitty-plugins.lua ledger, with legacy-TOML fallback and malformed-Lua coverage.
@Xuepoo
Xuepoo force-pushed the ctx-1486/fix-pwsh-completion branch from 140662d to 1b9eff6 Compare October 24, 2026 06:03
@Xuepoo
Xuepoo merged commit 1370bf0 into main Oct 24, 2026
20 checks passed
@Xuepoo
Xuepoo deleted the ctx-1486/fix-pwsh-completion branch October 24, 2026 07:05
@Xuepoo Xuepoo mentioned this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Area: command-line interface area:plugin Area: plugin host fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant