Skip to content

Commit 68ed15b

Browse files
echobtfactorydroid
andauthored
fix(gui): resolve TypeScript errors in Git components (#320)
Clean up unused variables and functions in Git components: - Bisect.tsx: Comment out unused search feature state - BlameView.tsx: Comment out prepared groupedLines function - BranchComparison.tsx: Remove unused createMemo import, comment out future features - DiffView.tsx: Comment out collapsedHunks, word diff functions, and line styling utilities - GitLFSManager.tsx: Comment out prepared getLFSLocks function - MergeEditor.tsx: Comment out line mapping, navigation helpers - WorktreeManager.tsx: Comment out getParentPath helper These utilities are preserved as comments for future feature development. Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 1b115df commit 68ed15b

7 files changed

Lines changed: 210 additions & 235 deletions

File tree

cortex-gui/src/components/git/Bisect.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ export interface BisectProps {
5151
export function Bisect(props: BisectProps) {
5252
const [wizardStep, setWizardStep] = createSignal<WizardStep>("idle");
5353
const [commits, setCommits] = createSignal<BisectCommit[]>([]);
54-
const [_loading, setLoading] = createSignal(false);
54+
const [, setLoading] = createSignal(false);
5555
const [operationLoading, setOperationLoading] = createSignal<string | null>(null);
56-
const [searchQuery, _setSearchQuery] = createSignal("");
57-
const [_showCommitSelector, _setShowCommitSelector] = createSignal(false);
56+
// Prepared for future search feature
57+
// const [searchQuery, setSearchQuery] = createSignal("");
58+
// const [showCommitSelector, setShowCommitSelector] = createSignal(false);
5859
const [bisectStatus, setBisectStatus] = createSignal<BisectStatus>({
5960
active: false,
6061
currentCommit: null,
@@ -285,17 +286,17 @@ export function Bisect(props: BisectProps) {
285286
}
286287
};
287288

288-
const _filteredCommits = createMemo(() => {
289-
const query = searchQuery().toLowerCase();
290-
if (!query) return commits();
291-
292-
return commits().filter(commit =>
293-
commit.message.toLowerCase().includes(query) ||
294-
commit.author.toLowerCase().includes(query) ||
295-
commit.hash.toLowerCase().includes(query) ||
296-
commit.shortHash.toLowerCase().includes(query)
297-
);
298-
});
289+
// Prepared for future search functionality
290+
// const filteredCommits = createMemo(() => {
291+
// const query = searchQuery().toLowerCase();
292+
// if (!query) return commits();
293+
// return commits().filter(commit =>
294+
// commit.message.toLowerCase().includes(query) ||
295+
// commit.author.toLowerCase().includes(query) ||
296+
// commit.hash.toLowerCase().includes(query) ||
297+
// commit.shortHash.toLowerCase().includes(query)
298+
// );
299+
// });
299300

300301
const formatDate = (dateStr: string): string => {
301302
const date = new Date(dateStr);

cortex-gui/src/components/git/BlameView.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,20 @@ export function BlameView(props: BlameViewProps) {
8181
return colors[index % colors.length];
8282
};
8383

84-
// Group consecutive lines by commit (prepared for future use)
85-
const _groupedLines = () => {
86-
const groups: { commit: BlameLine["commit"]; lines: BlameLine[] }[] = [];
87-
let currentGroup: { commit: BlameLine["commit"]; lines: BlameLine[] } | null = null;
88-
89-
for (const line of blameData()) {
90-
if (!currentGroup || currentGroup.commit.hash !== line.commit.hash) {
91-
currentGroup = { commit: line.commit, lines: [line] };
92-
groups.push(currentGroup);
93-
} else {
94-
currentGroup.lines.push(line);
95-
}
96-
}
97-
98-
return groups;
99-
};
84+
// Group consecutive lines by commit (prepared for future grouped view feature)
85+
// const groupedLines = () => {
86+
// const groups: { commit: BlameLine["commit"]; lines: BlameLine[] }[] = [];
87+
// let currentGroup: { commit: BlameLine["commit"]; lines: BlameLine[] } | null = null;
88+
// for (const line of blameData()) {
89+
// if (!currentGroup || currentGroup.commit.hash !== line.commit.hash) {
90+
// currentGroup = { commit: line.commit, lines: [line] };
91+
// groups.push(currentGroup);
92+
// } else {
93+
// currentGroup.lines.push(line);
94+
// }
95+
// }
96+
// return groups;
97+
// };
10098

10199
return (
102100
<div

cortex-gui/src/components/git/BranchComparison.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createSignal, createEffect, For, Show, createMemo } from "solid-js";
1+
import { createSignal, createEffect, For, Show } from "solid-js";
22
import { Icon } from "../ui/Icon";
33
import { gitCompare, GitCompareResult } from "../../utils/tauri-api";
44
import { getProjectPath } from "../../utils/workspace";
@@ -106,12 +106,12 @@ export function BranchComparison(props: BranchComparisonProps) {
106106
};
107107

108108
// Prepared for expandable sections (future feature)
109-
const _toggleSection = (section: "commits" | "files") => {
110-
_setExpandedSections(prev => ({
111-
...prev,
112-
[section]: !prev[section]
113-
}));
114-
};
109+
// const toggleSection = (section: "commits" | "files") => {
110+
// setExpandedSections(prev => ({
111+
// ...prev,
112+
// [section]: !prev[section]
113+
// }));
114+
// };
115115

116116
const getFileIcon = (status: string) => {
117117
switch (status) {
@@ -142,11 +142,11 @@ export function BranchComparison(props: BranchComparisonProps) {
142142
};
143143

144144
// Prepared for branch filtering (future feature)
145-
const _filteredBranches = createMemo(() => {
146-
return props.branches.filter(b =>
147-
b.name !== baseBranch() && b.name !== compareBranch()
148-
);
149-
});
145+
// const filteredBranches = createMemo(() => {
146+
// return props.branches.filter(b =>
147+
// b.name !== baseBranch() && b.name !== compareBranch()
148+
// );
149+
// });
150150

151151
return (
152152
<div

cortex-gui/src/components/git/DiffView.tsx

Lines changed: 104 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ export function DiffView(props: DiffViewProps) {
115115
const [loading, setLoading] = createSignal(false);
116116
const [viewMode, setViewMode] = createSignal<"unified" | "split">("unified");
117117
const [isFullscreen, setIsFullscreen] = createSignal(false);
118-
const [collapsedHunks, setCollapsedHunks] = createSignal<Set<number>>(new Set());
118+
// Prepared for collapsible hunks feature
119+
// const [collapsedHunks, setCollapsedHunks] = createSignal<Set<number>>(new Set());
119120
const [copied, setCopied] = createSignal(false);
120-
const [_highlightedLine, _setHighlightedLine] = createSignal<number | null>(null);
121+
// Prepared for line highlighting feature
122+
// const [highlightedLine, setHighlightedLine] = createSignal<number | null>(null);
121123
const [stagingHunk, setStagingHunk] = createSignal<number | null>(null);
122124
const [hoveredHunk, setHoveredHunk] = createSignal<number | null>(null);
123125
const [stagedHunks, setStagedHunks] = createSignal<Set<number>>(new Set());
@@ -129,9 +131,10 @@ export function DiffView(props: DiffViewProps) {
129131
const [editLoading, setEditLoading] = createSignal(false);
130132
const [savingEdit, setSavingEdit] = createSignal(false);
131133

132-
// These functions expose props for use in child components
133-
const _showLineNumbers = () => props.showLineNumbers !== false;
134-
const _enableWordDiff = () => props.enableWordDiff !== false;
134+
// These accessors expose props for use in the component (currently used internally)
135+
// Keeping as-is since they're part of the component interface for future enhancements
136+
void props.showLineNumbers; // Props used in rendering logic
137+
void props.enableWordDiff; // Props used in rendering logic
135138

136139
createEffect(() => {
137140
if (props.file) {
@@ -166,35 +169,31 @@ export function DiffView(props: DiffViewProps) {
166169
}
167170
};
168171

169-
// Utility functions for line styling (used in unified/split views)
170-
const _getLineBackground = (type: string, isHighlighted: boolean = false) => {
171-
const base = (() => {
172-
switch (type) {
173-
case "addition":
174-
return `color-mix(in srgb, ${tokens.colors.semantic.success} 15%, transparent)`;
175-
case "deletion":
176-
return `color-mix(in srgb, ${tokens.colors.semantic.error} 15%, transparent)`;
177-
case "header":
178-
return `color-mix(in srgb, ${tokens.colors.semantic.primary} 10%, transparent)`;
179-
default:
180-
return "transparent";
181-
}
182-
})();
183-
return isHighlighted ? "rgba(255, 255, 255, 0.1)" : base;
184-
};
185-
186-
const _getLineColor = (type: string) => {
187-
switch (type) {
188-
case "addition":
189-
return tokens.colors.semantic.success;
190-
case "deletion":
191-
return tokens.colors.semantic.error;
192-
case "header":
193-
return tokens.colors.semantic.primary;
194-
default:
195-
return tokens.colors.text.primary;
196-
}
197-
};
172+
// Utility functions for line styling - used by inline token-based rendering (future feature)
173+
// Currently using standalone getLineBackground/getLineColor functions at bottom of file
174+
// const getLineBackgroundTokenized = (type: string, isHighlighted: boolean = false) => {
175+
// const base = (() => {
176+
// switch (type) {
177+
// case "addition":
178+
// return `color-mix(in srgb, ${tokens.colors.semantic.success} 15%, transparent)`;
179+
// case "deletion":
180+
// return `color-mix(in srgb, ${tokens.colors.semantic.error} 15%, transparent)`;
181+
// case "header":
182+
// return `color-mix(in srgb, ${tokens.colors.semantic.primary} 10%, transparent)`;
183+
// default:
184+
// return "transparent";
185+
// }
186+
// })();
187+
// return isHighlighted ? "rgba(255, 255, 255, 0.1)" : base;
188+
// };
189+
// const getLineColorTokenized = (type: string) => {
190+
// switch (type) {
191+
// case "addition": return tokens.colors.semantic.success;
192+
// case "deletion": return tokens.colors.semantic.error;
193+
// case "header": return tokens.colors.semantic.primary;
194+
// default: return tokens.colors.text.primary;
195+
// }
196+
// };
198197

199198
const getLinePrefix = (type: string) => {
200199
switch (type) {
@@ -207,40 +206,33 @@ export function DiffView(props: DiffViewProps) {
207206
}
208207
};
209208

210-
// Toggle hunk collapse state (used for collapsible hunks feature)
211-
const _toggleHunkCollapse = (index: number) => {
212-
const newSet = new Set(collapsedHunks());
213-
if (newSet.has(index)) {
214-
newSet.delete(index);
215-
} else {
216-
newSet.add(index);
217-
}
218-
setCollapsedHunks(newSet);
219-
};
209+
// Toggle hunk collapse state - prepared for collapsible hunks feature
210+
// const toggleHunkCollapse = (index: number) => {
211+
// const newSet = new Set(collapsedHunks());
212+
// if (newSet.has(index)) {
213+
// newSet.delete(index);
214+
// } else {
215+
// newSet.add(index);
216+
// }
217+
// setCollapsedHunks(newSet);
218+
// };
220219

221220
/**
222221
* Generate a unified diff patch for a single hunk (used for git apply operations)
222+
* This is kept for reference but hunk staging now uses backend gitStageHunk command
223223
*/
224-
const _generateHunkPatch = (hunk: DiffHunk, filePath: string): string => {
225-
const lines: string[] = [];
226-
227-
// Add diff header
228-
lines.push(`diff --git a/${filePath} b/${filePath}`);
229-
lines.push(`--- a/${filePath}`);
230-
lines.push(`+++ b/${filePath}`);
231-
232-
// Add hunk header
233-
lines.push(hunk.header);
234-
235-
// Add hunk content
236-
for (const line of hunk.lines) {
237-
const prefix = getLinePrefix(line.type);
238-
lines.push(prefix + line.content);
239-
}
240-
241-
// Ensure trailing newline
242-
return lines.join('\n') + '\n';
243-
};
224+
// const generateHunkPatch = (hunk: DiffHunk, filePath: string): string => {
225+
// const lines: string[] = [];
226+
// lines.push(`diff --git a/${filePath} b/${filePath}`);
227+
// lines.push(`--- a/${filePath}`);
228+
// lines.push(`+++ b/${filePath}`);
229+
// lines.push(hunk.header);
230+
// for (const line of hunk.lines) {
231+
// const prefix = getLinePrefix(line.type);
232+
// lines.push(prefix + line.content);
233+
// }
234+
// return lines.join('\n') + '\n';
235+
// };
244236

245237
/**
246238
* Stage a single hunk by applying its patch to the index
@@ -578,60 +570,55 @@ export function DiffView(props: DiffViewProps) {
578570
}
579571
});
580572

581-
// Word-level diff computation (used for fine-grained change highlighting)
582-
const _computeWordDiff = (oldLine: string, newLine: string): { old: WordChange[], new: WordChange[] } => {
583-
const oldWords = oldLine.split(/(\s+)/);
584-
const newWords = newLine.split(/(\s+)/);
585-
586-
const oldResult: WordChange[] = [];
587-
const newResult: WordChange[] = [];
588-
589-
let i = 0, j = 0;
590-
while (i < oldWords.length || j < newWords.length) {
591-
if (i >= oldWords.length) {
592-
newResult.push({ value: newWords[j], added: true });
593-
j++;
594-
} else if (j >= newWords.length) {
595-
oldResult.push({ value: oldWords[i], removed: true });
596-
i++;
597-
} else if (oldWords[i] === newWords[j]) {
598-
oldResult.push({ value: oldWords[i] });
599-
newResult.push({ value: newWords[j] });
600-
i++;
601-
j++;
602-
} else {
603-
oldResult.push({ value: oldWords[i], removed: true });
604-
newResult.push({ value: newWords[j], added: true });
605-
i++;
606-
j++;
607-
}
608-
}
609-
610-
return { old: oldResult, new: newResult };
611-
};
573+
// Word-level diff computation - prepared for fine-grained change highlighting feature
574+
// const computeWordDiff = (oldLine: string, newLine: string): { old: WordChange[], new: WordChange[] } => {
575+
// const oldWords = oldLine.split(/(\s+)/);
576+
// const newWords = newLine.split(/(\s+)/);
577+
// const oldResult: WordChange[] = [];
578+
// const newResult: WordChange[] = [];
579+
// let i = 0, j = 0;
580+
// while (i < oldWords.length || j < newWords.length) {
581+
// if (i >= oldWords.length) {
582+
// newResult.push({ value: newWords[j], added: true });
583+
// j++;
584+
// } else if (j >= newWords.length) {
585+
// oldResult.push({ value: oldWords[i], removed: true });
586+
// i++;
587+
// } else if (oldWords[i] === newWords[j]) {
588+
// oldResult.push({ value: oldWords[i] });
589+
// newResult.push({ value: newWords[j] });
590+
// i++;
591+
// j++;
592+
// } else {
593+
// oldResult.push({ value: oldWords[i], removed: true });
594+
// newResult.push({ value: newWords[j], added: true });
595+
// i++;
596+
// j++;
597+
// }
598+
// }
599+
// return { old: oldResult, new: newResult };
600+
// };
612601

613-
// Render word-level diff with inline highlighting
614-
const _renderWordDiffContent = (words: WordChange[], type: "addition" | "deletion") => {
615-
return (
616-
<For each={words}>
617-
{(word) => {
618-
const isHighlighted = type === "addition" ? word.added : word.removed;
619-
return (
620-
<span
621-
style={{
622-
background: isHighlighted
623-
? (type === "addition" ? `color-mix(in srgb, ${tokens.colors.semantic.success} 40%, transparent)` : `color-mix(in srgb, ${tokens.colors.semantic.error} 40%, transparent)`)
624-
: "transparent",
625-
"border-radius": isHighlighted ? "2px" : "0"
626-
}}
627-
>
628-
{word.value}
629-
</span>
630-
);
631-
}}
632-
</For>
633-
);
634-
};
602+
// Render word-level diff with inline highlighting - prepared for future feature
603+
// const renderWordDiffContent = (words: WordChange[], type: "addition" | "deletion") => {
604+
// return (
605+
// <For each={words}>
606+
// {(word) => {
607+
// const isHighlighted = type === "addition" ? word.added : word.removed;
608+
// return (
609+
// <span style={{
610+
// background: isHighlighted
611+
// ? (type === "addition" ? `color-mix(in srgb, ${tokens.colors.semantic.success} 40%, transparent)` : `color-mix(in srgb, ${tokens.colors.semantic.error} 40%, transparent)`)
612+
// : "transparent",
613+
// "border-radius": isHighlighted ? "2px" : "0"
614+
// }}>
615+
// {word.value}
616+
// </span>
617+
// );
618+
// }}
619+
// </For>
620+
// );
621+
// };
635622

636623
return (
637624
<div

cortex-gui/src/components/git/GitLFSManager.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ async function unlockFile(repoPath: string, filePath: string, force: boolean = f
159159
}
160160

161161
// Prepared for locks feature (future use)
162-
async function _getLFSLocks(repoPath: string): Promise<LFSLock[]> {
163-
return invoke("git_lfs_locks", { path: repoPath });
164-
}
162+
// async function getLFSLocks(repoPath: string): Promise<LFSLock[]> {
163+
// return invoke("git_lfs_locks", { path: repoPath });
164+
// }
165165

166166
// ============================================================================
167167
// Helper Functions

0 commit comments

Comments
 (0)