Allow @-includes outside of workspaces (with permission) (#18470)

This commit is contained in:
Tommaso Sciortino
2026-02-09 12:24:28 -08:00
committed by GitHub
parent e73288f25f
commit 262e8384d4
17 changed files with 250 additions and 64 deletions

View File

@@ -1188,40 +1188,6 @@ describe('handleAtCommand', () => {
expect.stringContaining(`using glob: ${path.join(subDirPath, '**')}`),
);
});
it('should skip absolute paths outside workspace', async () => {
const outsidePath = '/tmp/outside-workspace.txt';
const query = `Check @${outsidePath} please.`;
const mockWorkspaceContext = {
isPathWithinWorkspace: vi.fn((path: string) =>
path.startsWith(testRootDir),
),
getDirectories: () => [testRootDir],
addDirectory: vi.fn(),
getInitialDirectories: () => [testRootDir],
setDirectories: vi.fn(),
onDirectoriesChanged: vi.fn(() => () => {}),
} as unknown as ReturnType<typeof mockConfig.getWorkspaceContext>;
mockConfig.getWorkspaceContext = () => mockWorkspaceContext;
const result = await handleAtCommand({
query,
config: mockConfig,
addItem: mockAddItem,
onDebugMessage: mockOnDebugMessage,
messageId: 502,
signal: abortController.signal,
});
expect(result).toEqual({
processedQuery: [{ text: `Check @${outsidePath} please.` }],
});
expect(mockOnDebugMessage).toHaveBeenCalledWith(
`Path ${outsidePath} is not in the workspace and will be skipped.`,
);
});
});
it("should not add the user's turn to history, as that is the caller's responsibility", async () => {