Repository navigation
fix(hooks): preserve project mode across default-off sessions - #1175
Open
Vaishnavi220506 wants to merge 1 commit into
Open
Vaishnavi220506 wants to merge 1 commit into
Vaishnavi220506 wants to merge 1 commit into
Conversation
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
Prevent a project-scoped
defaultMode: "off"session from deleting another project's live mode state, keep explicit user deactivation off after compaction, and make the statusline read the current project's mode.Problem
Fixes #1162. Starting a session in project B with the default mode set to
offremoved the shared.ponytail-activefile even when project A still had an active per-project mode. Project A's badge then disappeared. If project A compacted after its state was missing, the hook treated the missing state as a permanentoffand stopped injecting Ponytail rules.Cause
Project-scoped startup used the same
clearMode()path as an explicit user stop, so it always unlinked both the current project's state and the shared statusline mirror. The statusline also read only that shared mirror. Compaction usedreadMode() || 'off', which could not distinguish an explicit stop from state removed by another session.Changes
Keep project-scoped off operations out of the shared compatibility mirror.
Fall back to the configured default when compaction finds missing state.
Persist explicit deactivation as the literal
offmode and keep statusline scripts silent for that sentinel.Resolve the statusline from Claude's workspace payload and the per-project state file, with the shared file retained for project-less and older hosts.
Copy and uninstall the statusline helper alongside the existing shell/PowerShell wrappers.
Add subprocess regressions covering cross-project startup, project-aware badge output, missing-state compaction, and explicit stop followed by compaction.
This is intentionally limited to repairing the existing shared-default flow; it does not enable opt-in session modes and remains compatible with the direction of Add opt-in session modes while preserving shared defaults #1174.
Testing
HEAD:
f914aeab294d4d7a192a309fcc9b14e276d0c1adnode --test tests/session-state.test.js— 2 passed.09c434a— 2 failed for the intended reasons: the shared mirror was deleted and explicitoffwas not persisted.npm test— 144 passed, 2 skipped.node scripts/check-rule-copies.js— passed.node scripts/check-versions.js— passed.node --test tests/hooks-windows.test.js— 10 passed.Fixes #1162