From ded0414d2f611f87c8df4769a09ecd86270be0e3 Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Wed, 31 Dec 2025 06:29:36 +0000 Subject: [PATCH 1/3] fix(desktop): use base branch in changes header --- .../WorkspaceView/Sidebar/ChangesView/ChangesView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx index efbca05f246..cf426ea89bb 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx @@ -225,9 +225,9 @@ export function ChangesView() { ) : (
- {/* Against Main */} + {/* Against base branch */} toggleSection("against-main")} From 4e7db61caf9ba9e269152c3e7712a67de963e493 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 31 Dec 2025 22:01:29 -0800 Subject: [PATCH 2/3] Refactor againstMain naming --- .../src/lib/trpc/routers/changes/file-contents.ts | 10 +++++----- .../desktop/src/lib/trpc/routers/changes/status.ts | 12 ++++++------ .../ContentView/ChangesContent/ChangesContent.tsx | 2 +- .../Sidebar/ChangesView/ChangesView.tsx | 14 +++++++------- apps/desktop/src/renderer/stores/changes/store.ts | 4 ++-- apps/desktop/src/shared/changes-types.ts | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/desktop/src/lib/trpc/routers/changes/file-contents.ts b/apps/desktop/src/lib/trpc/routers/changes/file-contents.ts index d29026aac0b..8af04dd68e4 100644 --- a/apps/desktop/src/lib/trpc/routers/changes/file-contents.ts +++ b/apps/desktop/src/lib/trpc/routers/changes/file-contents.ts @@ -14,7 +14,7 @@ export const createFileContentsRouter = () => { worktreePath: z.string(), filePath: z.string(), oldPath: z.string().optional(), - category: z.enum(["against-main", "committed", "staged", "unstaged"]), + category: z.enum(["against-base", "committed", "staged", "unstaged"]), commitHash: z.string().optional(), defaultBranch: z.string().optional(), }), @@ -57,7 +57,7 @@ export const createFileContentsRouter = () => { }); }; -type DiffCategory = "against-main" | "committed" | "staged" | "unstaged"; +type DiffCategory = "against-base" | "committed" | "staged" | "unstaged"; interface FileVersions { original: string; @@ -74,8 +74,8 @@ async function getFileVersions( commitHash?: string, ): Promise { switch (category) { - case "against-main": - return getAgainstMainVersions(git, filePath, originalPath, defaultBranch); + case "against-base": + return getAgainstBaseVersions(git, filePath, originalPath, defaultBranch); case "committed": if (!commitHash) { @@ -91,7 +91,7 @@ async function getFileVersions( } } -async function getAgainstMainVersions( +async function getAgainstBaseVersions( git: ReturnType, filePath: string, originalPath: string, diff --git a/apps/desktop/src/lib/trpc/routers/changes/status.ts b/apps/desktop/src/lib/trpc/routers/changes/status.ts index 132306dc26e..c547b98558c 100644 --- a/apps/desktop/src/lib/trpc/routers/changes/status.ts +++ b/apps/desktop/src/lib/trpc/routers/changes/status.ts @@ -43,7 +43,7 @@ export const createStatusRouter = () => { return { branch: parsed.branch, defaultBranch, - againstMain: branchComparison.againstMain, + againstBase: branchComparison.againstBase, commits: branchComparison.commits, staged: parsed.staged, unstaged: parsed.unstaged, @@ -90,7 +90,7 @@ export const createStatusRouter = () => { interface BranchComparison { commits: GitChangesStatus["commits"]; - againstMain: ChangedFile[]; + againstBase: ChangedFile[]; ahead: number; behind: number; } @@ -100,7 +100,7 @@ async function getBranchComparison( defaultBranch: string, ): Promise { let commits: GitChangesStatus["commits"] = []; - let againstMain: ChangedFile[] = []; + let againstBase: ChangedFile[] = []; let ahead = 0; let behind = 0; @@ -128,9 +128,9 @@ async function getBranchComparison( "--name-status", `origin/${defaultBranch}...HEAD`, ]); - againstMain = parseNameStatus(nameStatus); + againstBase = parseNameStatus(nameStatus); - await applyNumstatToFiles(git, againstMain, [ + await applyNumstatToFiles(git, againstBase, [ "diff", "--numstat", `origin/${defaultBranch}...HEAD`, @@ -138,7 +138,7 @@ async function getBranchComparison( } } catch {} - return { commits, againstMain, ahead, behind }; + return { commits, againstBase, ahead, behind }; } async function applyUntrackedLineCount( diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/ChangesContent/ChangesContent.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/ChangesContent/ChangesContent.tsx index 0846693d949..23438b7e0ec 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/ChangesContent/ChangesContent.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/ChangesContent/ChangesContent.tsx @@ -28,7 +28,7 @@ export function ChangesContent() { const selectedFileState = getSelectedFile(worktreePath || ""); const selectedFile = selectedFileState?.file ?? null; - const selectedCategory = selectedFileState?.category ?? "against-main"; + const selectedCategory = selectedFileState?.category ?? "against-base"; const selectedCommitHash = selectedFileState?.commitHash ?? null; const { data: branchData } = trpc.changes.getBranches.useQuery( diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx index cf426ea89bb..ee0ec6d2e9c 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx @@ -165,7 +165,7 @@ export function ChangesView() { if ( !status || - !status.againstMain || + !status.againstBase || !status.commits || !status.staged || !status.unstaged || @@ -179,7 +179,7 @@ export function ChangesView() { } const hasChanges = - status.againstMain.length > 0 || + status.againstBase.length > 0 || status.commits.length > 0 || status.staged.length > 0 || status.unstaged.length > 0 || @@ -228,16 +228,16 @@ export function ChangesView() { {/* Against base branch */} toggleSection("against-main")} + count={status.againstBase.length} + isExpanded={expandedSections["against-base"]} + onToggle={() => toggleSection("against-base")} > handleFileSelect(file, "against-main")} + onFileSelect={(file) => handleFileSelect(file, "against-base")} /> diff --git a/apps/desktop/src/renderer/stores/changes/store.ts b/apps/desktop/src/renderer/stores/changes/store.ts index 444e6100f2a..15e68b9c5aa 100644 --- a/apps/desktop/src/renderer/stores/changes/store.ts +++ b/apps/desktop/src/renderer/stores/changes/store.ts @@ -44,7 +44,7 @@ const initialState = { viewMode: "side-by-side" as DiffViewMode, fileListViewMode: "grouped" as FileListViewMode, expandedSections: { - "against-main": true, + "against-base": true, committed: true, staged: true, unstaged: true, @@ -67,7 +67,7 @@ export const useChangesStore = create()( [worktreePath]: file ? { file, - category: category ?? "against-main", + category: category ?? "against-base", commitHash: commitHash ?? null, } : null, diff --git a/apps/desktop/src/shared/changes-types.ts b/apps/desktop/src/shared/changes-types.ts index e09d19f1315..7ef045b06d2 100644 --- a/apps/desktop/src/shared/changes-types.ts +++ b/apps/desktop/src/shared/changes-types.ts @@ -13,7 +13,7 @@ export type FileStatus = /** Change categories for organizing the sidebar */ export type ChangeCategory = - | "against-main" + | "against-base" | "committed" | "staged" | "unstaged"; @@ -41,7 +41,7 @@ export interface CommitInfo { export interface GitChangesStatus { branch: string; defaultBranch: string; // Default branch (main/master) - againstMain: ChangedFile[]; // All files changed vs default branch + againstBase: ChangedFile[]; // All files changed vs base branch commits: CommitInfo[]; // Individual commits on branch (not on default) staged: ChangedFile[]; unstaged: ChangedFile[]; From 15561a0dbaea83f047fb1741f6eef679d32d43c1 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 31 Dec 2025 22:04:41 -0800 Subject: [PATCH 3/3] truncate --- .../components/CategorySection/CategorySection.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CategorySection/CategorySection.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CategorySection/CategorySection.tsx index 19f596602f9..89142313834 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CategorySection/CategorySection.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CategorySection/CategorySection.tsx @@ -47,7 +47,9 @@ export function CategorySection({ ) : ( )} - {title} + + {title} + ({count})