Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/FileBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/integration/code/filebrowser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading