fix: preserve spawned workspace in models command

This commit is contained in:
Shakker
2026-04-29 23:40:16 +01:00
parent a887df9cd5
commit e327c96ce6
2 changed files with 23 additions and 1 deletions

View File

@@ -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);

View File

@@ -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) {