fix: entire attach preserves BaseCommit and active phase#1102
Merged
Soph merged 2 commits intoMay 4, 2026
Conversation
When entire attach was called on a session with an empty BaseCommit (e.g., after a hook initialization failure, or on a session created before entire was enabled), saveAttachSessionState wrote PhaseEnded and left BaseCommit empty. This prevented the prepare-commit-msg hook from recognizing the session, so subsequent commits never received Entire-Checkpoint trailers. Two changes in saveAttachSessionState: 1. Populate BaseCommit (and AttributionBaseCommit) from repo.Head() when the state's BaseCommit is empty. This activates the session so the prepare-commit-msg hook attaches trailers to future commits in the same session — eliminating the need to call entire attach again after a hook failure. 2. Do not unconditionally set Phase to PhaseEnded. If the session is already active (Phase.IsActive()), preserve that phase. Previously, calling entire attach on a running session would set PhaseEnded and break all subsequent commits in that session.
TestAttach_PopulatesBaseCommitFromHEAD covers the issue #411 symptom: attach used to leave BaseCommit empty, so the prepare-commit-msg hook never recognized the session and skipped Entire-Checkpoint trailers. TestAttach_PreservesActivePhase covers the second bug fixed here: calling attach on an already-active session must not clobber Phase to PhaseEnded. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Entire-Checkpoint: c71032ce5a68
alishakawaguchi
approved these changes
May 4, 2026
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.
Related to #411
When entire attach was called on a session with an empty BaseCommit (e.g., after a hook initialization failure, or on a session created before entire was enabled), saveAttachSessionState wrote PhaseEnded and left BaseCommit empty. This prevented the prepare-commit-msg hook from recognizing the session, so subsequent commits never received Entire-Checkpoint trailers.
Two changes in saveAttachSessionState:
Populate BaseCommit (and AttributionBaseCommit) from repo.Head() when the state's BaseCommit is empty. This activates the session so the prepare-commit-msg hook attaches trailers to future commits in the same session — eliminating the need to call entire attach again after a hook failure.
Do not unconditionally set Phase to PhaseEnded. If the session is already active (Phase.IsActive()), preserve that phase. Previously, calling entire attach on a running session would set PhaseEnded and break all subsequent commits in that session.