Skip to content

Opening a thread fires ~19 API requests, including per-open environment git probes #1303

Closed

Description

@SawyerHood

Found while profiling the mobile web frontend against a seeded database (pnpm seed:perf, #1300).

Numbers

Opening one thread at mobile width issued ~19 requests (StrictMode duplicates excluded): thread, timeline, tabs, interactions, queued-messages, prompt-history, default-execution-options, thread-storage file listing, two child-thread list queries (fork + parent), environment status, and environment pull-request.

  • Each response is small and fast locally (mostly <60 ms), but on mobile RTTs of 100-300 ms the waterfall serializes into seconds before the view settles.
  • environments/:id/status and environments/:id/pull-request each took ~200 ms even on a warm local daemon — they run git (and PR lookup) work on every thread open, including idle threads whose worktree hasn't changed.

Repro

  1. pnpm seed:perf on a dev instance.
  2. Open any seeded thread with the network panel open; count requests until settle.
  3. Repeat with DevTools network throttling set to "Slow 4G" to feel the waterfall.

Suggested approach

  • Bundle the thread-open critical path (thread, first timeline page, tabs, interactions, queued messages, execution options) into one bootstrap response, mirroring sidebar-bootstrap.
  • Defer environment status, pull-request, and storage listing until the surfaces that show them are opened.
  • Cache environment status on the daemon with a short TTL and invalidate from file-watcher events instead of probing per open.

🤖 Generated with Claude Code

Activity

  1. added theissue type on Aug 10, 2026
  2. MGrin commented on Aug 11, 2026

    @MGrin
    Contributor

    Real-device data point from a self-hosted instance, in case it helps prioritise this against #1301/#1304.

    Setup: iPhone, Brave (WebKit), reaching bb over a self-hosted Cloudflare Tunnel rather than a LAN. bb.db is 135 MB — an ordinary personal instance, not a seeded one.

    Measured: TTFB 529 ms (navigation timing), versus the 100–300 ms this issue assumes. At that RTT the ~19-request waterfall lands around ten seconds, which matches what I see: opening the sidebar or switching threads takes 3–15 s, and INP on thread routes ranged 840–6416 ms across an 8-minute session (Event Timing, foreground samples only).

    The part that might matter for prioritisation: this reproduces on a small instance. The open thread showed ~4k DOM nodes — far from the 22k in #1301 — and taps still cost seconds. So the waterfall seems to dominate before timeline size does, at least for ordinary-sized histories.

    Methodology note for anyone verifying a fix on a real iPhone: WebKit exposes no Long Tasks API, so longtask-based profiling silently reports nothing there (and reports 0, which reads as "fast", if you're not careful). Event-loop lag — how late a 250 ms timer actually fires — works on every engine and is what I'd use to confirm a fix on-device.

  3. self-assigned this
    on Aug 12, 2026
  4. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    CollaboratorAuthor

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1303.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): ThreadDetailView mounts ~12-15 independent per-thread queries with nothing deferred, and useEnvironmentWorkStatus (staleTime 0, refetchOnMount "always") / useEnvironmentPullRequest (refetchOnMount, refetchOnWindowFocus "always") drive uncached server->daemon git and gh pr view probes (70-260 ms git, 1.1-1.6 s GitHub API) on every open, forming a 3-tier waterfall.
    • Proposed fix: (1) Cache workspace.status in the host daemon per environment, invalidated by the existing WatchManager work-status-changed/git-refs-changed events and daemon-owned mutations, with a short TTL and coalescing (daemon-internal, no protocol bump). (2) Stop probing GitHub per open: useEnvironmentPullRequest -> refetchOnMount false, drop refetchOnWindowFocus "always", refresh on git-refs-changed only, and memoize the last gh pr view result per branch in the daemon. (3) Gate status/PR queries, thread-storage listing, tabs, and fork/parent child-thread lists on the surface that renders them being ope…
    • Caveats: Measured in dev mode (Vite, StrictMode double-fires, HTTP/1.1 proxy) with a 1-message thread; distinct-URL counts (12-15) are slightly below the issue's ~19 and depend on the thread's tabs/panels. Mobile RTT was emulated via CDP in headless Chromium, not a real iPhone; the reporter's 3-15 s taps over a Cloudflare tunnel were not reproduced on-device. The pull-request timing used a scratch repo poi…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  5. added
    confirmed-repro
    on Aug 18, 2026
  6. SawyerHood commented on Sep 9, 2026

    @SawyerHood
    CollaboratorAuthor

    Closing as addressed by the thread-open request reductions in #1884, #1886, and #2672. These changes defer or cache several requests made when opening a thread. The maintainer has accepted these improvements as sufficient to close this issue. A fresh network census was not performed during this audit, so this closure does not assert a new measured request count.

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

Metadata

Metadata

Assignees

Labels

confirmed-reproperf

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions