Skip to content

fix(app): PageUp history browsing settles above the latest turn - #4742

Merged
yomgui merged 4 commits into
devfrom
e2e/history-browse-pageup
Sep 11, 2026
Merged

yomgui merged 4 commits into
devfrom
e2e/history-browse-pageup

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Root cause

Triage cluster 7/K follow-on (reports/e2e-red-2026-09-09/triage.md, "Dismiss-then-notSee races"; PR #4724 fixed the dismiss race and reported this next failure): streamed-markdown-answer test 3 (v1 keeps long tool-rich history…) fails in browseHistory — added by #4683, reworked by #4687, never executed on the lane before — with keyboard browsing settles above the latest turn … expected 561 to be greater than or equal to 657.

The numbers pin it: the transcript viewport is ≈600 px tall, so PageUp scrolls 0.875 × 600 ≈ 525 px; at scroll-bottom the last user row sits at top ≈ 36 (the 20 shell-tool messages are below it); 36 + 525 = 561. PageUp was therefore pressed from the bottom, not from row 74 — the scrollIntoView performed by user.click(text=Settled history 075.) had already been undone.

Why (scroll-controller.ts): a scrollIntoView is not a wheel/key/pointer gesture, so handleScroll ignored it and the store stayed in stickyBottom. The click's pointerup then ran reconcile(), which in stickyBottom mode with the view not at the bottom calls scrollToBottom(). During streaming the ResizeObserver reconcile does the same on the next chunk. This is a product defect, not only a harness artefact: user bubbles are tabIndex=0, so Tab/Shift+Tab-focusing an older message scrolls it into view the same way, and the next click or streamed chunk yanks the reader back to the tail.

What changed

apps/app/src/react-app/domains/session/surface/scroll-controller.ts: in handleScroll's non-gesture branch, a scroll that leaves the view away from the bottom while the store is in stickyBottom (history ready, not restoring, no smooth jump in flight) now becomes the manual reading position (setManualScroll with the visible anchor) and cancels the pending re-bottom frame. The existing manual-mode anchor refresh is unchanged; live-tail clamping (still exactly at bottom) is unaffected. No spec was changed and no waits were added.

apps/app/tests/session-scroll.test.tsx: one focused regression in the existing file (focus reveal → click → resize keeps the position; clamping stays sticky). Red on origin/dev, green here — a unit check, not proof.

Stacked on #4724 (origin/e2e/dismiss-dialog-visibility, merged in via merge commit rather than rebase): without it test 3 dies earlier at the palette notSee and never reaches browseHistory (verified: run at e1397c664, dev-only base, failed at expectTargets line 188). Once #4724 lands this PR reduces to e1397c664.

Proof (Daytona, sha e1183df89444072f6438cddc91a5fa9c802d11ef, OPENWORK_EVAL_REF pinned — sandbox log HEAD is now at e1183df8)

pnpm evals:e2e streamed-markdown-answer --daytona

Placement line: {"command":"evals:e2e","lane":"e2e","daytona":true,"placement":"daytona","engine":"legacy","surface":"legacy","case":null,"vision":"defer","files":["streamed-markdown-answer"],"passed":1,"failed":3,"skipped":0,"skips":[],"consented":["OPENWORK_EVAL_E2E_TESTS"],"verdict":"failed"}

→ passed 1 / failed 3 / skipped 0.

  • × test 1 sending clears the composer… — triage Cluster 1/B (draftText is "\n"), out of scope, unchanged.
  • × test 2 a streaming answer renders as markdown… — Cluster 1/B (fresh-session send never starts: Streamed answer heading never appears), out of scope, unchanged.
  • × test 3 v1 keeps long tool-rich history… — this PR's claims pass. Step trace at this sha:
    • PASS the live cache retains history older than the native 140-message snapshot
    • PASS sending from older history reveals the exact latest user row above the composer without Jump to latest (contains the first browseHistory: click row 74 → PageUp → keyboard browsing settles above the latest turn satisfied, then the submitted row is revealed)
    • PASS new tool output becomes accessible without losing old targets while text grows
    • PASS passive streamed output does not jump away from the history being read (second browseHistory, mid-stream, then anchor movement ≤ 2 px over the whole stream)
    • PASS settled history and the advancing answer never disappear or duplicate
    • FAIL choose a reading message inside the retained history tail — Timed out waiting for persisted visible reading anchor after 10000ms; last value: null. This is fix(chat): show sent attachments immediately and preserve reading position #4687's Find → persisted reading-anchor claim, reached for the first time on the lane. By code path this change is inert there: the store is already in manual mode from the preceding PageUp gesture, and the new branch only acts in stickyBottom. Not touched here (see below).
  • ✓ CONT-01 restores the exact cumulative prefix…

Verdict for this PR's claim (browseHistory settles above the latest turn, idle and mid-stream): Passed — both occurrences have observable passing assertions in the trace. Spec-level verdict for the file remains Incomplete because of the three unrelated failures above. All six sandboxes from both runs were deleted by the testkit (verified with daytona sandbox list).

Also: pnpm --filter @openwork/app typecheck exit 0; bun test --isolate ./tests/session-scroll.test.tsx 15 pass / 0 fail; ./tests/live-step-scroll.test.ts 10 pass / 0 fail; git diff --check clean.

Warden: bare pnpm warden:check at HEAD e1183df89 / origin/dev 4e634905e (same refs after), exit 0, skills diff-security-review, confidentiality-review, desktop-den-sync-review all completed over the 4 committed files (includes #4724's two files because of the merge) — No findings. Run 61bd4837-2026-09-10T03-18-33-914Z.

Noticed, not touched

  1. fix(chat): show sent attachments immediately and preserve reading position #4687 follow-up (blocks the rest of test 3): after Find in conversation → Settled history 130. → Close find, the persisted scroll state is manual with an anchor, but readingGeometry(anchor.messageId) never matches within 10 s (anchor messageId changed once between the first two polls, then stayed stable). Candidates: the pt-16 → pt-4 padding change on close shifting content without a compensating scroll event, or an offset drift > 2 px between the saved anchor and the rendered row. Needs one instrumented run (saved anchor vs. visible rows) — the steps after it (switching conversations preserves the reading position…, cold reload…) have never run either.
  2. After a smooth jumpToLatest, smoothJump stays true until the next gesture/auto-bottom, so a focus reveal in that narrow window still won't become the reading position. Minor; left alone for the smallest diff.
  3. command-palette-search / command-palette-pin-rename still carry probe.eventually(… footer disappears) waits that fix(app): close the restart prompt and command palette synchronously on dismiss #4724 makes unnecessary.

…on dismiss

Base UI keeps a dialog popup mounted (and partially opaque) until its exit
animation or transition finishes, so the restart prompt and the command
palette stayed visible for 100-200 ms after Keep working / Escape. Hide the
popup with display:none as soon as it is closed; Base UI then unmounts it on
the next frame.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 10, 2026 9:40pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 9:40pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 9:40pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 9:40pm UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (11141 ms), confidentiality-review (26149 ms), desktop-den-sync-review (13508 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 2
  • Distinct heads in retained window: 2
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 2/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (e1183df89444072f6438cddc91a5fa9c802d11ef). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit 3a20e25f323d8ebc6ff10d9b5d5d88b611a19265 · selected evidence

Open review report

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3a20e25
Status: ✅  Deploy successful!
Preview URL: https://1a2448a5.openwork.pages.dev
Branch Preview URL: https://e2e-history-browse-pageup.openwork.pages.dev

View logs

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (3a20e25f323d8ebc6ff10d9b5d5d88b611a19265). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Resync against origin/dev 0b219dc4e (merge commit, no rebase)

Merge sha: 3a20e25f323d8ebc6ff10d9b5d5d88b611a19265 (Merge remote-tracking branch 'origin/dev' into e2e/history-browse-pageup, signed G).

Premise re-check (Jalil #4838 4462762b4, #4844 537aeef31, #4845 eff77792a, #4846 eaef65ce9). #4838/#4846 rewrote transcript loading (newest 24 first, uncapped background read, owner-keyed positions, SESSION_SCROLL_NAVIGATION_EVENT, Find→markScrollGesture via onBeforeJump). None of them changes handleScroll's non-gesture branch: on dev a scrollIntoView reveal from focus/click still leaves the store in stickyBottom and the next reconcile()/ResizeObserver re-bottoms the view. Both PR bodies say explicitly that the #4742 PageUp/focus-reveal fix is not included. So this PR is still needed, not redundant.

Conflict — apps/app/src/react-app/domains/session/surface/scroll-controller.ts (one hunk, the non-gesture branch): kept this PR's structure (manual-mode anchor refresh + new stickyBottom → setManualScroll on a non-gesture reveal, cancelFrames()) and adopted dev's scrollKey (owner-qualified key from #4846) in both setManualScroll calls. Everything else (rememberGeometry, refresh, navigation event, session-scroll.test.tsx) auto-merged.

Proof at 3a20e25f3 (OPENWORK_EVAL_REF pinned; sandbox log HEAD is now at 3a20e25f):

OPENWORK_EVAL_REF=3a20e25f323d8ebc6ff10d9b5d5d88b611a19265 pnpm evals:e2e streamed-markdown-answer --daytona

{"placement":"daytona","engine":"legacy","files":["streamed-markdown-answer"],"passed":1,"failed":3,"skipped":0,"verdict":"failed"}

  • test 3 v1 keeps long tool-rich history… step trace (evals/results/test-runs/2026-09-10T22-01-45-086Z-…, gitSha 3a20e25f3):
    • PASS the live cache retains history older than the native 140-message snapshot
    • PASS sending from older history reveals the exact latest user row above the composer without Jump to latest — first browseHistory (click row 74 → PageUp → keyboard browsing settles above the latest turn) — this PR's claim, idle
    • PASS new tool output becomes accessible without losing old targets while text grows
    • PASS passive streamed output does not jump away from the history being read — second browseHistory mid-stream — this PR's claim, streaming
    • PASS settled history and the advancing answer never disappear or duplicate
    • FAIL choose a reading message inside the retained history tail — Timed out waiting for persisted visible reading anchor after 10000ms; last value: null — fix(app): persist the reading anchor chosen through Find in the retained history tail #4780's Find-clearance defect, unchanged from this PR's original proof; fix(app): persist the reading anchor chosen through Find in the retained history tail #4780 is being resynced on top of this head.
  • ✓ CONT-01.
  • × test 1 — World setup timed out after a Daytona connection reset by peer while starting the Den stack (provisioning; no assertion reached). Out of scope (fix(app): keep a brand-new session sendable while its first snapshot loads #4757 cluster).
  • × test 2 — now fails one step later than before: step 1 finished blocks render as markdown… passes, step 2 live reasoning can be inspected before any reload while the answer is still streaming fails Target remained visible: {"text":"Preparing the formatted response."}. Different signature from the pre-merge run (Streamed answer heading never appears); not this PR's claim. Not yet attributed — needs a clean origin/dev control of the same spec before anyone calls it pre-existing (queued after the remaining resync proofs).

Verdict for this PR's claim: Passed on the merged head (both browseHistory assertions observable in the trace). File-level verdict for streamed-markdown-answer: Incomplete (tests 1/2 and step 6 above).

Also: pnpm --filter @openwork/app typecheck exit 0; bun test --isolate ./tests/session-scroll.test.tsx ./tests/live-step-scroll.test.ts 36 pass / 0 fail; git diff --check origin/dev...HEAD clean. All 5 Daytona sandboxes from this run deleted (verified by name against daytona sandbox list).

Still stacked on #4724 (open); once it lands this PR reduces to the scroll-controller.ts + session-scroll.test.tsx hunks.

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

#4747 revert check (#4870 on dev 858414c41): this branch does not contain 561b5c03a (git merge-base --is-ancestor 561b5c03a… HEAD → false; its merged ancestors do not either) and git diff origin/dev...HEAD -- apps/app/src/react-app/shell/desktop-runtime-boot.ts is empty. No in-branch revert needed.

@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Dev control for the test 2 red — OPENWORK_EVAL_REF=0b219dc4e5f2868c258dbe960d58c657dbe8d99b pnpm evals:e2e streamed-markdown-answer --daytona from a clean detached origin/dev worktree (sandbox log HEAD is now at 0b219dc4): passed 1 / failed 3 / skipped 0. Test 2 fails the same way on clean dev — step 1 finished blocks render as markdown… PASS, step 2 live reasoning can be inspected before any reload while the answer is still streaming FAIL Target remained visible: {"text":"Preparing the formatted response."} — so it is pre-existing on dev 0b219dc4e, not introduced by this branch. It is a new signature relative to the pre-dev base (there test 2 never got past the first send), so attribute it to today’s chat batch (#4838/#4844/#4845/#4846) first. Also on clean dev: test 3 fails at step 1 (Target remained visible: {"placeholder":"Search actions, settings, and sessions…"}) — the #4724 dismiss race, i.e. #4724 is still needed; test 1 expected '\n' to be '' (#4757 cluster); CONT-01 passes. All 7 control sandboxes deleted.

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 3a20e25f Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-app — 3a20e25f Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 3a20e25f Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 3a20e25f Deployed Sep 10, 2026 by vercel[bot]
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