Merge pull request #2707 from openchamber/feat/file-tree-depth-limit-497d
fix(fs): keep file-tree list paths through symlinks (#2627)
This commit is contained in:
@@ -29,6 +29,20 @@ describe('useFilesViewTabsStore', () => {
|
||||
expect(useFilesViewTabsStore.getState().byRoot[root]?.expandedPaths).toEqual(['/repo/src']);
|
||||
});
|
||||
|
||||
test('rejects realpath children of workspace symlinks (issue 2627)', () => {
|
||||
const root = '/workspace';
|
||||
const store = useFilesViewTabsStore.getState();
|
||||
|
||||
store.toggleExpandedPath(root, '/workspace/pkg');
|
||||
store.toggleExpandedPath(root, '/real/pkg/src');
|
||||
store.toggleExpandedPath(root, '/workspace/pkg/src');
|
||||
|
||||
expect(useFilesViewTabsStore.getState().byRoot[root]?.expandedPaths).toEqual([
|
||||
'/workspace/pkg',
|
||||
'/workspace/pkg/src',
|
||||
]);
|
||||
});
|
||||
|
||||
test('removes stale expanded paths by prefix without closing files', () => {
|
||||
const root = '/repo';
|
||||
const store = useFilesViewTabsStore.getState();
|
||||
|
||||
@@ -35,3 +35,4 @@ Own filesystem API behavior for the web server runtime, including workspace-boun
|
||||
## Notes for contributors
|
||||
- Keep filesystem policy (workspace root checks, error mapping, exec timeout behavior) inside this module, not in the composition root.
|
||||
- If adding new `/api/fs/*` endpoints, add them in `routes.js` and extend this document.
|
||||
- `GET /api/fs/list` may resolve symlinks with `realpath` to read directory contents, but the response `path` and each entry `path` must stay in the caller's requested path space (`path.join(requestedPath, name)`). Returning real paths breaks file-tree expansion for directories reached through workspace symlinks.
|
||||
|
||||
@@ -454,7 +454,7 @@ export const registerFsRoutes = (app, dependencies) => {
|
||||
// Non-cacheable commands always execute and are never stored.
|
||||
const runCommandWithGitReadCache = async ({ shell, shellFlag, command, resolvedCwd }) => {
|
||||
const cacheable = gitReadCacheTtlMs > 0 && isCacheableGitReadCommand(command);
|
||||
const cacheKey = cacheable ? `${resolvedCwd} | ||||