diff --git a/packages/server/src/server/plugins/lifecycle/handlers.test.ts b/packages/server/src/server/plugins/lifecycle/handlers.test.ts index a9110ff0d2..a5d2e6974a 100644 --- a/packages/server/src/server/plugins/lifecycle/handlers.test.ts +++ b/packages/server/src/server/plugins/lifecycle/handlers.test.ts @@ -403,11 +403,19 @@ test("terminal and command hooks can change only what Paseo runs", async () => { test("agent creation hooks keep the workspace, including from plugins that omit it", async () => { const request = { config: { provider: "claude", cwd: "/work/a" }, + metadata: { "issues.id": "ENG-1" }, workspaceId: "wks_a", }; + // A result built before either field existed keeps both. await expect( validateBeforeResult("agent.create.before", request, { config: request.config }), ).resolves.toEqual(request); + await expect( + validateBeforeResult("agent.create.before", request, { + config: request.config, + metadata: { "issues.id": "ENG-2" }, + }), + ).resolves.toEqual({ ...request, metadata: { "issues.id": "ENG-2" } }); await expect( validateBeforeResult("agent.create.before", request, { ...request, workspaceId: "wks_b" }), ).rejects.toThrow("agent.create.before hooks cannot change the workspace"); diff --git a/packages/server/src/server/session.ts b/packages/server/src/server/session.ts index 22f78852bf..c8724b9385 100644 --- a/packages/server/src/server/session.ts +++ b/packages/server/src/server/session.ts @@ -814,6 +814,10 @@ export class Session { private readonly daemonConfigStore: DaemonConfigStore; private readonly pushNotifications: PushNotifications; private readonly pluginRuntime: SessionOptions["pluginRuntime"]; + // What worktree setup and teardown commands run through: the plugins' hooks, or none. + private get commandLifecycle(): NonNullable | null { + return this.pluginRuntime ?? null; + } private readonly orchestrationSkills: SessionOptions["orchestrationSkills"]; private unsubscribeAgentEvents: (() => void) | null = null; private unsubscribeProjectMutations: (() => void) | null = null; @@ -1249,7 +1253,7 @@ export class Session { logger: this.sessionLogger, }); this.createAgentLifecycleDispatch = new CreateAgentLifecycleDispatch({ - lifecycle: this.pluginRuntime ?? null, + lifecycle: this.commandLifecycle, paseoHome: this.paseoHome, worktreesRoot: this.worktreesRoot, agentManager: this.agentManager, @@ -5709,7 +5713,7 @@ export class Session { ): Promise { return handleWorktreeArchiveRequest( { - lifecycle: this.pluginRuntime ?? null, + lifecycle: this.commandLifecycle, paseoHome: this.paseoHome, paseoWorktreesBaseRoot: this.worktreesRoot, github: this.github, @@ -7964,7 +7968,7 @@ export class Session { ): Promise { return createWorktreeWorkflow( { - lifecycle: this.pluginRuntime ?? null, + lifecycle: this.commandLifecycle, paseoHome: this.paseoHome, worktreesRoot: this.worktreesRoot, createPaseoWorktree: (workflowInput, serviceOptions) => @@ -8018,7 +8022,7 @@ export class Session { ): Promise { return handleWorkspaceSetupRunRequestMessage( { - lifecycle: this.pluginRuntime ?? null, + lifecycle: this.commandLifecycle, getWorkspace: (workspaceId) => this.workspaceRegistry.get(workspaceId), clearAutomationBlock: (workspaceId) => clearWorkspaceAutomationBlock(this.workspaceRegistry, workspaceId), @@ -8060,7 +8064,7 @@ export class Session { } return archiveByScope( { - lifecycle: this.pluginRuntime ?? null, + lifecycle: this.commandLifecycle, paseoHome: this.paseoHome, paseoWorktreesBaseRoot: this.worktreesRoot, github: this.github,