Skip to content

Commit 8ac4528

Browse files
centdixclaude
andauthored
fix: restore claude hooks after post-create (#114)
* fix: restore claude hooks after post-create Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: align runtime progress timing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b295d14 commit 8ac4528

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

backend/src/__tests__/lifecycle-service.test.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,39 @@ describe("LifecycleService", () => {
390390
expect(agentCommand).toContain(`Database: ${databaseUrl}`);
391391
});
392392

393+
it("reinstalls Claude runtime hooks after postCreate rewrites settings.local.json", async () => {
394+
const repoRoot = await initRepo();
395+
const runtime = new ProjectRuntime();
396+
const tmux = new FakeTmuxGateway();
397+
const additionalDirectory = "../windmill-ee-private__worktrees/hook-settings";
398+
const hooks = new FakeHookRunner(async (input) => {
399+
const claudeDir = join(input.cwd, ".claude");
400+
await mkdir(claudeDir, { recursive: true });
401+
await Bun.write(
402+
join(claudeDir, "settings.local.json"),
403+
`${JSON.stringify({
404+
permissions: {
405+
additionalDirectories: [additionalDirectory],
406+
},
407+
}, null, 2)}\n`,
408+
);
409+
});
410+
const lifecycle = makeLifecycleService(repoRoot, tmux, runtime, new FakeDockerGateway(), hooks);
411+
412+
await lifecycle.createWorktree({
413+
branch: "feature/hook-settings",
414+
});
415+
416+
const settingsText = await Bun.file(
417+
join(repoRoot, "__worktrees", "feature", "hook-settings", ".claude", "settings.local.json"),
418+
).text();
419+
420+
expect(settingsText).toContain(additionalDirectory);
421+
expect(settingsText).toContain("webmux-agentctl");
422+
expect(settingsText).toContain("claude-user-prompt-submit");
423+
expect(settingsText).toContain("status-changed --lifecycle idle");
424+
});
425+
393426
it("creates a managed worktree under an absolute worktree root", async () => {
394427
const repoRoot = await initRepo();
395428
const absoluteWorktreeRoot = await mkdtemp(join(tmpdir(), "webmux-absolute-worktrees-"));
@@ -522,8 +555,8 @@ describe("LifecycleService", () => {
522555

523556
expect(phases).toEqual([
524557
"feature/progress:creating_worktree",
525-
"feature/progress:preparing_runtime",
526558
"feature/progress:running_post_create_hook",
559+
"feature/progress:preparing_runtime",
527560
"feature/progress:starting_session",
528561
"feature/progress:reconciling",
529562
"feature/progress:finished",

backend/src/services/lifecycle-service.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,6 @@ export class LifecycleService {
140140
},
141141
);
142142

143-
await this.reportCreateProgress({
144-
branch,
145-
path: worktreePath,
146-
profile: profileName,
147-
agent,
148-
phase: "preparing_runtime",
149-
});
150-
await ensureAgentRuntimeArtifacts({
151-
gitDir: initialized.paths.gitDir,
152-
worktreePath,
153-
});
154-
155143
await this.reportCreateProgress({
156144
branch,
157145
path: worktreePath,
@@ -171,6 +159,17 @@ export class LifecycleService {
171159
meta: initialized.meta,
172160
worktreePath,
173161
});
162+
await this.reportCreateProgress({
163+
branch,
164+
path: worktreePath,
165+
profile: profileName,
166+
agent,
167+
phase: "preparing_runtime",
168+
});
169+
await ensureAgentRuntimeArtifacts({
170+
gitDir: initialized.paths.gitDir,
171+
worktreePath,
172+
});
174173
await this.reportCreateProgress({
175174
branch,
176175
path: worktreePath,

0 commit comments

Comments
 (0)