Skip to content

Retain Markdown reading offsets for open panel tabs - #5185

Merged
SawyerHood merged 1 commit into
mainfrom
slopcop/issue-5181
Oct 9, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
slopcop/issue-5181

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · new-issue-autopilot

Human comments

What was wrong

The secondary panel renders only the active file surface. Activating a browser surface removes the file's scroll container, and returning recreates it at offset zero. Switching to a shorter document can also clamp the shared wrapper. No scroll state outlives the ready Markdown body, even though its tab remains open. See the verified reproduction report.

What changed

  • Cache ephemeral positions by open panel tab ID and prune closed-tab entries.
  • Save native scroll events while the ready Markdown body is mounted; restore in its layout effect, not against a loading skeleton.
  • Remove listeners without saving during outgoing cleanup, avoiding layout-clamped offsets.
  • Add focused panel regressions for tab and hyperlink returns, separate document positions, delayed loading, and close/reopen cleanup.

The patch stays in the existing secondary-panel subsystem: 4 files, 284 additions + 6 deletions = 290 changed text lines. No dependency, stored-data, public API, CLI, protocol, or schema change is required.

How you verified

  • Authored the regression before the production fix. On trusted main, four reading-position tests fail with expected +0 to be 780; the close/reopen control passes. Repeated in a second clean checkout, then refreshed onto 178fd3c2c4aeef162dea517d850ead11f3b034df and reproduced again.
  • After the fix, 67 tests pass across the new regression and the existing file preview, panel collapse, and Markdown image-routing suites.
  • Native Chrome source-UI reproduction: 4 failures / 1 control pass before; all 5 scenarios pass after, including a real long-to-short layout clamp and restoration after loading.
  • pnpm exec turbo run test --filter=@bb/app -- src/components/secondary-panel/ThreadSecondaryPanel.markdown-scroll.test.tsx src/components/secondary-panel/ThreadSecondaryPanel.collapseControl.test.tsx src/components/secondary-panel/FilePreview.test.tsx src/components/secondary-panel/ThreadSecondaryPanelTabContent.markdown-images.test.tsx
  • pnpm exec turbo run typecheck lint --filter=@bb/app passes; lint retains existing warnings.
  • git diff --check passes; the fix has no binary changes.

The browser harness uses real source components with deterministic file retrieval and a local browser-surface activation callback. Installed desktop and Safari verification are not claimed.

Fixes #5181

AGENT GENERATED

@SawyerHood
SawyerHood merged commit bb5a62f into main Oct 9, 2026
28 checks passed
@SawyerHood
SawyerHood deleted the slopcop/issue-5181 branch October 9, 2026 16:15
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.

Markdown viewer loses scroll position when switching tabs or returning after opening a hyperlink

1 participant