Skip to content

fix(tui): respect display.show_thinking when rendering stored messages (#98)#201

Merged
quangdang46 merged 1 commit into
masterfrom
fix/respect-show-thinking-in-stored-messages
May 22, 2026
Merged

fix(tui): respect display.show_thinking when rendering stored messages (#98)#201
quangdang46 merged 1 commit into
masterfrom
fix/respect-show-thinking-in-stored-messages

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

stored_message_visible_text (in src/tui/app/state_ui_messages.rs) was concatenating ContentBlock::Reasoning with ContentBlock::Text in a single match arm, ignoring the display.show_thinking setting. Result: providers that emit reasoning_content (MiniMax, OpenRouter routing through Kimi/Qwen, Gemini's thinking blocks via the openrouter SSE path) leaked the chain-of-thought into the visible transcript even when the user had explicitly set show_thinking=false in their config.

This addresses issue #98: #98

Changes

  • src/tui/app/state_ui_messages.rs:
    • Split the match arm so Reasoning blocks are gated by crate::config::config().display.show_thinking.
    • Extracted the inner pure logic into stored_message_visible_text_with_show_thinking(message, show_thinking) so tests can pin the decision deterministically without mutating the global config.
  • 3 regression tests:
    • reasoning_block_hidden_when_show_thinking_is_false (the bug)
    • reasoning_block_shown_when_show_thinking_is_true
    • empty_reasoning_block_is_skipped_either_way (covers both polarities)

Tests

$ cargo test -p jcode --lib show_thinking_tests
test result: ok. 3 passed; 0 failed

Notes

The streaming path already respects show_thinking (src/agent/turn_streaming_*.rs, src/tui/app/turn.rs:655). The bug was specifically in the rendering of already-stored messages — i.e. session reload, scrollback re-render, and any code path that goes through stored_message_visible_text.

stored_message_visible_text was concatenating ContentBlock::Reasoning
with ContentBlock::Text in a single match arm, ignoring the
display.show_thinking setting. Result: providers that emit
reasoning_content (MiniMax, OpenRouter routing through Kimi/Qwen,
Gemini's thinking blocks via the openrouter SSE path) leaked the
chain-of-thought into the visible transcript even when the user had
explicitly set show_thinking=false in their config. See issue #98.

Split the match arm so Reasoning blocks are gated by
display.show_thinking. Extract the inner pure logic into
stored_message_visible_text_with_show_thinking so tests can pin the
decision deterministically without mutating the global config.

3 tests in src/tui/app/state_ui_messages.rs:
- reasoning_block_hidden_when_show_thinking_is_false  (the bug)
- reasoning_block_shown_when_show_thinking_is_true
- empty_reasoning_block_is_skipped_either_way

Closes #98
@quangdang46 quangdang46 merged commit 8e96076 into master May 22, 2026
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