Skip to content

Fix: Normalize FilesTouched paths to prevent missing checkpoint trail…#779

Open
Adityakk9031 wants to merge 1 commit intoentireio:mainfrom
Adityakk9031:#768
Open

Fix: Normalize FilesTouched paths to prevent missing checkpoint trail…#779
Adityakk9031 wants to merge 1 commit intoentireio:mainfrom
Adityakk9031:#768

Conversation

@Adityakk9031
Copy link
Copy Markdown

Issue
Commits never receive Entire-Checkpoint trailers despite hooks running correctly. The prepare-commit-msg hook finds sessions but logs "no content to link" for all of them.

The root cause is a path format mismatch in
stagedFilesOverlapWithContent
.
getStagedFiles()
returns repo-relative paths (e.g., src/screens/SessionDetail.tsx) from git diff --cached --name-only, but state.FilesTouched stores the exact paths the agent provides — often absolute (e.g., /Users/alex/project/src/screens/SessionDetail.tsx). The touchedSet[stagedPath] lookup silently fails, so no file ever reaches the content comparison logic.

A contributing factor is that opencode export returns invalid JSON, which prevents the active session's live transcript fallback from detecting content.

Solution
Normalize at write time:
mergeFilesTouched
now accepts a worktreePath parameter and normalizes all incoming paths to repo-relative form via a new
normalizeToRepoRelative
helper before storing them in state.FilesTouched.
Basename fallback at read time:
stagedFilesOverlapWithContent
now builds a secondary touchedByBase map keyed by filepath.Base(). When the exact path lookup fails, it falls back to basename matching to handle stale sessions from older CLI versions.
Debug logging: A new log line ("path format mismatch, matched by basename") makes this class of silent failure visible in future.

@Adityakk9031 Adityakk9031 requested a review from a team as a code owner March 25, 2026 20:17
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant