Skip to content

fix(hooks): preserve project mode across default-off sessions - #1175

Open
Vaishnavi220506 wants to merge 1 commit into
DietrichGebert:mainfrom
Vaishnavi220506:Vaishnavi220506/fix/session-default-off
Open

Vaishnavi220506 wants to merge 1 commit into
DietrichGebert:mainfrom
Vaishnavi220506:Vaishnavi220506/fix/session-default-off

Conversation

@Vaishnavi220506

Copy link
Copy Markdown
Contributor

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 off removed the shared .ponytail-active file 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 permanent off and 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 used readMode() || '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 off mode 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: f914aeab294d4d7a192a309fcc9b14e276d0c1ad

  • node --test tests/session-state.test.js — 2 passed.
  • Base check with only the new regression test on upstream 09c434a — 2 failed for the intended reasons: the shared mirror was deleted and explicit off was 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

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.

A session start with default off blanks other sessions' badge, and compaction then turns the missing flag into a permanent off

1 participant