From 52bc57d2eca2d8b0e2da3db43d665d34c3513590 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sun, 28 Dec 2025 11:43:40 -0800 Subject: [PATCH 1/2] Remove AI-generated code slop - Remove excessive comments that only restate what code does - Keep comments that explain why or document non-obvious behavior - Clean up obvious inline comments while preserving important context --- .../src/lib/trpc/routers/projects/projects.ts | 12 ------------ .../src/lib/trpc/routers/workspaces/utils/git.ts | 15 +++------------ .../src/lib/trpc/routers/workspaces/workspaces.ts | 1 - apps/desktop/src/main/lib/terminal-history.ts | 2 +- apps/desktop/src/renderer/lib/trpc-storage.ts | 1 - .../ContentView/TabsContent/TabView/index.tsx | 2 -- apps/desktop/src/renderer/stores/tabs/store.ts | 13 +------------ apps/desktop/src/renderer/stores/tabs/utils.ts | 6 ------ 8 files changed, 5 insertions(+), 47 deletions(-) diff --git a/apps/desktop/src/lib/trpc/routers/projects/projects.ts b/apps/desktop/src/lib/trpc/routers/projects/projects.ts index 0a015043544..e6381a711d7 100644 --- a/apps/desktop/src/lib/trpc/routers/projects/projects.ts +++ b/apps/desktop/src/lib/trpc/routers/projects/projects.ts @@ -100,7 +100,6 @@ function extractRepoName(urlInput: string): string | null { if (parsed.protocol === "http:" || parsed.protocol === "https:") { // Get pathname and strip query/hash (URL constructor handles this) const pathname = parsed.pathname; - // Get the last segment of the path repoSegment = pathname.split("/").filter(Boolean).pop(); } } catch { @@ -121,20 +120,15 @@ function extractRepoName(urlInput: string): string | null { if (!repoSegment) return null; - // Strip query string and hash if present (for edge cases) repoSegment = repoSegment.split("?")[0].split("#")[0]; - - // Remove trailing .git extension repoSegment = repoSegment.replace(/\.git$/, ""); - // Decode percent-encoded characters try { repoSegment = decodeURIComponent(repoSegment); } catch { // Invalid encoding, continue with raw value } - // Trim any remaining whitespace or special characters at boundaries repoSegment = repoSegment.trim(); // Validate against safe filename regex @@ -196,7 +190,6 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => { // If we can't get remotes, assume no origin } - // Get all branches (local and remote) const branchSummary = await git.branch(["-a"]); const localBranches: string[] = []; @@ -463,7 +456,6 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => { .delete(projects) .where(eq(projects.id, existingProject.id)) .run(); - // Continue to normal creation flow below } } @@ -658,14 +650,12 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => { throw new Error("Project not found"); } - // Find all workspaces for this project const projectWorkspaces = localDb .select() .from(workspaces) .where(eq(workspaces.projectId, input.id)) .all(); - // Kill all terminal processes in all workspaces of this project let totalFailed = 0; for (const workspace of projectWorkspaces) { const terminalResult = await terminalManager.killByWorkspaceId( @@ -674,10 +664,8 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => { totalFailed += terminalResult.failed; } - // Get workspace IDs for cleanup const closedWorkspaceIds = projectWorkspaces.map((w) => w.id); - // Remove all workspaces for this project if (closedWorkspaceIds.length > 0) { localDb .delete(workspaces) diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts index 6e48931dcc0..258a223fc5e 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts @@ -564,16 +564,8 @@ export async function checkBranchCheckoutSafety( const git = simpleGit(repoPath); try { - // Check for uncommitted changes const status = await git.status(); - // Check all forms of uncommitted changes: - // - staged: files added to index - // - modified: tracked files with unstaged changes - // - deleted: tracked files deleted but not staged - // - created: new files staged for commit - // - renamed: files renamed (staged) - // - conflicted: merge conflicts const hasUncommittedChanges = status.staged.length > 0 || status.modified.length > 0 || @@ -582,7 +574,6 @@ export async function checkBranchCheckoutSafety( status.renamed.length > 0 || status.conflicted.length > 0; - // Untracked files that could be overwritten by checkout const hasUntrackedFiles = status.not_added.length > 0; if (hasUncommittedChanges) { @@ -595,7 +586,7 @@ export async function checkBranchCheckoutSafety( }; } - // Block on untracked files as they could be overwritten + // Block on untracked files as they could be overwritten by checkout if (hasUntrackedFiles) { return { safe: false, @@ -606,11 +597,11 @@ export async function checkBranchCheckoutSafety( }; } - // Fetch and prune stale remote refs (best-effort) + // Fetch and prune stale remote refs (best-effort, ignore errors if offline) try { await git.fetch(["--prune"]); } catch { - // Ignore fetch errors (e.g., offline) - not critical for safety + // Ignore fetch errors } return { diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts b/apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts index 47908102401..00b3ce23c77 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts @@ -1340,7 +1340,6 @@ export const createWorkspacesRouter = () => { throw new Error("Workspace not found"); } - // Kill all terminal processes in this workspace const terminalResult = await terminalManager.killByWorkspaceId( input.id, ); diff --git a/apps/desktop/src/main/lib/terminal-history.ts b/apps/desktop/src/main/lib/terminal-history.ts index 4ad95e5aace..2d8e313b330 100644 --- a/apps/desktop/src/main/lib/terminal-history.ts +++ b/apps/desktop/src/main/lib/terminal-history.ts @@ -91,7 +91,7 @@ export class HistoryWriter { this.stream?.end(() => resolve()); }); } catch { - // Ignore close errors + // Ignore } } this.stream = null; diff --git a/apps/desktop/src/renderer/lib/trpc-storage.ts b/apps/desktop/src/renderer/lib/trpc-storage.ts index 0d855eca06f..e1a59ce987c 100644 --- a/apps/desktop/src/renderer/lib/trpc-storage.ts +++ b/apps/desktop/src/renderer/lib/trpc-storage.ts @@ -17,7 +17,6 @@ function createTrpcStorageAdapter(config: TrpcStorageConfig): StateStorage { try { const state = await config.get(); if (!state) return null; - // Wrap in zustand persist format return JSON.stringify({ state, version: 0 }); } catch (error) { console.error("[trpc-storage] Failed to get state:", error); diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx index 120edb366ff..b6df3608e13 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx @@ -42,7 +42,6 @@ export function TabView({ tab, panes }: TabViewProps) { const focusedPaneId = focusedPaneIds[tab.id]; - // Get valid pane IDs for this tab const validPaneIds = new Set(getPaneIdsForTab(panes, tab.id)); const cleanedLayout = cleanLayout(tab.layout, validPaneIds); @@ -73,7 +72,6 @@ export function TabView({ tab, panes }: TabViewProps) { removePane(removedId); } - // Update the layout updateTabLayout(tab.id, newLayout); }, [tab.id, tab.layout, updateTabLayout, removePane], diff --git a/apps/desktop/src/renderer/stores/tabs/store.ts b/apps/desktop/src/renderer/stores/tabs/store.ts index c099a0de0b5..00e050b4dfa 100644 --- a/apps/desktop/src/renderer/stores/tabs/store.ts +++ b/apps/desktop/src/renderer/stores/tabs/store.ts @@ -123,22 +123,18 @@ export const useTabsStore = create()( const tabToRemove = state.tabs.find((t) => t.id === tabId); if (!tabToRemove) return; - // Kill all terminals for panes in this tab const paneIds = getPaneIdsForTab(state.panes, tabId); for (const paneId of paneIds) { killTerminalForPane(paneId); } - // Remove all panes belonging to this tab const newPanes = { ...state.panes }; for (const paneId of paneIds) { delete newPanes[paneId]; } - // Remove tab const newTabs = state.tabs.filter((t) => t.id !== tabId); - // Update active tab if needed const workspaceId = tabToRemove.workspaceId; const newActiveTabIds = { ...state.activeTabIds }; const newHistoryStack = ( @@ -146,10 +142,9 @@ export const useTabsStore = create()( ).filter((id) => id !== tabId); if (state.activeTabIds[workspaceId] === tabId) { - newActiveTabIds[workspaceId] = findNextTab(state, tabId); + newActiveTabIds[workspaceId] = findNextTab(state, tabId ); } - // Clean up focused pane tracking const newFocusedPaneIds = { ...state.focusedPaneIds }; delete newFocusedPaneIds[tabId]; @@ -281,11 +276,9 @@ export const useTabsStore = create()( const tab = state.tabs.find((t) => t.id === tabId); if (!tab) return; - // Get panes that should exist based on the new layout const newPaneIds = new Set(extractPaneIdsFromLayout(layout)); const oldPaneIds = new Set(extractPaneIdsFromLayout(tab.layout)); - // Find removed panes and clean them up const removedPaneIds = Array.from(oldPaneIds).filter( (id) => !newPaneIds.has(id), ); @@ -326,7 +319,6 @@ export const useTabsStore = create()( const newPane = createPane(tabId, "terminal", options); - // Add pane to layout (append to the right) const newLayout: MosaicNode = { direction: "row", first: tab.layout, @@ -362,10 +354,8 @@ export const useTabsStore = create()( return; } - // Kill the terminal killTerminalForPane(paneId); - // Remove pane from layout const newLayout = removePaneFromLayout(tab.layout, paneId); if (!newLayout) { // This shouldn't happen since we checked isLastPaneInTab @@ -373,7 +363,6 @@ export const useTabsStore = create()( return; } - // Remove pane from panes map const newPanes = { ...state.panes }; delete newPanes[paneId]; diff --git a/apps/desktop/src/renderer/stores/tabs/utils.ts b/apps/desktop/src/renderer/stores/tabs/utils.ts index 078203d3122..a1e7bef16cf 100644 --- a/apps/desktop/src/renderer/stores/tabs/utils.ts +++ b/apps/desktop/src/renderer/stores/tabs/utils.ts @@ -94,7 +94,6 @@ export const generateTabName = (existingTabs: Tab[]): string => { }) .filter((n) => n > 0); - // Find the next available number let nextNumber = 1; while (existingNumbers.includes(nextNumber)) { nextNumber++; @@ -168,18 +167,13 @@ export const removePaneFromLayout = ( return layout === paneIdToRemove ? null : layout; } - // Recursively remove from both branches const newFirst = removePaneFromLayout(layout.first, paneIdToRemove); const newSecond = removePaneFromLayout(layout.second, paneIdToRemove); - // If both branches are gone, return null if (!newFirst && !newSecond) return null; - - // If one branch is gone, return the other if (!newFirst) return newSecond; if (!newSecond) return newFirst; - // Both branches still exist, return updated layout return { ...layout, first: newFirst, From 62a3cfcab9551e29cb5067cb5f696438fb9347d0 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sun, 28 Dec 2025 11:52:13 -0800 Subject: [PATCH 2/2] lint --- apps/desktop/src/renderer/stores/tabs/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/src/renderer/stores/tabs/store.ts b/apps/desktop/src/renderer/stores/tabs/store.ts index 00e050b4dfa..d28d8316add 100644 --- a/apps/desktop/src/renderer/stores/tabs/store.ts +++ b/apps/desktop/src/renderer/stores/tabs/store.ts @@ -142,7 +142,7 @@ export const useTabsStore = create()( ).filter((id) => id !== tabId); if (state.activeTabIds[workspaceId] === tabId) { - newActiveTabIds[workspaceId] = findNextTab(state, tabId ); + newActiveTabIds[workspaceId] = findNextTab(state, tabId); } const newFocusedPaneIds = { ...state.focusedPaneIds };