Repository navigation
Readable line lengths and inline resolved cell edit functionality - #223
Conversation
- readable line length - unresolved conflicts appear clearly as empty red-hued and red-dashed-bordered cards
- selection inter resolved vs. unresolved (unified, conflicted) rows is messed up - minor style issues
- fixes weird border for resolved rows - looks like the edits don't actually save after we click off.
- respects point clicked - respects selection intra code mirror resolved cell and inter cells of UI
- adds header bar with undo resolution button - different style for deletion of cell
- still a bit buggy on newlines - edit button is ugly :) - prefers simpler button to harder-to-maintain DOM work
…ells - Resolver store only stores total edit, not line by line or word by word edits; we abstract that away to code mirror - Save when "save edit" is called, show a warning nonce when user tries to click off w/o saving. - While cell is being edited, guard against any other global undo actions
Update helpers and all affected specs to match the new UI where resolved cells start in a read-only static view and require an explicit Edit -> save-edits round-trip.
- added regression test to handle this
- now, when a resolved cell is edited, the pressing undo gives a modal checking if the user is comfortable overwriting their commits.
…whilst editing. - currently failing.
the active row only leaves "save edits" available. - extend editWarningOnBlur test that asserts other row actions are disabled until save.
- small cleanups on <pre> paths, unnecessary styles, etc.
…ompt on destructive actions
- guarantees:
- linear history
- no conflicts when trying to edit multiple cells
- cm undo/redo vs global undo/redo still work just fine
- focus => cm undo/redo
- unfocus => global undo/redo
- modal on destructive actions (eg. "Apply resolution" or "Undo Selection")
reverts the last few commits creating the edit mode + modal when clicking off.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughImplements inline resolved-cell editing with draft autosave/unmount-commit, tracks editing rows in store, gates destructive actions (undo/accept-all/history) behind a discard-confirmation modal that can queue the intended action, and updates tests/helpers to use Changes
Sequence DiagramsequenceDiagram
actor User
participant UI as ConflictResolver (UI)
participant Row as MergeRow (Row)
participant Store as ResolverStore
participant Modal as WarningModal
User->>Row: Click "Use ..." / Apply choice
Row->>Store: selectChoice(index, choice, content)
Store->>Store: remove index from editingConflicts
Row->>Row: render static .resolved-cell
User->>Row: Click "Edit"
Row->>Store: startEditing(index)
Store->>Store: add index to editingConflicts
Row->>Row: show CodeMirror editor (draft)
User->>Row: Type (draft)
Row->>Row: update draft refs
User->>Row: Click outside (blur)
Row->>Row: autosave draft
Row->>Store: commitContent(index, resolvedContent)
Store->>Store: update choices, push history, clear takeAllChoice
Row->>Store: stopEditing(index)
Store->>Store: remove index from editingConflicts
Row->>Row: show static .resolved-cell
alt Destructive action while edits exist
User->>UI: Click Undo / Accept All / Jump
UI->>Modal: show "Discard edited resolutions?" (queue action)
alt Keep edits
User->>Modal: "Keep my edits"
Modal->>UI: dismiss queued action
else Discard edits
User->>Modal: "Discard edits"
Modal->>UI: invoke queued action
UI->>Store: perform queued undo/acceptAll/jump
Store->>Store: clear editingConflicts
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test-fixtures/shared/integrationUtils.ts (1)
150-196:⚠️ Potential issue | 🟠 Major
verifyAllConflictsMatchSide()stopped verifying the resolved text itself.This now treats a row as valid when the header says the right side and any resolved-content node exists. If the collapsed preview renders stale or wrong text for that side, the helper still reports success, so UI-only regressions in the resolved view go undetected. Preserve the chosen side’s source before resolving, or have callers pass the expected text so this helper can compare the rendered resolved content as well as the label.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/client/src/components/ConflictResolver.tsx`:
- Around line 106-134: The destructive handlers (undo, redo, jumpToHistory,
acceptAll, handleClearChoice and any other global actions) bypass
guardEditedResolutions and thus can commit/lose edited resolutions via
MergeRow's blur handler; update each place that currently calls the store
directly to instead call guardEditedResolutions(() => originalAction()) or,
where appropriate, early-disable the control when editingConflicts.size > 0;
ensure pendingDestructiveActionRef and setDestructiveActionWarning are used
consistently so the confirmation flow is shared, and add the same guard call for
any other handlers in the file (and the referenced ranges 549-699, 788-795) that
perform destructive/global state changes.
In `@packages/web/client/src/components/MergeRow.tsx`:
- Around line 81-83: The component MergeRow is rendering stale
draftResolvedContent when the editor switches out of edit mode; update the
effects that set draftResolvedContent (the useEffect at the shown block and the
similar blocks at the other noted ranges) to only copy
resolutionState.resolvedContent into draftResolvedContent when the row is
currently being edited (e.g., when isEditing/editingConflicts for this row is
true) or when resolutionState.resolvedContent actually changes while not
editing; otherwise, reset draftResolvedContent to the committed
resolutionState.resolvedContent so read-only mode always shows the committed
content. Reference the MergeRow component and the draftResolvedContent state and
the useEffect callbacks that currently depend on
resolutionState?.choice/resolvedContent and conflictIndex to make this
conditional update.
- Around line 79-80: The blur-suppression flag suppressBlurEditGuardRef.current
is being set in handleSaveEdits() and other handlers but never cleared, so it
incorrectly suppresses the first blur of the next edit session; change
handleSaveEdits() (and the other places that set
suppressBlurEditGuardRef.current, e.g., the other save/cancel handlers around
the referenced blocks) to clear the flag immediately after performing the save
(or schedule clearing on the next tick using setTimeout(...,0)) so
suppressBlurEditGuardRef.current is true only for the brief period needed to
ignore the current blur, and ensure the onBlur guard (the
relatedTarget?.closest('[data-editing-allow="true"]') check) continues to work
as intended.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c4597800-eb5a-4293-9179-b8a1bf8df972
📒 Files selected for processing (12)
apps/vscode-extension/tests/e2eResolution.test.tspackages/web/client/src/components/ConflictResolver.tsxpackages/web/client/src/components/MergeRow.tsxpackages/web/client/src/store/resolverStore.tspackages/web/client/src/styles.tspackages/web/tests/editWarningOnBlur.spec.tspackages/web/tests/perCellResolution.spec.tspackages/web/tests/settingsMatrix.spec.tspackages/web/tests/syntaxHighlighting.spec.tspackages/web/tests/takeAllButtons.spec.tspackages/web/tests/undoRedoActions.spec.tstest-fixtures/shared/integrationUtils.ts
- they all suffer from the same issue:
- editing state => click (WLOG) undo => save current => actually (WLOG) undo
- instead, what we want is to throw the warning modal for destructive actions like that while undoing.
- if "keep editing," scroll to currently editing spot (mindful of virtualization)
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/web/client/src/components/ConflictResolver.tsx (1)
636-648: 🧹 Nitpick | 🔵 TrivialSimplify the redundant block in
onKeyDown.The extra braces around the
handleJumpToHistorycall are unnecessary and inconsistent with the rest of the file's style.♻️ Suggested simplification
onKeyDown={event => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); - { - handleJumpToHistory(index); - setHistoryOpen(false); - } + handleJumpToHistory(index); + setHistoryOpen(false); } }}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/client/src/components/ConflictResolver.tsx` around lines 636 - 648, The onKeyDown handler contains an unnecessary extra block; remove the redundant braces so the handler directly calls handleJumpToHistory(index) and setHistoryOpen(false) when event.key is 'Enter' or ' ' to match the style used in the onClick handler and elsewhere; update the onKeyDown for the same element that references handleJumpToHistory and setHistoryOpen to simply preventDefault() then call those two functions without the extra { } wrapper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/client/src/components/MergeRow.tsx`:
- Around line 78-80: The blur-suppression ref suppressBlurEditGuardRef is left
true when handleSaveEdits sets it then calls onStopEditing, causing the editor
to unmount before onBlur fires and the flag persists into the next edit session;
modify handleSaveEdits (and the other save paths referenced around lines with
suppressBlurEditGuardRef usage) to clear suppressBlurEditGuardRef.current after
calling onStopEditing by scheduling the clear on a microtask (e.g.,
Promise.resolve().then(() => suppressBlurEditGuardRef.current = false)) or
remove the flag entirely and rely on the existing
relatedTarget?.closest('[data-editing-allow="true"]') guard in the onBlur
handler to handle blur-to-save-button cases; update the same pattern where
suppressBlurEditGuardRef is set (including other save handlers) so the flag does
not persist across unmounts.
- Around line 81-83: The read-only view shows stale draft because
draftResolvedContent (managed by setDraftResolvedContent in the useEffect inside
MergeRow) isn't cleared when isEditing becomes false; update the rendering so
that the read-only <pre> uses resolutionState?.resolvedContent directly instead
of draftResolvedContent when not editing, and apply the same change for the
other occurrence mentioned (the block around the symbols at lines ~372-375).
Locate the useEffect that sets draftResolvedContent and the JSX that renders
draftResolvedContent, and conditionally render resolutionState?.resolvedContent
whenever isEditing is false (or editingConflicts was cleared) to avoid showing
uncommitted drafts.
---
Outside diff comments:
In `@packages/web/client/src/components/ConflictResolver.tsx`:
- Around line 636-648: The onKeyDown handler contains an unnecessary extra
block; remove the redundant braces so the handler directly calls
handleJumpToHistory(index) and setHistoryOpen(false) when event.key is 'Enter'
or ' ' to match the style used in the onClick handler and elsewhere; update the
onKeyDown for the same element that references handleJumpToHistory and
setHistoryOpen to simply preventDefault() then call those two functions without
the extra { } wrapper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ff2e0c2c-cef4-4b8a-aefe-347cd891ff90
📒 Files selected for processing (5)
packages/web/client/src/components/ConflictResolver.tsxpackages/web/client/src/components/MergeRow.tsxpackages/web/tests/takeAllButtons.spec.tspackages/web/tests/undoRedoActions.spec.tstest-fixtures/shared/integrationUtils.ts
When a user clicked the Save button while editing a resolved cell, a race condition caused the `suppressBlurEditGuardRef` flag to persist into the next edit session, requiring two blur events to exit edit mode instead of one. Verify the fix by: 1. Enter edit mode on a resolved cell 2. Make some changes 3. Click the Save button 4. Enter edit mode again 5. Click outside the editor (blur) 6. Should exit edit mode on the first blur
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
packages/web/client/src/components/ConflictResolver.tsx (1)
145-159:⚠️ Potential issue | 🟠 MajorUndo/redo/history/take-all still tear down edit mode before the guard opens.
These actions are only guarded in
onClick, unlikeApply Resolutionat Line 719. If a resolved CodeMirror is focused, clicking one of these controls letsMergeRowblur/autosave and callonStopEditingbefore the warning modal appears. Choosing “Keep my edits” then preserves the content, but the edit session is already gone. Give these controls the same pre-blur interception ashandleResolveMouseDown, or disable them whileeditingConflicts.size > 0.Also applies to: 574-699, 719-720
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/client/src/components/ConflictResolver.tsx` around lines 145 - 159, The undo/redo/history/take-all handlers (handleUndo, handleRedo, handleAcceptAll, handleJumpToHistory) call guardEditedResolutions only on click, allowing focused editors to blur/autosave before the guard opens; change these controls to either (a) perform the guard on mouse-down like handleResolveMouseDown (invoke guardEditedResolutions from the onMouseDown handler so blur is prevented until the modal is resolved) or (b) disable the controls while editingConflicts.size > 0 (check editingConflicts.size and set disabled state) so they cannot trigger blur; update the UI event wiring accordingly for those four handlers to ensure pre-blur interception.packages/web/client/src/components/MergeRow.tsx (1)
166-170:⚠️ Potential issue | 🟠 MajorManual save leaves the blur-suppression flag armed for the next edit session.
The blur-to-save-button path is already skipped by the
relatedTarget?.closest('[data-editing-allow="true"]')check at Lines 363-364. After that,handleSaveEdits()setssuppressBlurEditGuardRef.current = trueand immediately unmounts the editor viaonStopEditing, so nothing clears the flag. The next real blur is then swallowed and won't autosave/exit edit mode. Remove the flag from the save path or clear it asynchronously right afteronStopEditing.Also applies to: 358-365
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/client/src/components/MergeRow.tsx` around lines 166 - 170, handleSaveEdits currently sets suppressBlurEditGuardRef.current = true and then calls onStopEditing, leaving the suppression flag armed for the next edit session; update handleSaveEdits (and the duplicate path around the other save call) to either not set the flag at all or clear it asynchronously after unmounting the editor — e.g., call onStopEditing(conflictIndex) then schedule suppressBlurEditGuardRef.current = false on the next tick (setTimeout(..., 0) or queueMicrotask) so the immediate manual-save flow still prevents the blur-guard but subsequent blurs behave normally.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/client/src/components/MergeRow.tsx`:
- Around line 91-98: The current useEffect cleanup captures stale values and
runs on dependency changes causing duplicate callbacks; change to an
unmount-only effect by replacing the current useEffect([...]) with useEffect(()
=> { return () => { ... } }, []) and read current values from refs instead of
the closed-over variables: maintain and update refs for isEditing (e.g.,
isEditingRef.current) and for the latest resolved content (e.g.,
latestResolvedContentRef.current) whenever isEditing or
resolutionState?.resolvedContent change, then in the unmount cleanup compare
draftResolvedContentRef.current to latestResolvedContentRef.current and
conditionally call onCommitContent(conflictIndex,
draftResolvedContentRef.current) and onStopEditing(conflictIndex); keep
references to onCommitContent/onStopEditing/conflictIndex stable or read them
from refs if they can change.
---
Duplicate comments:
In `@packages/web/client/src/components/ConflictResolver.tsx`:
- Around line 145-159: The undo/redo/history/take-all handlers (handleUndo,
handleRedo, handleAcceptAll, handleJumpToHistory) call guardEditedResolutions
only on click, allowing focused editors to blur/autosave before the guard opens;
change these controls to either (a) perform the guard on mouse-down like
handleResolveMouseDown (invoke guardEditedResolutions from the onMouseDown
handler so blur is prevented until the modal is resolved) or (b) disable the
controls while editingConflicts.size > 0 (check editingConflicts.size and set
disabled state) so they cannot trigger blur; update the UI event wiring
accordingly for those four handlers to ensure pre-blur interception.
In `@packages/web/client/src/components/MergeRow.tsx`:
- Around line 166-170: handleSaveEdits currently sets
suppressBlurEditGuardRef.current = true and then calls onStopEditing, leaving
the suppression flag armed for the next edit session; update handleSaveEdits
(and the duplicate path around the other save call) to either not set the flag
at all or clear it asynchronously after unmounting the editor — e.g., call
onStopEditing(conflictIndex) then schedule suppressBlurEditGuardRef.current =
false on the next tick (setTimeout(..., 0) or queueMicrotask) so the immediate
manual-save flow still prevents the blur-guard but subsequent blurs behave
normally.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6d1bdd33-d8a4-421a-8814-1508d0d183e8
📒 Files selected for processing (2)
packages/web/client/src/components/ConflictResolver.tsxpackages/web/client/src/components/MergeRow.tsx
…blur, then clicks button. - each affected control now intercepts onMouseDown, so if a cell is being edited, it'll bring up a warning modal.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/client/src/components/ConflictResolver.tsx`:
- Around line 138-143: confirmDestructiveActionWarning currently calls the raw
store actions (undo, redo, acceptAll, jumpToHistory) directly, bypassing
guardEditedResolutions; change it to invoke the existing safe wrapper handlers
(the onMouseDown-safe wrappers already defined around those actions) so that
after confirmation the guarded handlers run instead of raw actions—locate
confirmDestructiveActionWarning and replace the direct action invocations with
calls to the corresponding safe wrapper functions that call
guardEditedResolutions before dispatching the store actions.
- Around line 301-304: In ConflictResolver.tsx the drag-selection hit test uses
target?.closest(...) and currently checks for '.resolved-content-input' but the
read-only resolved view renders '.resolved-content-static', so starting a
selection there doesn't set isDraggingRef; update the selector used in the
target?.closest call (the one guarding isDraggingRef / drag start logic) to
include '.resolved-content-static' alongside '.resolved-content-input' so the
read-only view is treated the same as the editable one during drag selection.
- Around line 165-176: The modal's action buttons are missing the allow-list
attribute so the CodeMirror blur handler (which early-returns when
relatedTarget.closest('[data-editing-allow="true"]')) still commits via
onCommitContent() before dismissDestructiveActionWarning() or
confirmDestructiveActionWarning() run; update the destructiveActionModal and any
other modal/button elements referenced in handleResolveMouseDown and
mouseDownGuardActiveEditing to include data-editing-allow="true" on both the
"Keep my edits"/dismiss and "Proceed anyway"/confirm buttons so focus
transitions to those buttons bypass the commit in the blur handler.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 10e634a9-e5d8-4bd1-ac0a-61b31d345852
📒 Files selected for processing (2)
packages/web/client/src/components/ConflictResolver.tsxpackages/web/client/src/components/MergeRow.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/client/src/components/MergeRow.tsx`:
- Around line 198-215: The modal opens outside the editor and its focus shift
triggers the editor's blur autosave; to fix, ensure the modal root rendered by
renderViewportModal when showUndoWarning is true includes the editing-allow
marker so the editor ignores the focus move (add data-editing-allow="true" to
the outermost <div> passed into renderViewportModal for the undo warning modal),
and do the same for the other modal usages mentioned (the other
renderViewportModal instances around the same code paths). This ensures clicking
the Cancel/Confirm buttons (handlers cancelUndoResolution and
confirmUndoResolution) won't cause the editor blur autosave to run before those
handlers execute.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 061f43ab-1e9d-4f5b-831b-ef57a281027f
📒 Files selected for processing (1)
packages/web/client/src/components/MergeRow.tsx
- Include `.resolved-content-static` in drag-selection detection. - Mark the destructive-action warning modal as edit-safe via `data-editing-allow`. - Route mousedown-guarded actions (undo/redo/history jump/take-all) through the guarded handlers so confirmations still respect edited-resolution checks.
Readable line lengths look significantly better than not. That being said, designing around this UI was a challenge, mostly I envisioned:
Summary by CodeRabbit
New Features
Bug Fixes
Style
Tests