Skip to content

feat(telemetry): display session ID in terminal summary output - #870

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
AllenMuu:feat/telemetry-session-id
Aug 14, 2026
Merged

feat(telemetry): display session ID in terminal summary output#870
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
AllenMuu:feat/telemetry-session-id

Conversation

@AllenMuu

Copy link
Copy Markdown
Contributor

What

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. JSON output is unchanged.

Closes #866

Changes (+23/-5, 3 files)

  • internal/telemetry/events.go: add sessionID string param to
    PrintTraceSummary (appended at end of signature); when non-empty,
    print Session ID: <id> on its own line after the summary.
  • cmd/opencodereview/shared.go: pass ag.SessionID() at the call site.
  • internal/telemetry/events_test.go: 2 new smoke tests + 3 existing
    tests updated for the new signature.

Design notes

  • Param vs helper: a dedicated 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.
  • Empty-case clarification: the issue says the empty case is
    "e.g. dry-run / preview modes", but preview runs via runPreview/
    outputPreview* and never reaches PrintTraceSummary. The real
    empty case is Agent.SessionID() returning "" when session
    persistence is unavailable (internal/agent/agent.go). The
    if sessionID != "" guard handles this and is exercised by the
    empty test.

Verification

  • make check ✅ · make test ✅ (all 23 packages)
  • make coverage -> 90.2% total; PrintTraceSummary 100%.
  • New tests are smoke-test style (matching the 3 pre-existing
    PrintTraceSummary tests); branch coverage 100% (both guard arms).
    Real output assertions need a stdout.Swap(io.Writer) helper
    (stdout.Writer() captures os.Stdout at init) - flagged as
    follow-up, out of scope here.

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.
@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

@wu21-web wu21-web 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.

No issues found. Please use the pull request template next time, thank you.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 0b7492b into alibaba:main Aug 14, 2026
11 checks passed
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.
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.

feat(telemetry): display session ID in terminal summary output

4 participants