Repository navigation
fix(editor): preserve Markdown selection when leaving Find - #35764
brennanb2025 wants to merge 38 commits into
Conversation
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryThe PR publishes completed native selections before Find or editor actions consume them. It also returns panel-owned focus before closing Find.
|
|
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:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8426f35c-3d42-4b83-94c2-02f0df6dfb3d
Files selected for processing: 7-
src/renderer/src/components/editor/RichMarkdownEditorSurface.tsxsrc/renderer/src/components/editor/drag-selection-guard.tssrc/renderer/src/components/editor/rich-markdown-editor-config.tssrc/renderer/src/components/editor/rich-markdown-search-focus.adversarial.test.tssrc/renderer/src/components/editor/rich-markdown-search-focus.test.tssrc/renderer/src/components/editor/rich-markdown-search-focus.tstests/e2e/markdown-find-adversarial.spec.ts
Files with no reviewable changes: 1-
- src/renderer/src/components/editor/RichMarkdownEditorSurface.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
|
Not ready to merge. The repaired adjacent-Find callback passes its immediate-selection and prescribed drag/type outcomes on Windows and macOS. Whole native acceptance remains incomplete; N1 and C1 stay open. CI is green. The existing Windows evidence archive has now been retrieved, verified against the exporter’s size and SHA256, and read together with all six hidden whole-window images. The four formatting originals pass their recorded outcomes: Bold with Find closed, Bold from Find, Bold from genuine Replace, and backward Heading 2 preserve the intended browser/model/cache range, change only the expected document content, and show zero recorded viewport movement through FINAL. Link entry opens without submission and leaves the document unchanged; its original native-null settlement timeout is retained as an entry-only limit. Review-note entry likewise opens on the intended selection with an unchanged document and a successful hidden capture, but its post-capture listener cleanup/Escape and driver completion remain unproved at the time limit. The review-note case and the overall run remain limited. All six capture acknowledgements save the exited helper’s null ExitCode and successful hidden capture facts. Ticket 4155 stays closed; this was retrieval and offline review only, with no new test. N1 and C1 remain open, and the Mac viewport chain remains unaccepted. No completion marker or merge-ready claim is made. Windows ticket 4155: final appearance only; raw events establish earlier selection ordering. These captures do not lift the review-note or whole-run limit. A preceding Windows validation reached the original Bold-with-search-closed case. It made only “alpha” bold, preserved the rest of the document, matched browser/model/cache selection at release and the first toolbar press, and recorded no scroll movement. Independent review confirmed these bounded results. The required hidden whole-window capture succeeded with the window not visible, but the QA runner rejected its capture acknowledgement and stopped; the case remains limited, with no complete-case acceptance. At that point, the other five originals—Bold from Find, Bold from genuine Replace, backward Heading 2, Link entry and review-note entry—were unrun. Launch accepted only the authorized alias warning; the process ID, start time, executable-name and listener-ancestry checks passed. Shutdown required a forced stop after Browser.close timed out. All recorded processes, the lead, terminal, commands and transfers settled within the original 30-minute allowance, and the ticket is released. N1 and C1 remain open; the recorded Mac callback and two geometry reads stand, with its viewport chain still unaccepted. No further ticket, source change, completion marker or merge-ready claim is made. Previous Windows Bold-with-search-closed attempt: final formatting image only; raw events establish that attempt’s recorded selection order. That case remained limited because its capture acknowledgement was rejected. This image is not from the latest six-case retry. After Find moved focus away from rich Markdown, a later Shift-click could extend from the old search match. Closing Find or Replace could also leave Cmd/Ctrl+F unable to reopen it immediately. This PR completes the current browser selection through the editor's existing selection mechanism before an action consumes it, and restores panel-owned focus before removing search. Review used the full path and completed six historical production rounds. The newly commissioned pointer-ordering repair at The integrated viewport repair is tracked in STA-13206/#36781. A frozen install with scripts enabled verified the combined editor dependency patch on the admitted Windows machine. Windows and macOS both pass the original four-cell Find → bare return → immediate copy sequence, preserving exact plain/HTML payload, structured selection, four DOM selection classes, document and viewport. Both also pass the genuine held Replace continuation: the same press reaches the intended neighbouring-cell range, and immediate typing changes only that range. Historical raw failure labels and their narrower acceptance dispositions remain in the private ledger. Known main gaps: missing visible multi-cell fill is pre-existing on main, tracked in STA-13408. The no-Find controls show the same limitation. The separate IME Escape capture gap is tracked in STA-12792. Neither is changed here. The deferred native comparison concern and the tool-limited input remain disclosed in the private ledger; no outcome is claimed for either. For Brennan's review:
Additional bounded Windows Find-owner proof: Mac toolbar consumer evidence:
The first four preserve the intended range, exact formatting-only document change and viewport. Both entries open on the selected Prior Mac text-selection evidence on Mac: Shift-click after Find copies the intended cross-paragraph range. Mac: clicking inside the range establishes the intended caret before Shift-click after Replace. Mac: typing over a backward selection changes only the selected paragraphs. Mac: double-click after Replace selects alpha; immediate typing replaces only that word. Mac: triple-click after Find copies the exact paragraph. Mac: dragging after Replace and typing edits only the intended range. The original copies matched exactly. Typing changed only the intended word or paragraphs; forward and backward ranges retained their direction, and every observed visible-scroller position stayed unchanged. Double-click snapshots retain the observed native/model timing difference; the immediate word replacement and final state passed. These checks use the original copy-event and observer protocol. Prior failing input on The whole capture below shows the correct final typed result; it does not show or prove the earlier immediate selection state. The two original image-selection Escape/reopen checks passed their bounded outcomes, retaining the original settlement timeouts rather than calling them text-selection passes. The adjacent Replace, Details/code and later structured/close cases remain unrun; the fixed five-Tab close/reopen check remains owed. The later Windows text invocation was held before app/driver/native inputs. Windows toolbar formatting and entry evidence is retained, but its required hidden-inspector capture route was unmet; acceptance credit has not been waived. The changed adjacent-Find case has now run on the repaired Windows source through the required hidden inspector with the window not visible. At that point, all six toolbar originals remained unrun after the adjacent case stopped for viewport classification; the subsequent limited Windows results are reported above. The subsequent Mac adjacent-Find result is described below. The review ledger remains open. No completion marker or merge-ready claim is made. On the repaired Windows build, selecting the image and then clicking character 6 of Two earlier macOS attempts supplied no native verdict: the first stopped at the strict clone-path guard because the prepared plan mistook Parent folder for the resulting repository root; the next did not launch an app or driver because setup could not fit its remaining allowance. Those attempts are not passes or product failures. The subsequent corrected macOS run on published Both approved passive geometry reads were saved outside the unchanged callback. Measured content height fell from 4105 to 3993, and the maximum scroll position fell from 3164 to 3052 after the destructive edit. The final position is exactly 3052 with the edited text visible; the previous position no longer fits the final layout. Independent review confirmed this measured contraction and bottom-limited final position, but did not certify the actual scroll writer or every intermediate viewport state. Whole native/viewport acceptance remains uncredited; this Mac geometry does not fill the Windows measurement gap. N1 and C1 remain open. The affected multiple-click proof and other missing original checks retain their existing unrun or limited dispositions; the Windows toolbar results have since been examined separately. Earlier failures and limits are preserved. The test copy, lead and driver stopped and all owned commands and transfers settled within the authorized attempt budget; the QA ticket is released. No additional attempt, source repair, completion marker or merge-ready claim is made. The PR remains not ready. The Windows whole capture shows the final typed result; the earlier immediate state is established by raw events. |
The editor patch is unchanged, so the lock keeps this branch's prosemirror-view hash.
Main requires the source on the review controller. The selection test was the one call that still omitted it.
The add-note button appears only once the editor can name the copy the note belongs to. The selection checks were already passing.




























After using Find in rich Markdown, Shift-click could extend from an old search match instead of the clicked caret. Closing Find or Replace and immediately pressing Cmd/Ctrl+F could also fail to reopen it until the editor was clicked.
This change completes the current selection before Find, formatting, typing or copying consumes it. Clicking text beside an image and native multiple-click selection also update the editor before the next action. The editor checks whether a browser selection came from focus restoration before accepting it as a user selection, including while a drag remains active. Genuine outgoing input is still completed when focus leaves, and the drag keeps its existing lifetime and table protections. Explicit editor focus restores the current model selection before native focus can expose an older range. Frame-based selection reconciliation is removed.
Closing Find or Replace returns panel-owned focus to the editor synchronously before removing the panel. Closing while another pane or control owns focus leaves that control active. Editor-owned close completes pending selection before removing search highlights. Cmd/Ctrl+F can immediately reopen Find.
tracked in STA-12544
tracked in STA-12764
Plan: EditorState remains the sole remembered editor range. One selection-completion operation serves outgoing focus, native notifications and editor consumers. The existing editor engine is patched through the repository's version-pinned dependency patch mechanism so its focus classification, rich selection construction and native projection stay together. No saved caret, separate pointer controller or delayed selection replay is added.
Design: intended — rich table/atom selections, plugin selection construction, embedded controls and native table presentation remain with the current editor engine, which supports structures plain-text pointer controllers lack. Held drags keep their native presentation and complete before an action consumes them; selection-driven UI waits for completion. Explicit focus and external content replacement preserve the current accepted selection. Panel-owned focus returns synchronously on close.
Review path: full — repeated focus-selection bugs, prior delayed-focus/scroll failures, selection ownership, close ordering and teardown. No saved-data, wire or provider changes. Both tickets share one E2E spec and ship together.
Validation on merged revision
98442784: the current PR workflow passed, with static analysis, typecheck, all twelve unit shards, packaging and changed E2E specs. The completed check snapshot has 64 passed checks and 13 intentional skips. Earlier focused evidence remains seventeen unit files (224/224 cases), actual compiler execution across five projects, dependency isolation (22/22 cases), and eight Linux Markdown E2E cases. The unit tests exercise the real patched editor API, selection consumers, lifetime and N/10N operation bounds. The separate Windows-host CI setup repair tracked in #36715 is merged.The viewport repair tracked in STA-13206 landed in #36781 and is integrated here. The combined dependency patch retains both selection completion and passive-focus viewport handling. A scripts-on frozen install on the admitted Windows QA machine completed successfully; remaining native product acceptance is pending.
Earlier native runs retained exact four-cell copy but lost viewport position after returning from Find or Replace. Continued drag input then missed its intended table target. The staged acceptance on revision
98442784now passes on Windows and macOS: Find → bare editor focus → immediate copy preserves exact plain/HTML copy, the four-cell selection and DOM classes, document contents and viewport position (Windows 1985 → 1985; macOS 2036.5 → 2036.5). Missing visible multi-cell highlighting is pre-existing on main, tracked in STA-13408; the no-Find controls have the same limitation. It is outside this PR’s scope.The genuine held-Replace continuation also passes on both platforms. Returning to the editor while the pointer remains down preserves the original press and viewport; continued movement reaches the intended neighbouring-cell target, and immediate typing replaces exactly that range without changing outside content. A later macOS check exposed a harness-only synthetic focus route, also on main, no product caller (source-traced). Its utility-world focus call explicitly blurred Find and bypassed the editor’s page focus method; the viewport moved from 1887 to 0 before Shift-extension and copy could run. Escape, editor clicks, toolbar/menu returns and native Tab use different product paths. No speculative viewport repair is included. Additional original Mac selection, focus-ownership, toolbar and text-input checks passed within their recorded limits. Native acceptance is incomplete, and this PR is not ready to merge. Temporary diagnostic code remains removed.
QA limits; the two synthetic return chains are source-traced in the search close and pointer-return callers:
Prior native acceptance result on
98442784: with Find open on macOS, selecting the image and then clicking character 6 ofBefore atomleft the editor model and cached selection on the image in the immediate recorded snapshot, while the browser caret had moved into the text. The original assertion requiring an immediate text selection failed. The model naturally synchronized 12.3 ms later. The same unchanged callback then dragged across the image and typedxy: it produced exactlyBeforexy atom, removed the image, and preserved all content outside that target. This establishes the failed immediate assertion, not an observed typing-target or outside-content failure. The scroller changed from 3164 to 3052 during the first typing transaction; its cause has not been established.Later native acceptance stopped after that result. The adjacent Replace, editable Details/code, remaining structured/close cases and fixed five-Tab close/reopen check have not completed. The original Windows toolbar outcomes have recorded formatting/entry evidence, but their required hidden-inspector capture route was not met; no waiver or complete pass is claimed. The later Windows text invocation was held before any native input. No completion marker is asserted.
The pointer-ordering repair is now published at
66e1cdf7. Independent review accepted the source and test changes. On the admitted Windows machine, all 60 tests across six named editor files passed with the installed runtime verified against the reviewed patch; the adversarial file also passed after extending its scale contract to ordinary mouseup/click and native multiple-click completion. No existing work bound was relaxed. Full CI on the published repair passed: 64 successful checks and 13 intentional skips, including static analysis/typecheck, all twelve unit shards, packaging and changed E2E specs. Targeted native acceptance remains pending. The earlier failed snapshot is retained as historical evidence, not relabelled a pass.On the repaired Windows build, selecting the image and then clicking character 6 of
Before atomimmediately produced the correct text caret in the model, browser selection and cache. The unchanged drag-and-type sequence then produced exactlyBeforexy atom, removed the image and preserved all preceding content. The scroll position stayed at 3085 through the clicks and drag release, then moved to 2973 at the first document-changing typing transaction. Its cause remains unclassified: that Windows run did not measure content height or scroll maxima. At that point, all six Windows toolbar originals remained unrun; the subsequent limited Windows results are reported above.Two earlier macOS attempts supplied no native verdict: the first stopped at the strict clone-path guard because the prepared plan mistook Parent folder for the resulting repository root; the next did not launch an app or driver because setup could not fit its remaining allowance. Those attempts are not passes or product failures.
The subsequent corrected macOS run on published
66e1cdf7used the parent folder and verified the resultingfixture-sourcerepository, including.git, before opening the file. The byte-identical original adjacent-Find callback ran once. Its immediate snapshot now has the correct text caret in the model, browser selection and cache before the later selection notification. The prescribed drag and firstxytyping produced exactlyBeforexy atom, removed the image and left all 105 outside nodes unchanged. The required whole capture used the hidden inspector with the window not visible; it shows the final typed result, while raw events establish the earlier immediate selection.Both approved passive geometry reads were saved outside the unchanged callback. Measured content height fell from 4105 to 3993, and the maximum scroll position fell from 3164 to 3052 after the destructive edit. The final position is exactly 3052 with the edited text visible; the previous position no longer fits the final layout. Independent review confirmed this measured contraction and bottom-limited final position, but did not certify the actual scroll writer or every intermediate viewport state. Whole native/viewport acceptance remains uncredited; this Mac geometry does not fill the Windows measurement gap.
N1 and C1 remain open. The affected multiple-click proof and other missing original checks retain their existing unrun or limited dispositions; the Windows toolbar results have since been examined separately. Earlier failures and limits are preserved. The test copy, lead and driver stopped and all owned commands and transfers settled within the authorized attempt budget; the QA ticket is released. No additional attempt, source repair, completion marker or merge-ready claim is made. The PR remains not ready.
The existing Windows evidence archive has now been retrieved, verified against the exporter’s size and SHA256, and read together with all six hidden whole-window images. The four formatting originals pass their recorded outcomes: Bold with Find closed, Bold from Find, Bold from genuine Replace, and backward Heading 2 preserve the intended browser/model/cache range, change only the expected document content, and show zero recorded viewport movement through FINAL. Link entry opens without submission and leaves the document unchanged; its original native-null settlement timeout is retained as an entry-only limit. Review-note entry likewise opens on the intended selection with an unchanged document and a successful hidden capture, but its post-capture listener cleanup/Escape and driver completion remain unproved at the time limit. The review-note case and the overall run remain limited. All six capture acknowledgements save the exited helper’s null ExitCode and successful hidden capture facts. Ticket 4155 stays closed; this was retrieval and offline review only, with no new test. N1 and C1 remain open, and the Mac viewport chain remains unaccepted. No completion marker or merge-ready claim is made.
Windows ticket 4155: final appearance only; raw events establish earlier selection ordering. These captures do not lift the review-note or whole-run limit.
A preceding Windows validation reached the original Bold-with-search-closed case. It made only “alpha” bold, preserved the rest of the document, matched browser/model/cache selection at release and the first toolbar press, and recorded no scroll movement. Independent review confirmed these bounded results. The required hidden whole-window capture succeeded with the window not visible, but the QA runner rejected its capture acknowledgement and stopped; the case remains limited, with no complete-case acceptance. At that point, the other five originals—Bold from Find, Bold from genuine Replace, backward Heading 2, Link entry and review-note entry—were unrun. Launch accepted only the authorized alias warning; the process ID, start time, executable-name and listener-ancestry checks passed. Shutdown required a forced stop after Browser.close timed out. All recorded processes, the lead, terminal, commands and transfers settled within the original 30-minute allowance, and the ticket is released. N1 and C1 remain open; the recorded Mac callback and two geometry reads stand, with its viewport chain still unaccepted. No further ticket, source change, completion marker or merge-ready claim is made.
Previous Windows Bold-with-search-closed attempt: final formatting image only; raw events establish that attempt’s recorded selection order. That case remained limited because its capture acknowledgement was rejected. This image is not from the latest six-case retry.