mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:00:44 +00:00
fix: preserve spawned workspace in models command
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user