Skip to content

[0.0.28] feat(init): theme picker live preview while navigating (#2435) - #2616

Merged
Xuepoo merged 2 commits into
mainfrom
ctx-1499/feat-init-theme-live-preview
Oct 24, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
ctx-1499/feat-init-theme-live-preview

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2435

Summary

  • The bitty init theme picker now previews the entry under the cursor on
    every rendered frame instead of waiting for Enter. Each move installs the
    candidate through init_preview_push_theme_live, which resolves the same
    effective-config palette and calls Runtime::set_theme_palette — the one
    setter theme.set, live config reload, and ThemeChanged all end in (no
    second renderer).
  • The frame repaints one themed chrome strip from that same resolved theme:
    background/foreground, the 16 ANSI colors, and the cursor, selection, and
    focused/idle border swatches.
  • The preview is non-persistent: InitPreview::preview_theme never records a
    step snapshot, and no config, profile, session, or plugin-state file is
    written. Enter commits the highlighted theme exactly as before; Esc or
    end-of-input rolls the overlay back and restores the baseline palette.
  • The preview overlay and the wizard-owned live session now require a TTY
    stdout as well as a TTY stdin, so --yes, preset --profile seeds, and
    piped output keep their existing non-interactive behavior.
  • An unresolvable candidate leaves the previous theme in place (overlay,
    palette, and strip) and the existing Enter retry diagnostic still appears;
    nothing panics.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -p bitty-terminal --all-targets --locked -- -D warnings
  • cargo test -p bitty-terminal --bin bitty init → 126 passed
  • cargo test -p bitty-terminal --test cli_init_profile → 26 passed
  • New tests: 6 unit tests (apply-before-Enter, Esc restore, Enter commit,
    no-snapshot/no-write, invalid candidate, non-TTY/--yes) and 2
    binary-level tests (--yes and piped stdin).
  • bitty-manual guide: just check green (separate docs-only PR).

Pre-existing base failures (not introduced here)

Reproduced on a detached worktree at origin/main (15006647):

Priority: P2 | Area: cli/ui | Labels: feat,P2,area:cli,area:ui | Milestone: v0.0.28 | RFC: - | Task: CTX-1499

Summary by CodeRabbit

  • New Features
    • bitty init now previews theme choices as you move through them in an interactive terminal, including an updated palette display.
    • Press Enter to keep the selected theme, or Esc to restore the theme that was active before previewing. Invalid choices leave the current preview unchanged.
    • Live previews are unavailable in non-interactive sessions and when using --yes, --safe, --headless, or --test-mode; these flows retain their existing behavior.

@Xuepoo Xuepoo added this to the v0.0.28 milestone Oct 24, 2026
@Xuepoo Xuepoo added feat Feature area:ui Area: UI / layout P2 Priority: medium area:cli Area: command-line interface labels Oct 24, 2026
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: fcf6697e-7c54-4f59-8e7b-9c68e20dc74b
Commits

Reviewing files that changed from the base of the PR and between 410a5dd and 50d7061.

Files selected for processing: 4
  • CHANGELOG.md
  • crates/bitty-terminal/src/init.rs
  • crates/bitty-terminal/src/tests.rs
  • crates/bitty-terminal/tests/cli_init_profile.rs

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: 89e00346-f088-4951-8e7d-fd536fda23a2
Commits

Reviewing files that changed from the base of the PR and between 1500664 and 410a5dd.

Files selected for processing: 4
  • CHANGELOG.md
  • crates/bitty-terminal/src/init.rs
  • crates/bitty-terminal/src/tests.rs
  • crates/bitty-terminal/tests/cli_init_profile.rs

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

bitty init now previews the highlighted theme during interactive navigation. Enter commits the selection; Esc or end-of-input restores the prior theme. Preview setup requires TTY stdin and stdout and is disabled in specified non-interactive modes.

Changes: Init theme preview

Layer / File(s) Summary
Picker frame preview hook
crates/bitty-terminal/src/init.rs
The option picker accepts an optional per-frame hook and renders the returned line in key-loop and line-loop frames.
Theme preview and picker integration
crates/bitty-terminal/src/init.rs
Theme candidates update the in-memory preview without recording a step snapshot. When available, the runtime receives the changed palette. The theme picker supplies a themed strip, and preview setup requires TTY stdin and stdout while excluding --yes, --safe, --headless, and --test-mode.
Preview behavior and CLI validation
crates/bitty-terminal/src/tests.rs, crates/bitty-terminal/tests/cli_init_profile.rs, CHANGELOG.md
Tests cover preview, commit, cancellation, invalid candidates, and non-interactive behavior. The changelog describes preview and restore behavior and the non-persistence boundary.

Priority: Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Picker as bitty init theme picker
  participant Preview as InitThemePreview
  participant Runtime
  User->>Picker: Move cursor to a theme
  Picker->>Preview: Preview cursor candidate
  Preview->>Runtime: Apply changed palette when runtime is available
  Preview-->>Picker: Return themed strip
  Picker-->>User: Render preview frame
  User->>Picker: Press Enter, Esc, or end input
  Picker-->>User: Commit selection or restore prior theme
Loading

Possibly related PRs

  • bitty-terminal/bitty#2584: That PR adds focused and idle border colors to ThemePalette; this change uses the theme-palette contract to update visible chrome during preview.
Merge Risk: Minimal · up to 410a5

No identified issue blocks merging the live theme preview after normal checks.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2435 requires live preview on cursor movement, Esc rollback, Enter commit, no preview writes, safe non-TTY and --yes behavior, revert and non-TTY tests, and bitty-manual documentation. The … Add the required live theme preview documentation to bitty-manual in this pull request, then verify the documented behavior.
Docstring Coverage Inconclusive Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding a live theme preview to the init theme picker while navigating.
Out of Scope Changes check Passed The changed implementation, tests, and changelog all support issue #2435. The picker hook, runtime palette update, rollback behavior, TTY gates, and invalid-candidate handling are directly related to …
Full details: Out of Scope Changes check

Explanation

The changed implementation, tests, and changelog all support issue #2435. The picker hook, runtime palette update, rollback behavior, TTY gates, and invalid-candidate handling are directly related to the requested preview. No unrelated change is demonstrated.

Full details: Linked Issues check

Explanation

Issue #2435 requires live preview on cursor movement, Esc rollback, Enter commit, no preview writes, safe non-TTY and --yes behavior, revert and non-TTY tests, and bitty-manual documentation. The reviewed changes implement the preview hook, palette update, themed strip, rollback, commit, fail-soft invalid candidates, write protection, TTY gates, and tests. The whole-PR summary lists no bitty-manual change, and the bitty-manual diff is empty. The separate documentation PR does not establish completion in this PR.

Resolution

Add the required live theme preview documentation to bitty-manual in this pull request, then verify the documented behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 2 files. (2 skipped: 1 unsupported, 1 too large.)

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.

The theme step now previews the entry under the cursor on every picker
frame instead of waiting for Enter:

- apply the candidate through Runtime::set_theme_palette, the same sink
  theme.set, live config reload, and ThemeChanged use, resolved from the
  same effective-config mapping (no second renderer);
- repaint one themed chrome strip from that resolved palette (background,
  foreground, 16 ANSI colors, cursor, selection, focused/idle borders);
- keep the preview non-persistent: InitPreview::preview_theme records no
  step snapshot, and no config/profile/session state is written;
- gate the preview overlay and live session on a TTY stdout as well as a
  TTY stdin, so --yes, preset seeds, and piped output stay unchanged;
- ignore an unresolvable candidate (previous theme and existing retry
  diagnostic preserved).

Enter commits the highlighted theme as before; Esc/EOF rolls the overlay
back and restores the baseline palette.
@Xuepoo
Xuepoo force-pushed the ctx-1499/feat-init-theme-live-preview branch from 28a100b to 410a5dd Compare October 24, 2026 04:37

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard verification (independent agent, bitty blitz guard tick, 2026-10-24 13:55 CST)

Checks performed on head 50d7061a (ctx-1499/feat-init-theme-live-preview):

  1. gh pr checks 2616 on the exact head SHA: 20 pass, 0 fail, 0 pending (Quality gates,
    MSRV 1.85, Linux, Windows, macOS, Supply chain, CodeQL, VM tier all green).
  2. Diff scope matches the PR body: CHANGELOG.md, crates/bitty-terminal/src/init.rs,
    src/tests.rs, tests/cli_init_profile.rs — no unrelated files.
  3. Single-setter claim is consistent with the diff: the preview path funnels through
    Runtime::set_theme_palette, and InitPreview::preview_theme records no step snapshot,
    so no config/profile/session/plugin-state write can occur during preview.
  4. Non-interactive paths preserved: overlay and wizard live session gate on TTY stdout
    and TTY stdin, so --yes, preset --profile, and piped output keep current behavior.
  5. Determinism/authority scan: no hardcoded host paths, usernames, hosts, ports or repo
    URLs added; no let-chains (if … && let …) introduced, so MSRV 1.85 is safe.
  6. Failure path: unresolvable candidate leaves prior theme in place and surfaces the
    existing Enter-retry diagnostic — no panic path added.

Verdict: merge-eligible on the evidence above. This is a CI-plus-diff verification, not a
line-by-line design review; the author's local evidence (cargo test -p bitty-terminal --bin bitty init 126 passed, --test cli_init_profile 26 passed) is consistent with the green
Quality gates run.

@Xuepoo
Xuepoo merged commit 2ac3f88 into main Oct 24, 2026
20 checks passed
@Xuepoo
Xuepoo deleted the ctx-1499/feat-init-theme-live-preview branch October 24, 2026 05:53
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:ui Area: UI / layout feat Feature P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bitty init: theme picker should preview the theme live while navigating

1 participant