Skip to content

fix(editor): preserve Markdown scroll after image layout - #20956

Merged
nwparker merged 2 commits into
mainfrom
neil/sta-7618-the-scroll-position-of-the-md-file-changes-when-switching
Sep 16, 2026
Merged

nwparker merged 2 commits into
mainfrom
neil/sta-7618-the-scroll-position-of-the-md-file-changes-when-switching

Conversation

@nwparker

@nwparker nwparker commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

ELI5

Returning to a Markdown tab containing an image could jump to a different section. Keep the saved reading position when the image finishes laying out.

What Changed

Disable Chromium scroll anchoring on the rich-editor scroll container. Add an Electron regression test that delays image height until after tab restoration and checks both the saved offset and heading position.

Why

Orca already restores the scroll offset. Chromium then independently adjusts it when an image above the viewport gains height, overriding that restoration.

Linked Issue

STA-7618

Visual Proof

Native Windows reproduction on awin (Windows 11 build 26200, Orca 1.4.204-adhoc.20260916003841). Both runs start at 4,000 px / Section 31 and switch to another file tab and back. Windows validated the identical CSS declaration applied to the installed renderer; the patched source was built and tested on macOS.

Before: jumps to 5,177 px / Section 44 After: stays at 4,000 px / Section 31
Before After

Full evidence and platform limits.

Testing

  • Manually tested on native Windows via background Electron/CDP: image-document positions 3,200, 4,000, and 5,000 px are retained with the fix. Plain rich, source, preview, and terminal round trips also pass.
  • Regression test added: markdown-tab-scroll-restore.spec.ts. Before the fix: expected 4,000, received 5,484. Rebuilt patched app: 1 passed.
  • Renderer typecheck (tsc --noEmit -p config/tsconfig.tc.web.json), changed-file quality gate, formatting, and electron-vite build --mode e2e passed.

The exact reported Windows 10 / 1.4.200 binary and original document were unavailable. Linux and SSH-hosted documents were not executed; this changes renderer CSS only, with no host, filesystem, IPC, or path changes.

Review

  • Small, focused change; self-reviewed.
  • Cross-platform and remote behavior considered.
  • No upstream skill code copied.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestions only.

Reviewed changes

  • Disable scroll anchoring on the rich Markdown scroller — adds [overflow-anchor:none] to the scrollContainerRef element so Chromium stops re-anchoring the already-restored scrollTop when an image above the viewport finishes layout.
  • Regression E2E spec — new markdown-tab-scroll-restore.spec.ts seeds a 100-section document with a 400×1500 SVG, forces the image to 1px across a tab round trip, then asserts the restored offset (4000) and the Section 45 heading position both survive the image regaining its height. Verified to fail pre-fix (observed 5484 vs expected 4000), so it is a genuine guard, and it asserts on DOM geometry rather than store state.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 73ae3a82-20a6-47d5-99bb-1ac2ecc7060b

📥 Commits

Reviewing files that changed from the base of the PR and between 4eead71 and 89a72f0.

📒 Files selected for processing (1)
  • tests/e2e/markdown-tab-scroll-restore.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The editor scroll container now disables browser scroll anchoring. The end-to-end test defers fixture cleanup until after Electron shuts down. The final heading position assertion now uses toBeCloseTo with one decimal precision.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 89a72

The scroll-restoration change and its regression test updates do not show an unresolved issue that should block merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving Markdown scroll position after image layout.
Description check ✅ Passed The description is complete and focused. It includes the ELI5 explanation, changes, rationale, linked issue, visual proof, testing results, platform limits, and review notes. The issue is linked, alth…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 240efc2a-6877-47d2-a6d1-654e5e38fdbf

📥 Commits

Reviewing files that changed from the base of the PR and between 357c978 and 4eead71.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/RichMarkdownEditorSurface.tsx
  • tests/e2e/markdown-tab-scroll-restore.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Re-reviewed the delta since the prior pullfrog review (4eead71 → 89a72f0), a test-only hardening commit that addresses the earlier nitpick.

  • Cleanup moved to registerPostElectronShutdownCleanup — replaces the try/finally teardown so fixture removal runs after Electron shuts down, matching the repo convention (Windows keeps worktrees locked until Electron and its daemons exit) and no longer risking teardown noise masking a real assertion failure.
  • Heading-position assertion relaxed — toBe(originalTop) becomes toBeCloseTo(originalTop, 1), absorbing subpixel re-layout after the image regains height while the restored offset is still pinned exactly at 4000, so the spec remains a genuine pre-fix regression guard.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit e39b432 into main Sep 16, 2026
64 of 66 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
)

* fix(editor): preserve markdown scroll after image layout

* test(editor): harden scroll regression cleanup and geometry checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant