Skip to content

Commit e327c96

Browse files
committed
fix: preserve spawned workspace in models command
1 parent a887df9 commit e327c96

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/auto-reply/reply/commands-models.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,26 @@ describe("handleModelsCommand", () => {
369369
);
370370
});
371371

372+
it("uses spawned workspace for direct /models provider visibility", async () => {
373+
modelProviderAuthMocks.authenticatedProviders = new Set(["anthropic"]);
374+
const params = buildParams("/models");
375+
params.workspaceDir = "/tmp/current-workspace";
376+
params.sessionStore = {
377+
"agent:main:discord:direct:user-1": {
378+
sessionId: "target-session",
379+
updatedAt: Date.now(),
380+
spawnedWorkspaceDir: "/tmp/spawned-workspace",
381+
},
382+
};
383+
384+
const result = await handleModelsCommand(params, true);
385+
386+
expect(result?.reply?.text).toContain("- anthropic (2)");
387+
expect(modelProviderAuthMocks.createProviderAuthChecker).toHaveBeenCalledWith(
388+
expect.objectContaining({ workspaceDir: "/tmp/spawned-workspace" }),
389+
);
390+
});
391+
372392
it("returns a deprecation message for /models add when no provider is given", async () => {
373393
const result = await handleModelsCommand(buildParams("/models add"), true);
374394

src/auto-reply/reply/commands-models.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ export const handleModelsCommand: CommandHandler = async (params, allowTextComma
543543
currentModel: params.model ? `${params.provider}/${params.model}` : undefined,
544544
agentId: modelsAgentId,
545545
agentDir: modelsAgentDir,
546-
workspaceDir: modelsAgentId === currentAgentId ? params.workspaceDir : undefined,
546+
workspaceDir:
547+
targetSessionEntry?.spawnedWorkspaceDir ??
548+
(modelsAgentId === currentAgentId ? params.workspaceDir : undefined),
547549
sessionEntry: targetSessionEntry,
548550
});
549551
if (!reply) {

0 commit comments

Comments
 (0)