Repository navigation
fix(session): compare sessions recorded under different path spellings - #1750
Conversation
`session compare` refused two sessions belonging to the repository it was run in. The guard compared the recorded repo paths as strings, and a session stores whichever spelling the caller used: `C:\repo` when the OS resolved the path, `C:/repo` when --repo or Git handed it over. One repository therefore split across its own spellings. The viewer's compare route carries the same check. Export the helper `session.SameRepoPath`, which already solved this for delete (Clean first, then os.SameFile for symlinks and case-insensitive volumes), and call it from both sites. Reproduced against real sessions: 1.13.0 answers "sessions belong to different repositories: ... recorded in C:\tmp\ocr-live-demo, ... in C:/tmp/ocr-live-demo" for a pair this compares as "1 new, 1 persisting, 8 resolved". The new cmd-level test fails with that exact error when the string guard is restored.
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). |
NanaseInori
left a comment
There was a problem hiding this comment.
Reviewed all five changed files, the full shared helper, and the discussion. The SameRepoPath search found this PR and the merged deletion feature that introduced the helper; reusing it for comparison is a distinct fix for the two remaining string-equality guards.
The helper's implementation is unchanged: cleaned equal paths remain equal without filesystem access, while differing spellings require successful stat calls and matching filesystem identity. Both CLI and viewer comparison use it, and deletion retains the same logic under the exported name. The command regression rewrites persisted cwd and asserts an actual successful comparison. No blocking defect found.
I ran an isolated Linux Go fixture using the exact helper: trailing separators, a dot segment and a symlink compare equal; distinct directories and different vanished paths remain unequal; identical vanished paths remain equal. All six checks passed. This was not a Windows run or an execution of the repository/HTTP viewer suite.
This review was conducted by NanaseInori's review bot, using the model GPT-6 Astra Pro. If you need a human review, please manually @NanaseInori.
What
ocr session compare <before> <after>refuses two sessions of the repository it was run in, whenever the two sessions recorded different spellings of the same directory:C:\tmp\ocr-live-demoandC:/tmp/ocr-live-demoare one directory. A session stores whichever spelling the caller used — a resolved Windows path arrives backslashed,--repoand Git's forward-slash form arrive slashed, and a trailing separator is a third spelling. The guard compared the two recorded paths as strings.Where
The same comparison exists twice, and both are changed:
cmd/opencodereview/session_cmd.go,runSessionCompare— the CLI path above.internal/viewer/handler.go, the compare route — same string equality onSummary.CWD, so the WebUI refuses the same pair.How
The repository already solves this in
internal/session/delete.go, wheresameRepoPathcleans both sides and then falls back toos.SameFile— which also covers symlinks and the case-insensitive volumes whereA-Banda-bare one directory. That helper was unexported, which is presumably why the two compare sites reached for!=instead. It is nowsession.SameRepoPathand both sites call it. No new comparison logic is introduced; one existing, already-tested helper is shared.Tests
internal/session/delete_test.gogains a "the other separator spelling" case alongside the existing trailing-separator, dot-segment, symlink and case tests.cmd/opencodereview/session_cmd_test.gogainsTestRunSessionCompare_MixedRepoSpellings: two real sessions, one re-recorded with a trailing separator, compared successfully. Restoring the string guard makes it fail with exactly the error quoted above — the existing suite did not catch this, because every prior pair was recorded with one spelling, so the wiring is now pinned at the level that broke.Verified end to end against real sessions with a locally built binary:
1 new, 1 persisting, 8 resolvedwhere released v1.13.0 still answers "sessions belong to different repositories".Compatibility
The check only ever rejects pairs; making it accept more true positives cannot break a working call. Genuinely different repositories still error, and the existing viewer test asserting that case still passes.
Checks run locally
scripts/verify-license.sh,scripts/verify-english-only.go,go mod tidy,gofmt -s,go vetover all packages except/extensions/,go test -count=1over all packages,go build— all pass. No C compiler on this box, so-raceis left to CI, as are the cross-compile and CodeQL jobs.AI disclosure (CONTRIBUTING, AI-Assisted Development)
Developed with AI assistance: the Qoder CLI coding agent helped locate both call sites, spot that
delete.goalready had the right helper, and draft the tests. I reproduced the failure against the released v1.13.0 binary myself, ran every check above myself, reviewed each line, and can explain the change: export the existing helper, call it from both compare guards, pin the spelling case at the helper and at the command. No commit attributes authorship to an AI/LLM.