Skip to content

fix(session-log): detect ghost sessions from /clear to resolve correct log#661

Merged
backnotprop merged 2 commits intomainfrom
fix/session-resolve-cc
May 5, 2026
Merged

fix(session-log): detect ghost sessions from /clear to resolve correct log#661
backnotprop merged 2 commits intomainfrom
fix/session-resolve-cc

Conversation

@backnotprop
Copy link
Copy Markdown
Owner

Summary

  • After /clear, Claude Code creates a new session .jsonl but never updates ~/.claude/sessions/<pid>.json — the metadata retains the old sessionId
  • The ancestor-PID resolver (tier 1) confidently returns the stale log file, preventing fallthrough to mtime-based tiers that would pick the correct one
  • Fix: after tier 1 matches a log that isn't the newest by mtime, check whether the newer file's sessionId exists in any metadata file. If not registered → ghost from /clear → prefer it. If registered → concurrent session → keep PID result

Test plan

  • Existing 65 tests pass unchanged
  • New test: ghost session after /clear — prefers newer unregistered log
  • New test: concurrent sessions — keeps PID-based result when newer log is registered
  • Manual verification: /clear then /plannotator-last shows the post-clear message

Fixes #643

…t log

After /clear, Claude Code creates a new session (new .jsonl file) but
never updates ~/.claude/sessions/<pid>.json — the metadata retains the
old sessionId. The ancestor-PID resolver would confidently return the
stale log, preventing fallthrough to mtime-based tiers.

Fix: after tier-1 matches a log that isn't the newest by mtime, check
whether the newer file's sessionId is registered in any metadata file.
If not, it's a "ghost" session from /clear — prefer it. If it IS
registered, it belongs to a concurrent session — keep the PID result.

Fixes #643
Explicitly backdate the "older" file by 5 seconds instead of relying on
write order, which is non-deterministic when both files are created
within the same millisecond.
@backnotprop backnotprop merged commit e0fb690 into main May 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plannotator-last seems to open the same message all the time after running plannotator-compound

1 participant