open-code-review/internal/agent
Zhiming Wang c3e8a46323
fix(cli): stop preview from creating a review session (#784)
runPreview, runScanPreview, and delegate's preview each built a throwaway
agent via agent.New / scan.NewAgent purely to reach Preview. Both
constructors auto-create a session, and session.New opens persistence and
buffers a session_start record, so every preview created a JSONL file
under the OCR home. Preview never runs or finalizes a review, so that
file was left unfinalized and usually empty.

Make the exported entry point a package-level Preview(ctx, args) in both
internal/agent and internal/scan. It builds only what file selection
needs, so there is no session, manifest, or runner to leak. The existing
bodies stay as unexported methods, keeping the in-package tests
(including scan's regression test that Preview must not mutate a.items).

Deleting the file afterwards was rejected: it would still leak on crash
and would keep the wrong abstraction.

Tests assert at the CLI boundary, with a temporary OCR home, that no
session store is created by any of the three preview commands. They also
neutralize global git config, which git resolves via XDG_CONFIG_HOME
independently of HOME.
2026-08-08 20:55:54 +08:00
..
agent.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
agent_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
budget_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
coverage_test.go fix: remove timeout fields and more (#756) 2026-08-06 22:19:27 +08:00
estimate.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
estimate_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
getters_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
init_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
manifest_hash_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
manifest_integration_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
preview.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
preview_run_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
preview_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
util.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
util_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00