fix(desktop): write agent hooks directly to native config files
KI
8mo ago+765+765+012345678901234567890123456789-41-41-01234567890123456789
Summary
- Claude: Write hooks directly to
~/.claude/settings.jsoninstead of a separate file that required--settingsCLI flag via binary wrapper. The wrapper is now a plain pass-through. - Codex: Write hooks to
~/.codex/hooks.json(SessionStart/Stop, added in Codex CLI v0.111.0). The wrapper is still created for richer event support (task_started, approval_request) but hooks now work even without it. - Both use the same safe merge/reconciliation pattern already used for Cursor, Gemini, Droid, and Mastra — preserving user-defined hooks and non-hook settings.
This fixes the issue where some users weren't getting agent wrapper hooks because the binary wrapper wasn't being found in PATH (due to shell wrapper chain failures with ZDOTDIR, mise/asdf PATH conflicts, etc).
Test plan
- All 47 agent-setup tests pass (10 new tests for Claude/Codex settings merge)
- TypeScript compiles cleanly
- Verify
~/.claude/settings.jsongets hooks written on app startup - Verify
~/.codex/hooks.jsongets hooks written on app startup - Verify existing user hooks/settings are preserved after merge
- Verify hooks fire when running
claudeoutside Superset terminal (should no-op gracefully) - Verify hooks fire when running
claudeinside Superset terminal
Summary by cubic
Writes Claude and Codex agent hooks directly to their native config files so hooks work even when the wrapper isn’t in PATH, while preserving user settings.
- Bug Fixes
- Claude: write hooks to ~/.claude/settings.json; wrapper is now a pass-through. Removed old
claude-settings.jsoncode path. - Codex: write hooks to ~/.codex/hooks.json (SessionStart/Stop); wrapper kept for richer events.
- Safe merge: preserve user hooks and non-hook settings, remove stale Superset-managed hooks, idempotent, and skip writes on invalid or non-object JSON.
- Hooks are created on app startup via the existing setup flow.
- Claude: write hooks to ~/.claude/settings.json; wrapper is now a pass-through. Removed old
Summary by CodeRabbit
-
Refactor
- Agent setup now uses direct JSON-based config for Claude and Codex, managing hooks via global settings files for more robust handling and migrations.
- OpenCode flow updated to align with the new configuration and marker-based handling.
-
Tests
- Added comprehensive tests covering creation, merging, idempotence, and preservation of user-defined Claude and Codex hooks.