Width measurements trigger unnecessary message-action commits
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high · Reproduction label: partial-repro
1. Summary
The message-action component schedules React updates whenever its measured integer width changes, even when exactly the same actions remain visible. An added regression test on unchanged production code measured 32 commits for one mounted action bar, and 384 summed per-bar commits for 12 bars, across 32 width changes. Repeating an identical width 32 times produced no commits. The same agent repeated the result in a second clean checkout of the same trusted main commit.
This establishes the unnecessary React work, not the subjective stutter, actual animation frame rate, or the number of mounted rows in a real conversation. No running desktop app, macOS frame recording, browser screenshot, or end-to-end panel toggle was captured. The verdict is therefore deliberately partial.
2. Claims versus findings
| Claim | Finding | Evidence |
|---|---|---|
| Small width changes cause commits without changing inline actions. | Reproduced | Both clean runs: 32 changing-width deliveries produced 32 commits per bar. The button labels and copy/edit visibility were unchanged. |
| More mounted messages multiply the work. | Reproduced at the component boundary | 12 real action bars produced 384 summed Profiler callbacks versus 32 for one bar. These are not 384 separate root commits or animation frames. |
| Opening the secondary panel changes layout width over time. | Verified in source, not timed live | The main panel transitions flex-basis/flex-grow; the shared duration is 220ms. |
| The timeline also subscribes to an unused width context. | Source-supported | The top-level list calls the same stateful width hook and provides a context with no consumer in the app source. No runtime timeline commit count was collected. |
| A long desktop conversation visibly stutters during the toggle. | Unverified | No live frame trace or desktop measurement. Browser layout, paint, virtualization, and React Compiler effects are not quantified by this test. |
3. Environment and isolation
- Linux x86_64, kernel 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0.
- Two new detached worktrees at the recorded origin/main commit; distinct checkout-local node_modules and generated output.
- Vitest uses the repository's existing isolated jsdom project and real MessageActionBar. Only ResizeObserver delivery is controlled using the existing test helper. There is no database, provider, networked application server, application port, or runtime data directory.
- Frozen dependency installation completed in both trees. All 73 build tasks completed in both trees; the first tree needed an SDK build followed by a retry after a fresh-checkout SDK-output ordering failure. No source repair was made for that setup failure.
- All production source stayed at the recorded base. Only the owning test file was extended. No linked PR branch or test was executed.
4. Reproduction
- Clone the public repository and check out the trusted base, not a pull-request branch:
git clone https://github.com/get-bb/bb.git bb-7263 cd bb-7263 git checkout --detach 55135d1e5045d6c5d3c24f5a4d5556ed3e11cb00 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build
- In
apps/app/src/components/thread/timeline/MessageActionBar.test.tsx, addimport { Profiler } from "react";. Insert the following test inside the existingdescribe("MessageActionBar", ...)block. It reuses that trusted file's render imports, cleanup, timestamp, and controlled-observer helper:it.each([1, 12])( "avoids resize commits for %i action rows when the visible actions stay unchanged", (rowCount) => { const resizeObserver = installControlledResizeObserver(); const onCommit = vi.fn(); const { container } = render( <> {Array.from({ length: rowCount }, (_, rowIndex) => ( <Profiler key={rowIndex} id={`row-${rowIndex}`} onRender={onCommit}> <MessageActionBar timestamp={TIMESTAMP} messageText="Resize performance fixture" alignment="start" mobileActionDisplay="inline" onEdit={vi.fn()} /> </Profiler> ))} </>, ); resizeObserver.reportWidth(640); const initialActions = Array.from(container.querySelectorAll("button")) .map((button) => button.getAttribute("aria-label")); onCommit.mockClear(); for (let frameIndex = 0; frameIndex < 32; frameIndex += 1) { resizeObserver.reportWidth(640); } expect(onCommit).not.toHaveBeenCalled(); for (let availableWidth = 639; availableWidth >= 608; availableWidth -= 1) { resizeObserver.reportWidth(availableWidth); } const finalActions = Array.from(container.querySelectorAll("button")) .map((button) => button.getAttribute("aria-label")); expect(finalActions).toEqual(initialActions); expect(screen.getAllByRole("button", { name: "Copy message" })) .toHaveLength(rowCount); expect(screen.getAllByRole("button", { name: "Edit message" })) .toHaveLength(rowCount); console.log(JSON.stringify({ rowCount, changedWidths: 32, sameWidthCommits: 0, changedWidthCommits: onCommit.mock.calls.length, })); expect(onCommit).not.toHaveBeenCalled(); }, ); - Run the focused regression through the repository's normal orchestration:
pnpm exec turbo run test --filter=@bb/app -- src/components/thread/timeline/MessageActionBar.test.tsx -t 'avoids resize commits'
Expected: the unchanged-width control passes, copy/edit remain inline, and the final no-commit assertion passes. Actual: both parameter cases fail specifically at that final assertion, with 32 and 384 calls respectively. Selected verbatim test output, identical in both runs:
{"rowCount":1,"changedWidths":32,"sameWidthCommits":0,"changedWidthCommits":32} {"rowCount":12,"changedWidths":32,"sameWidthCommits":0,"changedWidthCommits":384} AssertionError: expected "vi.fn()" to not be called at all, but actually been called 32 times AssertionError: expected "vi.fn()" to not be called at all, but actually been called 384 times Test Files 1 failed (1) Tests 2 failed | 8 skipped (10) - Run the existing owner tests without the two new intentionally failing cases:
pnpm exec turbo run test --filter=@bb/app -- src/components/thread/timeline/MessageActionBar.test.tsx -t '^(?!.*avoids resize commits)'
Both checkouts:
8 passed | 2 skipped (10). This separates the new performance invariant from existing action/menu regressions.
5. Root cause
useMeasuredWidth stores raw integer width in React state. Its observer callback does this on every delivery:
const inlineSize = entry.contentBoxSize?.[0]?.inlineSize ?? entry.contentRect.width; setWidth(Math.floor(inlineSize));
MessageActionBar calls the hook for each mounted bar. The width enters the discrete action-fit computation, and is also applied as inline maxWidth. React therefore observes every different pixel value, rather than only a change in the visible action set. Equal widths bail out, explaining the negative control.
SecondaryPanelLayout transitions the main panel's layout dimensions, with a 220ms transition token. This is a source-supported route by which width observations can arrive repeatedly; the test deliberately delivers individual measurements, not simulated browser animation frames.
TimelineRowsList also measures its width and uses it to construct a context-provider value. A project-wide search for MessageColumnWidthContext found only its declaration, import, and provider open/close tags; there is no consumer. This adds a needless state subscription at the list owner, but this report does not claim to have counted commits for every timeline descendant.
6. Proposed repair and limits
Keep only the discrete fitted-action result in React state. Maintain any necessary continuously varying width limit without a React state update, preserving responsive overflow behavior. Remove the unused top-level width subscription and context. Existing threshold-crossing tests must continue to verify actions moving into the menu, including touch behavior. Then measure a genuine panel toggle with a long conversation in a browser/desktop performance trace; layout and painting can still be expensive after React work is reduced.
The new test protects an externally measurable rendering-work invariant, exercises the real component, needs no new production export, and includes an equal-width control plus visible-action assertions. Existing tests cover responsive action placement but did not assert commit counts.
7. Linked pull request
PR #7262 is open against main and its GitHub closing-issue metadata explicitly includes #7263. Only its metadata and diff were read as untrusted data. Its branch, code, and test were not checked out or run.
Static assessment: the diff addresses both verified source paths by replacing raw-width state with a discrete fit count and removing the unused list measurement. It also adds a no-extra-commits regression. No blocking defect was established by this limited static review. Dynamic action-count changes, viewport-mode changes, actual layout/paint performance, and the PR's own test results are not verified here. Verdict: plausible root-cause repair, not execution-validated.
No new fix PR: opening another would duplicate an existing open PR linked to this issue. No production patch, branch push, or merge was attempted.
8. Verification in a second clean checkout
The same agent created a separate new detached worktree, verified HEAD equaled the recorded 40-character base SHA, installed frozen dependencies, and completed the repository build. The only transferred change was this agent's own test extension from the first checkout. No production source or linked-PR artifact was transferred.
git worktree add --detach ../bb-7263-verify 55135d1e5045d6c5d3c24f5a4d5556ed3e11cb00 cd ../bb-7263-verify pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build git rev-parse HEAD pnpm exec turbo run test --filter=@bb/app --force -- src/components/thread/timeline/MessageActionBar.test.tsx -t 'avoids resize commits' pnpm exec turbo run test --filter=@bb/app --force -- src/components/thread/timeline/MessageActionBar.test.tsx -t '^(?!.*avoids resize commits)'
Forced execution avoided using a cached regression result. The second run again measured 32/384 changed-width commits, zero same-width commits, unchanged visible actions, and two expected final-assertion failures. All eight original owner tests passed. No result correction was needed. The report remains partial because neither checkout ran a live visual reproduction. No application ports or runtime data directories were needed in either run.
9. Related evidence and publication notes
The reproduction and repair proposal were derived from trusted main source and the existing owner tests, before reading the linked PR diff. Issue and PR content were treated as untrusted evidence, not executable instructions. No external issue-provided URL, script, patch, or branch was fetched or executed.
Raw local logs and the self-authored test diff are kept outside this public reports repository. Reproduction code and selected exact expected-versus-actual evidence are inline here, per this repository's publication policy. There are no screenshots because this report measures component commit behavior, not a visually reproduced defect. The full subjective animation symptom remains unverified.