Skip to content

fix(tui): model-aware thinking levels, vscode truecolor, suppress reload banner - #175

Merged
elkaix merged 4 commits into
mainfrom
fix/shell-thinking-vscode-banner
Jun 22, 2026
Merged

fix(tui): model-aware thinking levels, vscode truecolor, suppress reload banner#175
elkaix merged 4 commits into
mainfrom
fix/shell-thinking-vscode-banner

Conversation

@elkaix

@elkaix elkaix commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Scope GPT-5-family reasoning effort to each model's actually-supported levels so the selector and Shift+Tab cycle never offer (or send) levels the API rejects (e.g. minimal on gpt-5.4/5.5).
  • Promote VS Code-family integrated terminals (TERM_PROGRAM=vscode) to truecolor so diff add/remove tints render correctly instead of falling back to the 16-color path.
  • Skip the welcome banner on same-session reloads (/model, /theme, /new, fork, …) while keeping it for /clear and /reload.

Test plan

  • tests/core/test_model_thinking_levels.py — GPT-5 reasoning matrix and clamping
  • tests/ui_and_conv/test_terminal_capabilities.py — VS Code truecolor promotion
  • tests/ui_and_conv/test_shell_run_placeholders.py — banner suppress on reload
  • make check-pythinker-code && make test-pythinker-code (CI)

Summary by CodeRabbit

  • New Features
    • Reasoning-effort selections are now clamped to the active GPT-5 model’s supported levels before submission.
  • Bug Fixes
    • Diff cards no longer apply an opaque blue overlay; highlighted diffs strip background styling so terminal row/context tints display correctly.
    • VS Code–family terminals now correctly promote to truecolor for diff tinting.
    • Welcome-banner rendering is properly suppressed during reload flows when appropriate.
  • Tests
    • Added regression coverage for per-model reasoning-level scoping, welcome-banner suppression, VS Code truecolor detection, and background-free diff highlighting.

…oad banner

Scope GPT-5 reasoning effort to each model's supported set, promote
VS Code-family terminals to truecolor for diff tints, and skip the
welcome splash on same-session reloads.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20fb280a-512d-403c-b0e5-8470c0a284ea

📥 Commits

Reviewing files that changed from the base of the PR and between e47fa6c and 2a7b8f1.

📒 Files selected for processing (1)
  • tests/utils/test_diff_render.py

📝 Walkthrough

Walkthrough

Four independent fixes ship together: GPT-5-family thinking-effort levels are clamped per model version before reaching the API using new openai_gpt_reasoning_levels and available_model_thinking_levels helpers; color_depth() now promotes TERM_PROGRAM=vscode terminals to truecolor; in-session model/theme/thinking reloads suppress the welcome banner via a suppress_banner flag threaded through _reload_loop to Shell; and syntax-highlighted diff code no longer carries opaque background overlays, allowing terminal row tints to show correctly.

Changes

GPT-5 reasoning clamping, VS Code truecolor, and banner suppression

Layer / File(s) Summary
GPT-5 reasoning-level helpers and model-aware clamping
src/pythinker_code/llm.py, src/pythinker_code/soul/pythinkersoul.py, src/pythinker_code/ui/shell/slash.py, tests/core/test_model_thinking_levels.py
Introduces _GPT5_REASONING_RE, openai_gpt_reasoning_levels, and available_model_thinking_levels in llm.py; create_llm clamps thinking_effort to model-supported ladder via clamp_thinking_effort(..., available_model_thinking_levels(...)) when effort is explicitly requested; PythinkerSoul.available_thinking_efforts and /model//thinking slash commands derive options from model-scoped ladder; four tests verify per-version ladders, scoping fallback for non-GPT models, and clamping behavior.
VS Code terminal truecolor detection
src/pythinker_code/ui/terminal_capabilities.py, tests/conftest.py, tests/ui_and_conv/test_terminal_capabilities.py
color_depth() adds TERM_PROGRAM=vscode"truecolor" branch before TERM-based parsing; test conftest clears COLORTERM, WT_SESSION, and TERM_PROGRAM to stabilize color-tier testing; new test validates vscode promotion respects NO_COLOR/FORCE_COLOR precedence; 16-color fallback test extended to clear TERM_PROGRAM.
Welcome-banner suppression on non-clearing reloads
src/pythinker_code/ui/shell/__init__.py, src/pythinker_code/app.py, src/pythinker_code/cli/__init__.py, tests/ui_and_conv/test_shell_run_placeholders.py
Shell.__init__ accepts suppress_banner: bool = False and guards _print_welcome_info in run(); PythinkerCLI.run_shell threads flag to Shell; _reload_loop initializes suppress_banner=False and flips it to not e.clear_screen on Reload exceptions, so non-clearing reloads skip the splash; two tests assert banner prints once by default and is suppressed when flag is True.
CHANGELOG
CHANGELOG.md
Documents reasoning-effort clamping, diff background removal, VS Code truecolor detection, and banner suppression behavior in Unreleased section.

Diff background color stripping

Layer / File(s) Summary
Background removal from highlighted diff code
src/pythinker_code/utils/rich/diff_render.py, tests/utils/test_diff_render.py
Adds Span import and _without_bg and _strip_background helpers to remove background colors from RichStyle and Text spans; highlight_diff_code strips backgrounds from both text style and all spans while preserving foreground colors and trailing-newline cropping behavior; test asserts syntax-highlighted code carries no background styling (bgcolor is None) while foreground colors remain; autouse fixture isolates active code theme across test runs to prevent cross-test contamination.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Pythoughts-labs/pythinker-code#62: Both PRs modify welcome banner rendering in src/pythinker_code/ui/shell/__init__.py — this PR adds suppress_banner gating to avoid duplicate banners on reloads; PR #62 adjusts banner content, styling, and lifecycle behavior.

Suggested labels

bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.05% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format (type: fix, scope: tui) and accurately summarizes the three main changes: model-aware thinking levels, VS Code truecolor support, and suppress reload banner.
Description check ✅ Passed The description provides a clear summary of changes with detailed explanations and includes a comprehensive test plan; all required checklist items are either marked complete or noted as pending CI.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shell-thinking-vscode-banner

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

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pythinker_code/utils/rich/diff_render.py 72.72% 1 Missing and 2 partials ⚠️
src/pythinker_code/app.py 0.00% 1 Missing ⚠️
src/pythinker_code/ui/shell/slash.py 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Code-theme backgrounds masked diff row tints and caused a blue overlay
in VS Code-family terminals; drop bg on highlighted spans so add/remove
tints and the terminal background show through.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/utils/test_diff_render.py`:
- Around line 667-670: The test mutates the global code theme by calling
set_active_code_theme("catppuccin-adaptive") without restoring it, which can
cause test-order coupling. Add a new autouse fixture named
_restore_active_code_theme that saves the current active code theme before the
test runs using get_active_code_theme(), yields to allow the test to execute,
and then restores the original theme in a finally block using
set_active_code_theme(). This fixture should import get_active_code_theme and
set_active_code_theme from pythinker_code.utils.rich.syntax, following the same
pattern already demonstrated in tests/ui_and_conv/test_code_theme_opt_in.py.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a6237d54-962e-49e8-9e13-caf3d34374ab

📥 Commits

Reviewing files that changed from the base of the PR and between f90a931 and e47fa6c.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/pythinker_code/utils/rich/diff_render.py
  • tests/utils/test_diff_render.py

Comment thread tests/utils/test_diff_render.py
elkaix added 2 commits June 22, 2026 14:12
Add autouse fixture so set_active_code_theme in background-stripping
test does not leak process-global state between tests.
Refresh required checks after test fixture commit.
@elkaix
elkaix merged commit de0457f into main Jun 22, 2026
33 checks passed
@elkaix
elkaix deleted the fix/shell-thinking-vscode-banner branch June 22, 2026 18:32
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