fix(app): show the archive undo toast in the sidebar, with only Undo pressable

The archive button sat 2px from the kebab, so a press aimed at the menu could
archive the workspace. The toast card was a Pressable used only to pause on
hover, which made the whole card look clickable.

Toasts raised by the workspace list now land above the sidebar footer, next to
the row that raised them. A collapsed sidebar stays mounted and its rows still
handle the archive shortcut, so while it is hidden those toasts go to the app
host. A toast leaves when the sidebar hides because its dismissal is what ends
an archive's undo window.
This commit is contained in:
Mohamed Boudra
2026-11-08 12:31:07 +01:00
parent b509d499f7
commit 01a40957ea
8 changed files with 226 additions and 81 deletions
@@ -19,7 +19,9 @@ import {
expectDirectoryPresence,
expectHostWorkspaceSettledActive,
outlastUndoWindow,
pressArchiveShortcut,
pressUndoShortcut,
resizeSidebarToMinimum,
rowArchiveButton,
rowKebab,
undoButton,
@@ -84,7 +86,64 @@ test.describe("Workspace archive undo", () => {
rowArchiveButton(page, worktree.workspaceId).boundingBox(),
rowKebab(page, worktree.workspaceId).boundingBox(),
]);
expect(buttonBox && kebabBox && buttonBox.x + buttonBox.width <= kebabBox.x).toBe(true);
if (!buttonBox || !kebabBox) throw new Error("Row actions are not laid out");
expect(kebabBox.x - (buttonBox.x + buttonBox.width)).toBeGreaterThanOrEqual(8);
});
test("the archived toast sits over the sidebar above its footer, and only Undo presses", async ({
page,
}) => {
const worktree = await seedWorktree(page, "archive-toast-sidebar");
await archiveFromRowButton(page, worktree.workspaceId);
const [toastBox, footerBox] = await Promise.all([
page.getByTestId("workspace-archived-toast").boundingBox(),
page.getByTestId("sidebar-footer").boundingBox(),
]);
if (!toastBox || !footerBox) throw new Error("Toast or footer is not laid out");
expect(toastBox.x).toBeGreaterThanOrEqual(footerBox.x);
expect(toastBox.x + toastBox.width).toBeLessThanOrEqual(footerBox.x + footerBox.width);
expect(toastBox.y + toastBox.height).toBeLessThanOrEqual(footerBox.y);
expect(footerBox.y - (toastBox.y + toastBox.height)).toBeLessThanOrEqual(16);
await expect(page.getByTestId("app-toast-message")).toHaveCSS("cursor", "auto");
await expect(undoButton(page)).toHaveCSS("cursor", "pointer");
});
test("the archived toast keeps Undo inside the card at the narrowest sidebar", async ({
page,
}) => {
const worktree = await seedWorktree(page, "archive-toast-narrow");
await resizeSidebarToMinimum(page);
await archiveFromRowButton(page, worktree.workspaceId);
const [toastBox, undoBox] = await Promise.all([
page.getByTestId("workspace-archived-toast").boundingBox(),
undoButton(page).boundingBox(),
]);
if (!toastBox || !undoBox) throw new Error("Toast is not laid out");
expect(undoBox.x + undoBox.width).toBeLessThanOrEqual(toastBox.x + toastBox.width);
expect(undoBox.y + undoBox.height).toBeLessThanOrEqual(toastBox.y + toastBox.height);
});
test("archiving by shortcut with the sidebar collapsed shows the toast over the app", async ({
page,
}) => {
const worktree = await seedWorktree(page, "archive-toast-collapsed");
await workspaceRow(page, worktree.workspaceId).click();
await page.keyboard.press("ControlOrMeta+b");
await expect(workspaceRow(page, worktree.workspaceId)).not.toBeInViewport();
page.once("dialog", (dialog) => void dialog.accept());
await pressArchiveShortcut(page);
const toast = page.getByTestId("workspace-archived-toast");
await expect(toast).toBeInViewport();
const toastBox = await toast.boundingBox();
if (!toastBox) throw new Error("Toast is not laid out");
expect(toastBox.y).toBeLessThan(page.viewportSize()!.height / 2);
});
test("Cmd/Ctrl+Z right after archiving keeps the worktree", async ({ page }) => {
@@ -10,6 +10,8 @@ import { expectWorkspaceAbsentFromSidebar } from "./sidebar";
type DaemonClient = Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
const UNDO_SHORTCUT = process.platform === "darwin" ? "Meta+Z" : "Control+Z";
const ARCHIVE_SHORTCUT =
process.platform === "darwin" ? "Meta+Shift+Backspace" : "Control+Shift+Backspace";
/** The archived toast's lifetime, from `WORKSPACE_ARCHIVE_UNDO_WINDOW_MS`. */
const UNDO_WINDOW_MS = 6000;
@@ -46,6 +48,25 @@ export async function archiveFromRowButton(page: Page, workspaceId: string): Pro
await expect(undoButton(page)).toBeVisible();
}
/** Drags the sidebar's edge past its minimum, leaving it as narrow as it goes. */
export async function resizeSidebarToMinimum(page: Page): Promise<void> {
const handle = await page.getByTestId("left-sidebar-resize-handle").boundingBox();
if (!handle) throw new Error("Sidebar resize handle is not laid out");
const y = handle.y + handle.height / 2;
await page.mouse.move(handle.x + handle.width / 2, y);
await page.mouse.down();
await page.mouse.move(handle.x - 30, y, { steps: 8 });
await page.mouse.move(10, y, { steps: 16 });
await page.mouse.up();
await expect
.poll(async () => (await page.getByTestId("sidebar-footer").boundingBox())?.width)
.toBeLessThanOrEqual(200);
}
export async function pressArchiveShortcut(page: Page): Promise<void> {
await page.keyboard.press(ARCHIVE_SHORTCUT);
}
export async function pressUndoShortcut(page: Page): Promise<void> {
await page.keyboard.press(UNDO_SHORTCUT);
}