fix(ui): add back file split view#3632
Conversation
PR SummaryLow Risk Overview Updates header actions to cycle modes (including a new split-view button) and adjusts default mode selection when opening/creating files based on whether the file is previewable. Adds and exports a new Written by Cursor Bugbot for commit f2d1a52. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Greptile SummaryThis PR restores the file split-view feature that was lost during a previous refactor. The Key changes:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[File selected] --> B{isJustCreated?}
B -->|Yes| C[previewMode = 'editor']
B -->|No| D{isPreviewable?}
D -->|Yes| E[previewMode = 'preview']
D -->|No| F[previewMode = 'editor']
subgraph hasSplitView [hasSplitView = canEditText AND canPreview]
G["Button: label/icon shows NEXT mode\n(editor→'Split', split→'Preview', preview→'Edit')"]
G -->|click| H[handleCyclePreviewMode]
H -->|editor| I[split]
H -->|split| J[preview]
H -->|preview| K[editor]
end
subgraph previewOnly [canPreview only - currently unreachable]
L["Button: 'Edit' / 'Preview'"]
L -->|click| M[handleTogglePreview\npreview ↔ editor]
end
E --> hasSplitView
F --> FC[Save / Download / Delete actions only]
Last reviewed commit: f2d1a52 |
| const canPreview = file ? isPreviewable(file) : false | ||
| setPreviewMode(canPreview ? 'preview' : 'editor') | ||
| } | ||
| }, [selectedFileId, files]) |
There was a problem hiding this comment.
previewMode resets on every background files refetch
Adding files to this effect's dependency array means that whenever the useWorkspaceFiles query refetches (e.g., on window focus, network reconnect, or after any mutation like a rename/upload/delete), the effect re-runs and resets previewMode to the file's default. A user who manually switches from preview to editor mode will silently have their preference discarded on the next background data refresh.
The original code only had [selectedFileId] as a dependency, which is the correct intent — the mode should only reset when the user navigates to a different file.
The simplest fix is to exclude files from the dependency array with a suppression comment explaining the intent:
| }, [selectedFileId, files]) | |
| }, [selectedFileId]) // intentionally excluding `files` — previewMode should only reset when the selected file changes, not on every refetch |
If the lint warning is a concern, you can capture files in a ref that does not trigger the effect:
const filesRef = useRef(files)
useEffect(() => { filesRef.current = files }, [files])
useEffect(() => {
// ...
const file = selectedFileId ? filesRef.current.find((f) => f.id === selectedFileId) : null
// ...
}, [selectedFileId])
Summary
During a refactor we got rid of file split screens. This adds it back.
Now all files default to preview mode if one exists. They can then toggle to full screen edit -> split screen edit -> back to preview
Type of Change
Testing
Validated that html, md now have split view, icons are correct.
Checklist
Screenshots/Videos