From e327c96ce6ddeb63507d0766081b82d326b37920 Mon Sep 17 00:00:00 2001 From: Shakker Date: Wed, 29 Apr 2026 23:40:16 +0100 Subject: [PATCH] fix: preserve spawned workspace in models command --- src/auto-reply/reply/commands-models.test.ts | 20 ++++++++++++++++++++ src/auto-reply/reply/commands-models.ts | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply/commands-models.test.ts b/src/auto-reply/reply/commands-models.test.ts index 7edb545c901..0e7e1ea9d4e 100644 --- a/src/auto-reply/reply/commands-models.test.ts +++ b/src/auto-reply/reply/commands-models.test.ts @@ -369,6 +369,26 @@ describe("handleModelsCommand", () => { ); }); + it("uses spawned workspace for direct /models provider visibility", async () => { + modelProviderAuthMocks.authenticatedProviders = new Set(["anthropic"]); + const params = buildParams("/models"); + params.workspaceDir = "/tmp/current-workspace"; + params.sessionStore = { + "agent:main:discord:direct:user-1": { + sessionId: "target-session", + updatedAt: Date.now(), + spawnedWorkspaceDir: "/tmp/spawned-workspace", + }, + }; + + const result = await handleModelsCommand(params, true); + + expect(result?.reply?.text).toContain("- anthropic (2)"); + expect(modelProviderAuthMocks.createProviderAuthChecker).toHaveBeenCalledWith( + expect.objectContaining({ workspaceDir: "/tmp/spawned-workspace" }), + ); + }); + it("returns a deprecation message for /models add when no provider is given", async () => { const result = await handleModelsCommand(buildParams("/models add"), true); diff --git a/src/auto-reply/reply/commands-models.ts b/src/auto-reply/reply/commands-models.ts index b16c5e881a1..c5d95931ba3 100644 --- a/src/auto-reply/reply/commands-models.ts +++ b/src/auto-reply/reply/commands-models.ts @@ -543,7 +543,9 @@ export const handleModelsCommand: CommandHandler = async (params, allowTextComma currentModel: params.model ? `${params.provider}/${params.model}` : undefined, agentId: modelsAgentId, agentDir: modelsAgentDir, - workspaceDir: modelsAgentId === currentAgentId ? params.workspaceDir : undefined, + workspaceDir: + targetSessionEntry?.spawnedWorkspaceDir ?? + (modelsAgentId === currentAgentId ? params.workspaceDir : undefined), sessionEntry: targetSessionEntry, }); if (!reply) {