add --show-thinking flag to render comment reasoning - #889
Conversation
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
| if showThinking && comment.Thinking != "" { | ||
| wrapped := wrapByRunes(sanitizeTerminal(comment.Thinking), 100) | ||
| for i, ln := range wrapped { | ||
| if i == 0 { | ||
| fmt.Printf("\033[2m> Thinking: %s\033[0m\n", ln) | ||
| } else { | ||
| fmt.Printf("\033[2m> %s\033[0m\n", ln) | ||
| } | ||
| } | ||
| fmt.Println() | ||
| } |
There was a problem hiding this comment.
The thinking content is wrapped to 100 characters, but then a prefix is prepended (> Thinking: for the first line, > for subsequent lines). This causes the actual rendered line width to exceed 100 characters (~111 chars on the first line, ~102 on subsequent lines), which is inconsistent with the content block above and can cause unwanted terminal wrapping on narrower displays.
The wrap width should account for the prefix length to maintain consistent total line width.
Suggestion:
| if showThinking && comment.Thinking != "" { | |
| wrapped := wrapByRunes(sanitizeTerminal(comment.Thinking), 100) | |
| for i, ln := range wrapped { | |
| if i == 0 { | |
| fmt.Printf("\033[2m> Thinking: %s\033[0m\n", ln) | |
| } else { | |
| fmt.Printf("\033[2m> %s\033[0m\n", ln) | |
| } | |
| } | |
| fmt.Println() | |
| } | |
| if showThinking && comment.Thinking != "" { | |
| // Account for prefix width to maintain consistent total line width | |
| wrapped := wrapByRunes(sanitizeTerminal(comment.Thinking), 88) | |
| for i, ln := range wrapped { | |
| if i == 0 { | |
| fmt.Printf("\033[2m> Thinking: %s\033[0m\n", ln) | |
| } else { | |
| fmt.Printf("\033[2m> %s\033[0m\n", ln) | |
| } | |
| } | |
| fmt.Println() | |
| } |
5d11a5f to
1679c2c
Compare
|
Thanks for the PR — the tests are solid and I like that the default behavior stays untouched. That said, I think we'll pass on this one. Thanks again for the work on this! |
Description
Adds a
--show-thinkingflag toocr reviewandocr scanthat opt-in renders each comment'sThinking(LLM reasoning) in text and SARIF output. Defaultfalse— without the flag, output is byte-for-byte / field-for-field identical to today.showThinking && Thinking != "", render after the content block and before the diff, in dim style (\033[2m> Thinking: …\033[0m);Thinkingis sanitized viasanitizeTerminaland wrapped viawrapByRunes(..., 100).showThinking && Thinking != "", appendc.Content + "\n\n" + "Thinking: " + c.Thinkingtoresult.message.text; all other fields (ruleId, level, locations, fixes, partialFingerprints) unchanged.ocr sessionis out of scope (renderComment(c, false)).Files changed (all under
cmd/opencodereview/):shared_flags.goaddShowThinkingFlag; register inregisterReviewFlagsandregisterScanFlagsshared.goemitRunResultgainsshowThinking bool; text/sarif branches propagate it, json branch unchangedoutput.gorenderComment/outputText/outputTextWithWarningsrenderThinkingin dim stylesarif.gooutputSARIF/sarifResults/sarifResultFromCommentappendThinkingtomessage.textreview_cmd.go/scan_cmd.goshowThinking booloption, passed toemitRunResultsession_cmd.gorenderComment(c, false)*_test.gofalse; newTestRenderComment_Thinking*andTestOutputSARIF_Thinking*testsZero new third-party Go dependencies; no changes outside
cmd/opencodereview/.Type of Change
How Has This Been Tested?
TestRenderComment_ThinkingHiddenByDefault,TestRenderComment_ThinkingRendered,TestRenderComment_ThinkingEmptySkipped,TestRenderComment_ThinkingSanitized;TestOutputSARIF_ThinkingHiddenByDefault,TestOutputSARIF_ThinkingRendered,TestOutputSARIF_ThinkingEmptySkipped(cover non-empty / empty / default combinations).TestRenderComment*,TestOutputJSON*,TestOutputSARIF*,TestEmitRunResult*pass unchanged.gofmt -s -lclean on changed files;go vet ./cmd/opencodereview/...no warnings;go buildsucceeds; new core functions ≥ 90% coverage.Checklist
go fmt,go vet)Related Issues
closes #888