Skip to content

Commit a9d1ba4

Browse files
authored
Merge pull request #348 from CortexLM/fix/editor-typescript-errors-batch2
fix(editor): resolve remaining TypeScript errors in editor components
2 parents f035044 + 5dd0482 commit a9d1ba4

12 files changed

Lines changed: 71 additions & 64 deletions

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,6 @@ export function BookmarksGutter(props: BookmarksGutterProps) {
152152
}
153153
};
154154

155-
/**
156-
* Find if a line has a bookmark
157-
*/
158-
const hasBookmarkAtLine = (line: number): boolean => {
159-
if (!props.filePath) return false;
160-
const fileBookmarks = getBookmarksForFile(props.filePath);
161-
return fileBookmarks.some((b) => b.line === line);
162-
};
163-
164155
// Update decorations when bookmarks or file changes
165156
createEffect(() => {
166157
// Access bookmarks() to trigger reactivity

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ items.push({
536536
style={{
537537
left: `${menuPosition().x}px`,
538538
top: `${menuPosition().y}px`,
539-
background: tokens.colors.surface.raised,
539+
background: tokens.colors.surface.elevated,
540540
border: `1px solid ${tokens.colors.border.default}`,
541541
"border-radius": tokens.radius.md,
542542
"box-shadow": "var(--jb-shadow-popup)",
@@ -845,7 +845,7 @@ function ExportMenu(props: ExportMenuProps) {
845845
right: "0",
846846
top: "100%",
847847
"margin-top": tokens.spacing.sm,
848-
background: tokens.colors.surface.raised,
848+
background: tokens.colors.surface.elevated,
849849
border: `1px solid ${tokens.colors.border.default}`,
850850
"border-radius": tokens.radius.md,
851851
"box-shadow": "var(--jb-shadow-popup)",
@@ -2025,7 +2025,7 @@ export function DiagnosticsPanel(props: DiagnosticsPanelProps) {
20252025
<div
20262026
class="absolute bottom-4 right-4 px-3 py-2 rounded shadow-lg"
20272027
style={{
2028-
background: tokens.colors.surface.raised,
2028+
background: tokens.colors.surface.elevated,
20292029
border: `1px solid ${tokens.colors.border.default}`,
20302030
"border-radius": tokens.radius.md,
20312031
}}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - Keyboard shortcuts support
99
*/
1010

11-
import { createSignal, createEffect, onMount, onCleanup, Show, For, type JSX } from "solid-js";
12-
import { IconButton, Text, Badge } from "@/components/ui";
11+
import { createSignal, onMount, onCleanup, Show, For, type JSX } from "solid-js";
12+
import { IconButton, Text } from "@/components/ui";
1313
import { Icon } from "../ui/Icon";
1414

1515
// ============================================================================
@@ -56,8 +56,6 @@ export function DiffNavigator(props: DiffNavigatorProps) {
5656
const hasPrevious = () => props.currentIndex > 0;
5757
const hasNext = () => props.currentIndex < props.changes.length - 1;
5858

59-
const currentChange = () => props.changes[props.currentIndex];
60-
6159
const goToPrevious = () => {
6260
if (hasPrevious() && !props.disabled) {
6361
props.onNavigate(props.currentIndex - 1);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
* Polished Zed-like design with smooth animations and keyboard navigation.
66
*/
77

8-
import { Show, For, createSignal, createEffect, onCleanup, type JSX } from "solid-js";
8+
import { Show, For, createSignal, createEffect, onCleanup } from "solid-js";
99
import { Portal } from "solid-js/web";
1010
import { Icon } from "../ui/Icon";
1111
import { useGitHosting } from "@/context/GitHostingContext";
1212
import { useDebug } from "@/context/DebugContext";
13-
import { showReferencesPanel } from "../ReferencesPanel";
14-
import { showPeekReferences } from "./PeekReferences";
1513
import type { LineSelection } from "@/utils/git/types";
16-
import { ListItem, Text, Divider, EmptyState } from "@/components/ui";
1714

1815
// IMenuStyles interface - VS Code's 12 color properties for menus
1916
interface IContextMenuStyles {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { For, Show, type JSX } from "solid-js";
9-
import { Card, Text, LoadingSpinner } from "@/components/ui";
9+
import { Text, LoadingSpinner } from "@/components/ui";
1010

1111
interface EditorSkeletonProps {
1212
/** Number of skeleton lines to show (default: 20) */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,13 @@ export function LightBulbWidget(props: LightBulbWidgetProps) {
342342
);
343343

344344
// Add Ctrl+. keyboard shortcut
345-
const commandId = editor.addCommand(
345+
// addCommand returns a string (command ID) or null, not IDisposable
346+
// We can't dispose of it directly, but it will be cleaned up when editor is disposed
347+
editor.addCommand(
346348
monaco.KeyMod.CtrlCmd | monaco.KeyCode.Period,
347349
triggerCodeActions,
348350
"editorTextFocus"
349351
);
350-
// addCommand returns a string (command ID) or null, not IDisposable
351-
// We can't dispose of it directly, but it will be cleaned up when editor is disposed
352352

353353
// Initial update
354354
updateLightBulb();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* - BookmarksContext for bookmark marks
1616
*/
1717

18-
import { createEffect, onCleanup, createSignal, createMemo } from "solid-js";
18+
import { createEffect, onCleanup, createSignal } from "solid-js";
1919
import { useDiagnostics } from "@/context/DiagnosticsContext";
2020
import type * as Monaco from "monaco-editor";
2121

@@ -544,7 +544,7 @@ export function MinimapDecorations(props: MinimapDecorationsProps) {
544544
*/
545545
export function useMinimapDecorations(
546546
editor: () => Monaco.editor.IStandaloneCodeEditor | null,
547-
monaco: () => typeof Monaco | null
547+
_monaco: () => typeof Monaco | null
548548
) {
549549
const [decorationIds, setDecorationIds] = createSignal<string[]>([]);
550550

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

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
onCleanup,
2929
For,
3030
Show,
31-
type JSX,
31+
3232
type Accessor,
3333
} from "solid-js";
3434
import { Icon } from "../ui/Icon";
@@ -562,15 +562,15 @@ function FileHeader(props: {
562562
readOnly?: boolean;
563563
onToggle: () => void;
564564
onOpenFile?: () => void;
565-
onStageFile?: () => void;
566-
onUnstageFile?: () => void;
567-
onRevertFile?: () => void;
565+
onStageFile?: () => void | Promise<void>;
566+
onUnstageFile?: () => void | Promise<void>;
567+
onRevertFile?: () => void | Promise<void>;
568568
focused?: boolean;
569569
}) {
570570
const [isHovered, setIsHovered] = createSignal(false);
571571
const [actionLoading, setActionLoading] = createSignal<string | null>(null);
572572

573-
const handleAction = async (action: () => Promise<void> | undefined, name: string) => {
573+
const handleAction = async (action: () => void | Promise<void>, name: string) => {
574574
if (!action) return;
575575
setActionLoading(name);
576576
try {
@@ -595,7 +595,7 @@ function FileHeader(props: {
595595
cursor: "pointer",
596596
"user-select": "none",
597597
"border-bottom": `1px solid ${tokens.colors.border.divider}`,
598-
transition: `background ${tokens.motion.duration.fast}`,
598+
transition: `background ${tokens.transitions.fast}`,
599599
}}
600600
onClick={props.onToggle}
601601
onMouseEnter={() => setIsHovered(true)}
@@ -829,7 +829,8 @@ function InlineDiffEditor(props: {
829829
}) {
830830
let containerRef: HTMLDivElement | undefined;
831831
let diffEditorInstance: Monaco.editor.IStandaloneDiffEditor | null = null;
832-
let diffNavigator: Monaco.editor.IDiffNavigator | null = null;
832+
// Track current change index for navigation (since Monaco's DiffNavigator is deprecated)
833+
let currentChangeIndex = 0;
833834
const monacoManager = MonacoManager.getInstance();
834835

835836
onMount(async () => {
@@ -899,16 +900,40 @@ function InlineDiffEditor(props: {
899900
modified: modifiedModel,
900901
});
901902

902-
// Create diff navigator for change navigation
903-
diffNavigator = monaco.editor.createDiffNavigator(diffEditorInstance, {
904-
followsCaret: true,
905-
ignoreCharChanges: true,
906-
});
903+
// Helper function to navigate to a specific change
904+
const goToChange = (index: number) => {
905+
if (!diffEditorInstance) return;
906+
const changes = diffEditorInstance.getLineChanges();
907+
if (!changes || changes.length === 0) return;
908+
909+
// Clamp index to valid range
910+
currentChangeIndex = Math.max(0, Math.min(index, changes.length - 1));
911+
const change = changes[currentChangeIndex];
912+
913+
// Reveal the change in the modified editor
914+
const modifiedEditor = diffEditorInstance.getModifiedEditor();
915+
if (modifiedEditor && change) {
916+
modifiedEditor.revealLineInCenter(change.modifiedStartLineNumber);
917+
modifiedEditor.setPosition({ lineNumber: change.modifiedStartLineNumber, column: 1 });
918+
}
919+
};
907920

908921
// Expose navigation methods
909922
props.onEditorReady?.({
910-
goToNextChange: () => diffNavigator?.next(),
911-
goToPreviousChange: () => diffNavigator?.previous(),
923+
goToNextChange: () => {
924+
const changes = diffEditorInstance?.getLineChanges();
925+
if (changes && changes.length > 0) {
926+
currentChangeIndex = (currentChangeIndex + 1) % changes.length;
927+
goToChange(currentChangeIndex);
928+
}
929+
},
930+
goToPreviousChange: () => {
931+
const changes = diffEditorInstance?.getLineChanges();
932+
if (changes && changes.length > 0) {
933+
currentChangeIndex = (currentChangeIndex - 1 + changes.length) % changes.length;
934+
goToChange(currentChangeIndex);
935+
}
936+
},
912937
getChangesCount: () => {
913938
const changes = diffEditorInstance?.getLineChanges();
914939
return changes?.length ?? 0;
@@ -922,10 +947,6 @@ function InlineDiffEditor(props: {
922947
});
923948

924949
onCleanup(() => {
925-
if (diffNavigator) {
926-
diffNavigator.dispose();
927-
diffNavigator = null;
928-
}
929950
if (diffEditorInstance) {
930951
const model = diffEditorInstance.getModel();
931952
if (model) {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function VirtualizedSymbolItem(props: VirtualizedSymbolItemProps) {
254254
size="xs"
255255
truncate
256256
style={{ "max-width": "80px" }}
257-
title={symbol().detail}
257+
258258
>
259259
{symbol().detail}
260260
</Text>
@@ -410,7 +410,6 @@ function SymbolTypeFilterDropdown(props: SymbolTypeFilterDropdownProps) {
410410
const config = symbolTypeFilterConfig[type];
411411
const isEnabled = () => outline.isSymbolTypeEnabled(type);
412412
const count = () => outline.state.symbolTypeCounts[type] || 0;
413-
const Icon = symbolTypeIcons[type];
414413

415414
return (
416415
<ListItem
@@ -870,7 +869,7 @@ const filteredSymbols = () => sortSymbols(outline.getFilteredSymbols(), sortOrde
870869
onClick={handleRefresh}
871870
tooltip="Refresh"
872871
>
873-
<Icon name="rotate" size={14} spin={outline.state.loading} />
872+
<Icon name="rotate" size={14} style={{ animation: outline.state.loading ? "spin 1s linear infinite" : "none" }} />
874873
</IconButton>
875874
<Show when={props.onClose}>
876875
<IconButton
@@ -922,9 +921,11 @@ const filteredSymbols = () => sortSymbols(outline.getFilteredSymbols(), sortOrde
922921
"flex-shrink": "0",
923922
}}
924923
>
925-
<Text variant="muted" truncate title={activeFileName()}>
926-
{activeFileName()}
927-
</Text>
924+
<span title={activeFileName()}>
925+
<Text variant="muted" truncate>
926+
{activeFileName()}
927+
</Text>
928+
</span>
928929
<QuickFilterButtons />
929930
</div>
930931

@@ -951,7 +952,7 @@ const filteredSymbols = () => sortSymbols(outline.getFilteredSymbols(), sortOrde
951952
<Show when={outline.state.error && !outline.state.loading}>
952953
<EmptyState
953954
title="Error"
954-
description={outline.state.error}
955+
description={outline.state.error ?? undefined}
955956
style={{ padding: "16px" }}
956957
/>
957958
</Show>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
* - Consistent theming with Ayu Dark style
1414
*/
1515

16-
import { createSignal, createEffect, onMount, onCleanup, Show, For, createMemo } from "solid-js";
17-
import type { SignatureInformation, ParameterHintsState } from "@/types/editor";
16+
import { createSignal, createEffect, onMount, onCleanup, Show, createMemo } from "solid-js";
1817
import type { SignatureHelp, Position } from "@/context/LSPContext";
1918
import type * as Monaco from "monaco-editor";
2019
import { SafeHTML } from "../ui/SafeHTML";

0 commit comments

Comments
 (0)