Skip to content

Commit c9da981

Browse files
committed
docs(newTaskTool): explain dynamic Package.name config namespace\n\ntest(newTaskTool): verify config uses Package.name variant (roo-code-nightly)
1 parent 0776893 commit c9da981

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/core/tools/__tests__/newTaskTool.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,42 @@ describe("newTaskTool", () => {
629629
expect(mockGetConfiguration).toHaveBeenCalledWith("roo-cline")
630630
expect(mockGet).toHaveBeenCalledWith("newTaskRequireTodos", false)
631631
})
632+
633+
it("should use current Package.name value (roo-code-nightly) when accessing VSCode configuration", async () => {
634+
// Arrange: capture calls to VSCode configuration and ensure we can assert the namespace
635+
const mockGet = vi.fn().mockReturnValue(false)
636+
const mockGetConfiguration = vi.fn().mockReturnValue({
637+
get: mockGet,
638+
} as any)
639+
vi.mocked(vscode.workspace.getConfiguration).mockImplementation(mockGetConfiguration)
640+
641+
// Mutate the mocked Package.name dynamically to simulate a different build variant
642+
const pkg = await import("../../../shared/package")
643+
;(pkg.Package as any).name = "roo-code-nightly"
644+
645+
const block: ToolUse = {
646+
type: "tool_use",
647+
name: "new_task",
648+
params: {
649+
mode: "code",
650+
message: "Test message",
651+
},
652+
partial: false,
653+
}
654+
655+
await newTaskTool(
656+
mockCline as any,
657+
block,
658+
mockAskApproval,
659+
mockHandleError,
660+
mockPushToolResult,
661+
mockRemoveClosingTag,
662+
)
663+
664+
// Assert: configuration was read using the dynamic nightly namespace
665+
expect(mockGetConfiguration).toHaveBeenCalledWith("roo-code-nightly")
666+
expect(mockGet).toHaveBeenCalledWith("newTaskRequireTodos", false)
667+
})
632668
})
633669

634670
// Add more tests for error handling (invalid mode, approval denied) if needed

src/core/tools/newTaskTool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export async function newTaskTool(
5858
}
5959
const state = await provider.getState()
6060

61-
// Use Package.name to get the correct configuration namespace
61+
// Use Package.name (dynamic at build time) as the VSCode configuration namespace.
62+
// Supports multiple extension variants (e.g., stable/nightly) without hardcoded strings.
6263
const requireTodos = vscode.workspace
6364
.getConfiguration(Package.name)
6465
.get<boolean>("newTaskRequireTodos", false)

0 commit comments

Comments
 (0)