Skip to content

Commit 06df796

Browse files
committed
refactor(editor): infer Monaco types from public APIs
Replace direct monaco-editor type imports in AgentEditor with types inferred from OnMount and setModelMarkers. This reduces coupling to Monaco internals and keeps the editor typed against the APIs already used by @monaco-editor/react.refactor(editor): infer Monaco types from public APIs Replace direct monaco-editor type imports in AgentEditor with types inferred from OnMount and setModelMarkers. This reduces coupling to Monaco internals and keeps the editor typed against the APIs already used by @monaco-editor/react.
1 parent d7de131 commit 06df796

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/components/editor/AgentEditor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useCallback, useRef, useState, useEffect } from 'react';
22
import Editor, { type OnMount, type Monaco } from '@monaco-editor/react';
3-
import type { editor as monacoEditor } from 'monaco-editor';
43
import { useUI, uiStore, vfsStore, agentRegistry } from '../../stores/use-stores';
54
import { EditorToolbar } from './EditorToolbar';
65
import { validateAgentContent } from '../../utils/agent-validator';
@@ -16,7 +15,7 @@ export function AgentEditor() {
1615
function AgentEditorInner({ editingFilePath }: { editingFilePath: string | null }) {
1716
const setEditorDirty = useUI((s) => s.setEditorDirty);
1817
const isAgentFile = editingFilePath?.startsWith('agents/') ?? false;
19-
const editorRef = useRef<monacoEditor.IStandaloneCodeEditor | null>(null);
18+
const editorRef = useRef<Parameters<OnMount>[0] | null>(null);
2019
const monacoRef = useRef<Monaco | null>(null);
2120
const [content, setContent] = useState(() =>
2221
editingFilePath ? vfsStore.getState().read(editingFilePath) ?? '' : ''
@@ -40,7 +39,7 @@ function AgentEditorInner({ editingFilePath }: { editingFilePath: string | null
4039

4140
const diagnostics = validateAgentContent(value, isAgentFile);
4241

43-
const markers: monacoEditor.IMarkerData[] = diagnostics.map((d) => ({
42+
const markers: Parameters<Monaco['editor']['setModelMarkers']>[2] = diagnostics.map((d) => ({
4443
startLineNumber: d.startLine,
4544
endLineNumber: d.endLine,
4645
startColumn: d.startCol,

0 commit comments

Comments
 (0)