Skip to content

Commit 0a1aea1

Browse files
authored
🤖 Review: Move Files Changed to top and remove prefix subtraction (#382)
Repositions the file tree and simplifies the directory structure display. ## Changes - **File tree now on top/left**: In wide layout, appears on left side (was right). In narrow layout, appears at top. - **Full directory structure**: Removed common prefix extraction logic that automatically collapsed shared path segments. - **User control**: Users can now collapse/expand the entire tree hierarchy manually. ## Layout Changes - Wide layout: File tree on left with border-right - Narrow layout: File tree on top with border-bottom - Changed from `order: 2` to `order: 1` to ensure Files Changed is always first ## Technical Details Removed: - `extractCommonPrefix` logic from ReviewPanel - `commonPrefix` state and prop - `CommonPrefix` styled component - Navigation logic to start tree at common prefix Net **-43 LoC** (55 deletions, 12 insertions) _Generated with `cmux`_
1 parent f147297 commit 0a1aea1

File tree

2 files changed

+151
-202
lines changed

2 files changed

+151
-202
lines changed

src/components/RightSidebar/CodeReview/FileTree.tsx

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ const TreeHeader = styled.div`
132132
gap: 8px;
133133
`;
134134

135-
const CommonPrefix = styled.div`
136-
padding: 6px 12px;
137-
background: #1e1e1e;
138-
border-bottom: 1px solid #3e3e42;
139-
font-size: 11px;
140-
color: #888;
141-
font-family: var(--font-monospace);
142-
`;
143-
144135
const EmptyState = styled.div`
145136
padding: 20px;
146137
color: #888;
@@ -194,7 +185,6 @@ const TreeNodeContent: React.FC<{
194185
depth: number;
195186
selectedPath: string | null;
196187
onSelectFile: (path: string | null) => void;
197-
commonPrefix: string | null;
198188
getFileReadStatus?: (filePath: string) => { total: number; read: number } | null;
199189
expandStateMap: Record<string, boolean>;
200190
setExpandStateMap: (
@@ -205,7 +195,6 @@ const TreeNodeContent: React.FC<{
205195
depth,
206196
selectedPath,
207197
onSelectFile,
208-
commonPrefix,
209198
getFileReadStatus,
210199
expandStateMap,
211200
setExpandStateMap,
@@ -317,7 +306,6 @@ const TreeNodeContent: React.FC<{
317306
depth={depth + 1}
318307
selectedPath={selectedPath}
319308
onSelectFile={onSelectFile}
320-
commonPrefix={commonPrefix}
321309
getFileReadStatus={getFileReadStatus}
322310
expandStateMap={expandStateMap}
323311
setExpandStateMap={setExpandStateMap}
@@ -332,7 +320,6 @@ interface FileTreeExternalProps {
332320
selectedPath: string | null;
333321
onSelectFile: (path: string | null) => void;
334322
isLoading?: boolean;
335-
commonPrefix?: string | null;
336323
getFileReadStatus?: (filePath: string) => { total: number; read: number } | null;
337324
workspaceId: string;
338325
}
@@ -342,7 +329,6 @@ export const FileTree: React.FC<FileTreeExternalProps> = ({
342329
selectedPath,
343330
onSelectFile,
344331
isLoading = false,
345-
commonPrefix = null,
346332
getFileReadStatus,
347333
workspaceId,
348334
}) => {
@@ -353,42 +339,23 @@ export const FileTree: React.FC<FileTreeExternalProps> = ({
353339
{ listener: true }
354340
);
355341

356-
// Find the node at the common prefix path to start rendering from
357-
const startNode = React.useMemo(() => {
358-
if (!commonPrefix || !root) return root;
359-
360-
// Navigate to the node at the common prefix path
361-
const parts = commonPrefix.split("/");
362-
let current = root;
363-
364-
for (const part of parts) {
365-
const child = current.children.find((c) => c.name === part);
366-
if (!child) return root; // Fallback if path not found
367-
current = child;
368-
}
369-
370-
return current;
371-
}, [root, commonPrefix]);
372-
373342
return (
374343
<>
375344
<TreeHeader>
376345
<span>Files Changed</span>
377346
{selectedPath && <ClearButton onClick={() => onSelectFile(null)}>Clear filter</ClearButton>}
378347
</TreeHeader>
379-
{commonPrefix && <CommonPrefix>{commonPrefix}/</CommonPrefix>}
380348
<TreeContainer>
381-
{isLoading && !startNode ? (
349+
{isLoading && !root ? (
382350
<EmptyState>Loading file tree...</EmptyState>
383-
) : startNode ? (
384-
startNode.children.map((child) => (
351+
) : root ? (
352+
root.children.map((child) => (
385353
<TreeNodeContent
386354
key={child.path}
387355
node={child}
388356
depth={0}
389357
selectedPath={selectedPath}
390358
onSelectFile={onSelectFile}
391-
commonPrefix={commonPrefix}
392359
getFileReadStatus={getFileReadStatus}
393360
expandStateMap={expandStateMap}
394361
setExpandStateMap={setExpandStateMap}

0 commit comments

Comments
 (0)