Skip to content

Commit cb7e8a2

Browse files
echobtfactorydroid
andauthored
fix(gui): resolve TypeScript errors in editor components (#313)
- CodeEditor.tsx: Fix minimap autohide type, add non-null assertions for monacoInstance, cast unicode highlight records, fix CustomEvent/EventListener casting, cast ICodeEditor to IStandaloneCodeEditor for smart select, add optional chaining for props.file - EditorPanel.tsx: Remove unused imports, fix surface.raised to surface.elevated - TabBar.tsx: Remove unused Divider import, rename handleCloseAllIncludingPinned - MultiBuffer.tsx: Rename unused props/splitRatio/setSplitRatio parameters - LanguageTools.tsx: Remove unused Position import, fix addCommand push issue - FindReplaceWidget.tsx: Remove unused batch/findPrevMatch imports, rename unused showReplace/headerStyle/HistoryIcon/state variables - RenameWidget.tsx: Remove unused For import and RenameWidgetState/LSPPosition types - LSPIntegration.tsx: Fix SelectionRange.parent type with intersection cast This fixes ~50 TypeScript errors across 8 editor component files as identified by the AGENT2.md orchestration document. Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 3ee8839 commit cb7e8a2

File tree

8 files changed

+90
-105
lines changed

8 files changed

+90
-105
lines changed

cortex-gui/src/components/editor/CodeEditor.tsx

Lines changed: 64 additions & 76 deletions
Large diffs are not rendered by default.

cortex-gui/src/components/editor/EditorPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { EditorSkeleton } from "./EditorSkeleton";
55
import { Text, Card } from "@/components/ui";
66
import { Icon } from "../ui/Icon";
77
import { tokens } from "@/design-system/tokens";
8-
import { Box, Flex, VStack, HStack } from "@/design-system/primitives/Flex";
8+
// Box, Flex, VStack, HStack available from "@/design-system/primitives/Flex" if needed
99

1010
/**
1111
* EditorPanel - Main editor container component
@@ -52,7 +52,7 @@ export function EditorPanel() {
5252
background: `var(--vscode-editor-background, ${tokens.colors.surface.canvas})`,
5353
} as JSX.CSSProperties}
5454
>
55-
<Card padding="lg" style={{ "text-align": "center", background: tokens.colors.surface.raised }}>
55+
<Card padding="lg" style={{ "text-align": "center", background: tokens.colors.surface.elevated }}>
5656
<div style={{
5757
display: "flex",
5858
"flex-direction": "column",

cortex-gui/src/components/editor/FindReplaceWidget.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import {
2020
Show,
2121
For,
2222
createMemo,
23-
JSX,
24-
batch
23+
JSX
2524
} from "solid-js";
2625
import type * as Monaco from "monaco-editor";
2726
import {
@@ -33,7 +32,6 @@ import {
3332
createDefaultSearchHistory,
3433
findAllMatches,
3534
findNextMatch,
36-
findPrevMatch,
3735
replaceMatch,
3836
replaceAllMatches,
3937
addToSearchHistory,
@@ -80,7 +78,7 @@ const MAX_HISTORY_ITEMS = 20;
8078
// Styles
8179
// ============================================================================
8280

83-
const containerStyle = (isVisible: boolean, showReplace: boolean): JSX.CSSProperties => ({
81+
const containerStyle = (isVisible: boolean, _showReplace: boolean): JSX.CSSProperties => ({
8482
position: "absolute",
8583
top: "0",
8684
right: "20px",
@@ -97,7 +95,8 @@ const containerStyle = (isVisible: boolean, showReplace: boolean): JSX.CSSProper
9795
"pointer-events": isVisible ? "auto" : "none",
9896
});
9997

100-
const headerStyle: JSX.CSSProperties = {
98+
// Reserved for future header styling
99+
const _headerStyle: JSX.CSSProperties = {
101100
display: "flex",
102101
"align-items": "center",
103102
padding: "6px 8px",
@@ -323,7 +322,8 @@ const CloseIcon = () => (
323322
</svg>
324323
);
325324

326-
const HistoryIcon = () => (
325+
// Reserved for future history dropdown feature
326+
const _HistoryIcon = () => (
327327
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
328328
<circle cx="12" cy="12" r="10" />
329329
<polyline points="12 6 12 12 16 14" />
@@ -614,9 +614,9 @@ export function FindReplaceWidget(props: FindReplaceWidgetProps) {
614614
const state = findState();
615615
const match = allMatches[idx];
616616

617-
// Perform replacement
617+
// Perform replacement (we use executeEdits below, so just call for validation)
618618
const text = model.getValue();
619-
const { newText } = replaceMatch(text, match, state.replaceString, {
619+
replaceMatch(text, match, state.replaceString, {
620620
isRegex: state.isRegex,
621621
preserveCase: state.preserveCase,
622622
});
@@ -876,8 +876,8 @@ export function FindReplaceWidget(props: FindReplaceWidgetProps) {
876876

877877
// Effects
878878
createEffect(() => {
879-
// Re-search when options change
880-
const state = findState();
879+
// Re-search when options change (access state to create reactive dependency)
880+
const _state = findState();
881881
performSearch();
882882
});
883883

cortex-gui/src/components/editor/LSPIntegration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ function convertSelectionRange(
15741574

15751575
// Recursively convert parent if present
15761576
if (selRange.parent) {
1577-
monacoRange.parent = convertSelectionRange(
1577+
(monacoRange as Monaco.languages.SelectionRange & { parent?: Monaco.languages.SelectionRange }).parent = convertSelectionRange(
15781578
selRange.parent as { range: Range; parent?: { range: Range; parent?: unknown } }
15791579
);
15801580
}

cortex-gui/src/components/editor/LanguageTools.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { createStore } from "solid-js/store";
3232
import type * as Monaco from "monaco-editor";
3333
import { invoke } from "@tauri-apps/api/core";
34-
import { useLSP, type Range, type Position, type TextEdit } from "@/context/LSPContext";
34+
import { useLSP, type Range, type TextEdit } from "@/context/LSPContext";
3535
import { useEditor } from "@/context/EditorContext";
3636

3737
// ============================================================================
@@ -1024,12 +1024,10 @@ export function LanguageTools(props: LanguageToolsProps) {
10241024

10251025
const disposables: Monaco.IDisposable[] = [];
10261026

1027-
// Ctrl+. to open code actions
1028-
disposables.push(
1029-
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Period, () => {
1030-
openMenu();
1031-
})
1032-
);
1027+
// Ctrl+. to open code actions (returns command ID, not IDisposable)
1028+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Period, () => {
1029+
openMenu();
1030+
});
10331031

10341032
// Register code action provider keyboard shortcut
10351033
editor.addAction({

cortex-gui/src/components/editor/MultiBuffer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ interface MultiBufferToolbarProps {
473473
onUnsplit: () => void;
474474
}
475475

476-
function MultiBufferToolbar(props: MultiBufferToolbarProps) {
476+
function MultiBufferToolbar(_props: MultiBufferToolbarProps) {
477477
// Hidden by default - split controls are in TabBar actions
478478
// This toolbar is kept for backwards compatibility but not displayed
479479
return null;
@@ -543,7 +543,8 @@ export function MultiBuffer() {
543543
return 0.5;
544544
};
545545

546-
const [splitRatio, setSplitRatio] = createSignal(getSavedRatio());
546+
// Reserved for future resizable split feature
547+
const [_splitRatio, _setSplitRatio] = createSignal(getSavedRatio());
547548
const [agentModeActive, setAgentModeActive] = createSignal(false);
548549
const [newSplitIndex, setNewSplitIndex] = createSignal<number | null>(null);
549550

cortex-gui/src/components/editor/RenameWidget.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
* - Undo support after rename
1616
*/
1717

18-
import { Show, createSignal, createEffect, onCleanup, onMount, For } from "solid-js";
18+
import { Show, createSignal, createEffect, onCleanup, onMount } from "solid-js";
1919
import type * as Monaco from "monaco-editor";
2020
import { invoke } from "@tauri-apps/api/core";
2121
import type {
22-
RenameWidgetState,
2322
RenameLocation,
2423
EditorRange
2524
} from "@/types/editor";
2625
import type {
2726
PrepareRenameResult,
2827
WorkspaceEdit,
2928
TextEdit,
30-
Range as LSPRange,
31-
Position as LSPPosition
29+
Range as LSPRange
3230
} from "@/context/LSPContext";
3331

3432
// ============================================================================

cortex-gui/src/components/editor/TabBar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Icon } from "../ui/Icon";
33
import { useEditor, OpenFile } from "@/context/EditorContext";
44
import { useSettings, type WorkbenchEditorSettings } from "@/context/SettingsContext";
55
import { useDiagnostics } from "@/context/DiagnosticsContext";
6-
import { ListItem, Divider, ContextMenu, ContextMenuPresets } from "@/components/ui";
6+
import { ListItem, ContextMenu, ContextMenuPresets } from "@/components/ui";
77
import { tokens } from "@/design-system/tokens";
88
import { zenModeActive } from "@/components/ZenMode";
99

@@ -844,8 +844,8 @@ export function TabBar(props: TabBarProps) {
844844
editor.closeAllFiles(false);
845845
};
846846

847-
const handleCloseAllIncludingPinned = () => {
848-
// Close all tabs including pinned
847+
// Available for future use: Close all tabs including pinned
848+
const _handleCloseAllIncludingPinned = () => {
849849
editor.closeAllFiles(true);
850850
};
851851

0 commit comments

Comments
 (0)