Skip to content

Commit 1e79036

Browse files
committed
chore(files): drop platform references and non-essential inline comments
1 parent 2ca63c2 commit 1e79036

8 files changed

Lines changed: 34 additions & 52 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/resource/components/resource-header/resource-header.tsx

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,13 @@ interface BreadcrumbLocationPopoverProps {
371371
veilBoundaryRef: React.RefObject<HTMLDivElement | null>
372372
}
373373

374-
/** How long the reopen latch is held after a click-to-navigate, covering the route swap. */
375-
const NAVIGATE_LATCH_MS = 250
374+
/**
375+
* Grace period before a hover-out dismisses the path popover. Covers the gap
376+
* the pointer crosses between the trigger and the popover content (and brief
377+
* jitter at their edges); re-entering either within this window cancels the
378+
* close. Standard hover-intent close delay — not tied to any navigation timing.
379+
*/
380+
const POPOVER_CLOSE_DELAY_MS = 120
376381

377382
function BreadcrumbLocationPopover({
378383
icon: Icon,
@@ -382,61 +387,51 @@ function BreadcrumbLocationPopover({
382387
}: BreadcrumbLocationPopoverProps) {
383388
const [open, setOpen] = useState(false)
384389
const closeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
385-
/**
386-
* Suppresses reopen for the brief window between a click-to-navigate and the
387-
* route swap. Navigating away tears this popover down (the list and detail
388-
* views render different subtrees), so if `open` were still true the dimming
389-
* veil and popover content would snap away instead of fading — a visible
390-
* flash. {@link navigateAndClose} closes the popover before running the
391-
* crumb's handler and latches this so the pointer still resting on the
392-
* trigger can't re-fire `openPopover` mid-navigation. The latch is held by a
393-
* short timer (not cleared on the next pointer exit, which fires immediately
394-
* and would let the popover flash back open before the route swaps); the
395-
* timer releases it so the popover keeps working when the handler does not
396-
* actually navigate (e.g. an unsaved-changes guard that opens a modal).
397-
*/
398-
const navigatingRef = useRef(false)
399-
const navigateLatchRef = useRef<ReturnType<typeof setTimeout> | null>(null)
400390
const rootBreadcrumb = breadcrumbs[0]
401391

402-
const clearCloseTimeout = () => {
392+
const cancelScheduledClose = () => {
403393
if (closeTimeoutRef.current) {
404394
clearTimeout(closeTimeoutRef.current)
405395
closeTimeoutRef.current = null
406396
}
407397
}
408398

399+
/**
400+
* Hover-intent open. Driven only by pointer-/keyboard-enter — never by
401+
* pointer movement. This is what makes the popover dismiss cleanly on a
402+
* click-to-navigate: a stationary click fires no enter event, so once
403+
* {@link navigateAndClose} sets `open` false nothing re-opens it before the
404+
* route swaps. (A move-driven open would re-fire under the resting cursor and
405+
* flash the popover/veil back in mid-navigation.)
406+
*/
409407
const openPopover = () => {
410-
if (navigatingRef.current) return
411-
clearCloseTimeout()
408+
cancelScheduledClose()
412409
setOpen(true)
413410
}
414411

415412
const scheduleClose = () => {
416-
clearCloseTimeout()
413+
cancelScheduledClose()
417414
closeTimeoutRef.current = setTimeout(() => {
418415
setOpen(false)
419416
closeTimeoutRef.current = null
420-
}, 120)
417+
}, POPOVER_CLOSE_DELAY_MS)
421418
}
422419

420+
/**
421+
* Closes the popover up front, then runs the crumb's handler. Closing first
422+
* lets the veil fade and the popover play its exit animation instead of
423+
* snapping away when navigation unmounts the header.
424+
*/
423425
const navigateAndClose = (onClick?: () => void) => {
424426
if (!onClick) return
425-
navigatingRef.current = true
426-
clearCloseTimeout()
427+
cancelScheduledClose()
427428
setOpen(false)
428429
onClick()
429-
if (navigateLatchRef.current) clearTimeout(navigateLatchRef.current)
430-
navigateLatchRef.current = setTimeout(() => {
431-
navigatingRef.current = false
432-
navigateLatchRef.current = null
433-
}, NAVIGATE_LATCH_MS)
434430
}
435431

436432
useEffect(() => {
437433
return () => {
438434
if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current)
439-
if (navigateLatchRef.current) clearTimeout(navigateLatchRef.current)
440435
}
441436
}, [])
442437

@@ -453,10 +448,6 @@ function BreadcrumbLocationPopover({
453448
onBlur={scheduleClose}
454449
onMouseEnter={openPopover}
455450
onMouseLeave={scheduleClose}
456-
onMouseMove={openPopover}
457-
onPointerEnter={openPopover}
458-
onPointerLeave={scheduleClose}
459-
onPointerMove={openPopover}
460451
className={cn(
461452
chipVariants({ flush: true }),
462453
'max-w-none gap-1.5 px-2 transition-colors',
@@ -492,10 +483,6 @@ function BreadcrumbLocationPopover({
492483
)}
493484
onMouseEnter={openPopover}
494485
onMouseLeave={scheduleClose}
495-
onMouseMove={openPopover}
496-
onPointerEnter={openPopover}
497-
onPointerLeave={scheduleClose}
498-
onPointerMove={openPopover}
499486
>
500487
<PopoverSection className='px-1.5 py-0.5 text-[var(--text-muted)] text-xs'>
501488
<span className='inline-flex items-center gap-1'>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ export function FileViewer({
120120
return <CsvTablePreview key={file.id} file={file} workspaceId={workspaceId} />
121121
}
122122

123-
// Markdown renders in the inline rich editor when idle. During agent streaming we keep
124-
// the raw/preview editor, which already handles incremental token reconciliation.
125123
if (isMarkdownFile(file) && streamingContent === undefined) {
126124
return (
127125
<MarkdownFileEditor

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/code-block.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ export const MarkdownCodeBlock = CodeBlock.extend({
149149
})
150150

151151
/**
152-
* Code block with hover-revealed controls (language picker, line-wrap toggle, copy), in the
153-
* style of Linear's editor. The `language` attribute drives {@link CodeBlockHighlight}'s Prism
154-
* highlighting and serializes to the ```lang fence on save; wrap is a view-only preference.
152+
* Code block with hover-revealed controls (language picker, line-wrap toggle, copy). The
153+
* `language` attribute drives {@link CodeBlockHighlight}'s Prism highlighting and serializes to
154+
* the ```lang fence on save; wrap is a view-only preference.
155155
*/
156156
export const CodeBlockWithLanguage = MarkdownCodeBlock.extend({
157157
addNodeView() {

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/image.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function escapeAttr(value: string): string {
1717

1818
/**
1919
* Serialize an image to markdown when it has no explicit size, and to an HTML `<img>` tag when
20-
* it does — standard markdown has no width syntax, so a resized image must round-trip as HTML
21-
* (the same convention GitHub uses). Unsized images stay clean `![alt](src)`.
20+
* it does — standard markdown has no width syntax, so a resized image must round-trip as HTML to
21+
* preserve its dimensions. Unsized images stay clean `![alt](src)`.
2222
*/
2323
function imageMarkdown(node: JSONContent): string {
2424
const attrs = node.attrs ?? {}

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/keymap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function selectAdjacentLeaf(editor: Editor, direction: 'up' | 'down'): boolean {
3030
* Backspace below a divider is a confusing no-op.
3131
* - **Mod-A** inside a code block selects only that block's contents; pressing it again (when the
3232
* block is already fully selected) falls through to the default whole-document select-all, the
33-
* same scoped behavior as Linear and code editors.
33+
* same scoped behavior as a code editor.
3434
* - **ArrowUp/ArrowDown** select an adjacent divider or image (see {@link selectAdjacentLeaf}).
3535
*/
3636
export const EditorKeymap = Extension.create({

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ export function MarkdownFileEditor({
5454
return <PreviewLoadingFrame className='flex flex-1 flex-col' />
5555
}
5656

57-
// On a failed fetch, fall back to the raw editor rather than mount the rich editor over empty
58-
// content; a later retry-success resolves `data` and the gate decides normally.
5957
if (decisionRef.current === null && error) {
6058
return (
6159
<TextEditor

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/bubble-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface EditorBubbleMenuProps {
6666
}
6767

6868
/**
69-
* Floating formatting toolbar shown on text selection (Linear-style). Marks and the common
69+
* Floating formatting toolbar shown on text selection. Marks and the common
7070
* block types; the link button swaps the bar into an inline URL editor. Richer block inserts
7171
* live in the `/` slash menu. Active states are read through {@link useEditorState} so the bar
7272
* stays correct without re-rendering the editor on every transaction.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ interface RichMarkdownEditorProps {
3636

3737
/**
3838
* Inline WYSIWYG markdown editor (TipTap/ProseMirror) for markdown files. Renders a
39-
* single editing surface — markdown is transformed inline as you type, Linear-style —
40-
* with no raw/preview split. Content loading and autosave are delegated to
39+
* single editing surface — markdown is transformed inline as you type — with no raw/preview
40+
* split. Content loading and autosave are delegated to
4141
* {@link useEditableFileContent}; this component only renders the editor and bridges
4242
* markdown in and out of it.
4343
*/
@@ -98,7 +98,6 @@ export const RichMarkdownEditor = memo(function RichMarkdownEditor({
9898
.catch(() => null)
9999
const editor = editorInstanceRef.current
100100
if (!result || !editor) continue
101-
// The doc may have shrunk during the await; clamp so the insert can't land out of bounds.
102101
const safePosition = Math.min(position, editor.state.doc.content.size)
103102
try {
104103
editor

0 commit comments

Comments
 (0)