fix(files): browse ignored files and load folders on demand #11527
Mergedmaria-rcksmerged 3 commits into
main fromrefs/pull/11527/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/web/src/components/files/useDirectoryEntries.ts lines 67 to 67Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +44,21 @@44+ }45+ })()46+ .then((result) => {47+ if (!active.current || !result) return;48+ if (result._tag === "Success") {49+ setDirectories((previous) =>50+ new Map(previous).set(51+ directoryPath,52+ result.value.entries.filter(53+ (entry) =>54+ entry.path.slice(0, Math.max(0, entry.path.lastIndexOf("/"))) === directoryPath,55+ ),56+ ),57+ );58+ setErrors((previous) => {59+ const next = new Map(previous);60+ next.delete(directoryPath);61+ return next;62+ });63+ } else {64+ const cause = Cause.squash(result.cause);apps/web/src/components/files/FileBrowserPanel.tsx line 121Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -104,5 +105,17 @@104105 }: FileBrowserPanelProps) {105106 const { resolvedTheme } = useTheme();106107 const composerRef = useComposerHandleContext();107- const entriesQuery = useProjectEntriesQuery(environmentId, cwd);108- const entries = entriesQuery.data?.entries ?? [];108+ const {109+ entries: directoryEntries,110+ load,111+ refresh,112+ ready,113+ error,114+ isPending,115+ } = useDirectoryEntries(environmentId, cwd);116+ const [query, setQuery] = useState("");117+ const [expandAll, setExpandAll] = useState(false);118+ const pathSearch = useProjectPathSearch({ environmentId, cwd, query: query.slice(0, 256) }, 200);119+ const entries = useMemo(() => {120+ const result = new Map(directoryEntries.map((entry) => [entry.path, entry]));121+ if (query.trim() && !pathSearch.isPending) {apps/server/src/workspace/WorkspaceEntries.ts line 327OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -268,0 +307,21 @@307+ if (child.name === ".git" || (!child.isDirectory() && !child.isFile())) return [];308+ return [309+ {310+ path: target.relativePath ? `${target.relativePath}/${child.name}` : child.name,311+ kind: child.isDirectory() ? "directory" : "file",312+ },313+ ];314+ });315+ },316+ catch: toError,317+ });318+ // Use stdin so large directories cannot exceed the command-line argument limit.319+ // Ignore classification is optional in non-git workspaces or when git is unavailable.320+ const ignored = new Set<string>();321+ for (let offset = 0; offset < entries.length; offset += 1000) {322+ const chunk = entries.slice(offset, offset + 1000);323+ const result = yield* vcsProcess324+ .run({325+ operation: "WorkspaceEntries.list",326+ command: "git",327+ args: ["-c", "core.fsmonitor=false", "check-ignore", "--no-index", "-z", "--stdin"],apps/web/src/components/files/FileBrowserPanel.tsx line 115Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -104,5 +105,11 @@104105 }: FileBrowserPanelProps) {105106 const { resolvedTheme } = useTheme();106107 const composerRef = useComposerHandleContext();107- const entriesQuery = useProjectEntriesQuery(environmentId, cwd);108- const entries = entriesQuery.data?.entries ?? [];108+ const {109+ entries: directoryEntries,110+ load,111+ refresh,112+ ready,113+ error,114+ isPending,115+ } = useDirectoryEntries(environmentId, cwd);
- apps/web/src/components/files/FileBrowserPanel.tsx line 338OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -256,14 +320,19 @@320+ controller.abort();321+ };322+ }, [load, selectedPath]);256323 const handleSearchValueChange = (value: string) => {324+ setQuery(value);257325 if (value.trim().length === 0) {258326 search.close();259327 return;260328 }261329 search.setValue(value);262330 };263331 const handleRefresh = () => {264- entriesQuery.refresh();332+ refresh();333+ if (query.trim()) pathSearch.refresh();265334 onRefreshSelectedFile?.();266335 };267336 useWorkspaceMutationRefresh({268337 mutationId: workspaceMutationId,269- refresh: entriesQuery.refresh,338+ refresh,
- apps/web/src/components/files/FileBrowserPanel.tsx line 343Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -256,9 +319,20 @@319+ void (async () => {320+ const segments = selectedPath.split("/");321+ for (let index = 0; index < segments.length && !controller.signal.aborted; index++) {322+ await load(segments.slice(0, index).join("/"));323+ }324+ })();325+ return () => {326+ controller.abort();327+ };328+ }, [load, selectedPath]);256329 const handleSearchValueChange = (value: string) => {330+ setQuery(value);257331 if (value.trim().length === 0) {258332 search.close();259333 return;260334 }261335 search.setValue(value);262336 };263337 const handleRefresh = () => {264- entriesQuery.refresh();338+ refresh();
maria-rcks merged this21d53ca
maria-rcks closed this
Sign in to join this conversation.



macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed