Skip to content

Commit 66196b7

Browse files
committed
Control UI: pair wizard cancel and primary actions
1 parent 767bbb4 commit 66196b7

5 files changed

Lines changed: 68 additions & 18 deletions

File tree

‎ui/src/components/wizard-step-controls.ts‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type WizardStepControlsProps = {
2121
presentation?: "channels";
2222
answerLabel?: string;
2323
confirmAffirmativeLabel?: string;
24+
leadingAction?: TemplateResult;
2425
sensitiveRevealed?: boolean;
2526
onToggleSensitiveVisibility?: () => void;
2627
};
@@ -98,8 +99,13 @@ function renderAnswerButton(
9899
${props.answerLabel ?? label}
99100
</button>
100101
`;
101-
return props.presentation === "channels"
102-
? html`<div class="channels-wizard__footer">${button}</div>`
102+
if (props.presentation === "channels") {
103+
return html`<div class="channels-wizard__footer">${button}</div>`;
104+
}
105+
return props.leadingAction
106+
? html`<div class="wizard-step__actions wizard-step__actions--split">
107+
${props.leadingAction}${button}
108+
</div>`
103109
: button;
104110
}
105111

@@ -170,6 +176,11 @@ function renderProgressStep(props: WizardStepControlsProps) {
170176
<span class="wizard-step__spinner" aria-hidden="true"></span>
171177
${renderMessage(props)}
172178
</div>
179+
${props.leadingAction
180+
? html`<div class="wizard-step__actions wizard-step__actions--split">
181+
${props.leadingAction}
182+
</div>`
183+
: nothing}
173184
`;
174185
}
175186

@@ -271,9 +282,15 @@ function renderOptionsStep(props: WizardStepControlsProps) {
271282
}
272283

273284
function renderConfirmStep(props: WizardStepControlsProps) {
285+
const actionClass = stepClass(props, props.presentation === "channels" ? "footer" : "actions");
274286
return html`
275287
${renderMessage(props)}
276-
<div class=${stepClass(props, props.presentation === "channels" ? "footer" : "actions")}>
288+
<div
289+
class=${props.presentation !== "channels" && props.leadingAction
290+
? `${actionClass} wizard-step__actions--split`
291+
: actionClass}
292+
>
293+
${props.presentation === "channels" ? nothing : (props.leadingAction ?? nothing)}
277294
${[false, true].map(
278295
(answer) => html`<button
279296
type="button"
@@ -290,8 +307,9 @@ function renderConfirmStep(props: WizardStepControlsProps) {
290307

291308
/**
292309
* Renders the interactive controls for one `WizardStep`. Container-agnostic on
293-
* purpose: no dialog chrome, no cancel row, no page state — callers place the
294-
* result wherever the step is being asked (modal, panel, or chat bubble).
310+
* purpose: no dialog chrome or page state — callers place the result wherever
311+
* the step is being asked (modal, panel, or chat bubble). A caller may supply a
312+
* leading action so escape and answer controls share one footer row.
295313
*/
296314
export function renderWizardStepControls(
297315
props: WizardStepControlsProps,

‎ui/src/e2e/custodian-event-nudge.e2e.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ suite.define(() => {
319319
});
320320

321321
it("renders rich wizard controls and sends typed answers", async () => {
322+
if (captureUiProofEnabled) {
323+
await mkdir(uiProofArtifactDir, { recursive: true });
324+
}
322325
await suite.withPage(
323326
{
324327
colorScheme: "dark",
@@ -388,6 +391,33 @@ suite.define(() => {
388391
),
389392
),
390393
).toEqual([44, 44]);
394+
for (const viewport of [
395+
{ width: 390, height: 844, name: "phone" },
396+
{ width: 768, height: 1024, name: "tablet" },
397+
{ width: 1440, height: 900, name: "desktop" },
398+
]) {
399+
await page.setViewportSize(viewport);
400+
const [continueBox, cancelBox] = await Promise.all([
401+
continueButton.boundingBox(),
402+
cancelButton.boundingBox(),
403+
]);
404+
expect(cancelBox).not.toBeNull();
405+
expect(continueBox).not.toBeNull();
406+
expect(cancelBox!.x).toBeLessThan(continueBox!.x);
407+
expect(Math.abs(cancelBox!.y - continueBox!.y)).toBeLessThan(1);
408+
expect(
409+
await page.evaluate(
410+
() => document.documentElement.scrollWidth <= document.documentElement.clientWidth,
411+
),
412+
).toBe(true);
413+
if (captureUiProofEnabled) {
414+
await page.screenshot({
415+
animations: "disabled",
416+
fullPage: true,
417+
path: path.join(uiProofArtifactDir, `05-rich-wizard-actions-${viewport.name}.png`),
418+
});
419+
}
420+
}
391421

392422
await gateway.setMethodResponse("openclaw.chat", {
393423
sessionId: "e2e-rich-wizard",

‎ui/src/pages/custodian/transcript.ts‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,18 @@ export function renderCustodianTranscriptEntry(params: {
194194
sensitiveRevealed: params.wizardSecretVisible,
195195
onValueChange: params.onWizardValueChange,
196196
onAnswer: params.onWizardAnswer,
197-
onToggleSensitiveVisibility: params.onToggleWizardSecretVisibility,
198-
})}
199-
${params.showWizardCancel
200-
? html`<div class="custodian__wizard-actions">
201-
<button
197+
leadingAction: params.showWizardCancel
198+
? html`<button
202199
class="btn btn--ghost custodian__wizard-cancel"
203200
type="button"
204201
?disabled=${params.wizardDisabled}
205202
@click=${params.onWizardCancel}
206203
>
207204
${t("custodian.cancel")}
208-
</button>
209-
</div>`
210-
: nothing}
205+
</button>`
206+
: nothing,
207+
onToggleSensitiveVisibility: params.onToggleWizardSecretVisibility,
208+
})}
211209
</section>`
212210
: nothing}
213211
`;

‎ui/src/styles/custodian.css‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ openclaw-custodian-page {
280280
font-size: 14px;
281281
}
282282

283-
.custodian__wizard-actions {
284-
display: flex;
285-
justify-content: flex-start;
286-
}
287-
288283
.custodian__wizard-step .btn {
289284
min-height: 44px;
290285
}
@@ -309,6 +304,10 @@ openclaw-custodian-page {
309304
color: var(--text);
310305
}
311306

307+
.custodian__wizard-cancel {
308+
margin-right: auto;
309+
}
310+
312311
.custodian__thinking {
313312
display: flex;
314313
flex-direction: row;

‎ui/src/styles/wizard-step-controls.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
gap: 8px;
6969
}
7070

71+
.wizard-step__actions--split {
72+
align-items: center;
73+
justify-content: flex-end;
74+
}
75+
7176
.wizard-step__progress {
7277
display: flex;
7378
align-items: center;

0 commit comments

Comments
 (0)