Skip to content

๐Ÿคฏ LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

๐Ÿ› fix(files): expand collapsed git-ignored folders in the Files panel (#19840)

Arvin Xu381cca5e4471
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 623508bf38c..1047e6187f0 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -2472,6 +2472,7 @@
"workingPanel.files.showInReview": "Show in Review",
"workingPanel.files.showInSystem": "Reveal in Folder",
"workingPanel.files.title": "Files",
+ "workingPanel.files.truncatedNotice": "Some expanded folders are too large to list fully โ€” only the first entries are shown",
"workingPanel.files.views.changes": "Git Changes",
"workingPanel.files.views.project": "Project",
"workingPanel.files.views.title": "File View",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 9334688406d..bb247ad4971 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -2472,6 +2472,7 @@
"workingPanel.files.showInReview": "ๅœจๅฎกๆŸฅไธญๆŸฅ็œ‹",
"workingPanel.files.showInSystem": "ๅœจๆ–‡ไปถๅคนไธญๆ˜พ็คบ",
"workingPanel.files.title": "ๆ–‡ไปถ",
+ "workingPanel.files.truncatedNotice": "้ƒจๅˆ†ๅฑ•ๅผ€็š„ๆ–‡ไปถๅคนๅ†…ๅฎน่ฟ‡ๅคš๏ผŒไป…ๆ˜พ็คบๅ‰้ƒจๅˆ†ๆก็›ฎ",
"workingPanel.files.views.changes": "Git ๅ˜ๆ›ด",
"workingPanel.files.views.project": "้กน็›ฎ",
"workingPanel.files.views.title": "ๆ–‡ไปถ่ง†ๅ›พ",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index cf5113ca9fb..7d693d1624b 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2946,6 +2946,8 @@ export default {
'workingPanel.files.showInReview': 'Show in Review',
'workingPanel.files.showInSystem': 'Reveal in Folder',
'workingPanel.files.title': 'Files',
+ 'workingPanel.files.truncatedNotice':
+ 'Some expanded folders are too large to list fully โ€” only the first entries are shown',
'workingPanel.files.views.changes': 'Git Changes',
'workingPanel.files.views.project': 'Project',
'workingPanel.files.views.title': 'File View',
diff --git a/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx b/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx
index f7945acd99b..b2df672395f 100644
--- a/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx
+++ b/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import type { ReactNode as ReactNodeType, Ref } from 'react';
import { useImperativeHandle } from 'react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -29,83 +29,89 @@ const gitFilesMock = vi.hoisted(() => ({
}));
const openLocalFileMock = vi.hoisted(() => vi.fn());
const searchProjectFilesMock = vi.hoisted(() => vi.fn());
-const projectFilesMock = vi.hoisted(() => ({
- data: {
- entries: [
- { isDirectory: true, name: 'src', path: '/repo/src', relativePath: 'src/' },
- { isDirectory: true, name: 'foo', path: '/repo/src/foo', relativePath: 'src/foo/' },
- {
- isDirectory: false,
- name: 'bar.ts',
- path: '/repo/src/foo/bar.ts',
- relativePath: 'src/foo/bar.ts',
- },
- { isDirectory: false, name: 'root.ts', path: '/repo/root.ts', relativePath: 'root.ts' },
- {
- isDirectory: false,
- name: '__project_root__',
- path: '/repo/__project_root__',
- relativePath: '__project_root__',
- },
- {
- gitIgnored: true,
- isDirectory: false,
- name: '.env.local',
- path: '/repo/.env.local',
- relativePath: '.env.local',
- },
- {
- gitIgnored: true,
- isDirectory: false,
- name: '.DS_Store',
- path: '/repo/.DS_Store',
- relativePath: '.DS_Store',
- },
- { isDirectory: false, name: 'draft.md~', path: '/repo/draft.md~', relativePath: 'draft.md~' },
- {
- gitIgnored: true,
- isDirectory: true,
- name: '.git',
- path: '/repo/.git',
- relativePath: '.git/',
- },
- {
- gitIgnored: true,
- isDirectory: false,
- name: 'config',
- path: '/repo/.git/config',
- relativePath: '.git/config',
- },
- {
- gitIgnored: true,
- isDirectory: true,
- name: 'node_modules',
- path: '/repo/node_modules',
- relativePath: 'node_modules/',
- },
- {
- gitIgnored: true,
- isDirectory: true,
- name: '.next',
- path: '/repo/.next',
- relativePath: '.next/',
- },
- {
- gitIgnored: true,
- isDirectory: true,
- name: 'dist',
- path: '/repo/dist',
- relativePath: 'dist/',
- },
- { isDirectory: true, name: 'build', path: '/repo/build', relativePath: 'build/' },
- { isDirectory: true, name: '.github', path: '/repo/.github', relativePath: '.github/' },
- { isDirectory: true, name: '.vscode', path: '/repo/.vscode', relativePath: '.vscode/' },
- ],
- indexedAt: '2026-01-01',
- root: '/repo',
- source: 'git' as 'git' | 'glob',
- },
-}));
+const listProjectDirectoryMock = vi.hoisted(() => vi.fn());
+const projectFilesMock = vi.hoisted(() => {
+ const baseEntries = [
+ { isDirectory: true, name: 'src', path: '/repo/src', relativePath: 'src/' },
+ { isDirectory: true, name: 'foo', path: '/repo/src/foo', relativePath: 'src/foo/' },
+ {
+ isDirectory: false,
+ name: 'bar.ts',
+ path: '/repo/src/foo/bar.ts',
+ relativePath: 'src/foo/bar.ts',
+ },
+ { isDirectory: false, name: 'root.ts', path: '/repo/root.ts', relativePath: 'root.ts' },
+ {
+ isDirectory: false,
+ name: '__project_root__',
+ path: '/repo/__project_root__',
+ relativePath: '__project_root__',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: false,
+ name: '.env.local',
+ path: '/repo/.env.local',
+ relativePath: '.env.local',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: false,
+ name: '.DS_Store',
+ path: '/repo/.DS_Store',
+ relativePath: '.DS_Store',
+ },
+ { isDirectory: false, name: 'draft.md~', path: '/repo/draft.md~', relativePath: 'draft.md~' },
+ {
+ gitIgnored: true,
+ isDirectory: true,
+ name: '.git',
+ path: '/repo/.git',
+ relativePath: '.git/',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: false,
+ name: 'config',
+ path: '/repo/.git/config',
+ relativePath: '.git/config',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: true,
+ name: 'node_modules',
+ path: '/repo/node_modules',
+ relativePath: 'node_modules/',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: true,
+ name: '.next',
+ path: '/repo/.next',
+ relativePath: '.next/',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: true,
+ name: 'dist',
+ path: '/repo/dist',
+ relativePath: 'dist/',
+ },
+ { isDirectory: true, name: 'build', path: '/repo/build', relativePath: 'build/' },
+ { isDirectory: true, name: '.github', path: '/repo/.github', relativePath: '.github/' },
+ { isDirectory: true, name: '.vscode', path: '/repo/.vscode', relativePath: '.vscode/' },
+ ];
+
+ return {
+ baseEntries,
+ data: {
+ entries: [...baseEntries],
+ indexedAt: '2026-01-01',
+ root: '/repo',
+ source: 'git' as 'git' | 'glob',
+ },
+ };
+});
// โ”€โ”€โ”€ mocks โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@@ -158,6 +164,7 @@ vi.mock('../useProjectFiles', () => ({
vi.mock('@/services/projectFile', () => ({
projectFileService: {
+ listProjectDirectory: listProjectDirectoryMock,
searchProjectFiles: searchProjectFilesMock,
},
}));
@@ -265,12 +272,15 @@ const expandSearch = () => {
beforeEach(() => {
projectFilesMock.data.source = 'git';
+ projectFilesMock.data.entries = [...projectFilesMock.baseEntries];
explorerTreeProps.current = undefined;
handleSpies.focus.mockClear();
handleSpies.select.mockClear();
handleSpies.setExpanded.mockClear();
messageSpy.warning.mockClear();
openLocalFileMock.mockClear();
+ listProjectDirectoryMock.mockReset();
+ listProjectDirectoryMock.mockResolvedValue({ entries: [], truncated: false });
// Default to an empty result so EVERY call resolves to a promise. The search
// effect can fire more than once (debounce + effect re-run / StrictMode), and
// per-test `mockResolvedValueOnce` only covers the first call โ€” an extra,
@@ -683,3 +693,180 @@ describe('Files โ€” reveal request integration', () => {
expect(messageSpy.warning).not.toHaveBeenCalled();
});
});
+
+describe('Files โ€” collapsed ignored directories', () => {
+ const collapsedDirEntry = {
+ collapsed: true,
+ gitIgnored: true,
+ isDirectory: true,
+ name: '.agent-tracing',
+ path: '/repo/.agent-tracing',
+ relativePath: '.agent-tracing/',
+ };
+
+ const collapsedChildren = [
+ {
+ collapsed: true,
+ gitIgnored: true,
+ isDirectory: true,
+ name: 'runs',
+ path: '/repo/.agent-tracing/runs',
+ relativePath: '.agent-tracing/runs/',
+ },
+ {
+ gitIgnored: true,
+ isDirectory: false,
+ name: 'trace.jsonl',
+ path: '/repo/.agent-tracing/trace.jsonl',
+ relativePath: '.agent-tracing/trace.jsonl',
+ },
+ ];
+
+ const expandNodes = (ids: string[]) => {
+ const onExpandedChange = explorerTreeProps.current?.onExpandedChange as (ids: string[]) => void;
+ act(() => onExpandedChange(ids));
+ };
+
+ it('fetches and renders children when a collapsed ignored directory is expanded', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ listProjectDirectoryMock.mockResolvedValue({ entries: collapsedChildren, truncated: false });
+ render(<Files workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', '.agent-tracing/']);
+
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledWith({
+ deviceId: undefined,
+ relativePath: '.agent-tracing/',
+ root: '/repo',
+ });
+ const nodes = explorerTreeProps.current?.nodes as { id: string; parentId: string | null }[];
+ expect(nodes.find((node) => node.id === '.agent-tracing/trace.jsonl')?.parentId).toBe(
+ '.agent-tracing/',
+ );
+ expect(nodes.find((node) => node.id === '.agent-tracing/runs/')?.parentId).toBe(
+ '.agent-tracing/',
+ );
+ });
+ });
+
+ it('routes the fetch through the device RPC when a remote device is bound', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ render(<Files deviceId="dev_1" workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', '.agent-tracing/']);
+
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledWith({
+ deviceId: 'dev_1',
+ relativePath: '.agent-tracing/',
+ root: '/repo',
+ });
+ });
+ });
+
+ it('keeps expanding nested collapsed directories fetched from disk', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ listProjectDirectoryMock.mockImplementation(({ relativePath }: { relativePath: string }) =>
+ Promise.resolve(
+ relativePath === '.agent-tracing/'
+ ? { entries: collapsedChildren, truncated: false }
+ : {
+ entries: [
+ {
+ gitIgnored: true,
+ isDirectory: false,
+ name: 'run-1.json',
+ path: '/repo/.agent-tracing/runs/run-1.json',
+ relativePath: '.agent-tracing/runs/run-1.json',
+ },
+ ],
+ truncated: false,
+ },
+ ),
+ );
+ render(<Files workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', '.agent-tracing/']);
+ await waitFor(() => {
+ expect(
+ (explorerTreeProps.current?.nodes as { id: string }[]).some(
+ (node) => node.id === '.agent-tracing/runs/',
+ ),
+ ).toBe(true);
+ });
+
+ expandNodes(['\0project-root', '.agent-tracing/', '.agent-tracing/runs/']);
+
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledWith({
+ deviceId: undefined,
+ relativePath: '.agent-tracing/runs/',
+ root: '/repo',
+ });
+ expect(
+ (explorerTreeProps.current?.nodes as { id: string }[]).some(
+ (node) => node.id === '.agent-tracing/runs/run-1.json',
+ ),
+ ).toBe(true);
+ });
+ });
+
+ it('does not fetch directories the index already expanded, and fetches once per row', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ render(<Files workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', 'src/']);
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(listProjectDirectoryMock).not.toHaveBeenCalled();
+
+ expandNodes(['\0project-root', 'src/', '.agent-tracing/']);
+ expandNodes(['\0project-root', '.agent-tracing/']);
+
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ it('retries the listing on re-expand when the file host answered nothing (offline)', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ listProjectDirectoryMock.mockResolvedValue(undefined);
+ render(<Files workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', '.agent-tracing/']);
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledTimes(1);
+ });
+ expect(
+ (explorerTreeProps.current?.nodes as { id: string }[]).some(
+ (node) => node.id.startsWith('.agent-tracing/') && node.id !== '.agent-tracing/',
+ ),
+ ).toBe(false);
+
+ // Collapse and re-expand after the device comes back: must retry.
+ listProjectDirectoryMock.mockResolvedValue({ entries: collapsedChildren, truncated: false });
+ expandNodes(['\0project-root']);
+ expandNodes(['\0project-root', '.agent-tracing/']);
+
+ await waitFor(() => {
+ expect(listProjectDirectoryMock).toHaveBeenCalledTimes(2);
+ expect(
+ (explorerTreeProps.current?.nodes as { id: string }[]).some(
+ (node) => node.id === '.agent-tracing/trace.jsonl',
+ ),
+ ).toBe(true);
+ });
+ });
+
+ it('surfaces a truncation notice when the host caps the directory listing', async () => {
+ projectFilesMock.data.entries.push(collapsedDirEntry);
+ listProjectDirectoryMock.mockResolvedValue({ entries: collapsedChildren, truncated: true });
+ render(<Files workingDirectory="/repo" />);
+
+ expandNodes(['\0project-root', '.agent-tracing/']);
+
+ await waitFor(() => {
+ expect(screen.getByText('workingPanel.files.truncatedNotice')).toBeInTheDocument();
+ });
+ });
+});
diff --git a/src/features/Conversation/WorkingSidebar/Files/index.tsx b/src/features/Conversation/WorkingSidebar/Files/index.tsx
index b49def8a458..ebf930b967e 100644
--- a/src/features/Conversation/WorkingSidebar/Files/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Files/index.tsx
@@ -39,6 +39,7 @@ import { useGlobalStore } from '@/store/global';
import { filterProjectFileEntries, mergeMissingDeletedEntries } from './fileFilter';
import { isExcludedProjectFileEntry } from './fileVisibility';
+import { useCollapsedDirectoryChildren } from './useCollapsedDirectoryChildren';
import { buildGitStatusEntries, useGitWorkingTreeFiles } from './useGitWorkingTreeFiles';
import { useProjectFiles } from './useProjectFiles';
@@ -83,6 +84,16 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
flex: 1;
min-width: 0;
`,
+ truncated: css`
+ flex-shrink: 0;
+
+ padding-block: 4px;
+ padding-inline: 12px;
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+
+ font-size: 11px;
+ color: ${cssVar.colorTextTertiary};
+ `,
}));
const stripTrailingSlash = (value: string) => (value.endsWith('/') ? value.slice(0, -1) : value);
@@ -238,6 +249,7 @@ const Files = memo<FilesProps>(({ deviceId, workingDirectory }) => {
const [debouncedQuery, setDebouncedQuery] = useState('');
const [searchEntries, setSearchEntries] = useState<ProjectFileIndexEntry[] | undefined>();
const [isSearching, setIsSearching] = useState(false);
+ const [expandedIds, setExpandedIds] = useState<string[]>([]);
const projectRootName = getProjectRootName(projectRoot);
const normalizedDebouncedQuery = debouncedQuery.trim();
const isFiltering = normalizedDebouncedQuery.length > 0;
@@ -248,8 +260,16 @@ const Files = memo<FilesProps>(({ deviceId, workingDirectory }) => {
() => new Set(workingTreeGitStatus.map((entry) => entry.path)),
[workingTreeGitStatus],
);
+ // The index delivers fully git-ignored folders as childless collapsed rows;
+ // their children stream in here as the user expands them.
+ const { children: collapsedChildren, truncatedCount } = useCollapsedDirectoryChildren({
+ deviceId,
+ entries,
+ expandedIds,
+ projectRoot,
+ });
const displayEntries = useMemo(() => {
- const indexedEntries = isFiltering ? (searchEntries ?? []) : entries;
+ const indexedEntries = isFiltering ? (searchEntries ?? []) : [...entries, ...collapsedChildren];
const entriesWithDeleted = mergeMissingDeletedEntries(
indexedEntries,
isFiltering ? [] : (gitFiles?.deleted ?? []),
@@ -263,6 +283,7 @@ const Files = memo<FilesProps>(({ deviceId, workingDirectory }) => {
});
}, [
changedOnly,
+ collapsedChildren,
dirtyFilePaths,
entries,
gitFiles?.deleted,
@@ -300,8 +321,6 @@ const Files = memo<FilesProps>(({ deviceId, workingDirectory }) => {
[nodes],
);
- const [expandedIds, setExpandedIds] = useState<string[]>([]);
-
useEffect(() => {
setViewMode('project');
}, [deviceId, workingDirectory]);
@@ -640,6 +659,9 @@ const Files = memo<FilesProps>(({ deviceId, workingDirectory }) => {
/>
</div>
)}
+ {truncatedCount > 0 && (
+ <div className={styles.truncated}>{t('workingPanel.files.truncatedNotice')}</div>
+ )}
</Flexbox>
);
});
diff --git a/src/features/Conversation/WorkingSidebar/Files/useCollapsedDirectoryChildren.ts b/src/features/Conversation/WorkingSidebar/Files/useCollapsedDirectoryChildren.ts
new file mode 100644
index 00000000000..b127e69b9e6
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Files/useCollapsedDirectoryChildren.ts
@@ -0,0 +1,101 @@
+import type { ProjectFileIndexEntry } from '@lobechat/electron-client-ipc';
+import { useEffect, useState } from 'react';
+
+import { useSingleton } from '@/hooks/useSingleton';
+import { projectFileService } from '@/services/projectFile';
+
+interface UseCollapsedDirectoryChildrenParams {
+ deviceId?: string;
+ /** Indexed entries; tells the hook which expanded rows the index collapsed. */
+ entries: ProjectFileIndexEntry[];
+ /** Currently expanded tree ids (entry relativePaths). */
+ expandedIds: string[];
+ projectRoot: string;
+}
+
+interface CollapsedDirectoryChildren {
+ children: ProjectFileIndexEntry[];
+ /** Expanded directories whose on-disk listing exceeded the host-side cap. */
+ truncatedCount: number;
+}
+
+/**
+ * Children of collapsed (fully git-ignored) directories, fetched one level at a
+ * time as the user expands them. The project index deliberately omits these
+ * subtrees (`collapsed: true`), so the tree backfills them via
+ * `listProjectDirectory` โ€” an ignored subtree is read only when someone opens
+ * it. Returned children carry their own `collapsed` flags, so nested
+ * directories keep expanding on demand. Transport (local IPC vs remote device
+ * RPC) is picked inside `projectFileService` from `deviceId`.
+ */
+export const useCollapsedDirectoryChildren = ({
+ deviceId,
+ entries,
+ expandedIds,
+ projectRoot,
+}: UseCollapsedDirectoryChildrenParams): CollapsedDirectoryChildren => {
+ const scopeKey = `${deviceId ?? ''}\0${projectRoot}`;
+ const [loaded, setLoaded] = useState<{
+ entries: ProjectFileIndexEntry[];
+ scopeKey: string;
+ truncatedDirs: string[];
+ }>({ entries: [], scopeKey, truncatedDirs: [] });
+ // relativePath โ†’ scope it was requested for; dedupes fetches and drops stale resolves.
+ const requested = useSingleton(() => new Map<string, string>());
+
+ useEffect(() => {
+ requested.clear();
+ }, [scopeKey]);
+
+ const children = loaded.scopeKey === scopeKey ? loaded.entries : [];
+ const truncatedCount = loaded.scopeKey === scopeKey ? loaded.truncatedDirs.length : 0;
+
+ useEffect(() => {
+ const knownEntries = new Map(
+ [...entries, ...children].map((entry) => [entry.relativePath, entry]),
+ );
+
+ for (const id of expandedIds) {
+ if (requested.has(id)) continue;
+ const entry = knownEntries.get(id);
+ if (!entry?.isDirectory || !entry.collapsed) continue;
+
+ requested.set(id, scopeKey);
+ void Promise.resolve(
+ projectFileService.listProjectDirectory({ deviceId, relativePath: id, root: projectRoot }),
+ )
+ .then((result) => {
+ if (requested.get(id) !== scopeKey) return;
+ if (!result) {
+ // The file host answered nothing (e.g. remote device offline). Drop
+ // the marker so collapsing and re-expanding retries after reconnect.
+ requested.delete(id);
+ return;
+ }
+ setLoaded((previous) => {
+ const base = previous.scopeKey === scopeKey ? previous.entries : [];
+ const baseTruncated = previous.scopeKey === scopeKey ? previous.truncatedDirs : [];
+ const freshPaths = new Set(result.entries.map((child) => child.relativePath));
+ return {
+ entries: [
+ ...base.filter((child) => !freshPaths.has(child.relativePath)),
+ ...result.entries,
+ ],
+ scopeKey,
+ truncatedDirs:
+ result.truncated && !baseTruncated.includes(id)
+ ? [...baseTruncated, id]
+ : baseTruncated,
+ };
+ });
+ })
+ .catch((error) => {
+ // Allow a retry the next time the row is expanded.
+ requested.delete(id);
+ console.error('[Files] Failed to list collapsed directory:', error);
+ });
+ }
+ }, [children, deviceId, entries, expandedIds, projectRoot, scopeKey]);
+
+ return { children, truncatedCount };
+};
diff --git a/src/services/electron/localFileService.ts b/src/services/electron/localFileService.ts
index ab37eca0b94..86a797e38e1 100644
--- a/src/services/electron/localFileService.ts
+++ b/src/services/electron/localFileService.ts
@@ -33,6 +33,8 @@ import {
type OpenLocalFolderParams,
type PrepareSkillDirectoryParams,
type PrepareSkillDirectoryResult,
+ type ProjectDirectoryListParams,
+ type ProjectDirectoryListResult,
type ProjectFileIndexParams,
type ProjectFileIndexResult,
type ProjectFileSearchParams,
@@ -221,6 +223,12 @@ class LocalFileService {
return ensureElectronIpc().localSystem.searchProjectFiles(params);
}
+ async listProjectDirectory(
+ params: ProjectDirectoryListParams,
+ ): Promise<ProjectDirectoryListResult> {
+ return ensureElectronIpc().localSystem.listProjectDirectory(params);
+ }
+
async listProjectSkills(params: ListProjectSkillsParams): Promise<ListProjectSkillsResult> {
// Project-skill scanning lives in the main-process WorkspaceCtr ('workspace'
// group), split out of LocalFileCtr โ€” hence the namespace differs from the
diff --git a/src/services/projectFile.ts b/src/services/projectFile.ts
index 0b92073a9a3..ed33d6c03a6 100644
--- a/src/services/projectFile.ts
+++ b/src/services/projectFile.ts
@@ -3,6 +3,7 @@ import type {
LocalFilePreviewUrlParams,
LocalMoveFilesResultItem,
MoveLocalFileParams,
+ ProjectDirectoryListResult,
ProjectFileIndexResult,
ProjectFileSearchResult,
RenameLocalFileResult,
@@ -99,6 +100,25 @@ class ProjectFileService {
: localFileService.searchProjectFiles({ changedOnly, excludeIgnored, limit, query, scope });
}
+ /**
+ * Children of one directory the index collapsed (a fully git-ignored folder),
+ * read on demand when the user expands that row in the tree.
+ */
+ async listProjectDirectory({
+ deviceId,
+ relativePath,
+ root,
+ }: {
+ deviceId?: string;
+ relativePath: string;
+ root: string;
+ }): Promise<ProjectDirectoryListResult | undefined> {
+ return deviceId
+ ? ((await lambdaClient.device.listProjectDirectory.query({ deviceId, relativePath, root })) ??
+ undefined)
+ : localFileService.listProjectDirectory({ relativePath, root });
+ }
+
/** File preview payload for a file in a project working directory. */
async getLocalFilePreview({
deviceId,