fix(files): stop the file-viewer image reshift on open - #6390
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
Separately, the Reviewed by Cursor Bugbot for commit 08682da. Configure here. |
Greptile SummaryThe PR makes workspace image metadata reactive so markdown images can reserve their intrinsic dimensions before loading, while avoiding the query for caller-supplied content sources.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/hooks/queries/workspace-files.ts | Replaces the one-shot cache lookup with a reactive active-files subscription and rebuilds the image-dimensions adapter when file metadata arrives. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx | Disables the workspace-files subscription when a caller supplies its own content source. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention.ts | Renames the menu extension and associated editor storage to mentionMenu to avoid colliding with the persisted mention node. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/use-editor-mentions.ts | Updates mention-menu state synchronization to consistently use the renamed storage key. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-chip.tsx | Reads navigation configuration from the renamed mention-menu storage. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-chip.test.tsx | Correctly updates the test fixture to match the storage rename identified in the previous review. |
Reviews (3): Last reviewed commit: "fix(files): stop the duplicate 'mention'..." | Re-trigger Greptile
An embedded image in a markdown file reshifted on every open: it loaded ~2.3s in with no reserved box and shoved everything below it down (CLS ~0.17). The intrinsic dimensions ARE stored server-side, but the image node view never read them at render. useWorkspaceImageDimensionsAdapter read the active files list via queryClient.getQueryData — non-reactively — so on a cold file-view load it returned null at first render and, because the adapter identity was stable, never re-checked when the list later resolved. Read the list via a reactive useWorkspaceFiles subscription instead: the adapter re-runs the image node view's memoized dimension read when the list resolves, so it reserves the box from the stored dimensions before the (slower) image download finishes. The query key is shared, so it dedupes with surrounding views. Gate it behind `enabled` (driven by the absence of a caller-supplied contentSource) so the public share page — which passes a share token as workspaceId — doesn't fire a 404. Verified in a CLS harness: dims present -> 0 shift; dims absent -> 0.20.
4efbf79 to
2abb59e
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2abb59e. Configure here.
The @-mention menu extension and the mention node were both named 'mention', so TipTap logged "Duplicate extension names found: ['mention']" on every editor (twice under the collaborative placeholder + live pair). Rename the menu extension to 'mentionMenu' (the node keeps 'mention', its persisted doc-node type) and move its editor.storage.mention -> editor.storage.mentionMenu.
2abb59e to
08682da
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 08682da. Configure here.
Summary
untitled.mdmention itself never moved — the image just popped in nearby.useWorkspaceImageDimensionsAdapterread the files list viaqueryClient.getQueryDatanon-reactively. On a cold file-view load the list isn't cached when the image renders, so it returned null; and with a stable adapter identity it never re-checked when the list resolved → no reservation → reflow.useWorkspaceFilessubscription. The adapter re-identifies when the list arrives, re-running the image node view's memoized dimension read so it reserves the box from the stored dims before the slower image download finishes. Query key is shared (dedupes with surrounding views). Gated behindenabled: !contentSourceso the public share page (which passes a share token asworkspaceId) doesn't fire a 404.@-menu extension and the mention node were both namedmention(Duplicate extension names found: ['mention']). Renamed the menu extension tomentionMenu(node keepsmention, its persisted doc type) + moved its storage key.Type of Change
Testing
mentionwarning confirmed gone.Checklist