# Sidebar CSS experiment

The retained change removes the outer SidebarProvider's unused descendant query for an inset sidebar. Current app callers use the normal sidebar variant. Inset compositions can request bg-sidebar explicitly through className. No other :has rules were removed.

Baseline: [beb61e4d00](https://github.com/pingdotgg/t3code/commit/beb61e4d00e033915754299d144c8c313df4ad85), the former five-PR tip. The stack merged during this experiment; resulting main [211618fd9f](https://github.com/pingdotgg/t3code/commit/211618fd9f) has identical web/mobile/client-runtime source. The CSS commit was rebased onto that main as [6a961ad283](https://github.com/pingdotgg/t3code/commit/6a961ad2839106046f1463f8d1ffa74cd1879e59).

## Results

Six counterbalanced rounds per variant. Lower is better. Medians below are medians of per-round medians, not historical measurements combined across sessions.

| Metric | Parent | CSS change | Reduction |
| --- | ---: | ---: | ---: |
| Cached switch, median | 163.975 ms | 104.425 ms | 36.3% |
| Cached switch, pooled p95 | 250.9 ms | 155.4 ms | 38.1% |
| Growing code update, median | 104.85 ms | 27.05 ms | 74.2% |
| Growing code update, median per-run p95 | 130.3 ms | 42.05 ms | 67.7% |
| Prose after completed code, median | 13.875 ms | 12.725 ms | Mixed across rounds |
| Switches with sampled blank frames | 0/48 | 0/48 | No regression |

All six paired rounds improve for switching and growing code. Prose improves in only three of six pairs, so no reliable prose benefit is claimed. Summed synchronous update time for the fixed 960-update mix falls from 36,513.6 to 17,258.2 ms, a 52.7% reduction. This mix is dominated by growing code and is not an overall application speed claim.

## What was tried

1. Removing every :has rule was a diagnostic only. It showed a large benefit but breaks styling and was rejected.
2. Removing arbitrary quarters and semantic groups of rules after page load did not isolate a consistent improvement.
3. Selector/invalidation tracing found all 538 Affected by :has invalidations in a two-switch trace on the outer sidebar wrapper. No inset sidebar was present.
4. Restricting the rule to a direct sidebar child was built and benchmarked. It still recorded 538 wrapper invalidations and did not consistently improve switching. Rejected.
5. Removing just the unused wrapper rule before document load consistently improved all six switch rounds. The final source change was separately built and benchmarked, confirming the result.

The final two-switch trace records 15 Affected by :has invalidations. Profiling was separate from timing. Selector tracing adds overhead and its durations are not used as benchmark timings. See [Chrome's selector profiling documentation](https://developer.chrome.com/docs/devtools/performance/selector-stats).

## Method and validation

Production Chrome builds on the same Linux AMD EPYC-Genoa runner, origin, isolated backend and synthetic fixtures as the earlier direct comparison. Navigation uses two 400-message threads and the normal app pagination. Each round warms both destinations and measures eight switches. Ready means the correct route and destination end marker visibly rendered for two frames, timed at the first. No CPU throttling or recordings during timing.

Streaming uses the same temporary probe, 120 prose updates and 40 appended-code-line updates per round after warmup. To isolate CSS exactly, those streaming trials use byte-identical instrumented JavaScript with only the single compiled CSS rule removed in the candidate. The separately built final source was used for navigation and UI validation. Temporary probes and evidence are not committed.

Matched before/after screenshots cover light/dark themes, 1440x1000 and 390x844, sidebar visible/hidden or sheet open. Root backgrounds remain transparent and no horizontal page overflow appeared. Rapid interrupted navigation passed in both themes with no blank frames. Separate switch recordings preserve screenshot timestamps.

Production build, targeted formatting and lint checks completed. Lint reports the existing Math.random-in-render warning at sidebar.tsx:911, outside this change. No new tests mirroring a CSS class were added. Web verified; desktop shares the CSS but Electron was not run. Mobile native code is unaffected.

GPT-6 / Codex; browser verification with agent-browser.
