Skip to content

Commit 116057b

Browse files
committed
Refine supervisor timeout setting layout
1 parent 432ff25 commit 116057b

4 files changed

Lines changed: 85 additions & 26 deletions

File tree

packages/web/src/features/settings/components/settings-page.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,27 @@ describe("SettingsPage", () => {
289289
});
290290
});
291291

292+
it("renders the supervisor timeout control as an inline settings row", async () => {
293+
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
294+
if (op === "settings.get") {
295+
return {
296+
"supervisor.evaluationTimeoutSec": 600,
297+
};
298+
}
299+
return {};
300+
});
301+
const store = createConnectedStore(sendCommand);
302+
303+
renderSettingsPage(store);
304+
305+
const input = await screen.findByLabelText("Supervisor 超时(秒)");
306+
const field = input.closest(".settings-config-field");
307+
const control = input.closest(".settings-config-control");
308+
309+
expect(field).toHaveClass("settings-config-field--inline");
310+
expect(control).not.toBeNull();
311+
});
312+
292313
it("does not save supervisor timeout for non-integer numeric strings", async () => {
293314
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
294315
if (op === "settings.get") {

packages/web/src/features/settings/components/settings-page.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -640,36 +640,38 @@ function GeneralSettings({
640640
<h3 className="settings-group-title">{t("settings.supervisor.title")}</h3>
641641
<p className="settings-group-desc">{t("settings.supervisor.hint")}</p>
642642

643-
<div className="settings-config-field">
643+
<div className="settings-config-field settings-config-field--inline">
644644
<label className="settings-config-label" htmlFor="supervisor-evaluation-timeout">
645645
{t("settings.supervisor.evaluation_timeout")}
646646
</label>
647-
<input
648-
id="supervisor-evaluation-timeout"
649-
className="input"
650-
type="number"
651-
min={1}
652-
max={MAX_SUPERVISOR_EVALUATION_TIMEOUT_SEC}
653-
step={1}
654-
inputMode="numeric"
655-
aria-invalid={supervisorTimeoutError ? "true" : "false"}
656-
value={supervisorTimeoutDraft}
657-
onChange={(event) => {
658-
setSupervisorTimeoutDraft(event.target.value);
659-
if (supervisorTimeoutError) {
660-
setSupervisorTimeoutError(null);
661-
}
662-
}}
663-
onBlur={() => {
664-
void commitSupervisorTimeout();
665-
}}
666-
onKeyDown={(event) => {
667-
if (event.key === "Enter") {
668-
event.preventDefault();
647+
<div className="settings-config-control">
648+
<input
649+
id="supervisor-evaluation-timeout"
650+
className="input settings-input-compact"
651+
type="number"
652+
min={1}
653+
max={MAX_SUPERVISOR_EVALUATION_TIMEOUT_SEC}
654+
step={1}
655+
inputMode="numeric"
656+
aria-invalid={supervisorTimeoutError ? "true" : "false"}
657+
value={supervisorTimeoutDraft}
658+
onChange={(event) => {
659+
setSupervisorTimeoutDraft(event.target.value);
660+
if (supervisorTimeoutError) {
661+
setSupervisorTimeoutError(null);
662+
}
663+
}}
664+
onBlur={() => {
669665
void commitSupervisorTimeout();
670-
}
671-
}}
672-
/>
666+
}}
667+
onKeyDown={(event) => {
668+
if (event.key === "Enter") {
669+
event.preventDefault();
670+
void commitSupervisorTimeout();
671+
}
672+
}}
673+
/>
674+
</div>
673675
{supervisorTimeoutError ? (
674676
<span className="form-error" role="alert">
675677
{supervisorTimeoutError}

packages/web/src/styles/components.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,35 @@
954954
width: 100%;
955955
}
956956

957+
.settings-config-field--inline {
958+
display: grid;
959+
grid-template-columns: minmax(0, 1fr) auto;
960+
align-items: center;
961+
gap: var(--sp-3);
962+
}
963+
957964
.settings-config-label {
958965
display: block;
959966
font-size: var(--text-sm);
960967
color: var(--text-secondary);
961968
margin-bottom: var(--sp-2);
962969
}
963970

971+
.settings-config-field--inline .settings-config-label {
972+
margin-bottom: 0;
973+
}
974+
975+
.settings-config-control {
976+
display: flex;
977+
justify-content: flex-end;
978+
min-width: 0;
979+
}
980+
981+
.settings-input-compact {
982+
width: min(160px, 100%);
983+
text-align: right;
984+
}
985+
964986
.settings-provider-args-input {
965987
display: block;
966988
width: 100%;

packages/web/src/styles/components.theme.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,18 @@ describe("components.css theme-sensitive surfaces", () => {
293293
expect(ctrlLocked).toContain("var(--accent-blue)");
294294
expect(shiftArmed).toContain("var(--accent-blue)");
295295
});
296+
297+
it("keeps the supervisor timeout setting aligned as a label-left control-right row", () => {
298+
const inlineField = getLastRuleBlock(".settings-config-field--inline");
299+
const inlineLabel = getLastRuleBlock(".settings-config-field--inline .settings-config-label");
300+
const control = getLastRuleBlock(".settings-config-control");
301+
const compactInput = getLastRuleBlock(".settings-input-compact");
302+
303+
expect(inlineField).toContain("display: grid");
304+
expect(inlineField).toContain("grid-template-columns: minmax(0, 1fr) auto");
305+
expect(inlineField).toContain("align-items: center");
306+
expect(inlineLabel).toContain("margin-bottom: 0");
307+
expect(control).toContain("justify-content: flex-end");
308+
expect(compactInput).toContain("text-align: right");
309+
});
296310
});

0 commit comments

Comments
 (0)