feat(session): add 'ocr session comments <id>' viewer - #528
Open
nitishagar wants to merge 1 commit into
Open
Conversation
Add a read-only subcommand that surfaces the materialized content of review
comments from a saved session's review_item_done and review_item_reused records,
rendered in the same style as 'ocr review'. Today 'ocr session show' prints only
per-file comment counts.
Loader (internal/session):
- New CommentEntry type + LoadComments(repoDir, sessionID) returning per-record
comment groups. ItemDetail.Comments stays int (ocr session show unchanged).
- Sources comments from both done + reused records (matching TotalComments);
failed records carry no comments and are naturally excluded.
CLI (cmd/opencodereview):
- New 'ocr session comments <id>' subcommand mirroring 'ocr session show'.
- Flags: --repo, --json, --severity, --category (exact-match filters).
- Text path reuses the existing renderComment ([category . severity] + excerpt).
- --json emits a focused {session_id, comments:[]} payload whose element schema
matches the live review JSON. Empty/filtered-empty results are explicit.
Closes alibaba#505
Contributor
|
✅ OpenCodeReview: No comments generated. Looks good to me. |
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.
Summary
Adds a read-only
ocr session comments <id>subcommand that surfaces the content of review comments from a saved session, rendered in the same style asocr review. Closes #505.Today
ocr session showprints only per-file comment counts; this surfaces the actual materialized comments without re-running the review.Approach
Three small, additive changes (no existing function signatures changed):
internal/session/list.go): new standaloneCommentEntrytype +LoadComments(repoDir, sessionID)that returns per-record comment groups. Sources comments fromreview_item_doneandreview_item_reusedrecords (the same recordsTotalCommentscounts), so the viewer's count matches the summary.ItemDetail.Commentsstaysint—ocr session showis unchanged.cmd/opencodereview/session_cmd.go): newrunSessionCommentsmirroringrunSessionShow's flag wiring. Flags:--repo,--json,--severity,--category(single exact-match filters).renderComment([category · severity]badge + diff excerpt).--jsonemits a focused{"session_id", "comments":[]}payload whose element schema matches the live review JSON. Empty / fully-filtered results print an explicit message (text) or the empty-array envelope (JSON), never a silent empty exit.Why source from
review_item_done.commentsand notllm_response.tool_callsThe comment content is already materialized on disk as
[]model.LlmCommentbyWriteReviewItemDone/WriteReviewItemReused. Re-deriving fromllm_response.tool_calls.arguments.comments(the framing in the issue body) would re-parse raw LLM tool-call JSON — strictly more fragile for zero benefit. The materialized objects sit onejson.Unmarshalaway in the very records the viewer already walks.Verification
go fmt ./... && go vet ./...clean;go build ./...okgo test -race ./...green (23 packages)TotalCommentsparity withLoadDetail, on-disk order preserved, text output parity ([category · severity]+ path:line), JSON element-schema decode into[]model.LlmComment, severity & category filters, empty session + filtered-to-empty (explicit message /[]envelope), missing session id.Usage
README (EN + zh-CN/ja-JP/ko-KR/ru-RU) updated with examples.