fix: preserve spawned workspace in models command · openclaw/openclaw@e327c96
shakkernerd
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -369,6 +369,26 @@ describe("handleModelsCommand", () => {
|
369 | 369 | ); |
370 | 370 | }); |
371 | 371 | |
| 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 | + |
372 | 392 | it("returns a deprecation message for /models add when no provider is given", async () => { |
373 | 393 | const result = await handleModelsCommand(buildParams("/models add"), true); |
374 | 394 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -543,7 +543,9 @@ export const handleModelsCommand: CommandHandler = async (params, allowTextComma
|
543 | 543 | currentModel: params.model ? `${params.provider}/${params.model}` : undefined, |
544 | 544 | agentId: modelsAgentId, |
545 | 545 | agentDir: modelsAgentDir, |
546 | | -workspaceDir: modelsAgentId === currentAgentId ? params.workspaceDir : undefined, |
| 546 | +workspaceDir: |
| 547 | +targetSessionEntry?.spawnedWorkspaceDir ?? |
| 548 | +(modelsAgentId === currentAgentId ? params.workspaceDir : undefined), |
547 | 549 | sessionEntry: targetSessionEntry, |
548 | 550 | }); |
549 | 551 | if (!reply) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。