fix(history-linker): preserve paused/hibernated session UUID on rescan#118
Merged
Conversation
HistoryLinker.correlateSession() was calling DetectByPath (path-based fallback) for already-linked sessions regardless of their state. When a session was paused and other sessions subsequently ran in the same directory, their newer JSONL files became the "most recently modified" candidate. The next ScanAll() call (triggered by fsnotify or on server restart) then overwrote the paused session's correct conversation UUID with a different session's UUID, causing resume to launch with --resume <wrong-uuid> and continue the wrong conversation. Gate the path fallback so it is skipped for already-linked sessions in Paused or Hibernated state. Unlinked sessions and Active sessions (where /clear UUID detection via path heuristic is still needed) are unaffected. Adds two regression tests: - TestHistoryLinker_CorrelateSession_PausedSession_PreservesUUID - TestHistoryLinker_CorrelateSession_HibernatedSession_PreservesUUID Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
✅ Registry ValidationTest Coverage: 97/143 features have
|
Contributor
E2E RPC Latency |
Contributor
📊 Feature E2E CoverageFeature coverage report unavailable
|
Contributor
Go Benchmarks (Tier 1) |
Contributor
Frontend Terminal Throughput |
Stopped sessions have no live process (terminal state) and are subject to the same "most recently modified JSONL" misidentification as Paused and Hibernated sessions. Extend the pathFallbackAllowed guard to include Stopped, and add a regression test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
✅ Registry ValidationTest Coverage: 97/143 features have
|
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
HistoryLinker.correlateSession()calledDetectByPath(returns the most-recently-modified JSONL) for already-linked sessions regardless of status; newer files from other sessions overwrote the correct stored UUIDPausedandHibernatedsessions; their stored UUID is the authoritative valueWhat changed
session/history_linker.go— 10-line change incorrelateSession():Active sessions are unaffected — they still use the path fallback, which is needed so that
/clear-triggered UUID changes are detected when PID inspection is unavailable (test environments) or races.session/history_linker_test.go— 2 regression tests:TestHistoryLinker_CorrelateSession_PausedSession_PreservesUUIDTestHistoryLinker_CorrelateSession_HibernatedSession_PreservesUUIDReproduction scenario
~/wiki/)uuid-Ais stored~/wiki/directory (creating newer JSONL files)claude --resume uuid-C(wrong); after fix: launchesclaude --resume uuid-A(correct)Test plan
TestHistoryLinker_CorrelateSession_PausedSession_PreservesUUID— core regressionTestHistoryLinker_CorrelateSession_HibernatedSession_PreservesUUID— same for hibernatedTestHistoryLinker_CorrelateSession_Force_UpdatesUUIDAfterClear— existing test; confirms active sessions still update UUID after/clearmake test— all packages pass🤖 Generated with Claude Code