mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
Three bugs from Cursor Bugbot follow-up review:
1. Stale closure in handleEditorMount (Medium): useCallback([], []) captured
content='' at first render. When Monaco mounts after content loads (e.g.
switching from preview to editor mode), lastSyncedContentRef was never
initialized and external content changes stopped syncing. Fixed by keeping
a contentRef updated on every render and reading it inside handleEditorMount.
2. XLSX Ctrl+S discards active cell edit (Medium): handleSave read from
workbookRef.current before DataTable's in-progress editValue was committed.
Fixed by exposing commitEdit() from DataTable via useImperativeHandle
(using an always-current editStateRef so the handle stays stable) and
calling it at the top of handleSave.
3. Async workbook mutation fragility (Low): handleCellChange / handleHeaderChange
updated the workbook inside import('xlsx').then(), creating microtask-order
coupling with handleSave. Fixed by caching the xlsx module in xlsxModuleRef
on first parse and using it synchronously in both handlers.