Files
PaperClipAI/tests/e2e/classic-workspace.spec.ts
T
scotttongandScott Tong 67a30c9fad Give Expand feedback when the plan is already visible (#23003)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Task chat shows saved plans as cards.
> - Expand opens the plan in the task side pane.
> - When that plan is already visible, the same action gives no visible
feedback.
> - This pull request gives the visible plan a brief outline and moves
focus to it.
> - The outline points to the plan without changing its size or reading
position.

## Linked Issues or Issue Description

**What happened?**

Clicking Expand on a plan card gave no visible feedback when the same
plan was already selected in the side pane. Keyboard focus stayed on the
plan card.

**Expected behavior**

An already visible plan briefly highlights. Keyboard focus moves to the
plan and the next Tab reaches its comments button.

**Steps to reproduce**

1. Enable Classic Workspace and use the chat-style task interface.
2. Open a task with a saved plan. Click Expand on the plan card to show
the plan in the side pane.
3. Click Expand again while that plan is still visible. Repeat with
Enter on the focused card.

**Paperclip version or commit**

Reproduced on master at `e18fe61c8f`.

**Deployment mode**

Local dev, built from source.

## What Changed

- Recognize explicit activation of a plan card when its target already
occupies the open side pane, including when the plan opened
automatically.
- Move focus to the pane without scrolling and fade the outline over 520
ms. Show a brief static outline with reduced motion.
- Exercise first open, repeated activation, outline clearance, and
keyboard navigation in the Classic Workspace browser test.

## Verification

- Chrome on the real dev app with a saved plan. Confirmed pointer and
Enter activation, fade out, reduced motion, focus after the fade,
ordinary document links, and the full-view deep link.
- Ran the targeted Classic Workspace Playwright regression, the UI
typecheck, and the task side pane and document-link Vitest suites.
- `pnpm verify` delegates broader coverage to CI when an E2E spec
changes.

## Risks

- Low risk. The cue is scoped to explicit activation of a card for the
active plan on desktop. The change affects how focus moves after
activation.

## Model Used

- OpenAI Codex, GPT-6.2 Sol (`gpt-6.2-sol)), with code execution and
browser verification.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Scott Tong <1504818+scotttong@users.noreply.github.com>
2026-11-26 00:09:26 +00:00

90 lines
4.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { json, setup } from "./agent-chat.shared";
test("expanding an already visible plan briefly highlights it and preserves keyboard focus", async ({ page, request }) => {
const company = await json(await request.post("/api/companies", { data: { name: "Plan focus" } }));
const preference = await json(await request.get("/api/workspace-preferences/me"));
const preferenceUrl = `/api/companies/${company.id}/workspace-preferences/me`;
try {
await json(await request.put(preferenceUrl, { data: { coordinatorWorkspaceEnabled: false } }));
const issue = await json(await request.post(`/api/companies/${company.id}/issues`, {
data: { title: "Review the launch", status: "backlog" },
}));
await json(await request.put(`/api/issues/${issue.id}/documents/plan`, {
data: { title: "Launch plan", body: "# Launch plan\n\nReview the checklist.", format: "markdown" },
}));
await json(await request.put(`/api/issues/${issue.id}/documents/notes`, {
data: { title: "Launch notes", body: "Record the decisions.", format: "markdown" },
}));
await page.setViewportSize({ width: 1440, height: 900 });
const taskUrl = `/${company.issuePrefix}/issues/${issue.identifier}`;
await page.goto(taskUrl);
const card = page.getByRole("link", { name: "Open Plan revision 1", exact: true });
const pane = page.getByRole("tabpanel", { name: "Launch plan", exact: true });
await expect(pane.getByText("Review the checklist.")).toBeVisible();
await card.click();
await expect(pane).toBeFocused();
await page.getByRole("tab", { name: "Properties", exact: true }).click();
await card.click();
await expect(pane.getByText("Review the checklist.")).toBeVisible();
await expect(pane).not.toBeFocused();
await card.click();
await expect(pane).toBeFocused();
await expect(pane).toHaveCSS("animation-name", "plan-pane-attention");
await pane.evaluate(el => Promise.all(el.getAnimations().map(animation => animation.finished)).then(() => undefined));
await expect(pane).toHaveCSS("outline-color", /(?:, 0| \/ 0)\)$/);
await expect(pane).toBeFocused();
await card.press("Enter");
await expect(pane).toBeFocused();
await page.keyboard.press("Tab");
await expect(pane.getByRole("button", { name: "Open comments on plan" })).toBeFocused();
await card.press("Enter");
await expect(pane).toBeFocused();
await page.goto(`${taskUrl}#document-notes`);
const notes = page.getByRole("tabpanel", { name: "Launch notes", exact: true });
await expect(notes.getByText("Record the decisions.")).toBeVisible();
await expect(notes).not.toBeFocused();
} finally {
await json(await request.put(preferenceUrl, { data: { coordinatorWorkspaceEnabled: preference.coordinatorWorkspaceEnabled } }));
await request.delete(`/api/companies/${company.id}`);
}
});
test("Coordinator is standard and Classic is an explicit personal experiment", async ({ page, request }) => {
const original = await json(await request.get("/api/workspace-preferences/me"));
const f = await setup(request);
const settingsUrl = `/${f.company.issuePrefix}/company/settings/instance/experimental`;
const preferencePath = `/api/companies/${f.company.id}/workspace-preferences/me`;
try {
expect(original.coordinatorWorkspaceEnabled).toBe(true);
await page.goto(f.route);
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toBeVisible();
await page.goto(settingsUrl);
const classic = page.getByRole("switch", { name: "Enable classic workspace", exact: true });
await expect(classic).toBeEnabled();
await expect(classic).not.toBeChecked();
await expect(page.getByRole("switch", { name: "Enable coordinator workspace", exact: true })).toHaveCount(0);
await classic.click();
await expect(classic).toBeChecked();
await expect.poll(async () => (await json(await request.get("/api/workspace-preferences/me"))).coordinatorWorkspaceEnabled).toBe(false);
await page.goto(f.route);
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toHaveCount(0);
await page.goto(settingsUrl);
await page.reload();
await expect(classic).toBeChecked();
await classic.click();
await expect(classic).not.toBeChecked();
await page.goto(f.route);
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toBeVisible();
await page.reload();
await expect(page.getByRole("navigation", { name: "Workspace navigation" })).toBeVisible();
await page.goto(settingsUrl);
await expect(classic).not.toBeChecked();
} finally {
await request.put(preferencePath, { data: { coordinatorWorkspaceEnabled: original.coordinatorWorkspaceEnabled } });
await f.restore();
}
});