fix(desktop): harden Claude task hooks in prod
Merged
KI
8mo ago+241+241+012345678901234567890123456789-54-54-01234567890123456789
Summary
- trust explicit pane ids in the desktop notification hook server so early Claude lifecycle events are not dropped while persisted tabs state is still catching up
- make managed Claude hooks in
~/.claude/settings.jsonresolvenotify.shfrom$SUPERSET_HOME_DIRso dev and prod do not fight over one global hook path - add regression coverage for pane resolution and terminal env propagation of
SUPERSET_HOME_DIR
Regression context
12641a828 perf(desktop): reduce polling, persistence, and render churn (#2045)introduced debounced tabs-state persistence, which made early hook events race persisted pane state3583f9574 fix(desktop): write agent hooks directly to native config files (#2479)moved Claude hooks to the shared global~/.claude/settings.json, which let dev/prod overwrite each other's notify script path
Validation
bun test apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts apps/desktop/src/main/lib/terminal/env.test.ts apps/desktop/src/main/lib/notifications/server.test.ts apps/desktop/src/main/lib/notifications/resolve-pane-id.test.ts apps/desktop/src/main/lib/notifications/notification-manager.test.ts apps/desktop/src/renderer/stores/tabs/utils/resolve-notification-target.test.tsbunx biome check apps/desktop/src/main/lib/agent-setup/agent-wrappers-claude-codex-opencode.ts apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts apps/desktop/src/main/lib/terminal/env.test.ts apps/desktop/src/main/lib/notifications/server.ts apps/desktop/src/main/lib/notifications/resolve-pane-id.ts apps/desktop/src/main/lib/notifications/resolve-pane-id.test.ts apps/desktop/src/main/lib/notifications/server.test.ts
Notes
- black-box checked local Claude CLI hooks with
claude 2.1.79 - current machine state reproduced the shared global Claude hook issue:
~/.claude/settings.jsonwas pointing at the dev hook path while the terminal env was prod-scoped
Summary by cubic
Hardened Claude desktop notifications to trust explicit pane IDs and added a safer fallback resolver. Managed Claude hooks now resolve notify.sh from $SUPERSET_HOME_DIR so dev and prod can share one global config.
-
Bug Fixes
- Hook server trusts incoming
paneIdeven before app state initializes and falls back via newresolvePaneIdFromTabsState(tab/workspace/session); tests added. - Managed Claude hooks in
~/.claude/settings.jsonuse a dynamic command fromgetClaudeManagedHookCommandthat runs$SUPERSET_HOME_DIR/hooks/notify.sh, are detected as managed, and the terminal env preservesSUPERSET_HOME_DIR; tests updated.
- Hook server trusts incoming
-
Refactors
- Added inline docs for hook setup helpers.
Summary by CodeRabbit
-
New Features
- Claude integration: hook commands now use a runtime-resolved home-dir marker and unified managed-hook handling.
- Notifications: pane resolution logic centralized and exposed so routing works consistently across workspaces, tabs, and chat sessions.
-
Tests
- Added/updated tests for notification resolution and preservation of the runtime home-dir env var in terminal environments.