← reports

#7498 · Panel width inheritance invalidation

BugPriority: LowEffort: Lowui · perf · confirmed-reproGitHub issue2026-11-13

Trusted base: 070bf3df0aae0f009488f29d8941f5fec8532a93. Verdict: REPRODUCED · Root-cause confidence: high.

1. TL;DR

The right panel has a width custom property that is intended for the panel itself, but that value also propagates into its entire content tree. A focused Chrome trace with 2,400 descendants shows every one of those descendants restyled after each width write: 2,401 elements including the panel. An otherwise identical non-inherited control changes the same panel width while restyling just one element. This happens in both clean trusted checkouts. The reproduction verifies the style-invalidation mechanism, not the full app's reported toggle frame times.

2. Claims vs findings

ClaimStatusEvidence
Panel-only width changes restyle the whole panel tree.VerifiedForty of forty Chrome UpdateLayoutTree events report 2,401 elements in each checkout. Descendants inherit 40cqw.
A non-inherited registration confines invalidation to the panel.Verified mechanismControl with identical panel width changes reports one element on all forty writes; descendants have no inherited value.
The existing container-width fallback can be preserved.VerifiedUnset baseline and non-inherited control both compute to 350px in a 1,000px container; a 40cqw assignment computes to 400px.
The packaged app has particular open/close/drag frame-time spikes.UnverifiedNo packaged-app or full GitButler interaction was run. Our Chrome version, DPR, tree and timing metric differ. Do not compare these milliseconds directly with the issue's frame-time table.
The earlier resize mitigation does not remove the remaining invalidation.Verified in current sourceThe dragging guard suppresses intermediate writes, but drag completion and non-drag resize still call the inherited writer.

3. Environment

4. Minimal reproduction

  1. Download harness.mjs and browser-repro.js from the complete inline listings below. Prepare trusted source using the commands below. Replace HOST_ID and SESSION_ID with identifiers returned by the BB commands.
  2. The harness derives the custom-property name from the source resize writer, confirms its consumer, and uses the trusted theme's actual @property blocks. It creates a 1,000px container with an aside and 2,400 children, without loading the rest of the app.
  3. The browser test alternates width between 40cqw and 41cqw, then forces a descendant style read. It records Chrome trace element counts for 40 writes. It repeats with a separate, non-inherited control property on the same aside. No production file is patched.
  4. Expect the panel-local invariant to fail on this base (child value should be empty, and only the owner should need style recomputation). The reproduction returns success when it detects that failure and its control passes. This is a bug-detection harness, not a passing product regression suite.
git clone https://github.com/get-bb/bb.git bb-7498-base
cd bb-7498-base
git checkout --detach 070bf3df0aae0f009488f29d8941f5fec8532a93
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
node /path/to/harness.mjs "$PWD" /tmp/bb-7498-first-data 49231

# In another terminal, use an explicit connected browser host from bb machine list:
bb browser-automation open --backend local --headless --machine HOST_ID --json
bb browser-automation run SESSION_ID --script "globalThis.fixtureHtml = $(curl --fail --silent http://127.0.0.1:49231/ | node -e 'let data=""; process.stdin.on("data",chunk=>data+=chunk).on("end",()=>console.log(JSON.stringify(data)))'); $(cat /path/to/browser-repro.js)" --timeout-ms 120000 --json

# Repeat with a second clean checkout, fresh browser session, data directory and port:
git worktree add --detach ../bb-7498-second 070bf3df0aae0f009488f29d8941f5fec8532a93
node /path/to/harness.mjs ../bb-7498-second /tmp/bb-7498-second-data 49232
# Repeat the browser command against port 49232, with the new session ID.

Observed result in both checkouts:

expected panel-local invariant: childProperty="", restyles per write=1
actual trusted main: childProperty="40cqw", restyles per write=2401 (40/40 writes)
non-inherited control: childProperty="", restyles per write=1 (40/40 writes)
invariantPass=false; controlPass=true
RunBaseline median write + forced readControl medianRestyled elementsUnset fallback
13.10 ms1.30 ms2,401 → 1 on all 40 writes350 px → 350 px
23.10 ms1.40 ms2,401 → 1 on all 40 writes350 px → 350 px

These are synchronous write-plus-forced-read samples, not animation frame times; each sample includes remaining layout cost. The direct restyle counts are the primary evidence, not timing.

Actual isolated browser fixture with measured baseline and control restyle counts
Actual second-run screenshot of the isolated measurement fixture, not the bb app. The result shows 2,401 baseline restyles versus one for the non-inherited control.

Reproduction scripts

harness.mjs (complete)
import { readFileSync, mkdirSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
import { execFileSync } from "node:child_process";
import { createServer } from "node:http";

const [checkout, dataDirectory, portArgument] = process.argv.slice(2);
if (!checkout || !dataDirectory || !/^\d+$/.test(portArgument ?? "")) {
  throw new Error("Usage: node harness.mjs CHECKOUT TEMP_DATA PORT");
}
const port = Number(portArgument);
if (port < 40000 || port > 60000) throw new Error("Use a temporary QA port");
const base = resolve(checkout);
const css = readFileSync(resolve(base, "apps/app/src/components/ui/theme.css"), "utf8");
const hook = readFileSync(resolve(base, "apps/app/src/components/secondary-panel/useSecondaryPanelResize.ts"), "utf8");
const component = readFileSync(resolve(base, "apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx"), "utf8");
const property = hook.match(/const applySwipeWidth[\s\S]*?setProperty\(\s*"([^"]+)"/)?.[1];
if (!property || !component.includes(`var(${property},`)) {
  throw new Error("The resize writer and width consumer no longer match this reproduction");
}
const registrations = Array.from(css.matchAll(/@property\s+[\w-]+\s*\{[^}]*\}/g), match => match[0]).join("\n");
const commit = execFileSync("git", ["-C", base, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
const metadata = { commit, property, registrationCount: Array.from(css.matchAll(/@property\s/g)).length };
const page = `<!doctype html><html><head><meta charset="utf-8"><title>7498: browser invalidation fixture</title><style>${registrations}
body { font: 16px system-ui; margin: 24px; background: #fafaf8; color: #222; }
main { container-type: inline-size; width: 1000px; }
aside { width: var(${property}, 35cqw); height: 400px; overflow: hidden; border: 1px solid; }
aside div { height: 1px; }
pre { white-space: pre-wrap; }
</style></head><body><h1>Right-panel custom-property invalidation</h1><p>Isolated browser fixture using trusted source registrations, not the full app.</p><main><aside></aside></main><pre id="result">Ready</pre><script>window.fixtureMetadata = ${JSON.stringify(metadata)}; const surface = document.querySelector("aside"); for (let index = 0; index < 2400; index++) { surface.append(document.createElement("div")); }</script></body></html>`;
mkdirSync(dataDirectory, { recursive: true });
writeFileSync(resolve(dataDirectory, "metadata.json"), JSON.stringify(metadata, null, 2));
createServer((request, response) => {
  if (request.url !== "/") { response.writeHead(404); response.end(); return; }
  response.writeHead(200, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" });
  response.end(page);
}).listen(port, "127.0.0.1", () => console.log(JSON.stringify({ port, ...metadata })));
browser-repro.js (complete)
const page = await browser.getPage("main");
await page.setViewport({ width: 1440, height: 1000, deviceScaleFactor: 1 });
if (globalThis.fixtureHtml) {
  await page.setContent(globalThis.fixtureHtml);
} else {
  await page.goto(globalThis.harnessUrl ?? "http://127.0.0.1:49231/");
}
const metadata = await page.evaluate(() => window.fixtureMetadata);
const session = await page.createCDPSession();
async function measure(label, property) {
  await page.evaluate(propertyName => {
    const surface = document.querySelector("aside");
    surface.style.setProperty(propertyName, "40cqw");
    getComputedStyle(surface.lastElementChild).width;
  }, property);
  const completed = new Promise(resolve => session.once("Tracing.tracingComplete", resolve));
  await session.send("Tracing.start", { categories: "devtools.timeline", transferMode: "ReturnAsStream" });
  const observation = await page.evaluate(propertyName => {
    const surface = document.querySelector("aside");
    const child = surface.lastElementChild;
    const durations = [];
    for (let sample = 0; sample < 40; sample++) {
      const started = performance.now();
      surface.style.setProperty(propertyName, `${sample % 2 === 0 ? 41 : 40}cqw`);
      getComputedStyle(child).width;
      durations.push(performance.now() - started);
    }
    return {
      descendants: surface.querySelectorAll("*").length,
      childProperty: getComputedStyle(child).getPropertyValue(propertyName).trim(),
      ownerProperty: getComputedStyle(surface).getPropertyValue(propertyName).trim(),
      ownerWidth: getComputedStyle(surface).width,
      durations,
    };
  }, property);
  await session.send("Tracing.end");
  const { stream } = await completed;
  let trace = "";
  for (;;) {
    const chunk = await session.send("IO.read", { handle: stream });
    trace += chunk.base64Encoded ? Buffer.from(chunk.data, "base64").toString() : chunk.data;
    if (chunk.eof) break;
  }
  await session.send("IO.close", { handle: stream });
  const events = JSON.parse(trace).traceEvents.filter(event => event.name === "UpdateLayoutTree");
  const elementCounts = events.map(event => event.args?.elementCount ?? event.args?.data?.elementCount).filter(count => typeof count === "number");
  const sorted = [...observation.durations].sort((left, right) => left - right);
  return { label, ...observation, medianMilliseconds: sorted[Math.floor(sorted.length / 2)], restyledElementCounts: elementCounts, styleUpdateCount: events.length };
}
const fallbackWidth = await page.evaluate(() => getComputedStyle(document.querySelector("aside")).width);
const baseline = await measure("trusted-main", metadata.property);
const controlProperty = "--qa-contained-width";
await page.evaluate(propertyName => {
  const registration = document.createElement("style");
  registration.textContent = `@property ${propertyName} { syntax: "*"; inherits: false; }`;
  document.head.append(registration);
  const surface = document.querySelector("aside");
  surface.style.removeProperty(window.fixtureMetadata.property);
  surface.style.width = `var(${propertyName}, 35cqw)`;
}, controlProperty);
const controlFallbackWidth = await page.evaluate(() => getComputedStyle(document.querySelector("aside")).width);
const control = await measure("non-inherited-control", controlProperty);
const results = {
  ...metadata,
  userAgent: await page.evaluate(() => navigator.userAgent),
  fallbackWidth,
  controlFallbackWidth,
  baseline,
  control,
  invariantPass: baseline.childProperty === "" && baseline.restyledElementCounts.every(count => count <= 1),
  controlPass: control.childProperty === "" && control.ownerWidth === "400px" && controlFallbackWidth === fallbackWidth && control.restyledElementCounts.length === 40 && control.restyledElementCounts.every(count => count === 1),
};
await session.detach();
await page.evaluate(value => { document.querySelector("#result").textContent = JSON.stringify(value, null, 2); }, results);
console.log(JSON.stringify(results, null, 2));
if (!results.controlPass) throw new Error("Non-inherited control failed");
if (results.invariantPass) throw new Error("The trusted-main defect did not reproduce");

5. Root cause

The panel writes an unregistered custom property on its aside, so the value inherits into every descendant and each write invalidates their computed styles.

secondaryPanelRef.current?.style.setProperty(
  "--secondary-swipe-width",
  `${size}cqw`,
);

width: `var(--secondary-swipe-width, ${persistedWidthPercent}cqw)`

Changing the width can still require descendant layout even when style invalidation is contained. A registration removes this measured style-inheritance overhead; it does not guarantee zero layout or a particular frame budget.

6. Proposed fix

Register the panel-only width property as non-inherited, leaving its unset state without a concrete initial value so the existing container-width fallback remains effective. The separate control demonstrates both unchanged sizing and the removal of inherited invalidation. Test actual descendant computed values and invalidation in a real browser, and retain fallback coverage. No production fix branch was created because an open linked PR already owns this issue.

7. PR review

#7499 — static review only

GitHub metadata confirms this open PR closes #7498. Its head was 4a0db7d06e766f05720a1ba31b867345e85cec4c when reviewed. Its two-file diff adds a non-inherited registration and source-level CSS assertions. This directly targets the verified cause and intentionally preserves the var() fallback. No blocking static finding was identified. The source-text assertions are weaker than a real-browser behavioral check; the report's Chrome control adds that separate evidence.

Only GitHub metadata and diff were read as untrusted data. The PR branch, tests and build were not checked out or executed. Its own benchmark and CI claims are not independently certified here. The control was designed from the trusted writer, consumer and existing sidebar registration.

8. Related issues

#6511 is a merged resize-write-frequency mitigation. Current source retains its dragging guard; this report concerns the inheritance cost of writes that remain.

9. Verification

The same agent repeated the reproduction directly, without a workflow or verification subagent, in a second clean worktree at 070bf3df0aae0f009488f29d8941f5fec8532a93. Both source checkouts were clean after restoring an unrelated generated web route file produced by the first build. The second frozen install, existing SDK build and full Turbo build succeeded (73 tasks, 71 cached). The second harness used port 49232, a new data directory and a newly opened browser session. It produced the same 40 baseline counts of 2,401 and 40 control counts of one, the same inherited child value, and the same 350px fallback. No verdict correction was necessary. This is a repeated clean run by the same agent, not independent verification.

10. Appendix and limits

First run: complete measurement results
{
  "commit": "070bf3df0aae0f009488f29d8941f5fec8532a93",
  "property": "--secondary-swipe-width",
  "registrationCount": 1,
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/149.0.0.0 Safari/537.36",
  "fallbackWidth": "350px",
  "controlFallbackWidth": "350px",
  "baseline": {
    "label": "trusted-main",
    "descendants": 2400,
    "childProperty": "40cqw",
    "ownerProperty": "40cqw",
    "ownerWidth": "400px",
    "durations": [
      3.8000000715255737,
      3.100000023841858,
      3.0999999046325684,
      3.100000023841858,
      3.100000023841858,
      3.200000047683716,
      3.0999999046325684,
      3.100000023841858,
      3.100000023841858,
      3.200000047683716,
      3.0999999046325684,
      3.100000023841858,
      3.200000047683716,
      3.1999999284744263,
      3.100000023841858,
      3.100000023841858,
      3.200000047683716,
      3.0999999046325684,
      3.100000023841858,
      3.100000023841858,
      3.100000023841858,
      3.1999999284744263,
      3.200000047683716,
      3.100000023841858,
      3.1999999284744263,
      3.200000047683716,
      3.200000047683716,
      3.0999999046325684,
      3.3000000715255737,
      3.100000023841858,
      3.0999999046325684,
      3.200000047683716,
      3.200000047683716,
      3.299999952316284,
      3.100000023841858,
      3.1999999284744263,
      3.200000047683716,
      3,
      3.5,
      3
    ],
    "medianMilliseconds": 3.100000023841858,
    "restyledElementCounts": [
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401
    ],
    "styleUpdateCount": 40
  },
  "control": {
    "label": "non-inherited-control",
    "descendants": 2400,
    "childProperty": "",
    "ownerProperty": "40cqw",
    "ownerWidth": "400px",
    "durations": [
      2.200000047683716,
      1.399999976158142,
      1.5,
      1.2999999523162842,
      1.3000000715255737,
      1.399999976158142,
      1.399999976158142,
      1.2999999523162842,
      1.3000000715255737,
      1.2999999523162842,
      1.399999976158142,
      1.5,
      1.5,
      1.3000000715255737,
      1.2999999523162842,
      1.3000000715255737,
      1.399999976158142,
      1.2999999523162842,
      1.399999976158142,
      1.4000000953674316,
      1.1999999284744263,
      1.399999976158142,
      1.3000000715255737,
      1.2999999523162842,
      1.399999976158142,
      1.3000000715255737,
      1.2999999523162842,
      1.5,
      1.2000000476837158,
      1.5,
      1.5,
      1.2999999523162842,
      1.3000000715255737,
      1.399999976158142,
      1.2999999523162842,
      1.3000000715255737,
      1.399999976158142,
      1.2999999523162842,
      1.399999976158142,
      1.3000000715255737
    ],
    "medianMilliseconds": 1.3000000715255737,
    "restyledElementCounts": [
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1
    ],
    "styleUpdateCount": 40
  },
  "invariantPass": false,
  "controlPass": true
}
Second run: complete measurement results
{
  "commit": "070bf3df0aae0f009488f29d8941f5fec8532a93",
  "property": "--secondary-swipe-width",
  "registrationCount": 1,
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/149.0.0.0 Safari/537.36",
  "fallbackWidth": "350px",
  "controlFallbackWidth": "350px",
  "baseline": {
    "label": "trusted-main",
    "descendants": 2400,
    "childProperty": "40cqw",
    "ownerProperty": "40cqw",
    "ownerWidth": "400px",
    "durations": [
      3.399999976158142,
      3.200000047683716,
      3.100000023841858,
      3.100000023841858,
      3.0999999046325684,
      3.100000023841858,
      3.100000023841858,
      3.200000047683716,
      3.0999999046325684,
      3.200000047683716,
      3.100000023841858,
      3.299999952316284,
      3.100000023841858,
      3.100000023841858,
      3.5,
      3.1999999284744263,
      3.100000023841858,
      3.8000000715255737,
      3.1999999284744263,
      3.100000023841858,
      3.100000023841858,
      3.100000023841858,
      3.0999999046325684,
      3.200000047683716,
      3,
      3.100000023841858,
      3.100000023841858,
      3.299999952316284,
      3.100000023841858,
      3.1999999284744263,
      3.100000023841858,
      3.100000023841858,
      3.100000023841858,
      3.100000023841858,
      3.0999999046325684,
      3.200000047683716,
      3.100000023841858,
      3.1999999284744263,
      3.100000023841858,
      3.100000023841858
    ],
    "medianMilliseconds": 3.100000023841858,
    "restyledElementCounts": [
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401,
      2401
    ],
    "styleUpdateCount": 40
  },
  "control": {
    "label": "non-inherited-control",
    "descendants": 2400,
    "childProperty": "",
    "ownerProperty": "40cqw",
    "ownerWidth": "400px",
    "durations": [
      1.5,
      1.3000000715255737,
      1.399999976158142,
      1.5,
      1.5,
      2.600000023841858,
      1.399999976158142,
      1.2999999523162842,
      1.3000000715255737,
      1.5999999046325684,
      1.4000000953674316,
      1.2999999523162842,
      1.399999976158142,
      1.399999976158142,
      1.4000000953674316,
      1.399999976158142,
      1.2999999523162842,
      1.3000000715255737,
      1.399999976158142,
      1.600000023841858,
      1.399999976158142,
      1.399999976158142,
      1.399999976158142,
      1.3000000715255737,
      1.399999976158142,
      1.5,
      1.399999976158142,
      2.200000047683716,
      1.2999999523162842,
      1.399999976158142,
      1.399999976158142,
      1.3000000715255737,
      1.399999976158142,
      1.2999999523162842,
      1.4000000953674316,
      1.5,
      1.5,
      1.2999999523162842,
      1.2999999523162842,
      1.3000000715255737
    ],
    "medianMilliseconds": 1.399999976158142,
    "restyledElementCounts": [
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1
    ],
    "styleUpdateCount": 40
  },
  "invariantPass": false,
  "controlPass": true
}

Reproduction files and raw CLI envelopes are retained locally, not committed to this public reports repository. All required scripts and numerical evidence are inline above.

> AGENT GENERATED