Skip to content

Commit c5b4ad3

Browse files
authored
Add collapse toggle for project file tree (#37)
- Make the Files section in the sidebar collapsible - Preserve the existing workspace file tree under the toggle
1 parent b0a099f commit c5b4ad3

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

apps/web/src/components/Sidebar.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
} from "../appSettings";
4848
import { isElectron } from "../env";
4949
import { APP_STAGE_LABEL, APP_VERSION } from "../branding";
50-
import { isLinuxPlatform, isMacPlatform, newCommandId, newProjectId } from "../lib/utils";
50+
import { cn, isLinuxPlatform, isMacPlatform, newCommandId, newProjectId } from "../lib/utils";
5151
import { useStore } from "../store";
5252
import { shortcutLabelForCommand } from "../keybindings";
5353
import { derivePendingApprovals, derivePendingUserInputs } from "../session-logic";
@@ -402,6 +402,7 @@ export default function Sidebar() {
402402
const [expandedThreadListsByProject, setExpandedThreadListsByProject] = useState<
403403
ReadonlySet<ProjectId>
404404
>(() => new Set());
405+
const [filesExpanded, setFilesExpanded] = useState(true);
405406
const renamingCommittedRef = useRef(false);
406407
const renamingInputRef = useRef<HTMLInputElement | null>(null);
407408
const dragInProgressRef = useRef(false);
@@ -1409,11 +1410,23 @@ export default function Sidebar() {
14091410

14101411
{project.expanded && activeProjectThread ? (
14111412
<div className="mx-2 mt-2 border-sidebar-border/50 border-t pt-2">
1412-
<div className="mb-1.5 flex items-center gap-1.5 px-2 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/58">
1413+
<button
1414+
type="button"
1415+
className="mb-1.5 flex w-full items-center gap-1.5 px-2 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/58 hover:text-muted-foreground/80"
1416+
onClick={() => setFilesExpanded((prev) => !prev)}
1417+
>
1418+
<ChevronRightIcon
1419+
className={cn(
1420+
"size-3 shrink-0 transition-transform",
1421+
filesExpanded && "rotate-90",
1422+
)}
1423+
/>
14131424
<FolderIcon className="size-3 shrink-0" />
14141425
<span>Files</span>
1415-
</div>
1416-
<WorkspaceFileTree cwd={activeWorkspaceCwd} resolvedTheme={resolvedTheme} />
1426+
</button>
1427+
{filesExpanded && (
1428+
<WorkspaceFileTree cwd={activeWorkspaceCwd} resolvedTheme={resolvedTheme} />
1429+
)}
14171430
</div>
14181431
) : null}
14191432
</CollapsibleContent>

0 commit comments

Comments
 (0)