Sessions accumulate in ~/.opencodereview/sessions/ with no way to remove one
short of deleting files by hand. The Viewer stays read-only by design, so
deletion belongs in the CLI, where the caller already owns the files.
The session id is enough on its own: the command looks for it under every
repository, so it works from anywhere. That a session is stored under a
directory derived from its repository is an implementation detail, and making
the caller stand in the right repository to delete by id pushes that detail
onto them. --repo narrows the search rather than enabling it.
An id saved for more than one repository lists the candidates and deletes
nothing. encodeRepoPath replaces separators with "-", so two repository paths
can share one sessions directory and one id can name two different files;
choosing between them would be a coin flip on a file that cannot be recovered.
The command prints the session's repository, branch, start time, file count
and comment count in the same format `ocr session list` uses, then asks to
confirm. A non-interactive stdin answers no, so `--yes` has to be passed
deliberately from a pipeline or CI.
Reports an unreadable session rather than folding it into "corrupt" -- a
session whose metadata cannot be parsed is still deletable, since that is the
record most likely to need removing. Documented in all five locales of the CLI
reference.
Co-authored-by: Qiyuanqiii <267806965+Qiyuanqiii@users.noreply.github.com>
Co-authored-by: wu21-web <wu2196674@icloud.com>
* feat(viewer): export a session to a self-contained HTML file (#1167)
The only renderer for a review session was the live viewer HTTP server, so
there was no way to archive a review as a CI artifact.
Adds viewer.ExportSession, which drives the same template and the same
LoadSession the HTTP handler does, but renders into an io.Writer with both
/static/ assets inlined. The assets are passed as template.CSS and
template.JS: html/template refuses to interpolate an untyped string into a
<style> or <script>, and would silently emit ZgotmplZ for the stylesheet and
a JSON string literal for the script. session.html gains three gates on a new
Static field, so the served page is unchanged — the field is zero for every
HTTP render — while the exported page inlines the assets and de-links the two
site-absolute breadcrumb anchors, which are dead over file://. style.css
widens nav.breadcrumb a to cover the .crumb span that replaces one of them.
Exposed as `ocr session export [session-id]`, on `session` rather than as a
`viewer --export` flag because `viewer` is cobra.NoArgs and session_cmd.go
already owns session-id resolution and completion. The id is optional and
defaults to the newest session: a successful `ocr review` never prints its
session id, so requiring one would push every CI archive step through
`--format json`. Output goes through the shared --output/-o writer, with
"html" added to isMachineReadable so the page is not run through
stripAnsiWriter, which would eat the ESC bytes in trace-quoted source. The
page is rendered fully into a buffer before the first write, so a failure
part-way through Execute cannot leave a truncated file behind.
Also adds maximumArgs, mirroring the existing minimumArgs, so the optional
positional reports the command's own usage rather than cobra's raw
"accepts at most 1 arg(s), received 2".
Documented in all five locales of cli-reference.md, including the warning
that the artifact embeds reviewed source.
Signed-off-by: ChethanUK <chethanuk@outlook.com>
* refactor(viewer): share the header brand between served and exported pages
Signed-off-by: ChethanUK <chethanuk@outlook.com>
* feat: Apply batched suggestions from code review
Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>
---------
Signed-off-by: ChethanUK <chethanuk@outlook.com>
Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>
* feat(session): compare findings across two review sessions (#922)
After a fix-and-rerun cycle there is no way to see what changed between two
saved sessions short of diffing two comment lists by hand. Adds
`ocr session compare <before> <after>`, with `--json`, grouping findings into
new, persisting, resolved and not-reviewed.
Matching is on path, category and snippet rather than line numbers, so a
finding that only drifted down the file still counts as persisting.
* fix(session): pass os.Stdout to renderComment after main's signature change
renderComment gained an io.Writer parameter on main after this branch was
cut, so the merge left the compare printer calling it with one argument and
the package failing to build. The rest of session_cmd.go already passes
os.Stdout; this matches it, and the stale comment explaining why the printer
avoided an io.Writer no longer applies.
Claude-Session: https://claude.ai/code/session_01FoMHZQ3qqdt98LHTwSJuTG
---------
Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>