Skip to content

fix(desktop): reap stale notify.sh paths from in-repo dev worktrees#3698

Merged
Kitenite merged 1 commit into
mainfrom
meowing-saffron
Apr 24, 2026
Merged

fix(desktop): reap stale notify.sh paths from in-repo dev worktrees#3698
Kitenite merged 1 commit into
mainfrom
meowing-saffron

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 24, 2026

Summary

  • Dev setup (.superset/lib/setup/steps.sh) points SUPERSET_HOME_DIR at $PWD/superset-dev-data — without a leading dot — so the managed-hook regex /\.superset(?:-[^/'"\s\\]+)?\// never matched those paths.
  • Result: after deleting a dev worktree, its notify.sh path stayed in ~/.codex/hooks.json forever, even though the file was gone.
  • Widen the pattern to also recognize superset-dev-data/ so the reaper can swap in the current hook path. Added a regression test covering the in-repo .worktrees/<name>/superset-dev-data/ layout.

Test plan

  • bun test apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts
  • Verify stale notify.sh entries from deleted dev worktrees are replaced with the current path on desktop startup

Summary by cubic

Fixes stale notify.sh entries in ~/.codex/hooks.json when deleting in-repo dev worktrees by recognizing superset-dev-data paths used by the dev setup. On desktop startup, the reaper now replaces old paths with the current hook path.

  • Bug Fixes
    • Expanded managed-hook regex to match both /.superset.../ and /superset-dev-data/ paths.
    • Added a regression test for .worktrees/<name>/superset-dev-data/ to ensure stale paths are removed and replaced.

Written for commit 12b4319. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Improved recognition of managed hook paths in development configurations, now supporting additional directory layouts.
  • Tests
    • Added test coverage for stale hook paths in development worktrees, verifying proper cleanup and path management.

Dev setup writes SUPERSET_HOME_DIR=<worktree>/superset-dev-data (no leading
dot), which didn't match the managed-hook regex, so stale notify.sh entries
from deleted dev worktrees stuck around in ~/.codex/hooks.json. Widen the
pattern to also recognize `superset-dev-data/` and add a regression test.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The managed-hook command matcher now recognizes hook paths in both standard /.superset.../ and alternate /superset-dev-data/ directories. A corresponding test case verifies that stale hook paths from dev worktrees are properly handled and replaced with current paths.

Changes

Cohort / File(s) Summary
Hook path detection logic
apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts
Updated path-regex to recognize superset-managed hooks in both standard and dev-data directory layouts.
Hook path handling tests
apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts
Added test case for stale hook paths in dev worktrees, verifying that managed events retain current paths and discard stale ones.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hook in the worktree, a hook by a name,
Whether standard or dev-data, they're all the same!
The regex now sees both paths with delight,
While tests ensure stale paths fade from sight. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: fixing stale notify.sh paths from deleted dev worktrees.
Description check ✅ Passed The description covers the issue, solution, and testing approach, though the 'Related Issues' and 'Screenshots' sections are missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch meowing-saffron

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR fixes a gap in the stale-hook reaper: dev worktrees set SUPERSET_HOME_DIR to <worktree>/superset-dev-data (no leading dot), so the old regex \/\.superset(?:-[^/'"\s\\]+)?\/ never matched those paths and left dead notify.sh entries in ~/.codex/hooks.json after a worktree was deleted. The fix adds superset-dev-data as an alternation in the pattern and includes a targeted regression test.

Confidence Score: 5/5

Safe to merge — minimal, well-targeted regex fix with a direct regression test and no correctness or security concerns.

The change is a one-line regex update with a clear motivation, a good explanatory comment, and a purpose-built test. The new superset-dev-data alternative is specific enough (combined with the existing /hooks/${scriptName} guard) to avoid false positives. No existing tests are affected and no P0/P1 findings were identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts Widened SUPERSET_MANAGED_HOOK_PATH_PATTERN regex to also match /superset-dev-data/ path segments alongside the existing /.superset/ variants, with a clear explanatory comment.
apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts Added regression test covering the in-repo .worktrees//superset-dev-data/ layout, verifying stale paths are replaced across all three hook event types (SessionStart, UserPromptSubmit, Stop).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["hooks.json entry read\n(command string)"] --> B{"normalized.includes\n'/hooks/scriptName'?"}
    B -- No --> C["return false\n(not managed)"]
    B -- Yes --> D{"SUPERSET_MANAGED_HOOK_PATH_PATTERN\n.test(normalized)?"}
    D -- No --> C
    D -- Yes --> E["return true\n(managed → eligible for reaping)"]

    subgraph Pattern [Regex alternation]
        F["/.superset/\nor /.superset-suffix/\n(original)"]
        G["/superset-dev-data/\n(new — dev worktree layout)"]
    end
    D -.-> Pattern
Loading

Reviews (1): Last reviewed commit: "fix(desktop): reap stale notify.sh paths..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts (1)

9-13: Minor coupling to steps.sh constant.

The literal superset-dev-data here mirrors the directory name set by .superset/lib/setup/steps.sh (SUPERSET_HOME_DIR=$PWD/superset-dev-data). If that constant is ever renamed on the shell side, this regex will silently stop reaping stale entries again. Consider a short code comment pointing to the exact steps.sh line (or a shared constant/name comment block) so future renames stay in sync.

No action required for this PR — the pre-gate on /hooks/${scriptName} already keeps the false-positive surface minimal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts` around lines
9 - 13, The regex constant SUPERSET_MANAGED_HOOK_PATH_PATTERN embeds the literal
"superset-dev-data" which mirrors SUPERSET_HOME_DIR in the shell setup; add a
short clarifying comment next to SUPERSET_MANAGED_HOOK_PATH_PATTERN that
references the exact shell variable (SUPERSET_HOME_DIR) and the steps.sh
location/line where it's defined (or note to keep these in sync / consider a
shared constant), so future rename of SUPERSET_HOME_DIR in
.superset/lib/setup/steps.sh is obvious to maintainers.
apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts (1)

1196-1259: Good regression coverage.

The fixture path contains no /.superset/ segment, so it can only match via the new superset-dev-data branch — exactly the scenario from the PR description. Assertions cover all three managed Codex events.

Optional: for parity with the neighboring replaces stale Codex hook commands from old superset paths test, you could write content back to codexHooksPath and re-invoke getCodexGlobalHooksJsonContent to assert idempotency on the dev-worktree layout too. Not required.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts` around lines
1196 - 1259, Add an idempotency check to the test by writing the returned
content back to the same Codex hooks file and re-calling
getCodexGlobalHooksJsonContent to ensure the function is stable for dev-worktree
layouts; specifically, after computing content (and after the existing
assertions) write content to the codexHooksPath file and call
getCodexGlobalHooksJsonContent(currentHookPath) again, asserting the new return
equals the first content; reference the test's codexHooksPath variable and the
getCodexGlobalHooksJsonContent function when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts`:
- Around line 9-13: The regex constant SUPERSET_MANAGED_HOOK_PATH_PATTERN embeds
the literal "superset-dev-data" which mirrors SUPERSET_HOME_DIR in the shell
setup; add a short clarifying comment next to SUPERSET_MANAGED_HOOK_PATH_PATTERN
that references the exact shell variable (SUPERSET_HOME_DIR) and the steps.sh
location/line where it's defined (or note to keep these in sync / consider a
shared constant), so future rename of SUPERSET_HOME_DIR in
.superset/lib/setup/steps.sh is obvious to maintainers.

In `@apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts`:
- Around line 1196-1259: Add an idempotency check to the test by writing the
returned content back to the same Codex hooks file and re-calling
getCodexGlobalHooksJsonContent to ensure the function is stable for dev-worktree
layouts; specifically, after computing content (and after the existing
assertions) write content to the codexHooksPath file and call
getCodexGlobalHooksJsonContent(currentHookPath) again, asserting the new return
equals the first content; reference the test's codexHooksPath variable and the
getCodexGlobalHooksJsonContent function when making this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d9b00a8-e672-499f-acf2-b381e12a990a

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce1519 and 12b4319.

📒 Files selected for processing (2)
  • apps/desktop/src/main/lib/agent-setup/agent-wrappers-common.ts
  • apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@Kitenite Kitenite merged commit b7f73f3 into main Apr 24, 2026
6 of 7 checks passed
@Kitenite Kitenite deleted the meowing-saffron branch April 24, 2026 05:58
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

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