Skip to content

Commit 0714daa

Browse files
grimmerkclaude
andcommitted
fix: review — unique tmp prefix + exact path match for hooks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7b2ea53 commit 0714daa

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/session-status-hooks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const installHooks = (): void => {
8383

8484
// Check if our hook is already installed
8585
const hasOurHook = settings.hooks[event].some((entry: any) =>
86-
entry.hooks?.some((h: any) => h.command?.includes(HOOK_MARKER))
86+
entry.hooks?.some((h: any) => h.command === HOOK_SCRIPT_PATH)
8787
);
8888

8989
if (!hasOurHook) {
@@ -128,7 +128,7 @@ export const removeHooks = (): void => {
128128
if (!settings.hooks[event]) continue;
129129
const before = settings.hooks[event].length;
130130
settings.hooks[event] = settings.hooks[event].filter((entry: any) =>
131-
!entry.hooks?.some((h: any) => h.command?.includes(HOOK_MARKER))
131+
!entry.hooks?.some((h: any) => h.command === HOOK_SCRIPT_PATH)
132132
);
133133
if (settings.hooks[event].length === 0) {
134134
delete settings.hooks[event];
@@ -158,7 +158,7 @@ export const isHooksInstalled = (): boolean => {
158158
// Check if at least one of our events has our hook
159159
return HOOK_EVENTS.some(event =>
160160
settings.hooks[event]?.some((entry: any) =>
161-
entry.hooks?.some((h: any) => h.command?.includes(HOOK_MARKER))
161+
entry.hooks?.some((h: any) => h.command === HOOK_SCRIPT_PATH)
162162
)
163163
);
164164
} catch {
@@ -320,7 +320,7 @@ export const cleanupStaleStatuses = (activeSessionIds: Set<string>): void => {
320320
export const writeStatusFile = (sessionId: string, status: string): void => {
321321
try {
322322
fs.mkdirSync(STATUS_DIR, { recursive: true });
323-
const tmpFile = path.join(STATUS_DIR, `.${sessionId}.tmp`);
323+
const tmpFile = path.join(STATUS_DIR, `.codev-${sessionId}.tmp`);
324324
const targetFile = path.join(STATUS_DIR, `${sessionId}.json`);
325325
fs.writeFileSync(tmpFile, JSON.stringify({ status, timestamp: Math.floor(Date.now() / 1000), cwd: '' }));
326326
fs.renameSync(tmpFile, targetFile);

0 commit comments

Comments
 (0)