feat(telemetry): display session ID in terminal summary output - #870
Merged
Conversation
Print the review session UUID on a separate line after the terminal summary so users can copy it for `ocr resume` without --format json or filesystem browsing. The line is omitted when the session ID is empty (e.g. when session persistence is unavailable). JSON output is unchanged.
5 tasks
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
wu21-web
approved these changes
Aug 13, 2026
Closed
7 tasks
Merged
14 tasks
lizhengfeng101
pushed a commit
that referenced
this pull request
Aug 15, 2026
… TraceSummary struct (#909) * refactor(telemetry): replace PrintTraceSummary positional params with TraceSummary struct PrintTraceSummary had grown to nine positional parameters after the session ID landed in #870, making call sites hard to read and easy to get wrong. Introduce a TraceSummary struct and pass it as a single argument (Option A in the issue); printed output is unchanged. Also add stdout.Swap, which swaps the package writer under the existing mutex and returns a restore function, so tests can capture and assert output written through stdout.Writer(). The PrintTraceSummary tests now assert the exact summary, cache-token, and session lines instead of only verifying the call does not panic. Closes #906 * docs(stdout): clarify Swap concurrency doc comment The mutex in Swap and its restore closure already guarantees memory safety under concurrent access; the remaining hazard is semantic — concurrent swaps produce non-deterministic restore ordering. Rephrase the comment to state that distinction, as suggested in PR review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Print the review session UUID on a separate line after the terminal
summary, so users can copy it for
ocr resumewithout--format jsonor filesystem browsing. The line is omitted when the session ID is
empty. JSON output is unchanged.
Closes #866
Changes (+23/-5, 3 files)
internal/telemetry/events.go: addsessionID stringparam toPrintTraceSummary(appended at end of signature); when non-empty,print
Session ID: <id>on its own line after the summary.cmd/opencodereview/shared.go: passag.SessionID()at the call site.internal/telemetry/events_test.go: 2 new smoke tests + 3 existingtests updated for the new signature.
Design notes
PrintSessionID(sessionID string)helper would arguably be cleaner than a 9th positional param on
PrintTraceSummary(separates summary-stats from session-identity).Kept the param approach to match the issue's hint and minimize review
friction; happy to refactor if preferred.
"e.g. dry-run / preview modes", but
previewruns viarunPreview/outputPreview*and never reachesPrintTraceSummary. The realempty case is
Agent.SessionID()returning""when sessionpersistence is unavailable (
internal/agent/agent.go). Theif sessionID != ""guard handles this and is exercised by theempty test.
Verification
make check✅ ·make test✅ (all 23 packages)make coverage-> 90.2% total;PrintTraceSummary100%.PrintTraceSummarytests); branch coverage 100% (both guard arms).Real output assertions need a
stdout.Swap(io.Writer)helper(
stdout.Writer()capturesos.Stdoutat init) - flagged asfollow-up, out of scope here.