Skip to content

Commit 3bae054

Browse files
committed
feat(editor): replace Monaco with Pierre's editor in the file viewer and the Code tab
One CodeEditor on @pierre/diffs (already shipped for diffs) replaces Monaco in both places: the editable file viewer and the read-only workflow Code tab. - Lighter and faster: opening a .ts file loads ~460 KB instead of ~1.25 MB plus up to 9 MB of language workers; first paint is 4x faster, the heap a third to a half of Monaco's up to 30k lines, and highlighting never blocks the main thread. - Highlighting runs on Pierre's WebAssembly highlighter, so the CSP allows 'wasm-unsafe-eval' (WebAssembly compilation only); Shiki is the fallback. - Read-only is a guard in front of a live editor, so search, selection and copy keep working; Tab leaves the editor, every edit is refused. - External updates (streaming, refresh, reload) keep the scroll position and never join the undo history; a growing document follows its end. - Chrome uses the app's tokens: a --surface-hover caret line, ::selection and find colors, a quiet bracket match, and one syntax palette for Shiki and Zed themes. - Removes the Monaco wrapper, its themes and workers, the Code tab's language registration and minimal-edit helper, and the Monaco-only PostHog filter.
1 parent 64a3953 commit 3bae054

21 files changed

Lines changed: 680 additions & 833 deletions

File tree

‎apps/sim/app/_shell/paste-admission-guard.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { assessTextPaste, formatPasteLimit, PASTE_LIMITS } from '@sim/utils/past
66
import { readSelectionContextFromClipboard } from '@/lib/mothership/chat/selection-clipboard'
77

88
const EDITABLE_TARGET_SELECTOR =
9-
'input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="hidden"]), textarea, [contenteditable]:not([contenteditable="false"]), .monaco-editor, .xterm'
9+
'input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="hidden"]), textarea, [contenteditable]:not([contenteditable="false"]), [data-code-editor], .xterm'
1010

1111
function finitePositiveAttribute(element: Element | null, name: string): number | undefined {
1212
const raw = element?.getAttribute(name)
@@ -29,7 +29,7 @@ function clipboardHasImageFile(data: DataTransfer | null): boolean {
2929
* crash-only fallback. This layer bounds only the clipboard payload, so a small paste into an already
3030
* large field keeps native behavior. Editors with a real result-size contract enforce it themselves.
3131
* Targets that explicitly handle clipboard images may claim those file events before the text guards.
32-
* The capture listener runs before React, ProseMirror, Monaco, and xterm parse the clipboard value.
32+
* The capture listener runs before React, ProseMirror, the code editor, and xterm parse the clipboard value.
3333
*/
3434
export function PasteAdmissionGuard() {
3535
const { toast: notify } = useToast()

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/editor-context-menu.tsx‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
DropdownMenuShortcut,
99
DropdownMenuTrigger,
1010
} from '@sim/emcn'
11-
import { Blimp, Clipboard, Duplicate, Scissors, Search, SelectAll } from '@sim/emcn/icons'
11+
import { Blimp, Clipboard, Duplicate, Scissors, SelectAll } from '@sim/emcn/icons'
1212

1313
interface EditorContextMenuProps {
1414
isOpen: boolean
@@ -21,7 +21,6 @@ interface EditorContextMenuProps {
2121
onCopyAll: () => void
2222
onPaste: () => void
2323
onSelectAll: () => void
24-
onFind: () => void
2524
/** Adds the current selection to Chat as a reference. Omit to hide the item. */
2625
onAddToChat?: () => void
2726
}
@@ -37,7 +36,6 @@ export function EditorContextMenu({
3736
onCopyAll,
3837
onPaste,
3938
onSelectAll,
40-
onFind,
4139
onAddToChat,
4240
}: EditorContextMenuProps) {
4341
return (
@@ -103,11 +101,6 @@ export function EditorContextMenu({
103101
Select all
104102
<DropdownMenuShortcut>⌘A</DropdownMenuShortcut>
105103
</DropdownMenuItem>
106-
<DropdownMenuItem onSelect={onFind}>
107-
<Search />
108-
Find
109-
<DropdownMenuShortcut>⌘F</DropdownMenuShortcut>
110-
</DropdownMenuItem>
111104
</DropdownMenuContent>
112105
</DropdownMenu>
113106
)

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/monaco-editor.tsx‎

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)