Skip to content

Commit 9885a84

Browse files
refactor(web): simplify global styling (#6381)
Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 196c8ea commit 9885a84

69 files changed

Lines changed: 851 additions & 1123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: UI Consistency
3+
model: claude-opus-5
4+
effort: high
5+
input: full_diff
6+
tools:
7+
- browse_code
8+
- git_tools
9+
- github_api_read_only
10+
- modify_pr
11+
include:
12+
- "apps/web/src/**/*.ts"
13+
- "apps/web/src/**/*.tsx"
14+
- "apps/web/src/**/*.css"
15+
conclusion: failure
16+
showToolCalls: true
17+
---
18+
19+
# UI consistency review
20+
21+
Review changed web UI code and directly affected call sites for consistency with the shared component system, Tailwind ownership, and the behavioral constraints below. Apply these rules when a pull request creates, moves, or modifies controls or styling. Do not demand unrelated repository-wide cleanup.
22+
23+
The goal is not to minimize CSS or class counts at any cost. The goal is to put each behavior in the smallest correct owner while preserving interaction, theming, accessibility, layout, and browser behavior.
24+
25+
## Shared controls and variants
26+
27+
- Prefer the core UI primitives in `apps/web/src/components/ui` over native controls or locally reconstructed primitives. In ordinary product UI, a raw `<button>` that recreates `Button`, a raw input that recreates `Input` or `InputGroup`, or a local trigger that recreates `Select`, `Toggle`, or `Menu` is a concrete finding.
28+
- Do not flag raw elements that intentionally implement a semantic row, tab, resize handle, swatch, image target, editor surface, or another interaction whose behavior or geometry differs from the core primitive.
29+
- When multiple call sites repeat the same durable geometry or treatment, prefer a named primitive size or variant. Examples include compact controls, micro icon actions, muted ghost actions, and glass actions. Keep contextual layout, width, and color at the call site.
30+
- Flag large call-site class strings that override a primitive's core height, radius, padding, focus ring, cursor, hit target, or base state colors. Prefer extending the primitive contract when the same pattern is genuinely shared.
31+
- Preserve accessibility and interaction semantics during migrations: focus-visible rings, disabled behavior, loading state, keyboard behavior, pointer cursor, `aria-*`, Base UI or Radix render/close props, and coarse-pointer hit targets.
32+
- Do not require tests for a tiny visual-only class migration. Require focused tests when primitive composition changes behavior, prop forwarding, state transitions, keyboard handling, or width/defaulting logic.
33+
34+
## CSS and Tailwind ownership
35+
36+
- Ordinary one-owner presentation belongs in the owning TS or TSX module as static Tailwind classes or owner-level CSS variables. Examples include local geometry, spacing, typography, backgrounds, borders, simple vendor pseudo-elements, and component-only positioning.
37+
- Keep global CSS when it is genuinely reusable or behaviorally complex: generated markdown or imperative DOM, custom elements and shadow roots, masks, shared or complex pseudo-elements, animations, glass composition, runtime theme variables, safe-area calculations, scrollbar-lane preservation, Electron drag regions, and browser/vendor integration. Simple owner-local pseudo-elements may still belong in the owning module.
38+
- Before calling a selector dead, trace literal, dynamic, generated, imperative, test, custom-element, and shadow-root consumers. Search both the emitted class string and any class-valued field names through their final DOM sink. A helper returning a class is not proof that it is rendered, and a missed downstream property read can make a deletion unsafe.
39+
- Flag duplicate declarations only after comparing cascade layer, selector specificity, inheritance, runtime theme scope, media/variant scope, and the final owning element. Textually identical declarations are not necessarily behaviorally redundant.
40+
- When moving CSS into Tailwind, preserve selector scope and cascade ownership. A utility at the owner is preferable to a fragile global override that depends on stylesheet order.
41+
- Do not request moving complex global behavior into arbitrary Tailwind merely to reduce `index.css`. Do not preserve ordinary one-owner CSS merely because it already exists globally.
42+
43+
## Themes and generated CSS
44+
45+
- Use the project variants for theme-only declarations:
46+
- dark-only declarations use `@variant dark`;
47+
- light-only declarations use `@variant light`;
48+
- raw `.dark` should remain only in the `dark` and `light` custom-variant definitions.
49+
- Preserve custom themes and runtime token bridges. Removing a variable or selector is safe only when all runtime, inspector, generated, and theme-palette consumers are accounted for.
50+
- Inspect emitted production CSS after unusual variants, arbitrary selectors, nested pseudo-elements, or attribute matching. Source syntax that looks valid is insufficient.
51+
- Flag malformed or empty emitted selectors such as empty `:is()` or `:not(:is())`, selector branches that can never match their own class attribute, and transformations that silently drop the intended rule.
52+
- Prefer source-level logic over clever selectors when behavior depends on consumer-provided class strings. Preserve `MenuPopup`'s current defaulting contract: a string `className` containing a `w-*`, `min-w-*`, or `max-w-*` utility after variant prefixes are stripped suppresses `min-w-32`; a string without one and a functional/non-string `className` keep the default. Arbitrary width values count as width utilities, and the consumer class must be merged last so it retains control. Do not replace this with a raw class-attribute substring selector.
53+
- Do not fail solely because a valid emitted selector is verbose or because a source rule uses an intentional custom property.
54+
55+
## Scroll and virtualized lists
56+
57+
- `ScrollArea` owns and masks its Base UI viewport. A virtualized list usually owns a native scrolling element and cannot automatically reuse viewport-specific `ScrollArea` behavior.
58+
- Repeated native or virtualized overflow fades should use the shared virtualized-scroll-fade contract rather than component-named mask selectors.
59+
- Preserve runtime top and bottom overflow state. Do not replace dynamic fades with an always-on static mask.
60+
- Preserve fade geometry and keep the native scrollbar lane opaque so the track and thumb stay visible and usable. A visually similar mask that fades the scrollbar is a regression.
61+
- Verify actual scroll behavior when changing virtualizers, masks, overflow ownership, or scrollbar selectors. Source-level class comparison is not enough.
62+
63+
## Visual and layout preservation
64+
65+
- Preserve responsive geometry, titlebar insets, panel and inline-preview modes, desktop Electron layout, light and dark contrast, clipping, radius, and composable shadows.
66+
- For meaningful visual changes, prefer available real-app evidence using the actual component and state. A mock recreation does not validate the real component. Light and dark evidence is useful when theme-sensitive styles change, but missing or inaccessible evidence alone is not a finding; report only a concrete regression supported by the diff, code, or available artifacts.
67+
- Do not treat a screenshot as proof of keyboard, overflow, scrollbar, responsive, or runtime-theme behavior. Pair visual evidence with source, computed-style, emitted-CSS, or interaction checks as appropriate.
68+
- Be alert to shared primitive color indirection. When a primitive routes icon color through a CSS variable, ensure migrated contextual icons retain their intended tone, including pressed and disabled states.
69+
70+
## Change discipline
71+
72+
- Review the pull request's changed scope and directly affected consumers. Do not turn a focused PR into a demand for unrelated legacy cleanup.
73+
- Prefer the smallest durable contract over a component-specific workaround or a broad abstraction with one consumer.
74+
- Preserve intentional exceptions and comments that explain browser, virtualizer, theme, or Electron constraints.
75+
- If a proposed cleanup cannot prove ownership or semantic equivalence, ask for evidence or leave it unchanged rather than guessing.
76+
- Select verification gates according to the changed behavior: typecheck or focused tests for typing and interaction contracts, production build and emitted-CSS inspection for Tailwind or selector transformations, and real-app evidence for meaningful visual behavior when available. These gates are complementary when applicable, but do not require every gate for tiny visual-only migrations or fail solely because an artifact the configured tools cannot produce is absent.
77+
78+
## Reporting
79+
80+
Report only concrete violations introduced by changed lines or behavior, plus pre-existing behavior that the patch directly makes relevant or worsens. Touching a large file does not make unrelated retained issues reportable. Prefer precise inline comments on the smallest relevant line range. Explain the broken behavior or ownership rule, not merely the preferred syntax, and state the smallest expected fix. A clear consistency or regression risk may fail the check. Do not fail for optional aesthetic preferences, harmless class ordering, or unrelated legacy code.
81+
82+
This check defaults to failure. When there are no findings, stop immediately and make the entire final response exactly `All clear` on one line. Do not add a title, explanation, punctuation, Markdown, JSON, or trailing analysis, and do not continue reasoning after deciding the review is clean.

‎apps/web/src/components/AgentsPanel.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { useEffect, useRef, useState } from "react";
2828
import { cn } from "~/lib/utils";
2929
import { orchestrationEnvironment } from "~/state/orchestration";
3030
import { ScrollArea } from "~/components/ui/scroll-area";
31+
import { Button } from "~/components/ui/button";
3132

3233
/**
3334
* In-flight states all present as Working (one steady state, per the
@@ -282,14 +283,15 @@ function WorkflowScriptView({
282283
<span className="truncate font-mono text-[.65rem] text-muted-foreground">
283284
{scriptPath.split("/").at(-1)}
284285
</span>
285-
<button
286-
type="button"
286+
<Button
287+
size="icon-micro"
288+
variant="ghost-muted"
287289
onClick={onClose}
288290
aria-label="Close script"
289-
className="ml-auto text-muted-foreground hover:text-foreground"
291+
className="ml-auto"
290292
>
291293
<X aria-hidden className="size-3" />
292-
</button>
294+
</Button>
293295
</div>
294296
<div className="max-h-72 overflow-auto p-2">
295297
{result._tag === "Success" ? (
@@ -417,14 +419,14 @@ function ExpandedWorkflowSection({
417419
<span className="ml-auto font-mono normal-case text-muted-foreground/80">
418420
{settled}/{members.length} settled
419421
</span>
420-
<button
421-
type="button"
422+
<Button
423+
size="icon-micro"
424+
variant="ghost-muted"
422425
onClick={onCollapse}
423426
aria-label="Collapse workflow"
424-
className="text-muted-foreground hover:text-foreground"
425427
>
426428
<ChevronDown aria-hidden className="size-3" />
427-
</button>
429+
</Button>
428430
</div>
429431
<PhaseRail group={group} />
430432
{scriptOpen && canShowScript ? (

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
} from "./ThreadStatusIndicators";
5252
import { Button } from "./ui/button";
5353
import { Switch } from "./ui/switch";
54+
import { getVirtualizedScrollFadeClassName } from "./ui/scroll-area";
5455
import {
5556
Combobox,
5657
ComboboxEmpty,
@@ -814,9 +815,11 @@ export function BranchToolbarBranchSelector({
814815
maybeFetchNextBranchPage();
815816
}}
816817
className={cn(
817-
"scrollbar-gutter-stable overflow-x-hidden overscroll-y-contain ps-1 pe-0 pt-2 pb-1 [--fade-size:1.5rem]",
818-
showTopBranchScrollFade && "mask-t-from-[calc(100%-var(--fade-size))]",
819-
showBottomBranchScrollFade && "mask-b-from-[calc(100%-var(--fade-size))]",
818+
"scrollbar-gutter-stable overflow-x-hidden overscroll-y-contain ps-1 pe-0 pt-2 pb-1",
819+
getVirtualizedScrollFadeClassName({
820+
top: showTopBranchScrollFade,
821+
bottom: showBottomBranchScrollFade,
822+
}),
820823
)}
821824
style={{ maxHeight: "14rem" }}
822825
/>

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
449449
{children}
450450
</table>
451451
</ScrollArea>
452-
<div className="chat-markdown-table-footer select-none">
452+
<div className="mt-0.5 flex items-center justify-between select-none">
453453
<Tooltip>
454454
<TooltipTrigger
455455
render={
@@ -642,12 +642,12 @@ function MarkdownCodeBlock({
642642

643643
return (
644644
<div
645-
className="chat-markdown-codeblock border border-border/70 bg-secondary leading-snug dark:border-transparent dark:bg-input/32"
645+
className="chat-markdown-codeblock my-[0.65rem] overflow-hidden rounded-[var(--radius)] border border-border/70 bg-secondary leading-snug dark:border-transparent dark:bg-input/32"
646646
data-language={language}
647647
data-wrap={wrapped ? "true" : "false"}
648648
>
649-
<div className="chat-markdown-codeblock-header select-none">
650-
<span className="chat-markdown-codeblock-title">
649+
<div className="chat-markdown-codeblock-header flex items-center justify-between gap-2 pt-1.5 pr-1.5 pb-0 pl-3 select-none">
650+
<span className="inline-flex min-w-0 items-center gap-[0.4rem] [font-family:var(--font-mono,ui-monospace,SFMono-Regular,monospace)] [font-size:0.6875rem]">
651651
<MarkdownCodeBlockTitleContent
652652
fenceTitle={fenceTitle}
653653
language={language}
@@ -897,7 +897,10 @@ const failedFaviconHosts = new Set<string>();
897897
const MarkdownLinkFavicon = memo(function MarkdownLinkFavicon({ host }: { host: string }) {
898898
const [failedHost, setFailedHost] = useState<string | null>(null);
899899
return (
900-
<span className="chat-markdown-link-favicon" aria-hidden>
900+
<span
901+
className="ms-[0.25em] me-[0.2em] inline-flex size-[14px] [vertical-align:-0.125em]"
902+
aria-hidden
903+
>
901904
{failedHost === host || failedFaviconHosts.has(host) ? (
902905
<GlobeIcon className={MARKDOWN_LINK_FAVICON_CLASS_NAME} />
903906
) : (
@@ -1044,7 +1047,7 @@ function MarkdownExternalLinkContent({
10441047
const leadingLength = leadingExternalLinkTextLength(plainText);
10451048
return (
10461049
<>
1047-
<span className="chat-markdown-link-leading">
1050+
<span className="whitespace-nowrap">
10481051
<MarkdownLinkFavicon host={host} />
10491052
{plainText.slice(0, leadingLength)}
10501053
</span>
@@ -1060,7 +1063,7 @@ function MarkdownExternalLinkContent({
10601063
const leadingLength = leadingExternalLinkTextLength(firstChild);
10611064
return (
10621065
<>
1063-
<span className="chat-markdown-link-leading">
1066+
<span className="whitespace-nowrap">
10641067
<MarkdownLinkFavicon host={host} />
10651068
{firstChild.slice(0, leadingLength)}
10661069
</span>
@@ -1072,7 +1075,7 @@ function MarkdownExternalLinkContent({
10721075

10731076
return (
10741077
<>
1075-
<span className="chat-markdown-link-leading">
1078+
<span className="whitespace-nowrap">
10761079
<MarkdownLinkFavicon host={host} />
10771080
{firstChild}
10781081
</span>
@@ -1289,7 +1292,7 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
12891292
side="top"
12901293
className="max-w-[min(40rem,calc(100vw-2rem))] font-mono text-[11px] leading-tight"
12911294
>
1292-
<div className="markdown-file-link-tooltip-scroll overflow-x-auto whitespace-nowrap">
1295+
<div className="overflow-x-auto whitespace-nowrap [scrollbar-color:color-mix(in_srgb,var(--border)_78%,transparent)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-[color-mix(in_srgb,var(--border)_78%,transparent)] [&::-webkit-scrollbar-track]:bg-transparent">
12931296
{displayPath}
12941297
</div>
12951298
</TooltipPopup>
@@ -1699,7 +1702,7 @@ function ChatMarkdown({
16991702
return (
17001703
<div
17011704
className={cn(
1702-
"chat-markdown w-full min-w-0 text-sm leading-relaxed text-foreground/80",
1705+
"chat-markdown w-full min-w-0 text-sm leading-relaxed text-foreground/80 [overflow-wrap:anywhere] [word-break:break-word]",
17031706
className,
17041707
)}
17051708
onCopy={handleCopy}

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6023,8 +6023,9 @@ function ChatViewContent(props: ChatViewProps) {
60236023
// One inset in both states: the controls move between containers when
60246024
// the right panel opens, and a different right offset made them jump
60256025
// sideways on every toggle.
6026-
"workspace-titlebar-controls z-50 mr-px gap-1 [-webkit-app-region:no-drag]",
6026+
"absolute top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
60276027
)}
6028+
data-workspace-titlebar-controls
60286029
>
60296030
{rightPanelOpen && !shouldUseRightPanelSheet ? (
60306031
<RightPanelMaximizeControl
@@ -6165,12 +6166,12 @@ function ChatViewContent(props: ChatViewProps) {
61656166
"bg-background transition-[padding-left] duration-200 ease-linear motion-reduce:transition-none",
61666167
isElectron
61676168
? cn(
6168-
"workspace-topbar drag-region relative px-3 sm:px-5",
6169+
"drag-region relative flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center px-3 sm:px-5",
61696170
reserveTitleBarControlInset &&
61706171
!inlineRightPanelOwnsTitleBar &&
61716172
"wco:pr-[var(--workspace-native-controls-inset)]",
61726173
)
6173-
: "workspace-topbar pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]",
6174+
: "flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]",
61746175
COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
61756176
)}
61766177
>
@@ -6273,16 +6274,17 @@ function ChatViewContent(props: ChatViewProps) {
62736274
className="pointer-events-none absolute left-1/2 z-30 flex -translate-x-1/2 justify-center py-1.5"
62746275
style={{ bottom: composerOverlayHeight + 4 }}
62756276
>
6276-
<button
6277-
type="button"
6277+
<Button
62786278
aria-label="Scroll to end"
62796279
title="Scroll to end"
62806280
onClick={() => scrollToEnd(true)}
6281-
className="chat-composer-glass pointer-events-auto flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1 text-muted-foreground text-xs shadow-sm transition-colors hover:border-border hover:text-foreground hover:cursor-pointer"
6281+
className="pointer-events-auto gap-1.5 rounded-full px-3 text-muted-foreground hover:text-foreground"
6282+
size="xs"
6283+
variant="glass"
62826284
>
62836285
<ChevronDownIcon className="size-3.5" />
62846286
Scroll to end
6285-
</button>
6287+
</Button>
62866288
</div>
62876289
)}
62886290
</div>
@@ -6299,7 +6301,7 @@ function ChatViewContent(props: ChatViewProps) {
62996301
>
63006302
<div
63016303
ref={attachDraftHeroTransitionGroupRef}
6302-
className="chat-composer-horizontal-inset w-full"
6304+
className="w-full ps-[calc(env(safe-area-inset-left)+0.75rem)] pe-[calc(env(safe-area-inset-right)+0.75rem)] sm:ps-[calc(env(safe-area-inset-left)+1.25rem)] sm:pe-[calc(env(safe-area-inset-right)+1.25rem)]"
63036305
>
63046306
<div className="pointer-events-auto relative z-10">
63056307
{isDraftHeroState ? (

0 commit comments

Comments
 (0)