fix(web): normalize structured task confirmations (#3234)

This commit is contained in:
José Almeida
2026-09-01 16:01:55 +00:00
committed by GitHub
parent 3a93e65060
commit 646ff0063f
11 changed files with 164 additions and 16 deletions
@@ -60,13 +60,20 @@ describe("ActionConfirmPopover", () => {
it("supports a wider bounded surface without changing the default width", async () => {
render(<Harness />);
expect(screen.getByRole("dialog").className).toContain("w-64");
const defaultDialog = screen.getByRole("dialog");
expect(defaultDialog.className).toContain("w-64");
expect(
defaultDialog.querySelector<HTMLElement>('[data-slot="popover-description"]')?.className,
).not.toContain("text-pretty");
cleanup();
render(<Harness size="wide" />);
const wideDialog = screen.getByRole("dialog");
expect(wideDialog.className).toContain("w-72");
expect(wideDialog.className).toContain("max-w-[calc(100vw-1rem)]");
expect(
wideDialog.querySelector<HTMLElement>('[data-slot="popover-description"]')?.className,
).toContain("text-pretty");
});
it("closes before invoking an unresolved confirmation and returns focus on cancel", async () => {
@@ -216,7 +216,12 @@ function ActionConfirmPopoverContent({
<PopoverHeader>
<PopoverTitle id={titleId}>{title}</PopoverTitle>
{description ? (
<PopoverDescription id={descriptionId}>{description}</PopoverDescription>
<PopoverDescription
id={descriptionId}
className={size === "wide" ? "text-pretty" : undefined}
>
{description}
</PopoverDescription>
) : null}
</PopoverHeader>
<div className="flex justify-end gap-2">
@@ -5,15 +5,29 @@ import { useTranslation } from "react-i18next";
export function SessionDeleteDescription({
isPrimary,
isOnlySession,
structured = false,
}: {
isPrimary: boolean;
isOnlySession: boolean;
structured?: boolean;
}) {
const { t } = useTranslation();
const primaryNotice = isPrimary && !isOnlySession;
if (structured) {
return (
<>
<p>{t("task:thisWillPermanentlyDeleteTheConversation")}</p>
{primaryNotice && <p className="font-medium">{t("task:thisIsThePrimarySessionAnother")}</p>}
{isOnlySession && <p className="font-medium">{t("task:thisIsTheOnlySessionFor")}</p>}
</>
);
}
return (
<>
<span>{t("task:thisWillPermanentlyDeleteTheConversation")}</span>
{isPrimary && !isOnlySession && (
{primaryNotice && (
<span className="mt-2 block font-medium">{t("task:thisIsThePrimarySessionAnother")}</span>
)}
{isOnlySession && (
@@ -26,6 +26,12 @@ describe("DeleteSessionDialog", () => {
expect(dialog.textContent).toContain("permanently delete the conversation history");
expect(dialog.textContent).toContain("task workspace and its files are kept");
expect(dialog.textContent).toContain("only session for this task");
const description = dialog.querySelector('[data-slot="alert-dialog-description"]');
expect(description).not.toBeNull();
expect(description?.id).toBe(dialog.getAttribute("aria-describedby"));
expect(description?.classList.contains("min-w-0")).toBe(true);
expect(description?.classList.contains("text-left")).toBe(true);
expect(description?.querySelectorAll("p")).toHaveLength(2);
// No uncommitted/unpushed warning belongs on session deletion.
expect(dialog.textContent).not.toContain("uncommitted");
expect(dialog.textContent).not.toContain("unpushed");
@@ -53,8 +53,12 @@ export function DeleteSessionDialog({
<AlertDialogHeader>
<AlertDialogTitle>{t("task:deleteSession")}</AlertDialogTitle>
<AlertDialogDescription asChild>
<div>
<SessionDeleteDescription isPrimary={isPrimary} isOnlySession={sessionCount === 1} />
<div className="min-w-0 space-y-2 text-left">
<SessionDeleteDescription
isPrimary={isPrimary}
isOnlySession={sessionCount === 1}
structured
/>
</div>
</AlertDialogDescription>
</AlertDialogHeader>
@@ -70,17 +70,25 @@ describe("task detach confirmation adapters", () => {
});
it("keeps task-switcher detachment on its existing modal branch", async () => {
const longTaskTitle = `Child task ${"x".repeat(180)}`;
render(
<TaskDetachTargetConfirmDialog
target={{ id: "child", title: "Child task", workspaceMode: "inherit_parent" }}
target={{ id: "child", title: longTaskTitle, workspaceMode: "inherit_parent" }}
detachingTaskId={null}
onDismiss={vi.fn()}
onConfirm={vi.fn()}
/>,
);
await waitFor(() =>
expect(screen.getByRole("alertdialog", { name: "Detach task from parent?" })).not.toBeNull(),
);
await waitFor(() => {
const dialog = screen.getByRole("alertdialog", { name: "Detach task from parent?" });
const description = dialog.querySelector('[data-slot="alert-dialog-description"]');
expect(description).not.toBeNull();
expect(description?.id).toBe(dialog.getAttribute("aria-describedby"));
expect(description?.classList.contains("min-w-0")).toBe(true);
expect(description?.classList.contains("text-left")).toBe(true);
expect(description?.querySelectorAll("p")).toHaveLength(3);
expect(description?.textContent).toContain(longTaskTitle);
});
});
});
@@ -28,13 +28,32 @@ export type TaskDetachConfirmationCopyProps = {
function TaskDetachDescription({
taskTitle,
sharesParentWorkspace,
}: TaskDetachConfirmationCopyProps): ReactNode {
structured = false,
}: TaskDetachConfirmationCopyProps & { structured?: boolean }): ReactNode {
const { t } = useTranslation();
const title = taskTitle || t("task:thisTask2");
if (structured) {
return (
<>
<p className="break-words">
{t("task:detachWillBecomeTopLevel", {
taskTitle: title,
})}
</p>
<p>{t("task:detachingChangesTheHierarchyOnlyAccess")}</p>
{sharesParentWorkspace && (
<p className="font-medium text-foreground">{t("task:thisTaskSharesItsParentS")}</p>
)}
</>
);
}
return (
<span className="block space-y-2">
<span className="block">
{t("task:detachWillBecomeTopLevel", {
taskTitle: taskTitle || t("task:thisTask2"),
taskTitle: title,
})}
</span>
<span className="block">{t("task:detachingChangesTheHierarchyOnlyAccess")}</span>
@@ -208,10 +227,11 @@ export function TaskDetachConfirmDialog({
<AlertDialogHeader>
<AlertDialogTitle>{t(DETACH_TASK_FROM_PARENT_KEY)}</AlertDialogTitle>
<AlertDialogDescription asChild>
<div>
<div className="min-w-0 space-y-2 text-left">
<TaskDetachDescription
taskTitle={taskTitle}
sharesParentWorkspace={sharesParentWorkspace}
structured
/>
</div>
</AlertDialogDescription>
@@ -0,0 +1,70 @@
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { TaskResetEnvConfirmDialog } from "./task-reset-env-confirm-dialog";
afterEach(cleanup);
describe("TaskResetEnvConfirmDialog", () => {
it("renders structured warning copy through one left-aligned description", () => {
render(
<TaskResetEnvConfirmDialog open onOpenChange={vi.fn()} hasWorktreePath onConfirm={vi.fn()} />,
);
const dialog = screen.getByRole("alertdialog", { name: "Reset environment?" });
const description = dialog.querySelector('[data-slot="alert-dialog-description"]');
expect(description).not.toBeNull();
expect(description?.id).toBe(dialog.getAttribute("aria-describedby"));
expect(description?.classList.contains("min-w-0")).toBe(true);
expect(description?.classList.contains("text-left")).toBe(true);
expect(description?.querySelectorAll("p")).toHaveLength(2);
expect(description?.textContent).toContain("Any uncommitted or unpushed changes");
});
it("requires acknowledgment and passes the push-branch choice to confirmation", () => {
const onConfirm = vi.fn();
render(
<TaskResetEnvConfirmDialog
open
onOpenChange={vi.fn()}
hasWorktreePath
onConfirm={onConfirm}
/>,
);
const confirm = screen.getByTestId("reset-env-confirm") as HTMLButtonElement;
expect(confirm.disabled).toBe(true);
fireEvent.click(
screen.getByRole("checkbox", {
name: /push the current branch to its remote before resetting/i,
}),
);
fireEvent.click(
screen.getByRole("checkbox", {
name: /I understand any uncommitted changes will be lost/i,
}),
);
expect(confirm.disabled).toBe(false);
fireEvent.click(confirm);
expect(onConfirm).toHaveBeenCalledWith({ pushBranch: true });
});
it("locks both choices and confirmation while resetting", () => {
render(
<TaskResetEnvConfirmDialog
open
onOpenChange={vi.fn()}
hasWorktreePath
isResetting
onConfirm={vi.fn()}
/>,
);
for (const checkbox of screen.getAllByRole("checkbox")) {
expect((checkbox as HTMLButtonElement).disabled).toBe(true);
}
expect((screen.getByTestId("reset-env-confirm") as HTMLButtonElement).disabled).toBe(true);
});
});
@@ -49,7 +49,7 @@ export function TaskResetEnvConfirmDialog({
<AlertDialogHeader>
<AlertDialogTitle>{t("task:resetEnvironment")}</AlertDialogTitle>
<AlertDialogDescription asChild>
<div className="space-y-2">
<div className="min-w-0 space-y-2 text-left">
<p>{t("task:thisTearsDownTheCurrentContainer")}</p>
<p className="text-destructive">{t("task:anyUncommittedOrUnpushedChangesIn")}</p>
</div>
+1 -1
View File
@@ -106,7 +106,7 @@ the final composition.
- [x] [Task 01: Standardize surface typography primitives](task-01-standardize-surface-typography-primitives.md) (completed)
- [x] [Task 02: Normalize structured app confirmations](task-02-normalize-structured-app-confirmations.md) (completed)
- [x] [Task 03: Refine task cleanup confirmations](task-03-refine-task-cleanup-confirmations.md) (completed)
- [ ] [Task 04: Normalize structured task confirmations](task-04-normalize-structured-task-confirmations.md)
- [x] [Task 04: Normalize structured task confirmations](task-04-normalize-structured-task-confirmations.md) (completed)
- [ ] [Task 05: Add responsive text hierarchy E2E](task-05-add-responsive-text-hierarchy-e2e.md)
## Risks
@@ -1,7 +1,7 @@
---
id: "04-normalize-structured-task-confirmations"
title: "Normalize structured task confirmations"
status: pending
status: completed
wave: 2
depends_on:
- "01-standardize-surface-typography-primitives"
@@ -93,4 +93,18 @@ pnpm run i18n:check
## Results
Pending implementation.
- RED: Focused assertions failed against the pre-change wrapperless fragments
and spans because the three dialogs lacked the required semantic paragraph
structure, left alignment, containment, and single description boundary.
- GREEN: Session deletion, task detachment, and environment reset now render
structured paragraphs inside one `min-w-0 text-left` AlertDialog description;
compact popover and inline descriptions remain unchanged.
- Added a shared session-delete description renderer plus focused coverage for
all three surfaces, including a 180-character dynamic task title.
- Focused verification passed with 3 test files and 11 tests. Web typecheck,
focused ESLint with `--max-warnings 0`, `pnpm run i18n:check`, targeted
Prettier, and `git diff --check` also passed on the integrated stack.
- Exact-head E2E integration exposed that the archive-only wide popover had
lost its specified pretty prose wrapping. The wide size contract now applies
`text-pretty` to its description while the default popover remains unchanged;
the shared popover and archive confirmation suites pass 20 tests.