Skip to content

perf(chat): prioritize visible thread history and preserve scroll - #4838

Merged
reachjalil merged 2 commits into
devfrom
perf/thread-viewport-loading
Sep 10, 2026
Merged

reachjalil merged 2 commits into
devfrom
perf/thread-viewport-loading

Conversation

@reachjalil

Copy link
Copy Markdown
Member

Summary

Opening a conversation currently waits for the entire transcript, mounts all message groups, and delays loading feedback for two seconds. This change prioritizes the part the person is reading while retaining access to the complete history.

  • Add a transcript-scoped Suspense boundary with immediate, accessible loading feedback; keep the composer and surrounding pane mounted.
  • Read the newest 24 messages first, or the saved reading message and nearby native message IDs. Start the uncapped full-history read after a paint opportunity; never treat the preview as complete history.
  • Mount whole message groups near the reading anchor first, keep the latest group available, and fill remaining groups in bounded background batches. Preserve the visible anchor or bottom while replacing estimated spacers.
  • Persist bounded scroll-height and nearby-ID hints, cache measured group heights by session and width, and retain legacy reading anchors without consuming missing or clamped positions prematurely. Find requests all groups; input takes precedence over restoration.
  • Preserve the newly merged follow-up interruption behavior: explicit sends reuse or finish the complete history read rather than deciding what to interrupt from a partial preview.

No permanent history truncation or virtualized eviction. No message bodies or tool outputs are added to persisted scroll state. The independent PageUp and Find-clearance fixes in #4742 and #4780 are not included.

Verification

Verdict: Incomplete. The selected component/native-adapter checks pass, but exact-head real-app evidence and latency measurements are still missing. No measured speedup is claimed.

Candidate: d71c725fb7f043d52e1eb7583b2091af87475f46, rebased on dev at 23143497940c871bda4a9aaebb82bd86c3f95530. Both included commits are signed.

Passed, from apps/app:

bun test --isolate ./tests/session-history.test.tsx ./tests/session-scroll.test.tsx ./tests/progressive-message-list.test.tsx ./tests/opencode-session-native.test.ts ./tests/message-list-loading.test.tsx ./tests/chat-message-grouping.test.ts
./node_modules/.bin/tsc --noEmit
git diff --check
  • Focused tests: 105 passed, 0 failed, 0 skipped, 833 assertions; exit 0.
  • App typecheck and whitespace check: exit 0.
  • Tests cover staged reads, Suspense feedback, saved-region lookup, stale-owner exclusion, native read cancellation, progressive mounting, geometry retention, clamped anchors, and complete-history reuse for sends. DOM geometry in component tests is simulated, not browser-layout proof.

Deferred / not passing evidence:

  • The existing session-full-history-on-open journey now checks the newest message is visible without scrolling and stays visible while the rest mounts, but has not been run on this candidate. Run from the repository root with the authorized placement:
    pnpm evals:e2e session-full-history-on-open
  • Cold-load latency, native browser anchoring, rapid-switch/split-pane end-to-end behavior, and published exact-head evidence remain unverified.
  • A separate earlier step-fold component probe reported missing PlatformProvider fixture setup. It was not revalidated and is not counted as passing or classified as pre-existing.

One unusually large assistant group still mounts as a unit. Required repository CI remains unchanged.

@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 7:46pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 7:46pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 7:46pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 7:46pm UTC

@github-actions

Copy link
Copy Markdown
Contributor

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

Commit d71c725fb7f043d52e1eb7583b2091af87475f46 · selected evidence

Open review report

@github-actions

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 (161507 ms), confidentiality-review (265461 ms), spec-provenance-review (169783 ms), desktop-den-sync-review (351524 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • 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: 1/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 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 (d71c725fb7f043d52e1eb7583b2091af87475f46). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit 4462762 into dev Sep 10, 2026
27 checks passed
yomgui added a commit that referenced this pull request Sep 11, 2026
…s mid-send (#4894)

Since #4838 an explicit send awaits the uncapped snapshot read
(ensureFullSnapshot) so it can decide against complete history whether
to interrupt delegated work. That read is owned by the surface's useQuery
observer. Development builds run every mount effect twice (StrictMode
simulates an unmount), so the hero's one-step Run task, which fires from
a mount effect, always saw its reader drop and re-subscribe while the read
was in flight; TanStack cancelled the read (CancelledError, revert) and
the send treated it as a failure: the pending row vanished, the draft and
attachments came back as ready chips, a CancelledError card appeared, and
no upload started.

When the reader is still present after the cancellation, read again
instead of failing the send. Once nobody observes the thread anymore the
cancellation stands, so history actions abandoned by navigation behave as
before.

Signed-off-by: Guillaume Loret <[email protected]>
reachjalil added a commit that referenced this pull request Sep 13, 2026
…read

After a restart, reopening a thread whose turn was interrupted and typing the
next message could show it as pending and then hand the text back to the
composer with an error. Since #4838 the send waited on the uncapped
complete-history read so a follow-up could tell whether it must interrupt a
delegated task; on a cold engine that read can outlast the renderer's request
timeout, and the timed-out read failed the send itself.

Decide the interruption from cached complete history when the thread has it,
otherwise from one bounded newest read, and never block a send on the uncapped
read. Keep a transport failure's own message when the SDK settles without a
response instead of surfacing a TypeError in its place.

Proof: evals/specs/thread-continues-after-restart.e2e.test.ts covers a crash
(SIGKILL of the process group), an ordinary quit, and a relaunch whose
complete-history read is slower than the request timeout; each case requires
the typed continuation to be accepted exactly once, answered, and never
returned to the composer, with earlier history intact and no replay of the
interrupted tool. The slow-read case bounces the message on the previous
send path. Unit coverage in session-history.test.tsx and
opencode-session-native.test.ts.
reachjalil added a commit that referenced this pull request Sep 13, 2026
…read (#4958)

After a restart, reopening a thread whose turn was interrupted and typing the
next message could show it as pending and then hand the text back to the
composer with an error. Since #4838 the send waited on the uncapped
complete-history read so a follow-up could tell whether it must interrupt a
delegated task; on a cold engine that read can outlast the renderer's request
timeout, and the timed-out read failed the send itself.

Decide the interruption from cached complete history when the thread has it,
otherwise from one bounded newest read, and never block a send on the uncapped
read. Keep a transport failure's own message when the SDK settles without a
response instead of surfacing a TypeError in its place.

Proof: evals/specs/thread-continues-after-restart.e2e.test.ts covers a crash
(SIGKILL of the process group), an ordinary quit, and a relaunch whose
complete-history read is slower than the request timeout; each case requires
the typed continuation to be accepted exactly once, answered, and never
returned to the composer, with earlier history intact and no replay of the
interrupted tool. The slow-read case bounces the message on the previous
send path. Unit coverage in session-history.test.tsx and
opencode-session-native.test.ts.

This branch was successfully deployed

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