fix(desktop): sync Claude hooks into CLAUDE_CONFIG_DIR profiles

Closed
CA
3mo ago
+166-24

What & why

Superset derives Claude pane activity status (processing/waiting-for-input/idle)
and notifications entirely from Claude Code's native lifecycle hooks, which
Superset installs by writing directly into ~/.claude/settings.json.

When Claude Code is launched with CLAUDE_CONFIG_DIR pointing at a different
profile directory — a common pattern for running multiple accounts/orgs side
by side, e.g.:

alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'

Claude Code reads its hooks from that directory instead, which never receives
Superset's managed hooks. The result is a silent failure: activity status
stays stuck at idle and no notifications fire, with no error surfaced.

The generated claude wrapper now checks $CLAUDE_CONFIG_DIR at invocation
time. When set, it asks the running app (via the existing local hook server,
same pattern as /hook/complete) to merge Superset's managed hooks into that
directory's settings.json before exec'ing the real binary. The merge reuses
the existing hook-merge logic (now parameterized by path instead of hardcoded
to ~/.claude), so existing user settings/hooks in that file are preserved.
For a plain claude invocation (no CLAUDE_CONFIG_DIR), this is a complete
no-op.

Scoped to Claude only, matching the bug I noticed myself. Codex has an analogous
per-profile override (CODEX_HOME) that isn't handled here — flagging as
possible follow-up scope rather than bundling it into this PR since I do not use Codex myself at the moment.

As an aside: users can work around this today without a code change, by
copying the same hooks block Superset writes into ~/.claude/settings.json
directly into their profile directories. That works (the hook command
resolves $SUPERSET_HOME_DIR at runtime, so it's install-independent), but
it's a static one-time copy — it won't cover profiles created later, and
won't pick up future changes to the managed hook the way ~/.claude/settings.json
does automatically on every app boot. This PR fixes it at the source instead.

Video of the fix in action

https://github.com/user-attachments/assets/d09a7c30-6680-4c41-b283-270e260e9013

How I tested it

  • Added unit tests covering the new sync function (merges into an arbitrary
    directory, preserves existing settings, creates the directory/file when
    missing, no-ops on empty/relative input) and the wrapper's exec line.
  • bun run test (desktop package): 2251 pass, 0 fail.
  • bun run lint clean.
  • Verified end-to-end against a running dev build: confirmed the regenerated
    wrapper contains the new logic, then hit the new endpoint directly against
    a real settings.json, confirming existing settings are preserved and
    hooks are merged in correctly.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs

Summary by cubic

Fixes missing activity status and notifications for Claude when launched with CLAUDE_CONFIG_DIR by syncing Superset-managed hooks into that profile’s settings.json at runtime. No change for default ~/.claude setups.

  • Bug Fixes
    • Claude wrapper checks $CLAUDE_CONFIG_DIR and calls /hook/claude-config-sync to merge managed hooks before exec; no-op otherwise.
    • Added /hook/claude-config-sync endpoint that merges hooks into the target settings.json, preserving existing settings; shared merge logic now accepts a path.
    • Added tests for config-dir sync, wrapper exec line, and path-based merge behavior.