Skip to content

Commit 5da7f7b

Browse files
committed
fix(gui): inset the Claude account-pool warning and threshold field
`.card` carries no padding of its own — `.card-row`, `.card-sub` and `.setting-row` each supply the 16px inset. The experimental warning box and the threshold field are none of those, so in the Anthropic account-pool card they rendered flush against the card border while the title row and the rotation rows sat 16px in. Measured in the dashboard at 814px card width: title 17px from the card edge, warning box and threshold input 1px. The warning takes margin rather than padding: it draws its own border, so padding insets only its text and leaves the border on the card edge. The threshold field takes padding because the `.input` inside is full-width, so the field owns the inset for the label, the control and the help line. This is the same fix `.account-pool-strategy-card` already carries for the Codex pool card, applied to the card that still had the gap. Moving the box styles out of inline `style` is part of it: an inline `padding` outranks any stylesheet rule, so leaving it there would keep the inset unreachable.
1 parent 3e3a028 commit 5da7f7b

3 files changed

Lines changed: 137 additions & 14 deletions

File tree

‎gui/src/components/provider-workspace/AnthropicAccountPoolSettings.tsx‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default function AnthropicAccountPoolSettings({
145145
const toggleDisabled = loading || saving || loadError || (!enabled && accountCount < 2);
146146

147147
return (
148-
<div className="card" style={{ marginTop: 12 }} aria-busy={loading || saving}>
148+
<div className="card anthropic-pool-card" aria-busy={loading || saving}>
149149
<div className="card-row" style={{ alignItems: "flex-start", gap: 12 }}>
150150
<div style={{ flex: 1 }}>
151151
<strong>{t("anthropicPool.title")}</strong>
@@ -179,17 +179,7 @@ export default function AnthropicAccountPoolSettings({
179179
</button>
180180
</div>
181181

182-
<div
183-
role="alert"
184-
className="card-sub"
185-
style={{
186-
marginTop: 10,
187-
padding: "10px 16px",
188-
border: "1px solid var(--border, #c9a227)",
189-
borderRadius: 6,
190-
background: "color-mix(in srgb, var(--warn, #c9a227) 12%, transparent)",
191-
}}
192-
>
182+
<div role="alert" className="card-sub anthropic-pool-card__notice">
193183
{t("anthropicPool.experimentalWarning")}
194184
</div>
195185

@@ -199,7 +189,7 @@ export default function AnthropicAccountPoolSettings({
199189

200190
{enabled && state && (
201191
<>
202-
<label className="field" style={{ display: "block", marginTop: 12 }}>
192+
<label className="field anthropic-pool-card__field">
203193
<span className="field-label">{t("anthropicPool.threshold")}</span>
204194
<input
205195
className="input mono"

‎gui/src/styles.css‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,8 @@ dialog.modal-overlay::backdrop {
17321732
.account-pool-strategy-card > strong { display: block; margin: 0; }
17331733
.account-pool-strategy-card > .card-sub,
17341734
.account-pool-strategy-controls > .card-sub,
1735-
.account-pool-strategy-controls .field .card-sub {
1735+
.account-pool-strategy-controls .field .card-sub,
1736+
.anthropic-pool-card__field .card-sub {
17361737
/* Already inside the padded card — don't double-indent like account-card subs. */
17371738
margin: 0;
17381739
padding: 0;
@@ -1755,6 +1756,30 @@ dialog.modal-overlay::backdrop {
17551756
white-space: nowrap;
17561757
min-width: 0;
17571758
}
1759+
1760+
/*
1761+
* Claude account-pool card — the same inset `.account-pool-strategy-card` above already
1762+
* fixes, on the card that still had it. `.card` has no padding, so each child brings its
1763+
* own 16px: `.card-row`, `.card-sub` and `.setting-row` do, the warning box and the
1764+
* threshold field do not, so those two rendered flush against the card border.
1765+
*
1766+
* The warning takes margin, not padding: it is a bordered box, so its own padding insets
1767+
* the text and leaves the border itself on the card edge.
1768+
*/
1769+
.anthropic-pool-card { margin-top: 12px; }
1770+
.anthropic-pool-card__notice {
1771+
margin: 10px 16px 0;
1772+
padding: 10px 16px;
1773+
border: 1px solid var(--border, #c9a227);
1774+
border-radius: 6px;
1775+
background: color-mix(in srgb, var(--warn, #c9a227) 12%, transparent);
1776+
}
1777+
.anthropic-pool-card__field {
1778+
display: block;
1779+
margin-top: 12px;
1780+
/* The `.input` inside is full-width, so the field owns the inset for the whole group. */
1781+
padding: 0 16px;
1782+
}
17581783
.api-active-keys-skeleton {
17591784
min-height: 96px;
17601785
border: 1px solid var(--border-soft);
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { expect, test } from "bun:test";
2+
3+
/**
4+
* Claude account-pool card inset contract.
5+
*
6+
* Source-text assertions, not rendered measurements: happy-dom performs no layout, so a
7+
* getBoundingClientRect() here returns zeros and would prove nothing. Rendered proof was
8+
* captured in a real browser during the fix — the title sat 17px from the card's left
9+
* edge while the warning box and the threshold input sat at 1px. This file's job is to
10+
* keep the CSS shape that produced that gap from coming back silently.
11+
*
12+
* The bug: `.card` carries no padding of its own, so each child supplies the 16px inset.
13+
* `.card-row`, `.card-sub` and `.setting-row` all do, which is why the title row, the help
14+
* line and the rotation rows were indented. The experimental warning box and the threshold
15+
* field are none of those three, so they ran flush against the card border.
16+
*/
17+
18+
const cssUrl = new URL("../src/styles.css", import.meta.url);
19+
const tsxUrl = new URL(
20+
"../src/components/provider-workspace/AnthropicAccountPoolSettings.tsx",
21+
import.meta.url,
22+
);
23+
24+
/** Strip comments so no assertion can pass on prose that quotes a value. */
25+
function withoutComments(css: string): string {
26+
return css.replace(/\/\*[\s\S]*?\*\//g, "");
27+
}
28+
29+
/**
30+
* Body of a top-level rule. Anchored with no leading whitespace on purpose: `.setting-row`
31+
* also appears indented inside an `@media` block that only sets `flex-wrap`, and matching
32+
* that one instead would read the inset off the wrong rule.
33+
*/
34+
function ruleBody(css: string, selector: string): string {
35+
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36+
const match = css.match(new RegExp(`(^|\\n)${escaped}\\s*\\{([^}]*)\\}`));
37+
if (!match) throw new Error(`rule not found: ${selector}`);
38+
return match[2];
39+
}
40+
41+
/** Horizontal component of a `margin`/`padding` shorthand, in px. */
42+
function horizontal(body: string, property: "margin" | "padding"): number {
43+
const match = body.match(new RegExp(`(?:^|;)\\s*${property}:\\s*([^;]+)`));
44+
if (!match) throw new Error(`${property} not found in: ${body.trim()}`);
45+
const parts = match[1].trim().split(/\s+/);
46+
// 1 value: all sides. 2-3 values: second is the horizontal one. 4: right, then left.
47+
const side = parts.length === 1 ? parts[0] : parts[1];
48+
const px = side.match(/^([\d.]+)(?:px)?$/);
49+
if (!px) throw new Error(`${property} value is not a px length: ${side}`);
50+
return Number(px[1]);
51+
}
52+
53+
/** The inset every padded row in this card already uses. */
54+
async function rowInset(): Promise<number> {
55+
const css = withoutComments(await Bun.file(cssUrl).text());
56+
const cardRow = horizontal(ruleBody(css, ".card-row"), "padding");
57+
const settingRow = horizontal(ruleBody(css, ".setting-row"), "padding");
58+
const cardSub = horizontal(ruleBody(css, ".card-sub"), "padding");
59+
// The three disagree only if the card's own baseline moved, which this contract cannot
60+
// silently follow — a mismatch means the target inset has to be re-decided, not guessed.
61+
expect(settingRow).toBe(cardRow);
62+
expect(cardSub).toBe(cardRow);
63+
return cardRow;
64+
}
65+
66+
test("the warning box is inset by the same amount as the card's padded rows", async () => {
67+
const css = withoutComments(await Bun.file(cssUrl).text());
68+
const notice = ruleBody(css, ".anthropic-pool-card__notice");
69+
70+
// Margin, not padding: the box draws a border, so padding alone insets the text and
71+
// leaves the border itself sitting on the card edge — the original bug, one layer in.
72+
expect(horizontal(notice, "margin")).toBe(await rowInset());
73+
});
74+
75+
test("the threshold field is inset by the same amount as the card's padded rows", async () => {
76+
const css = withoutComments(await Bun.file(cssUrl).text());
77+
const field = ruleBody(css, ".anthropic-pool-card__field");
78+
79+
// The `.input` inside is full-width, so the field carries the inset for the whole group;
80+
// without it the input's own border reaches the card edge.
81+
expect(horizontal(field, "padding")).toBe(await rowInset());
82+
});
83+
84+
test("the help line inside the threshold field is not indented twice", async () => {
85+
const css = withoutComments(await Bun.file(cssUrl).text());
86+
87+
// `.card-sub` brings its own 16px, which lands on top of the field's inset and pushes the
88+
// help text out of line with the label directly above it.
89+
const group = css.match(
90+
/(^|\n)([^{}]*\.anthropic-pool-card__field \.card-sub\s*)\{([^}]*)\}/,
91+
);
92+
expect(group).not.toBeNull();
93+
expect(horizontal(group![3], "padding")).toBe(0);
94+
});
95+
96+
test("the component styles the warning and the field by class, not inline", async () => {
97+
const tsx = await Bun.file(tsxUrl).text();
98+
99+
expect(tsx).toContain('className="card-sub anthropic-pool-card__notice"');
100+
expect(tsx).toContain('className="field anthropic-pool-card__field"');
101+
102+
// The inline box styles are what bypassed the inset: an inline `padding` also outranks
103+
// any stylesheet rule, so reintroducing one silently disables the fix above.
104+
expect(tsx).not.toContain('padding: "10px 16px"');
105+
expect(tsx).not.toContain("borderRadius");
106+
expect(tsx).not.toMatch(/style=\{\{[^}]*marginTop: 10/);
107+
expect(tsx).not.toMatch(/style=\{\{[^}]*display: "block"/);
108+
});

0 commit comments

Comments
 (0)