fix: gemma thinking - #841
Conversation
📝 WalkthroughWalkthroughThis PR adds support for Gemma-style channel thinking markers ( ChangesGemma Channel Thinking Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/mesh-llm-ui/src/features/chat/components/thinking-segments.test.ts (1)
25-39: ⚡ Quick winAdd test case for unclosed Gemma thinking segment.
The existing test suite covers unclosed
<think>tags (line 41-45), but there's no equivalent test for the Gemma format. The parser correctly handles unclosed Gemma thinking at lines 71-74 ofthinking-segments.tsby settingopen: true, but this edge case lacks test coverage.✅ Proposed test case
it('splits Gemma channel thinking when the thought marker is missing the leading pipe', () => { expect(splitAssistantThinking('<channel|>thoughtCheck facts.<channel|>Final answer.')).toEqual([ { kind: 'thinking', text: 'Check facts.', open: false }, { kind: 'response', text: 'Final answer.' } ]) }) + + it('keeps an unclosed Gemma thinking segment open for streaming', () => { + expect(splitAssistantThinking('<|channel|>thoughtStill analyzing the input')).toEqual([ + { kind: 'thinking', text: 'Still analyzing the input', open: true } + ]) + })As per coding guidelines: "Cover edge cases in tests: missing status, empty peers, client nodes, warm/cold models, malformed attachment data, and localStorage failures."
🤖 Prompt for 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. In `@crates/mesh-llm-ui/src/features/chat/components/thinking-segments.test.ts` around lines 25 - 39, Add a new unit test in thinking-segments.test.ts that exercises splitAssistantThinking for an unclosed Gemma-format thinking segment: call splitAssistantThinking with a string containing an opening Gemma marker and thought text but no closing channel marker (e.g., starting with "<|channel|>thought...") and assert the result is a single thinking segment with text normalized (capitalized/punctuation as parser does) and open: true (i.e., [{ kind: 'thinking', text: '<expected normalized text>', open: true }]). Use the same test style and expect/assert helpers as the other tests so it parallels the existing unclosed <think> case and references splitAssistantThinking and the thinking-segments parsing behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@crates/mesh-llm-ui/src/features/chat/components/thinking-segments.test.ts`:
- Around line 25-39: Add a new unit test in thinking-segments.test.ts that
exercises splitAssistantThinking for an unclosed Gemma-format thinking segment:
call splitAssistantThinking with a string containing an opening Gemma marker and
thought text but no closing channel marker (e.g., starting with
"<|channel|>thought...") and assert the result is a single thinking segment with
text normalized (capitalized/punctuation as parser does) and open: true (i.e.,
[{ kind: 'thinking', text: '<expected normalized text>', open: true }]). Use the
same test style and expect/assert helpers as the other tests so it parallels the
existing unclosed <think> case and references splitAssistantThinking and the
thinking-segments parsing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 990cebea-a395-4a15-aa8f-c4aa4543068d
📒 Files selected for processing (3)
crates/mesh-llm-ui/src/features/chat/components/MessageRow.test.tsxcrates/mesh-llm-ui/src/features/chat/components/thinking-segments.test.tscrates/mesh-llm-ui/src/features/chat/components/thinking-segments.ts
Summary by CodeRabbit
New Features
Tests