Repository navigation
Description
Summary
The built-in Markdown viewer in the right-hand pane loses its reading position when switching to another tab and returning. Clicking a hyperlink that opens a new browser tab and then returning to the still-open Markdown tab causes the same reset to the top. The tab should retain its position for as long as it remains open.
Versions and environment
- Reproduced against a clean public
maincheckout atfdcc4e3eafb032bfed76b9fd4708abbb75802481on 2026-10-07. - Source investigation: Fedora Linux 44 (Workstation Edition), Node.js v24.15.0, Google Chrome 154.0.8037.92, headless viewport 1400 × 900.
- The original report concerns the bb right-hand Markdown pane; the reporter's desktop version was not independently established.
- Verification used the real
ThreadSecondaryPanel, built-in file preview, Markdown renderer, and application styles in an isolated loopback Vite harness, with deterministic file content. It did not launch or modify the installed desktop runtime. - No agent provider is required. The reporter disabled Markdown PRO and still reproduced the problem; the source/browser reproduction also loaded no plugin.
Steps to reproduce
-
In a bb project checkout, create a long Markdown fixture:
python3 - <<'PY' from pathlib import Path text = "\n\n".join( f"## Section {i}\n\nParagraph {i}." for i in range(1, 81) ) text += "\n\n[Open a new tab](https://example.com/)\n" Path("scroll-repro.md").write_text(text) PY
-
Open
scroll-repro.mdin the thread's right-hand pane. From a terminal in that bb thread,bb thread open scroll-repro.mdopens the file. -
Open another browser tab in the pane, then select the Markdown tab again.
-
Scroll the Markdown document partway down, for example to Section 30.
-
Select the other browser tab, then return to
scroll-repro.md. -
Observe that the document is back at Section 1.
Hyperlink variant:
- With the Markdown document active, scroll down to its Open a new tab hyperlink.
- Click the hyperlink, allowing bb to open/select the new browser tab.
- Return to
scroll-repro.md; observe that it is back at Section 1.
The smallest source-level reproduction needs only a ready long Markdown document, its real secondary-panel tab, and a browser tab. Cached, already-ready document data is sufficient; a file reload is not necessary.
Expected vs actual
Expected: returning to a still-open Markdown tab restores the same reading position, including after opening a hyperlink in a new tab.
Actual: the document returns to the top. The pristine-source headless browser assertions produced:
FAIL ordinary tab switching Expected values to be strictly equal:
0 !== 960
FAIL hyperlink opens a new tab Expected values to be strictly equal:
0 !== 4841
FAIL switch to a short Markdown document and back Expected values to be strictly equal:
0 !== 960
FAIL restore after loading Expected values to be strictly equal:
0 !== 960
PASS closed and reopened document starts at top
{"passed":1,"failed":4}
These are measured scrollTop values in pixels, not an inferred visual reset. Closing and reopening a document was included as a control and correctly started at zero.
Evidence
Investigation report: source trace and browser/test results are recorded in this section. Originating bb investigation: @thread:thr_23dguf3j4u.
Observed lifecycle:
ThreadSecondaryPanelselects only the active surface content.- Activating a browser surface removes the file-preview scroll wrapper. Returning creates a new
[data-file-preview-scroll-container]element with offset zero. - The built-in
MarkdownFilePreviewhas no scroll-state save/restore. - Switching from a long Markdown document to a short one also lets the browser clamp the shared container's offset. Saving the outgoing position in layout-effect cleanup is too late in that case.
Diagnosis: the tab lifecycle discards DOM scroll state without retaining it for the still-open document. No explicit reset policy or documented requirement to restart reading at the top was found.
Local fix verified, not published: record native scroll events in a per-open-tab cache owned by the secondary panel, restore when the ready Markdown body mounts, and prune closed-tab entries. Restore after the document finishes loading, rather than against its loading placeholder. Do not overwrite the saved offset during outgoing cleanup after layout clamping.
Regression coverage uses the real panel, WorkspaceFilePreviewTabContent, and Markdown renderer with mocked file retrieval. Both reported scenarios failed before the fix on repeated runs. Six regression cases pass with the fix: ordinary tab switching, hyperlink return, independent Markdown positions, restoration after loading, outgoing layout clamping, and close/reopen cleanup. The related suites pass 68 tests in total; app typecheck and lint also pass (existing lint warnings remain).
The same browser loop, first against pristine production files from HEAD and then against the local patch, passed all five scenarios after the fix. No installed runtime changes or PR were made.
What you ruled out
- Markdown PRO is not required: the reporter reproduced with it disabled, and the source/browser harness used the built-in viewer without plugins.
- Not dependent on document fetching: ready/cached content reproduces the reset.
- Still reproduces on the tested
maincommit above. - Searched open and closed issues and open PRs using Markdown, preview, scroll, scroll-position, and tab/position terms; no matching report or fix was found.
- Not Markdown file preview: external links do nothing on click — MarkdownPreview gets no linkRouting.onOpenLink, so the target="_blank" default is swallowed #3395: that report concerns external hyperlinks doing nothing, rather than losing the reading position after a tab successfully opens.
- Not Closing a secondary-panel tab jumps to the left neighbor instead of the source tab #3014: that report concerns which tab becomes active after closing another tab, rather than the selected document's scroll offset.
- Not Right panel polish: toggle jump, open/close reflow, tab-strip rough edges #435: that report concerns panel transitions and tab-strip scrolling, rather than document scroll-state retention.
Suggested priority and effort
Required triage metadata: area label ui, built-in issue type Bug. GitHub denied the reporter permission to set both fields (AddLabelsToLabelable and UpdateIssueIssueType); a maintainer needs to apply them. Per the filing guide, priority and effort belong in built-in issue fields, not labels.
Medium priority, likely low effort. Repeated tab navigation interrupts reading long documents; no document data is lost. The current workaround is to manually find the reading position again.
Checks
- Reproduced on the
mainsource commit identified above; installed desktop end-to-end verification is explicitly outside this investigation. - Searched open and closed issues for the same problem.
- Included the originating bb thread reference and investigation evidence; this body ends with the required attribution.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 8, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui,confirmed-repro.Retain Markdown reading offsets for open panel tabs (#5185)