diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index 836516ec..4896917f 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -151,12 +151,12 @@ interface FileBrowserProps { /** Placeholder hunkId for FileBrowser comments — there's no jj diff hunk to anchor to. */ const FILE_BROWSER_COMMENT_HUNK_ID = "browser"; -// Filter out .git and .treq files/directories (but keep .github, .gitignore, etc.) +// Hidden files can contain useful project configuration, but hidden directories +// are implementation details that should not appear in the code tree. function filterHiddenEntries(entries: DirectoryEntry[]): DirectoryEntry[] { - return entries.filter((entry) => { - const { name } = entry; - return name !== ".git" && name !== ".treq"; - }); + return entries.filter( + (entry) => !entry.is_directory || !entry.name.startsWith("."), + ); } // Virtualization constants diff --git a/test/integration/code/filebrowser.test.tsx b/test/integration/code/filebrowser.test.tsx index c73a11c0..212a07ad 100644 --- a/test/integration/code/filebrowser.test.tsx +++ b/test/integration/code/filebrowser.test.tsx @@ -95,6 +95,25 @@ describe("Dashboard - FileBrowser integration", () => { await screen.findByRole("button", { name: /back/i }); }); + it("hides hidden directories from the directory tree", async () => { + await setupWorkspace("feat/filebrowser-hidden-directories-test", { + "app.ts": "export const app = true;\n", + ".secret/config.json": "{}\n", + ".env": "VISIBLE_FILE=true\n", + }); + + const fileBrowser = await openWorkspaceCodeBrowser( + user, + "feat/filebrowser-hidden-directories-test", + "app.ts", + ); + + expect(fileBrowser.queryByText(".jj")).toBeNull(); + expect(fileBrowser.queryByText(".git")).toBeNull(); + expect(fileBrowser.queryByText(".secret")).toBeNull(); + expect(fileBrowser.getByText(".env")).toBeTruthy(); + }); + it("reloads the open file and directory tree after a scoped filesystem refresh", async () => { const { workspace, workspacePath } = await setupWorkspace( "feat/filebrowser-refresh-test",