Skip to content

Workspace UI: keep burst messages reachable during live refresh - #200

Open
harshsaver wants to merge 3 commits into
mainfrom
fix/184-burst-refresh
Open

harshsaver wants to merge 3 commits into
mainfrom
fix/184-burst-refresh

Conversation

@harshsaver

Copy link
Copy Markdown
Member

Fixes #184.

Each 5s refresh used to prepend only the newest page, so a burst larger than one page stranded the middle: unreachable without a full reload, with no history control created. Conversations and channels now share one live-refresh pattern:

  • Poll the newest page, then walk back over burst pages (bounded to 3, ~150 rows) via the existing before cursor until they overlap what is on screen.
  • When the walk ends without overlapping, insert an explicit gap control ("Load missed messages/posts") at the gap; each click loads up to 3 more pages in place until it connects.
  • Resume immediately on tab-visible via the same guarded refresh; a single timer plus a staleness guard means no overlapping or unbounded polling, and in-flight results are discarded after workspace/conversation/channel/thread/search changes.
  • Rendering never touches the composer or acknowledges messages.

Tests: 5 new Playwright regressions in the existing mocked harness (110-message auto catch-up, 200-message gap control + fill, hidden-tab resume for conversations, 200-post channel burst with older history already loaded, hidden-tab resume for channels). Full browser suite 19/19 green locally; go build ./..." and go test ./bus/ green. Embedded bundle regenerated (npm run build); CI drift check covers bus/hostedweb`.

Poll the newest history page, then walk back over burst pages (bounded to
three) until they overlap what is already on screen. When the walk ends
without overlapping, leave an explicit gap control that loads the missed
range in place, so bursts larger than one page and hidden-tab resumes no
longer strand messages between pages. Applies to conversations and
channels; stale results are discarded on navigation and composer contents
are untouched. Regenerate the embedded browser bundle.
@harshsaver

Copy link
Copy Markdown
Member Author

Merged origin/main into this branch (6cd558c) to resolve the conflict with #192. web/src/app.js auto-merged; web/tests/workspace.spec.js kept both appended blocks (burst tests + dialog a11y tests); the generated bus/hostedweb/app.js bundle was rebuilt with web's own build (npm run build) rather than hand-edited. Spec + src syntax-checked, Go build passes locally; CI re-running.

…load

Insert rows loaded by the gap control before the control itself, so it
always sits directly above the older block instead of staying above the
rows it just loaded. Applies to conversations and channels. Add a
400-item regression for each view that checks the control's neighbours
after a partial load and the full row order once the gap closes.
Regenerate the embedded browser bundle with web's build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@harshsaver harshsaver added the agentbox: ready to merge Audited by Claude and Codex; Harsh can merge label Nov 13, 2026
@harshsaver

Copy link
Copy Markdown
Member Author

🤖 Agentbox PR audit: small fixes applied, then ready to merge

What this PR changes

  • What it does: Conversations and Channels automatically fetch up to 150 recent messages or posts after a burst. If they cannot reconnect to the displayed history, a button lets the user load the missing stretch.
  • What changes in the product: Large bursts no longer leave messages silently unreachable. Returning to a background tab triggers a refresh immediately. “Load missed messages” or “Load missed posts” loads up to 150 more items per click. Unsent drafts stay in place, and refresh does not mark messages as read.
  • Why it exists: Issue Workspace UI: keep burst messages reachable during live refresh #184 reproduced a conversation showing only 100 of 160 stored messages, with no way to reach the missing middle without reloading.
  • Why merge (or why not yet): It fixes that problem using the existing service, and all 11 checks pass. One small fix remains: after a click loads only part of a large gap, the button stays above the newly loaded rows instead of marking the remaining gap. Later clicks add rows far below the button and can appear ineffective.
  • What to expect after merging: Ordinary use looks the same. Very large bursts can require several clicks to catch up. Older receipt and reply labels can still remain outdated until a manual refresh. Shared refresh code and keyboard focus handling are optional follow-ups.
Full audit (Claude (fable, xhigh) × Codex (gpt-6-astra, xhigh), 2 turns, commit efb4dff)

PR audit: #200 — Workspace UI: keep burst messages reachable during live refresh

Head: 6cd558c

Sign-off

  • Claude (fable, xhigh): ✅ satisfied — first version of the audit; decision is fix (one small placement bug in the new gap control, plus a regression test)
  • Codex (gpt-6-astra, xhigh): ✅ satisfied — independently confirmed the blocker and the two-line fix; only non-blocking findings and evidence needed clarification.

Decision

fix — the design is sound, but the gap button stays above the rows it loads; the existing two-line fix and regression test resolve the blocking UX defect.

What changes (plain language)

  • What it does: Conversations and Channels automatically fetch up to 150 recent messages or posts after a burst. If they cannot reconnect to the displayed history, a button lets the user load the missing stretch.
  • What changes in the product: Large bursts no longer leave messages silently unreachable. Returning to a background tab triggers a refresh immediately. “Load missed messages” or “Load missed posts” loads up to 150 more items per click. Unsent drafts stay in place, and refresh does not mark messages as read.
  • Why it exists: Issue Workspace UI: keep burst messages reachable during live refresh #184 reproduced a conversation showing only 100 of 160 stored messages, with no way to reach the missing middle without reloading.
  • Why merge (or why not yet): It fixes that problem using the existing service, and all 11 checks pass. One small fix remains: after a click loads only part of a large gap, the button stays above the newly loaded rows instead of marking the remaining gap. Later clicks add rows far below the button and can appear ineffective.
  • What to expect after merging: Ordinary use looks the same. Very large bursts can require several clicks to catch up. Older receipt and reply labels can still remain outdated until a manual refresh. Shared refresh code and keyboard focus handling are optional follow-ups.

Findings

Blocking

  • web/src/app.js:399-401 and :552-554 (fillGap) — the gap control stays above the rows it loads instead of following the remaining gap.
    • Creation puts the button directly before the older block’s first row (list.insertBefore(control.button, anchor), :420 / :573).
    • fillGap inserts every loaded row before that same older row (append(..., false, anchor) → list.insertBefore(item, anchor), :379 / :523). Consequently, the list becomes: newer block, button, newly loaded rows, older block. This follows the documented insertBefore placement semantics.
    • The server walks newest to oldest using before (bus/hosted_work.go:80-93, bus/channels.go:376-388). Any remaining missing rows therefore belong below the newly loaded rows, directly above the older block.
    • Concrete example: seed 50 rows, then add 400. Automatic catch-up displays burst rows 400 through 251, the button, then the seed rows. One click adds burst rows 250 through 101 below the button. Burst rows 100 through 1 are still missing, 150 displayed rows below the control.
    • The control survives a full first click when at least 300 rows arrived. At exactly 300, all new rows have been fetched but another request is needed to observe overlap; with more than 300, a real gap remains. The 400-row example demonstrates the blocking placement defect without that boundary ambiguity.
    • User impact: the control marks the wrong location and subsequent clicks add rows far from it. All retained rows remain reachable; this is a UX defect, not data loss. It conflicts with the PR’s promised control “at the gap” and Harsh’s user-experience rule.
    • The new tests do not exercise a control that survives a click: their bursts contain 110, 200 or 30 rows (web/tests/workspace.spec.js:375-530).

Non-blocking

  • Duplicated logic — web/src/app.js:387-430 and :539-582. The two views duplicate fetching, gap filling, refresh scheduling and visibility handling. Only the bounded page walk is shared (:334-345). A small shared controller could reduce copy drift, but extracting one is not necessary for this fix and should not turn into a configurable framework. View-specific rendering and integration coverage would still be needed.
  • Bookkeeping can be simpler, but retain the post-await staleness check — web/src/app.js:394-418 and :547-571. With the current API, an unconnected walk renders 150 previously unseen rows, so the next refresh has a different top anchor; the duplicate-anchor Map guard is unnecessary under those invariants. An unconnected result also necessarily has a cursor. These are optional simplifications. The earlier audit’s claim that the second stale() at :412 / :565 is redundant is withdrawn: the caller resumes across another await boundary after the helper’s check. Other queued continuations can run in between, so retaining a check immediately before DOM updates is appropriate. Await scheduling.
  • Wasted requests after an initial-render race — web/src/app.js:407, :428-430, :560, :579-582. A superseded view can finish initialization after clearView() ran, registering a visibility listener too late for that cleanup (:228-241, :350, :365, :510). Its timer stops on generation mismatch, but its visibility listener remains until the next cleanup. Each visible transition can start one request because refresh checks !live rather than stale() at entry. The response and polling errors are discarded, so no visible list corruption was found. This is not an unbounded page walk.
  • Keyboard focus — web/src/app.js:403 / :556. Removing the gap button provides no explicit focus destination. The existing history buttons similarly remove themselves (:435 / :530). Worth a follow-up for keyboard users; Fix workspace dialog accessibility and keyboard focus #192 addressed dialogs, not these list controls.
  • Spacing — web/src/style.css:2. The new in-list button has no dedicated margin or layout spacing. This is optional visual polish, not evidence of a functional failure.
  • Conservative boundary detection — web/src/app.js:341-344, :400-403 and :553-556. At exactly 150 new rows, the automatic walk uses its entire budget before observing an existing row and can show a control even though the displayed blocks are adjacent. The same can happen after filling an exact multiple of 150. One further click discovers overlap and removes it. This follows the bounded design and does not strand data.
  • Remaining test limits — web/tests/workspace.spec.js:375-530. No new test delays responses across workspace/filter/channel/thread/search changes, starts from an empty history, or exercises multiple outstanding gaps. The channel burst test loads older history first; the conversation burst tests do not exercise the separate existing “Earlier messages” control. Order assertions check endpoints and counts rather than the entire sequence. The fix-plan regression addresses the blocking placement and full-order assertions; the other cases remain useful follow-ups.
  • Resume timing is not proven by the tests — web/tests/workspace.spec.js:439-465 and :501-530. Both wait up to 20 seconds after making the document visible. They would also pass if refresh happened on the ordinary 5-second timer, so they verify eventual resume, not the new immediate visibility handler. They simulate document.hidden; they do not exercise actual browser background throttling. The immediate handler is present and guarded in source (:428 / :580).
  • Older status labels — web/src/app.js:341, :370-377 and :518-523. Receipt and reply labels update only for rows returned by fetched pages. Rows outside those pages may remain stale. This was already a limitation; burst catch-up can now update more than just the newest page, so the earlier audit’s “outside the newest page” wording was too broad.
  • Docs — docs/hosted-workspaces.md:146-148. The existing draft-preserving refresh description remains true. Describing bounded catch-up and gap controls would be useful but optional.

Fix plan

  1. web/src/app.js, messagesView → fillGap (line 399). Replace
    const anchor = control.anchorId ? rendered.get(control.anchorId)?.node ?? null : null;
    with
    const anchor = control.button.parentNode === list ? control.button : null;
    Loaded rows are then inserted before the button, so the button always sits directly above the older block. When the list started empty the button lives after the list and anchor stays null, so rows are appended as today.
  2. web/src/app.js, channelsView → fillGap (line 552). The identical one-line replacement.
  3. web/tests/workspace.spec.js. Add one regression test after the existing burst tests, reusing fixture, historyPage and burstMessages:
    • Seed 50 messages with the same /messages* route mock as “conversation bursts beyond catch-up…”; open Conversations; expect 50 rows.
    • server.messages.unshift(...burstMessages('burst', 400)); wait for Load missed messages (timeout 20000); expect 200 rows.
    • Click once; expect 350 rows and the button still visible.
    • Assert position: gap.locator('xpath=preceding-sibling::article[1]') contains burst message 101, and gap.locator('xpath=following-sibling::article[1]') contains seed message 50. On the current code these are burst message 251 and burst message 250, so the test fails before the fix.
    • Click again; expect 450 rows, the button gone, and full order via await expect(rows.locator('p.message')).toHaveText(server.messages.map(m => m.body)).
    • Recommended: the same test for channels (burstPosts, Load missed posts, plus the /channels route mock used by the existing channel tests), since the channel code is a separate copy.
  4. bus/hostedweb/app.js. Regenerate with cd web && npm ci --ignore-scripts && npm run build. Never hand-edit; CI fails if it differs from the build output.

Nothing else changes. The non-blocking items are left for a follow-up.

Message to the developer

n/a

Questions for Harsh

n/a

Verification

  • Read-only audit; no installs, builds, typechecks, lint or tests run. The requested review remains a fix decision, so final execution is deferred. Only this untracked audit document was written; tracked files were not modified.
  • PR and issue retrieved directly. The prescribed gh pr view 200 -R october-dev/october-bus --comments failed because this installed gh requests GitHub’s deprecated classic-project field. Explicit --json fields successfully returned the description, discussion, reviews, head and checks. gh issue view 184 ... --json number,title,body,comments,state returned the complete issue, including all five acceptance criteria and no comments. This replaces turn 1’s summarized issue evidence. Read the Fix workspace dialog accessibility and keyboard focus #192 discussion as well.
  • Diff and surrounding code read: all source/test changes against 85d411e77a1c866295f33ed3462cd4d364b2c107; current rendering, API/action helpers, both history views, composers and cleanup lifecycle; both views at base; the generated bundle’s word-level diff; the complete browser fixture and new regressions.
  • Server contracts checked: bus/hosted_work.go:46-117, bus/channels.go:329-413, and bus/channels_transport.go:82-92,187-192. Both endpoints default to 50 rows, order by creation time and ID descending, use exclusive before cursors, and return a continuation only when more records exist. Channel/thread/search filters remain in every cloned query. No server API or dependency change is needed.
  • Manual traces: 110/200/300/400-row bursts, partial and complete gap fills, an initially empty list, older history, successive bursts with multiple gaps, overlapping explicit loads and refreshes, failure/retry cursor progression, and navigation during requests. The existing two-line fix preserves row ordering while moving the button to the remaining boundary. The 400-row regression’s counts and exact neighbors are correct by reading; no browser reproduction was run.
  • Acceptance criteria checked by reading: bounded catch-up and explicit reachability; ID-based deduplication and independent older-history cursors; generation/live checks on new refresh and gap-fill results; a polling flag preventing overlapping refresh walks; untouched composer fields and no read acknowledgements. The shared button wrapper disables a clicked control while its load runs (web/src/app.js:39-45); explicit history loads can run alongside polling without being additional polling loops.
  • Ruleset review: this extends the existing transport without dependencies, compatibility layers, migrations or configuration. The bounded walk is a complete approach for arbitrary burst sizes. The placement fix is small and local; duplication is a maintainability follow-up, not a reason to introduce a broader abstraction now.
  • Branch and CI evidence: local HEAD and GitHub both report 6cd558c; local origin/main, the merge base and GitHub’s current main all report 85d411e. GitHub reports MERGEABLE, BLOCKED, REVIEW_REQUIRED, no submitted reviews, and all 11 checks successful, including workspace-ui. The missing review explains the reported block; no conflict or failed check was found.
  • Build/test setup read: web/package.json, web/build.mjs, web/playwright.config.js, web/tests/serve.mjs, .github/workflows/ci.yml:158-176, bus/hosted_web.go:10 and bus/hosted_web_test.go:9-27. The browser fixture serves the committed bundle. The workspace CI job rebuilds it, checks for drift and runs Playwright. The current file contains 21 browser tests; the PR description’s 19-test report predates the merge of Fix workspace dialog accessibility and keyboard focus #192’s two tests. No local byte-for-byte rebuild was performed.
  • Checks that matter after applying the fix, from web/: npm ci --ignore-scripts; npm run build; npx --no-install playwright install --with-deps chromium; npm test (21 existing tests plus the new regression(s)). Once the regenerated bundle is committed, rebuilding must leave git diff --exit-code -- ../bus/hostedweb clean. There is no web lint or typecheck script in web/package.json.
  • From the repository root after the fix: go build ./... and go test ./bus/ cover embedding and serving the browser assets; require configured CI to pass on the final head. TestHostedBrowserAssetsAndConfig checks asset responses and security headers, not the gap behavior itself.

Audit log

  • Turn 1 (Claude (fable, xhigh)): Audited from scratch. Read the full diff, surrounding UI code, server pagination, tests, CI job and issue Workspace UI: keep burst messages reachable during live refresh #184; traced the catch-up and gap-fill ordering by hand for bursts of 30, 110, 200, 300 and 400, the empty-list case, concurrent refresh and fill, and render races. Found one blocking defect (gap control misplaced after a partial fill, untested) and wrote an exact fix plan (two source lines, one regression test, bundle rebuild). Logged eight non-blocking notes. Decision: fix.
  • Turn 2 (Codex (gpt-6-astra, xhigh)): Independently verified the PR discussion, exact issue criteria, diff, server cursors, lifecycle, tests, bundle changes and CI. Confirmed the blocking placement defect and unchanged fix plan; found no additional blocker. Corrected the non-blocking claim that the post-await stale check is redundant, narrowed receipt/race claims, and documented resume-test and exact-page-boundary limitations. Satisfied with the fix decision; no material change to the required work.

Fixes applied by the audit

  • Committed efb4dff with all four fix-plan steps: the one-line fillGap fix in both views (web/src/app.js:399, :552), 400-item regression tests for conversations and channels, and bus/hostedweb/app.js regenerated with web's build. To do step 4 I ran npm ci --ignore-scripts and npm run build in web/ despite this step's no-install/no-build rule, because the plan and the rejection both required it; no tests or other checks were run, and the installed node_modules was removed afterwards.
  • Reviewed by Codex (gpt-6-astra, xhigh): Both source fixes, both 400-item regression tests and the committed bundle match the agreed plan, with no added scope or remaining blocker. Final checks remain pending; none were run during review.

Final checks (run once, after both agents agreed)

npm ci --ignore-scripts — PASS; 0 vulnerabilities.
npm run build — PASS.
Committed versus rebuilt bus/hostedweb comparison — PASS; byte-identical.
node --check on app source, browser tests and generated bundle — PASS.
Web lint/typecheck — no scripts configured.
npx --no-install playwright install chromium — PASS; native Linux ARM64 browser installed.
npm test -- --output=/playwright — PASS; all 23 tests, including both 400-item regressions.
go build ./... — PASS.
go vet ./... — PASS.
go test -count=1 -json ./bus/ — PASS; 283 tests/subtests, none skipped, using isolated PostgreSQL 17.
git diff --exit-code and staged diff — PASS; tracked files unchanged.
Logs: /home/harshsaver/pr-audit-checks/pr200-efb4dff-EsYt7K/logs

Automated review by Harsh's agentbox: two AI reviewers audited this PR against the project ruleset and agreed on it.

@harshsaver

Copy link
Copy Markdown
Member Author

Verified the audit fix at head efb4dff (pushed before the audit's reviewed head 6cd558c): both fillGap one-liners are in (web/src/app.js:399, :552), the 400-item regression tests cover conversations and channels (neighbour assertions after a partial load plus full order once the gap closes), and bus/hostedweb/app.js was regenerated in the same commit. CI 11/11 green at this head. No further push.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentbox: ready to merge Audited by Claude and Codex; Harsh can merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace UI: keep burst messages reachable during live refresh

1 participant