MCPcopy Create free account
hub / github.com/agent-tower/core / EditorView

Function EditorView

packages/web/src/components/workspace/EditorView.tsx:204–504  ·  view source on GitHub ↗
({
  workingDir,
  className,
  readOnly = false,
})

Source from the content-addressed store, hash-verified

202 )
203}
204
205export interface EditorViewHandle {
206 openFile: (path: string, line?: number, column?: number) => void
207}
208
209type PendingLocation = {
210 path: string
211 line: number
212 column?: number
213}
214
215export const EditorView = React.forwardRef<EditorViewHandle, { workingDir?: string; className?: string; readOnly?: boolean }>(function EditorView({
216 workingDir,
217 className,
218 readOnly = false,
219}, ref) {
220 const { t } = useI18n()
221 const [tabs, setTabs] = useState<OpenTab[]>([])
222 const [activePath, setActivePath] = useState<string | null>(null)
223 const [editorReady, setEditorReady] = useState(false)
224 const [editorLoadFailed, setEditorLoadFailed] = useState(false)
225 const [editorMountVersion, setEditorMountVersion] = useState(0)
226 const [pendingLocation, setPendingLocation] = useState<PendingLocation | null>(null)
227 const editorInstanceRef = useRef<MonacoEditor.IStandaloneCodeEditor | null>(null)
228 const saveMutation = useSaveFile()
229
230 useEffect(() => {
231 let cancelled = false
232 void import('@/lib/monaco')
233 .then(({ preloadMonaco }) => preloadMonaco())
234 .then(() => {
235 if (!cancelled) setEditorReady(true)
236 })
237 .catch(() => {
238 if (!cancelled) setEditorLoadFailed(true)
239 })
240 return () => {
241 cancelled = true
242 }
243 }, [])
244
245 // File tree width & collapse state
246 const [treeWidth, setTreeWidth] = useState(280)
247 const [treeCollapsed, setTreeCollapsed] = useState(false)
248 const [isDragging, setIsDragging] = useState(false)
249 const treeWidthBeforeCollapse = useRef(280)
250
251 const toggleCollapse = useCallback(() => {
252 setTreeCollapsed((prev) => {
253 if (!prev) treeWidthBeforeCollapse.current = treeWidth
254 else setTreeWidth(treeWidthBeforeCollapse.current)
255 return !prev
256 })
257 }, [treeWidth])
258
259 // Drag-to-resize logic
260 const onDragStart = useCallback((e: React.MouseEvent) => {
261 e.preventDefault()

Callers

nothing calls this directly

Calls 8

useI18nFunction · 0.90
useSaveFileFunction · 0.90
useFileContentFunction · 0.90
cnFunction · 0.90
isImageFileFunction · 0.85
inferMonacoLanguageFunction · 0.85
currentMethod · 0.80
basenameFunction · 0.70

Tested by

no test coverage detected