Skip to content

fix(app): persist the reading anchor chosen through Find in the retained history tail - #4780

Merged
yomgui merged 8 commits into
devfrom
e2e/find-reading-anchor
Sep 11, 2026
Merged

yomgui merged 8 commits into
devfrom
e2e/find-reading-anchor

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" → #4724 → #4742 → this): streamed-markdown-answer test 3 (v1 keeps long tool-rich history…) failed at the step choose a reading message inside the retained history tail (#4687's Find → persisted reading anchor claim) with Timed out waiting for persisted visible reading anchor after 10000ms; last value: null — the first time the lane ever reached it (#4742's "Noticed, not touched" item 1).

The persisted anchor was there and in manual mode; what never matched was the ≤ 2 px offset check. SessionSurface gave the find bar its clearance by toggling pt-16 ↔ pt-4 on the scroll container itself. A padding change on the scroller is a CSS scroll-anchoring suppression trigger, so when Find closes the whole transcript shifts up 48 px under the reader, scrollTop does not move and no scroll event fires — the controller never gets a chance to refresh the anchor, which stays 48 px stale. Verified in the app's own Chromium (Electron 43 / Chrome 150) with a minimal scroller: padding-top 16→64→16 leaves scrollTop unchanged and fires zero scroll events (the first visible row's offset jumps −23 → −15 → −23), while the same 48 px change inside the content is anchored (scrollTop 3000 → 3048, one scroll event).

This is a product defect, not a wrong claim (pt-16 predates the anchor persistence work: #2477 vs #4687): opening or closing ⌘F visibly jumps the transcript by 48 px, and a later restore (session switch / reload) lands the reading row 48 px away from where the person left it.

What changed

apps/app/src/react-app/domains/session/surface/session-surface.tsx (one hunk): the scroller keeps a fixed pt-4; while Find owns the surface a 48 px aria-hidden spacer is rendered as the first child of the content column instead. Native scroll anchoring keeps the reading row in place (manual mode), the resulting scroll event lets the controller re-save a truthful anchor, and in sticky-bottom mode the content ResizeObserver re-bottoms exactly as the padding did before. No spec change, no waits.

Stacked on #4724 (origin/e2e/dismiss-dialog-visibility) and #4742 (origin/e2e/history-browse-pageup), merged in with merge commits (no rebase); their files are untouched here. Without them test 3 dies earlier (palette notSee, then browseHistory) and never reaches this step. Once both land, this PR reduces to b3bd4205d.

Proof (Daytona, sha b3bd4205d52da5c5afc98927606255f95b9c276b, OPENWORK_EVAL_REF pinned — sandbox log HEAD is now at b3bd4205)

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, owned by fix(app): keep a brand-new session sendable while its first snapshot loads #4757, unchanged.
  • × test 2 a streaming answer renders as markdown… — Cluster 1/B (fix(app): keep a brand-new session sendable while its first snapshot loads #4757); this run additionally hit a Daytona 502 during Den provisioning (no assertion reached).
  • × test 3 v1 keeps long tool-rich history… — this PR's claim passes. Step trace at this sha (test-run.json, run 2026-09-10T04-36-10-463Z):
    • 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
    • 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
    • PASS settled history and the advancing answer never disappear or duplicate
    • PASS choose a reading message inside the retained history tail (1008 ms; the persisted anchor matched the rendered row within 2 px on the second poll) — red on fix(app): PageUp history browsing settles above the latest turn #4742's head.
    • PASS switching conversations preserves the reading position, full cached history and scoped targets — never reached before; the restored anchor matched on the first poll.
    • FAIL cold reload keeps the bounded history tail ordered and old and new tool links usable — next never-reached step, see below.
  • ✓ CONT-01 restores the exact cumulative prefix…

Two further diagnostic runs of test 3 only (vitest -t, same sha, temporary uncommitted instrumentation after user.reload(), not proof) reproduced steps 1–7 green both times.

Verdict for this PR's claim: Passed (observable passing assertion for the Find → persisted anchor step and for the session-switch restore that depends on it). File-level verdict for streamed-markdown-answer remains Incomplete because of the three failures above. All sandboxes from the three 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; git diff --check origin/dev...HEAD clean.

Warden: bare pnpm warden:check at HEAD b3bd4205d / origin/dev 7d5097d42 (same refs after), exit 0; skills diff-security-review, confidentiality-review, desktop-den-sync-review all completed over the 4 committed source files (includes #4724/#4742 hunks because of the merges) — No findings. Log .warden/logs/89fb6f18-2026-09-10T05-11-20-691Z.jsonl.

Noticed, not touched

  1. Test 3, step cold reload keeps the bounded history tail ordered… — stale claim. With instrumentation, after user.reload() the surface came back with all 152 messages, the saved anchor restored and expectReadingPosition() passed; the step then failed on expect(await orderedHistory()).toEqual(retainedHistory) — expected ['Settled history 001.', …(149)] to deeply equal ['Settled history 054.', …(96)]. de965e2b1 (fix(app): load the whole transcript when opening a session #4695, "load the whole transcript when opening a session") landed after fix(chat): show sent attachments immediately and preserve reading position #4687 wrote this claim and deliberately fetches the snapshot with no limit (session-surface.tsx:1283), so the renderer no longer shows a bounded tail after a cold reload. The claim needs re-expressing (likely toEqual(world.history), plus revisiting retainedHistory.length < world.history.length, which now only describes the raw API) — a product decision I did not make here.
  2. Same step, run 1: readingGeometry returned null for the full 60 s (surface or row absent). Instrumentation on a later run showed the renderer still on "Starting OpenWork — If startup does not finish, reload to try again" immediately after user.reload(), with document.body === null at t≈0; it recovered within 3 s there. Run 1 may be that startup screen persisting; worth a look by whoever owns item 1.
  3. fix(app): PageUp history browsing settles above the latest turn #4742's items 2–3 (post-jumpToLatest smoothJump window; redundant probe.eventually waits in the palette specs) still stand.

…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.
…Find opens or closes

The find bar's clearance toggled padding-top on the scroll container. A padding
change on the scroller is a scroll-anchoring suppression trigger, so the
transcript shifted 48px under the reader with no scroll event and the persisted
reading anchor stayed 48px stale. Render the clearance inside the content
column instead; the browser anchors it and the controller re-saves the anchor.
@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 10:00pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 10:00pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 10:00pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 10:00pm 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 (15258 ms), confidentiality-review (25155 ms), desktop-den-sync-review (26363 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 (b3bd4205d52da5c5afc98927606255f95b9c276b). 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 5a5ac9d3449a1129b850d5d712ce0d7efcefb431 · 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: 5a5ac9d
Status: ✅  Deploy successful!
Preview URL: https://b9241b76.openwork.pages.dev
Branch Preview URL: https://e2e-find-reading-anchor.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 (5a5ac9d3449a1129b850d5d712ce0d7efcefb431). 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 commits, no rebase)

Merge sha: 5a5ac9d3449a1129b850d5d712ce0d7efcefb431 (Merge origin/e2e/history-browse-pageup into e2e/find-reading-anchor, signed G). Merged the updated #4742 (3a20e25f3, which already carries origin/dev), so origin/dev is contained and a separate git merge origin/dev is a no-op. No conflicts: the session-surface.tsx hunk (fixed pt-4 scroller + in-flow 48 px spacer while Find owns the surface) auto-merged over #4838/#4844/#4845/#4846.

Premise re-check (mandatory here — Jalil #4846 eaef65ce9 "preserve reading navigation during history loading"). #4846 makes Find call markScrollGesture before scrollIntoView (onBeforeJump), cancels a pending late-result jump on SESSION_SCROLL_NAVIGATION_EVENT, and owner-keys the persisted positions. It does not touch the clearance: dev's scroller still toggles ${findOwned ? "pt-16" : "pt-4"} on the scroll container, i.e. the scroll-anchoring suppression trigger that leaves the saved anchor 48 px stale when Find closes. #4846's body also says the Find-clearance change in #4780 is not duplicated. Still needed.

Proof at 5a5ac9d34 (OPENWORK_EVAL_REF pinned; sandbox log HEAD is now at 5a5ac9d3):

OPENWORK_EVAL_REF=5a5ac9d3449a1129b850d5d712ce0d7efcefb431 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/…-v1-keeps-long-tool-rich-history-…, gitSha 5a5ac9d34):

  • 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
  • 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
  • PASS settled history and the advancing answer never disappear or duplicate
  • PASS choose a reading message inside the retained history tail (1491 ms) — this PR's claim; red at fix(app): PageUp history browsing settles above the latest turn #4742's merged head 3a20e25f3 one run earlier (Timed out waiting for persisted visible reading anchor after 10000ms), green here.
  • FAIL switching conversations preserves the reading position, full cached history and scoped targets — expected [ 'Settled history 082.', …(68) ] to deeply equal [ 'Settled history 001.', …(149) ]. The reading position restored (that part of the step is the expectReadingPosition() poll, which passed), then the one-shot orderedHistory() read saw only rows 082–150.

Attribute the step-7 red to #4838 first. At this branch's pre-resync head b3bd4205d the same step passed (see the PR body: "never reached before; the restored anchor matched on the first poll"); the spec text is unchanged and the only delta is origin/dev. Rows 082–150 = the groups around the saved anchor (~130) plus the latest group, which is exactly #4838's progressive mounting on re-open ("mount whole message groups near the reading anchor first … fill remaining groups in bounded background batches"). The spec's claim "full cached history" is expressed as a single immediate read; under dev's loading model it is only eventually true. I did not change the assertion here (out of this PR's scope; no waits/loosening) — it needs a decision: re-express the read as a settle (as expectReadingPosition already is) in a spec-only change, or have #4838 finish mounting before the restored anchor reports settled. The same pattern applies to #4792's cold-reload step (toEqual(world.history) right after expectReadingPosition()), which this run could not reach.

Other tests, none this PR's claim: × test 1 existing: Send clears the input before server acceptance — expected '\n' to be '' (Cluster 1/B, #4757); × test 2 step 2 live reasoning can be inspected before any reload while the answer is still streaming — Target remained visible: {"text":"Preparing the formatted response."} (same as at 3a20e25f3; not yet attributed, dev control queued); ✓ CONT-01.

Verdict for this PR's claim: Passed on the merged head. File-level verdict: Incomplete (above).

Also: pnpm --filter @openwork/app typecheck exit 0; bun test --isolate ./tests/session-scroll.test.tsx ./tests/find-bar.test.tsx ./tests/session-history.test.tsx 53 pass / 0 fail; git diff --check origin/dev...HEAD clean. All 7 Daytona sandboxes from this run were deleted (verified against daytona sandbox list).

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

@yomgui
yomgui merged commit d639727 into dev Sep 11, 2026
29 checks passed
yomgui added a commit that referenced this pull request Sep 11, 2026
…tended transcript load (#4792)

* fix(app): close the restart prompt and command palette synchronously 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.

* fix(session): keep a focus reveal as the reading position instead of snapping back to the tail

* fix(app): keep the reading position and its saved anchor stable when Find opens or closes

The find bar's clearance toggled padding-top on the scroll container. A padding
change on the scroller is a scroll-anchoring suppression trigger, so the
transcript shifted 48px under the reader with no scroll event and the persisted
reading anchor stayed 48px stale. Render the clearance inside the content
column instead; the browser anchors it and the controller re-saves the anchor.

* test(evals): expect the whole transcript after a cold reload in the long-history journey

`de965e2b1` (#4695) deliberately fetches the session snapshot without a
`limit`, so a cold open renders every message instead of the newest 140.
The step written by #4614 still expected the bounded 97-row tail after
`user.reload()` and failed once #4780 let the lane reach it.

Re-express the claim as `toEqual(world.history)`, keep the reading-anchor
restore and the tool-link checks, and keep the engine's `?limit=140` page as
the negative witness: it still lacks the oldest turn that the reopened
surface must show.

---------

Signed-off-by: Guillaume Loret <[email protected]>

This branch was successfully deployed

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