You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Makes Ctrl-C cancellation a durable, user-visible terminal outcome for OCR sessions.
Propagates the ocr scan command context through preview, telemetry, scan.Agent.Run, and result emission.
Persists cancelled sessions with:
terminal_reason: "cancelled"
cancellation_reason: "context canceled"
Preserves completed scan checkpoints so --resume reuses completed files and reruns only unfinished files.
Aligns cancellation handling across scan and diff-review paths, including cancellation while loading diffs and before a skipped review is finalized.
Keeps cancellation distinct from deadline expiration and ordinary input/enumeration failures.
Makes ocr session list/show and ocr viewer agree on cancelled sessions. Viewer details now show aborted (cancelled: context canceled).
Skips scan dedup/project-summary LLM work after cancellation, avoiding requests that would immediately fail.
Type of Change
Bug fix (non-breaking change that fixes an issue)
New feature (non-breaking change that adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Refactoring (no functional changes)
Documentation update
CI / Build / Tooling
How Has This Been Tested?
make test passes locally
Manual testing
Regression coverage verifies:
cancelled scan sessions persist session_end with cancelled terminal metadata;
cancellation during scan enumeration is finalized, while deadline and ordinary enumeration failures are not misclassified as user cancellation;
a completed scan item is checkpointed before cancellation, and resume reuses it while rerunning unfinished items;
cancelled review sessions are consistently classified during diff loading and dispatch;
viewer list/detail parsing and detail-page rendering expose the cancelled state and reason;
cancelled scan runs do not create dedup or project-summary LLM requests;
the emitted trace ID belongs to the scan.run span.
Also ran:
make test (race-enabled)
make check (license, English-only check, formatting, module tidy, and go vet)
git diff --check
Live LLM verification with Volcengine Ark (doubao-seed-2-1-turbo-260628):
ocr llm test passed.
A single-file scan completed successfully.
During a two-file scan, SIGINT was sent after the first file checkpoint completed.
The cancelled session preserved the completed checkpoint.
ocr scan --resume reused the completed file and ran only the unfinished file.
Some OpenAI-compatible models did not emit OCR's required task_done tool call; this provider-compatibility behavior is tracked separately from this cancellation fix.
Checklist
My code follows the project's coding style (go fmt, go vet)
I have performed a self-review of my code
I have added tests that prove my fix is effective or my feature works
New and existing unit tests pass locally with my changes
I have updated the documentation accordingly (not applicable; no user-facing documentation changes are needed)
⚠️ GitHub could not post this as an inline comment: Lines 226-227 could not be resolved (outside PR diff hunks)
Bug: After the refactoring, ctx now refers to the signal-aware context passed in, while runCtx is the context with the newly created span. TraceIDFromContext(ctx) will return an empty string (or a parent trace ID if one happened to exist), not the trace ID of the "scan.run" span we just created.
This should use runCtx to get the trace ID of the span that was started on line 223. The old code used ctx because that was the variable holding the span context before the refactoring renamed it to runCtx.
💡 Suggested Change
Before:
if telemetry.IsEnabled() {
traceID = telemetry.TraceIDFromContext(ctx)
After:
if telemetry.IsEnabled() {
traceID = telemetry.TraceIDFromContext(runCtx)
During manual Ctrl-C/resume testing today, I found several cancellation gaps beyond the original scan context propagation:
cancellation terminal metadata was not persisted consistently across scan and review paths;
ocr session and ocr viewer could present different status for the same cancelled session;
post-cancellation scan work could still attempt dedup or project-summary LLM requests.
Addressed in 16f8f45 (fix(session): persist cancelled scan and review sessions). The commit persists and surfaces cancelled session state, aligns scan/review handling, preserves resume checkpoints, and adds regression coverage for these paths.
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
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.
Description
Makes Ctrl-C cancellation a durable, user-visible terminal outcome for OCR sessions.
ocr scancommand context through preview, telemetry,scan.Agent.Run, and result emission.terminal_reason: "cancelled"cancellation_reason: "context canceled"--resumereuses completed files and reruns only unfinished files.ocr session list/showandocr vieweragree on cancelled sessions. Viewer details now showaborted (cancelled: context canceled).Type of Change
How Has This Been Tested?
make testpasses locallyRegression coverage verifies:
session_endwith cancelled terminal metadata;scan.runspan.Also ran:
make test(race-enabled)make check(license, English-only check, formatting, module tidy, andgo vet)git diff --checkLive LLM verification with Volcengine Ark (
doubao-seed-2-1-turbo-260628):ocr llm testpassed.ocr scan --resumereused the completed file and ran only the unfinished file.task_donetool call; this provider-compatibility behavior is tracked separately from this cancellation fix.Checklist
go fmt,go vet)Related Issues
Closes #995