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
brsbl added a commit that referenced this pull request Oct 18, 2026
## Human comments

## What was wrong

Markdown used a content-height layout that required a scrolling parent.
Plugin file openers render the built-in preview inside a full-height,
overflow-hidden region, leaving long documents without a scroll
container. #5185's offset tracking did not change these layout classes.

## What changed

- Markdown previews now own a bounded scroll container inside the
secondary panel.
- The existing per-tab offset tracking saves and restores that
container.
- A regression covers full-height opener hosts and returning from a
shorter document.

## How you verified

- Remote regression proof: test-only [CI
run](https://github.com/get-bb/bb/actions/runs/38068969721) fails with
`Missing file scroll container`.
- Chrome 155.0.0.0: hard reload, wheel scroll to 800px, short-document
switch, and return restore exactly 800px.
- Final [remote
CI](https://github.com/get-bb/bb/actions/runs/38069347516) passes: all
six Markdown scroll tests, app tests, lint, and typecheck.
- Focused review at 561d36a found no P0–P2 issues; the final follow-up
only formats the test harness.

Before: e9ad6b0 · After: 54ee42f ·
Captured at 2×.
Both captures use the same fixture, Preview tab, and 800px wheel input;
before remains at zero.

| Screen / state | Viewport | Before | After |
| --- | --- | --- | --- |
| Thread Markdown Preview after wheel input | Desktop · 1280×577 |
![Before: clipped
Markdown](https://github.com/user-attachments/assets/c4c22993-08dc-406b-a1b7-4a2bdeb6e22e)
| ![After: Markdown
scrolls](https://github.com/user-attachments/assets/4a0749ce-d7a2-4ff4-8292-a7b406c16f73)
|
| Thread Markdown Preview after wheel input | Compact web · 390×844 |
![Before: clipped compact
Markdown](https://github.com/user-attachments/assets/1659effa-3fe9-4198-b538-25de06c70a63)
| ![After: compact Markdown
scrolls](https://github.com/user-attachments/assets/1cfb189b-86d5-4229-912d-77a888e2a3f9)
|

User QA approval is pending.

<details>
<summary>Preview ownership and fixture</summary>

[Branch dev
app](http://localhost:15456/projects/proj_7p5tk5zht6/threads/thr_78gf3vvetj)
remains running in terminal `term_pbpi7vf66x` on host `host_57pj4zhqxr`,
environment `env_unhfrbci6j`, from this PR worktree via `pnpm dev`. App
port 15456, server port 23456, daemon port 31456. Fresh dev data;
synthetic long and short documents; a minimal file opener delegates to
`Original`. This reproduces the same full-height opener path without
needing a production plugin or personal data.

</details>

Fixes #5336

BB-Thread-ID: thr_frq37qj86d

> AGENT GENERATED
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