Skip to content

Commit a34751b

Browse files
committed
🤖 Port changes from main commits 0a1aea1 and f147297
Apply changes that landed in main after our rebase base point: 1. Review Panel (0a1aea1): - Remove extractCommonPrefix import and usage - Remove commonPrefix state - Simplify file tree to show full directory structure 2. FileTree (0a1aea1): - Remove commonPrefix prop from component interface - Remove startNode computation logic - Remove CommonPrefix display element - Render from root node directly 3. ProjectSidebar (f147297): - Wrap Add Project button in TooltipWrapper - Show tooltip on hover matching other UI elements - Remove redundant title attribute These are non-styling logic changes that need to be preserved in the Tailwind migration.
1 parent 00e5b17 commit a34751b

File tree

3 files changed

+16
-51
lines changed

3 files changed

+16
-51
lines changed

src/components/ProjectSidebar.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,18 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
426426
<h2 className="m-0 text-[13px] font-semibold text-[#cccccc] uppercase tracking-[0.8px]">
427427
Projects
428428
</h2>
429-
<button
430-
onClick={onAddProject}
431-
title="Add Project"
432-
aria-label="Add project"
433-
className="w-6 h-6 bg-transparent text-[#cccccc] border border-transparent rounded cursor-pointer text-lg flex items-center justify-center p-0 transition-all duration-200 hover:bg-[#2a2a2b] hover:border-[#3c3c3c]"
434-
>
435-
+
436-
</button>
429+
<TooltipWrapper inline>
430+
<button
431+
onClick={onAddProject}
432+
aria-label="Add project"
433+
className="w-6 h-6 bg-transparent text-[#cccccc] border border-transparent rounded cursor-pointer text-lg flex items-center justify-center p-0 transition-all duration-200 hover:bg-[#2a2a2b] hover:border-[#3c3c3c]"
434+
>
435+
+
436+
</button>
437+
<Tooltip className="tooltip" align="right">
438+
Add Project
439+
</Tooltip>
440+
</TooltipWrapper>
437441
</div>
438442
<div className="flex-1 overflow-y-auto">
439443
{projects.size === 0 ? (

src/components/RightSidebar/CodeReview/FileTree.tsx

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const TreeNodeContent: React.FC<{
5555
depth: number;
5656
selectedPath: string | null;
5757
onSelectFile: (path: string | null) => void;
58-
commonPrefix: string | null;
5958
getFileReadStatus?: (filePath: string) => { total: number; read: number } | null;
6059
expandStateMap: Record<string, boolean>;
6160
setExpandStateMap: (
@@ -66,7 +65,6 @@ const TreeNodeContent: React.FC<{
6665
depth,
6766
selectedPath,
6867
onSelectFile,
69-
commonPrefix,
7068
getFileReadStatus,
7169
expandStateMap,
7270
setExpandStateMap,
@@ -213,7 +211,6 @@ const TreeNodeContent: React.FC<{
213211
depth={depth + 1}
214212
selectedPath={selectedPath}
215213
onSelectFile={onSelectFile}
216-
commonPrefix={commonPrefix}
217214
getFileReadStatus={getFileReadStatus}
218215
expandStateMap={expandStateMap}
219216
setExpandStateMap={setExpandStateMap}
@@ -228,7 +225,6 @@ interface FileTreeExternalProps {
228225
selectedPath: string | null;
229226
onSelectFile: (path: string | null) => void;
230227
isLoading?: boolean;
231-
commonPrefix?: string | null;
232228
getFileReadStatus?: (filePath: string) => { total: number; read: number } | null;
233229
workspaceId: string;
234230
}
@@ -238,7 +234,6 @@ export const FileTree: React.FC<FileTreeExternalProps> = ({
238234
selectedPath,
239235
onSelectFile,
240236
isLoading = false,
241-
commonPrefix = null,
242237
getFileReadStatus,
243238
workspaceId,
244239
}) => {
@@ -249,23 +244,6 @@ export const FileTree: React.FC<FileTreeExternalProps> = ({
249244
{ listener: true }
250245
);
251246

252-
// Find the node at the common prefix path to start rendering from
253-
const startNode = React.useMemo(() => {
254-
if (!commonPrefix || !root) return root;
255-
256-
// Navigate to the node at the common prefix path
257-
const parts = commonPrefix.split("/");
258-
let current = root;
259-
260-
for (const part of parts) {
261-
const child = current.children.find((c) => c.name === part);
262-
if (!child) return root; // Fallback if path not found
263-
current = child;
264-
}
265-
266-
return current;
267-
}, [root, commonPrefix]);
268-
269247
return (
270248
<>
271249
<div className="py-2 px-3 border-b border-[#3e3e42] text-xs font-medium text-[#ccc] font-primary flex items-center gap-2">
@@ -279,23 +257,17 @@ export const FileTree: React.FC<FileTreeExternalProps> = ({
279257
</button>
280258
)}
281259
</div>
282-
{commonPrefix && (
283-
<div className="py-1.5 px-3 bg-[#1e1e1e] border-b border-[#3e3e42] text-[11px] text-[#888] font-monospace">
284-
{commonPrefix}/
285-
</div>
286-
)}
287260
<div className="flex-1 min-h-0 p-3 overflow-y-auto font-monospace text-xs">
288-
{isLoading && !startNode ? (
261+
{isLoading && !root ? (
289262
<div className="py-5 text-[#888] text-center">Loading file tree...</div>
290-
) : startNode ? (
291-
startNode.children.map((child) => (
263+
) : root ? (
264+
root.children.map((child) => (
292265
<TreeNodeContent
293266
key={child.path}
294267
node={child}
295268
depth={0}
296269
selectedPath={selectedPath}
297270
onSelectFile={onSelectFile}
298-
commonPrefix={commonPrefix}
299271
getFileReadStatus={getFileReadStatus}
300272
expandStateMap={expandStateMap}
301273
setExpandStateMap={setExpandStateMap}

src/components/RightSidebar/CodeReview/ReviewPanel.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ import { useReviewState } from "@/hooks/useReviewState";
3131
import { parseDiff, extractAllHunks } from "@/utils/git/diffParser";
3232
import { getReviewSearchStateKey } from "@/constants/storage";
3333
import { Tooltip, TooltipWrapper } from "@/components/Tooltip";
34-
import {
35-
parseNumstat,
36-
buildFileTree,
37-
extractNewPath,
38-
extractCommonPrefix,
39-
} from "@/utils/git/numstatParser";
34+
import { parseNumstat, buildFileTree, extractNewPath } from "@/utils/git/numstatParser";
4035
import type { DiffHunk, ReviewFilters as ReviewFiltersType } from "@/types/review";
4136
import type { FileTreeNode } from "@/utils/git/numstatParser";
4237
import { matchesKeybind, KEYBINDS, formatKeybind } from "@/utils/ui/keybinds";
@@ -137,7 +132,6 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
137132
const [isPanelFocused, setIsPanelFocused] = useState(false);
138133
const [refreshTrigger, setRefreshTrigger] = useState(0);
139134
const [fileTree, setFileTree] = useState<FileTreeNode | null>(null);
140-
const [commonPrefix, setCommonPrefix] = useState<string | null>(null);
141135
// Map of hunkId -> toggle function for expand/collapse
142136
const toggleExpandFnsRef = useRef<Map<string, () => void>>(new Map());
143137

@@ -220,13 +214,9 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
220214
const numstatOutput = numstatResult.data.output ?? "";
221215
const fileStats = parseNumstat(numstatOutput);
222216

223-
// Extract common prefix for display (don't modify paths)
224-
const prefix = extractCommonPrefix(fileStats);
225-
226217
// Build tree with original paths (needed for git commands)
227218
const tree = buildFileTree(fileStats);
228219
setFileTree(tree);
229-
setCommonPrefix(prefix);
230220
}
231221
} catch (err) {
232222
console.error("Failed to load file tree:", err);
@@ -710,7 +700,6 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
710700
selectedPath={selectedFilePath}
711701
onSelectFile={setSelectedFilePath}
712702
isLoading={isLoadingTree}
713-
commonPrefix={commonPrefix}
714703
getFileReadStatus={getFileReadStatus}
715704
workspaceId={workspaceId}
716705
/>

0 commit comments

Comments
 (0)