Skip to content

perf(app): avoid reprocessing settled history during v1 streaming - #4614

Merged
reachjalil merged 3 commits into
devfrom
perf/stable-transcript-rendering
Sep 8, 2026
Merged

reachjalil merged 3 commits into
devfrom
perf/stable-transcript-rendering

Conversation

@reachjalil

Copy link
Copy Markdown
Member

Problem

V1 text streaming updates the transcript array every render flush. Two preparation paths repeated work over unchanged history before React could reuse the message rows:

  • Snapshot/live merging inserted cached-only messages one by one into a growing array, then sorted again. Long caches beyond the 140-message snapshot incurred quadratic chronology scans.
  • Artifact/link extraction rescanned unchanged text and serialized every completed tool result on each update, including completed tools in the active answer.

Change

  • Collect and sort once when message timestamps are unique and finite. Ties, absent/invalid timestamps retain the existing source-neighbor insertion rules. Preserve history, duplicate-ID semantics, and unchanged message references.
  • Cache extraction by immutable part reference, with distinct text role/file-mention variants. Changed parts are rescanned; dedup order and confidence rules remain unchanged. Return fresh target objects to isolate caller mutations.
  • Extend existing unit and streaming journeys. No Markdown renderer, permissions, cache-lifetime, or v2 transport changes.

Deterministic work measurements

Fixed 140-message snapshot, one delta after warming the merge cache. Both merge functions have the same counts:

Cached messages Timestamp reads before After
200 2,092 202
400 34,592 402
800 219,592 802

100 unchanged 10,000-character tool outputs across 20 text-only updates: 2,000 repeated serializations before; zero after warmup. Initial extraction still runs once. These are operation counts, not claims about frame rate or total app speed. History iteration, target merging, sorting, and changed-text scanning remain.

Verification — Passed (v1)

Exact head: a95dda45850974a55d3109d9e0310902dc2504aa.

OPENWORK_EVAL_ENGINE=v1 OPENWORK_EVAL_REF=a95dda45850974a55d3109d9e0310902dc2504aa pnpm evals:e2e streamed-markdown-answer

Cold-boot: 2 passed, 0 failed, 0 skipped, exit 0.
placement: daytona (daytona CLI authenticated).

  • Existing streaming Markdown, reasoning, active-stream reload, settled history and video controls passed.
  • Added v1 journey persists 150 native no-reply messages and 20 shell results through HTTP while the actual SSE subscriber builds history. It verifies ordered/nonduplicated history beyond the 140-message snapshot, advancing answer continuity, old/new tool-output targets, quick-switch cache continuity, target isolation, and the bounded tail after cold reload.
  • Exact-head receipts are published below. Native history is not injected into renderer state.
  • Focused unit checks: 64 passed, 0 failed, 5,917 assertions.
  • pnpm --filter @openwork/app typecheck: passed.
  • Browser callback validation and diff whitespace check: passed.

Earlier attempts: the added journey first exhausted its overall timeout after completing streaming assertions; it now explicitly allows 15 minutes including cold resource setup. A later assertion assumed full cache retention after lengthy palette checks; the existing inactive cache expires at 15 seconds. The final journey separates immediate warm returns from cold reload instead of changing cache policy. All owned sandboxes were deleted.

Broader eval typecheck/ratchet checks were not green during authoring and are not classified as pre-existing. A separate scripts render-state suite could not load a missing export; focused maintained tests above passed. Cross-platform, v2 E2E, frame-time profiling, composer memoization, Markdown tail payload reuse, and cache-lifetime changes remain deferred.

The new journey is an independent addition to the existing streaming spec; it leaves #4585 video/recovery sections unchanged.

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Sep 8, 2026 7:55am UTC
openwork-den Ignored Ignored Sep 8, 2026 7:55am UTC
openwork-diagnostics Ignored Ignored Sep 8, 2026 7:55am UTC
openwork-landing Ignored Ignored v0 Sep 8, 2026 7:55am UTC

@reachjalil

Copy link
Copy Markdown
Member Author

Test evidence — a-streaming-answer-renders-as-markdown-block-by-block-and-settles-to-the-same-do — ✅ passed

SHA a95dda4 · engine v1

✅ passed · 0 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

[world] mock(mcp) · den(daytona) · desktop(as admin) · workspace(/tmp/openwork-streamed-markdown-answer-1788853311562) · [seed:raw] evalIn() ×5 · session("New task")
[probe:raw] [probe:raw] eval()
[user] type(composer, "Write the streamed markdown answer. STREAM_MARKDOWN_ANSWER") · Run task · click(Run task) · see(text=Write the streamed markdown answer. STREAM_MARKDOWN_ANSWER, timeoutMs=2000) · see(text=Streamed answer heading, timeoutMs=90000) · notSee(text=Closing paragraph epsilon.) · notSee(text=## Streamed) · notSee(text=Preparing the formatted response.) · see(label=/^(Thinking…|Thought)$/) · label=/^(Thinking…|Thought)$/ · click(label=/^(Thinking…|Thought)$/) · see(text=Preparing the formatted response.)
[probe] text
[user] notSee(text=Closing paragraph epsilon.) · label=/^(Thinking…|Thought)$/ · click(label=/^(Thinking…|Thought)$/) · notSee(text=Preparing the formatted response.)
[probe:raw] [probe:raw] eval()
[user] notSee(text=Closing paragraph epsilon.) · reload
[probe:raw] [probe:raw] eval()
[user] see(text=Closing paragraph epsilon., timeoutMs=120000) · see(Run task, timeoutMs=60000)
[probe] text
[user] see(text=alpha list item) · see(text=const streamed = "delta";) · notSee(text=/Something went wrong/) · notSee(text=Preparing the formatted response.) · label=Thought · click(label=Thought) · see(text=Preparing the formatted response.)
[probe] text ×2
[probe:raw] [probe:raw] eval()
[user] reload · see(text=Closing paragraph epsilon., timeoutMs=120000)
[probe] text
[user] see(text=Write the streamed markdown answer. STREAM_MARKDOWN_ANSWER) · see(text=Streamed answer heading) · notSee(text=Preparing the formatted response.) · label=Thought · click(label=Thought) · see(text=Preparing the formatted response.)
[probe] text ×2
[probe:raw] [probe:raw] eval() ×2
steps 1 ✅ finished blocks render as markdown while later blocks are still arriving (15.3s) · 2 ✅ live reasoning can be inspected before any reload while the answer is still streaming (7.8s) · 3 ✅ sent text and finished blocks stay visible before reloading the active stream (4.1s) · 4 ✅ the settled answer shows every block exactly once and no markdown syntax (23.3s) · 5 ✅ the settled reasoning is collapsed and can be inspected separately (1.1s) · 6 ✅ sent text and streamed blocks never disappear or duplicate after reload (0.1s) · 7 ✅ a referenced workspace video has controls and plays only when requested (0.4s) · 8 ✅ history renders the same document after a reload (5.9s) · 9 ✅ reloaded reasoning stays collapsed until inspected separately (1.1s)
verdict passed · 22 user observations (see ×13, notSee ×9) · 13 probes · steps 9/9


Test run created 2026-09-08T07:38:13.942Z · Source: evals/results/test-runs/2026-09-08T07-38-13-942Z-a-streaming-answer-renders-as-markdown-block-by-block-and-settles-to-the-same-do/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4614 --test-run 2026-09-08T07-38-13-942Z-a-streaming-answer-renders-as-markdown-block-by-block-and-settles-to-the-same-do

@reachjalil

Copy link
Copy Markdown
Member Author

Test evidence — v1-keeps-long-tool-rich-history-ordered-and-its-detected-links-available-as-the- — ✅ passed

SHA a95dda4 · engine v1

✅ passed · 0 expectations passed · 0 failed · 0 pending

screenshots not attached (gh < 2.99; run brew upgrade gh)

[world] mock(mcp) · den(daytona) · desktop(as admin) · workspace(/tmp/openwork-streamed-markdown-answer-1788853602880) · [seed:raw] evalIn() ×5 · session("New task") · mock(mcp) · den(daytona) · desktop(as admin) · workspace(/tmp/openwork-streamed-tool-history-1788853831839) · [seed:raw] evalIn() ×3 · session("Unrelated history review") · session("Long tool history") · [seed:raw] evalIn()
[probe:raw] [probe:raw] eval()
[probe] desktopApi(GET /workspace/ws_187b66be5b9f/opencode/session/ses_f80009105ffeBLjBAKuwl1qPYA/message?limit=140)
[user] press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "history-tool-01", replace) · see(label=/^history-tool-01\b/) · type(placeholder=Search servers and artifacts..., "history-tool-20", replace) · see(label=/^history-tool-20\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…) · press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "latest-tool-result", replace) · notSee(label=/^latest-tool-result\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…)
[probe:raw] [probe:raw] eval()
[user] type(composer, "Continue the history review and report the latest tool result.") · Run task · click(Run task) · see(text=History review is advancing., timeoutMs=90000) · notSee(text=History review is complete.)
[probe:raw] [probe:raw] eval()
[user] press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "history-tool-01", replace) · see(label=/^history-tool-01\b/) · type(placeholder=Search servers and artifacts..., "history-tool-20", replace) · see(label=/^history-tool-20\b/) · type(placeholder=Search servers and artifacts..., "latest-tool-result", replace) · see(label=/^latest-tool-result\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…) · see(text=The next review section is arriving., timeoutMs=90000) · notSee(text=History review is complete.)
[probe:raw] [probe:raw] eval()
[user] see(text=History review is complete., timeoutMs=120000) · see(Run task, timeoutMs=60000)
[probe:raw] [probe:raw] eval() ×3
[agent] run(session.open)
[user] see(composer, editable) · notSee(text=History review is advancing.)
[agent] run(session.open)
[user] see(text=History review is complete.)
[probe:raw] [probe:raw] eval()
[user] press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "history-tool-01", replace) · see(label=/^history-tool-01\b/) · type(placeholder=Search servers and artifacts..., "history-tool-20", replace) · see(label=/^history-tool-20\b/) · type(placeholder=Search servers and artifacts..., "latest-tool-result", replace) · see(label=/^latest-tool-result\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…)
[agent] run(session.open)
[user] see(composer, editable) · press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "history-tool-01", replace) · notSee(label=/^history-tool-01\b/) · type(placeholder=Search servers and artifacts..., "history-tool-20", replace) · notSee(label=/^history-tool-20\b/) · type(placeholder=Search servers and artifacts..., "latest-tool-result", replace) · notSee(label=/^latest-tool-result\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…)
[probe] desktopApi(GET /workspace/ws_187b66be5b9f/opencode/session/ses_f80009105ffeBLjBAKuwl1qPYA/message?limit=140)
[agent] run(session.open)
[user] reload · see(text=History review is complete., timeoutMs=60000)
[probe:raw] [probe:raw] eval() ×3
[user] press(Control+K) · type(placeholder=Search actions, settings, and sessions…, "Accessible items", replace) · label=/^Accessible items/ · click(label=/^Accessible items/) · type(placeholder=Search servers and artifacts..., "history-tool-01", replace) · see(label=/^history-tool-01\b/) · type(placeholder=Search servers and artifacts..., "history-tool-20", replace) · see(label=/^history-tool-20\b/) · type(placeholder=Search servers and artifacts..., "latest-tool-result", replace) · see(label=/^latest-tool-result\b/) · press(Escape) · notSee(placeholder=Search servers and artifacts...) · press(Escape) · notSee(placeholder=Search actions, settings, and sessions…) · notSee(text=/Something went wrong/)
[probe:raw] [probe:raw] eval()
steps 1 ✅ the live cache retains history older than the native 140-message snapshot (22.9s) · 2 ✅ new tool output becomes accessible without losing old targets while text grows (48.8s) · 3 ✅ settled history and the advancing answer never disappear or duplicate (57.0s) · 4 ✅ switching conversations preserves the full cached history and keeps targets scoped (37.1s) · 5 ✅ cold reload keeps the bounded history tail ordered and old and new tool links usable (18.8s)
verdict passed · 39 user observations (see ×19, notSee ×20) · 14 probes · steps 5/5


Test run created 2026-09-08T07:43:03.505Z · Source: evals/results/test-runs/2026-09-08T07-43-03-505Z-v1-keeps-long-tool-rich-history-ordered-and-its-detected-links-available-as-the/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4614 --test-run 2026-09-08T07-43-03-505Z-v1-keeps-long-tool-rich-history-ordered-and-its-detected-links-available-as-the

@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 (a95dda45850974a55d3109d9e0310902dc2504aa). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit 4d0e30a into dev Sep 8, 2026
27 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]>
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