Commit 6f7011a
committed
fix: idempotent hook install must compare path, not substring
The earlier `contains("claude-session-track")` check skipped reinstall
whenever ANY hook with that substring was present — even if it pointed
at a now-defunct path. On Nix/NixOS this leaves stale /nix/store hashes
in ~/.claude/settings.json across rebuilds: the previous derivation
gets garbage-collected, the next tmux start sees the stale-but-named
hook and bails, and Claude Code emits
SessionStart:clear hook error
bash: <gone-path>/hooks/claude-session-track.sh: No such file
New behaviour:
- Skip only when the EXACT current command (path-equal) is already
installed.
- Otherwise filter out any prior instance of this hook (any path,
name-matched), drop entries whose hooks list went empty, and
install the current path.
Result: each tmux start self-heals stale entries left by an earlier
derivation. Idempotent on the right dimension.
Verified with three scenarios:
1. Settings file containing a stale-path hook → replaced with
current path on next run.
2. Repeated invocations on a current-path settings file → no
duplicates added (count stays at 1).
3. Empty {} settings file → fresh install creates both
SessionStart and SessionEnd hooks.
Same fix applied to the SessionEnd hook (symmetric structure).1 parent a7691f3 commit 6f7011a
1 file changed
Lines changed: 27 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
62 | 79 | | |
63 | 80 | | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
69 | | - | |
70 | | - | |
| 86 | + | |
| 87 | + | |
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
74 | 91 | | |
75 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
| |||
0 commit comments