Skip to content

feat(cli): polish color, completions, narrow-terminal output (#958) - #1115

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/cli-polish-completions-color
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/cli-polish-completions-color

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

CLI polish pass for #958 covering two concrete user-visible behaviors:
NO_COLOR support and graceful narrow-terminal output. The existing
completions surface (polylogue/cli/shell_completion_values.py, last
revised by #1109) already covers the issue's dynamic-completer
acceptance criteria — provider names, conversation IDs, tags, repo,
cwd-prefix, tool names — so this PR does not touch it.

Problem

  • The CLI honored POLYLOGUE_FORCE_PLAIN but ignored the cross-tool
    NO_COLOR convention (https://no-color.org/). Downstream pipelines
    setting NO_COLOR=1 still got ANSI escape codes in any TTY path.
  • output_summary_list and output_search_hits built fixed-shape Rich
    tables (ID/Date/Provider/Title/Msgs[/Match]) with a 63-char title
    budget, regardless of terminal width. At narrow widths (≤60 columns)
    the table overflowed; at the 40-column edge it became unreadable.

Solution

polylogue/cli/shared/formatting.py:

  • New no_color_requested() honors the NO_COLOR env var per the
    no-color.org spec (presence of any non-empty value = no color).
  • should_use_plain() now bridges NO_COLOR to plain mode, matching
    the user-visible effect ("no color in output") without touching
    polylogue/ui/ (owned by another lane). Documented as a deliberate
    short-form: true color-suppression-without-layout-drop would require
    flipping no_color=False in polylogue/ui/facade.py.

polylogue/cli/query_output.py:

  • New _summary_list_layout(width), _search_hit_layout(width),
    _title_budget(width) helpers pin a deterministic
    wide(≥80)/mid(≥60)/narrow(≥40)/sub-narrow column selection.
  • output_summary_list and output_search_hits consult
    env.ui.console.width and assemble columns/rows from the selected
    set; below 40 columns we fall back to a single title column rather
    than letting Rich wrap.

tests/unit/cli/test_color_and_layout.py:

  • Pins NO_COLOR detection semantics (presence vs empty), the
    should_use_plain bridge, end-to-end polylogue list byte-level
    ANSI absence under NO_COLOR=1, the layout column sets at every
    breakpoint, and the title-budget monotonicity contract.

Out of scope (deferred to follow-ups):

Verification

nix develop -c devtools verify --quick   # all 16 steps green
nix develop -c pytest tests/unit/cli/ -q  # 1088 passed, 1 xfailed

The new contracts (test_color_and_layout.py) cover both behaviors:
13 tests, all pinned to public-observable surfaces (env var, exit
codes, column-set tuples, title-budget integers).

Ref #958

🤖 Generated with Claude Code

Adds NO_COLOR environment-variable support to `should_use_plain` so
downstream pipelines that follow the cross-tool no-color.org convention
get ANSI-free output without having to set the Polylogue-specific
POLYLOGUE_FORCE_PLAIN override.

Adds a width-aware layout for `output_summary_list` and
`output_search_hits`: at wide (>=80), mid (>=60), narrow (>=40), and
sub-narrow widths the column set and title-truncation budget degrade
gracefully so a 40-column terminal still produces a readable table.

Pins both contracts with `tests/unit/cli/test_color_and_layout.py`.

Ref #958

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 59 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 02f99aa9-1b4d-419c-991c-a384c49e91ca

📥 Commits

Reviewing files that changed from the base of the PR and between e6b7122 and de36c9c.

📒 Files selected for processing (3)
  • polylogue/cli/query_output.py
  • polylogue/cli/shared/formatting.py
  • tests/unit/cli/test_color_and_layout.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/cli-polish-completions-color

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 and usage tips.

@Sinity
Sinity merged commit 109ccfd into master May 17, 2026
3 checks passed
@Sinity
Sinity deleted the feature/feat/cli-polish-completions-color branch May 17, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant