Skip to content

fix: self-heal legacy untagged ccstatusline hooks on sync#490

Open
bit-saver wants to merge 1 commit into
sirmalloc:mainfrom
bit-saver:fix/self-heal-legacy-ccstatusline-hooks
Open

fix: self-heal legacy untagged ccstatusline hooks on sync#490
bit-saver wants to merge 1 commit into
sirmalloc:mainfrom
bit-saver:fix/self-heal-legacy-ccstatusline-hooks

Conversation

@bit-saver

Copy link
Copy Markdown

Problem

stripManagedHooks removes only entries tagged ccstatusline-managed. Untagged hooks — written by pre-tag versions, an npx-vs-global-binary command variant, settings synced from another machine, or a manual edit — are invisible to it. So every syncWidgetHooks leaves them in place and adds a fresh managed copy beside them: ccstatusline hooks accumulate in ~/.claude/settings.json, and saving from the configurator never converges.

Fix

stripManagedHooks now also drops untagged entries whose hook command matches the ccstatusline --hook invocation (/ccstatusline.* --hook(?:\s|$)/), then re-adds the deduped managed set as before. Hook sync becomes idempotent even for legacy installs — it migrates old/untagged hooks into the managed set automatically. Non-ccstatusline user hooks are untouched.

The match requires a space before --hook and a trailing word boundary so it can't catch unrelated --hook* substrings.

Tests

Adds vitest cases to src/utils/__tests__/hooks.test.ts (real temp CLAUDE_CONFIG_DIR, no mocks):

  • legacy untagged ccstatusline hooks heal to a single managed hook per event (no duplication), while a non-ccstatusline user hook is preserved;
  • repeated syncs starting from a legacy state stay at one managed hook per event (idempotent).

bun run lint passes clean; the hooks suite passes.

stripManagedHooks only removed entries tagged 'ccstatusline-managed', so
untagged hooks written by pre-tag versions survived every sync and piled up
beside the freshly-written managed hooks. Also strip untagged entries whose
command matches the ccstatusline --hook invocation, making hook sync idempotent
for legacy installs. Non-ccstatusline user hooks are untouched.
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.

1 participant