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>
This commit is contained in:
scotttongandScott Tong authored and GitHub committed 2026-11-26 00:09:26 +00:00
1 parent 3f1632c7b7
commit 67a30c9fad
6 files changed
+126 -11

No files matched your search

+49
View File
@@ -1,6 +1,55 @@
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);
@@ -176,6 +176,7 @@ export function TaskChatPlanPreviewCard({
return (
<a
href={href}
data-plan-expand
data-testid={testId}
aria-label={ariaLabel ?? `Open Plan${revision == null ? "" : ` revision ${revision}`}`}
className={sharedClassName}
@@ -2,6 +2,7 @@ import { CoordinatorConversationTasksPanel } from "@/components/coordinator/Coor
import { useCoordinatorWorkspaceEnabled } from "@/hooks/useCoordinatorWorkspaceEnabled";
import { TextAttachmentContext } from "@/context/TextAttachmentContext";
import { TaskAttachmentPanel } from "./TaskAttachmentPanel";
import { focusPlanPane, scheduleTaskPaneScroll } from "./task-pane-focus";
import { useQueryView } from "@/components/QueryView";
import { useTaskBrowsers } from "@/hooks/useTaskBrowsers";
import { taskPluginPanelActivationKey, taskPluginPanelId, type TaskPluginPanel } from "@/hooks/useTaskPluginPanels";
@@ -125,7 +126,7 @@ export interface TaskSidePanelProps {
onCheckMonitorNow?: () => void;
checkingMonitorNow?: boolean;
fileTabsEnabled: boolean;
documentDeepLink?: { requestId: number; documentKey: string } | null;
documentDeepLink?: { requestId: number; documentKey: string; focusActivePlan?: boolean } | null;
showDocumentSourceTask?: boolean;
onArtifactVisibilityChange?: (showsArtifact: boolean) => void;
/** A new durable output asks the host to reveal this tab once. */
@@ -503,8 +504,10 @@ function TaskSidePanelForScope({
// A refresh must not replay a link after the user selects another tab.
handledDocumentRequestRef.current = documentDeepLink.requestId;
if (coordinatorWorkspaceEnabled) userInteractedRef.current = true;
controller.openTab(taskPanelDocumentTab(documentDeepLink.documentKey, label, target?.revisionId, documentIssueId));
}, [controller.openTab, documentDeepLink, documents, planDocument, location.hash, issue.id]);
const tab = taskPanelDocumentTab(documentDeepLink.documentKey, label, target?.revisionId, documentIssueId);
if (documentDeepLink.focusActivePlan && documentDeepLink.documentKey === "plan" && tab.id === controller.activeTabId) focusPlanPane(bodyRef.current);
controller.openTab(tab);
}, [controller.activeTabId, controller.openTab, documentDeepLink, documents, planDocument, location.hash, issue.id]);
// Existing URL-backed workspace links remain the external integration API.
useEffect(() => {
@@ -594,11 +597,10 @@ function TaskSidePanelForScope({
}
}
useEffect(() => {
const top = controller.activeTabId ? scrollPositionsRef.current.get(controller.activeTabId) ?? 0 : 0;
window.requestAnimationFrame(() => bodyRef.current?.scrollTo({ top, behavior: "auto" }));
useLayoutEffect(() => {
const top = scrollPositionsRef.current.get(controller.activeTabId ?? "") ?? 0;
return scheduleTaskPaneScroll(bodyRef.current, top);
}, [controller.activeTabId]);
useEffect(() => {
if (activeTab) return;
window.requestAnimationFrame(() => {
@@ -0,0 +1,36 @@
export function focusPlanPane(pane: HTMLElement | null) {
if (!pane) return;
pane.tabIndex = -1;
pane.focus({ preventScroll: true });
if (pane.ownerDocument.activeElement !== pane) {
pane.removeAttribute("tabindex");
return;
}
if (!pane.hasAttribute("data-plan-pane-attention")) {
pane.setAttribute("data-plan-pane-attention", "");
pane.addEventListener("blur", () => {
pane.removeAttribute("data-plan-pane-attention");
pane.removeAttribute("tabindex");
}, { once: true });
return;
}
const cue = pane.getAnimations().find(animation =>
animation instanceof CSSAnimation && animation.animationName === "plan-pane-attention");
if (cue) {
cue.currentTime = 0;
cue.play();
}
}
export function scheduleTaskPaneScroll(pane: HTMLElement | null, top: number) {
if (!pane) return;
const frame = requestAnimationFrame(() => pane.scrollTo({ top, behavior: "auto" }));
return () => {
cancelAnimationFrame(frame);
if (pane.hasAttribute("data-plan-pane-attention")) pane.blur();
};
}
+17
View File
@@ -476,6 +476,7 @@
--motion-ease-scroll-pill-in: cubic-bezier(0.23, 1, 0.32, 1);
--motion-ease-scroll-pill-out: cubic-bezier(0.7, 0, 0.84, 0);
--motion-pane-glide: 320ms; /* properties-pane maximize/restore glide */
--plan-pane-attention-duration: 520ms;
--motion-pane-reveal: var(--motion-duration-slow);
--motion-ease-pane-reveal: var(--motion-ease-out-expo);
--motion-pane-width-reset: 200ms;
@@ -1487,6 +1488,22 @@ html:has(.paperclip-app-shell[data-keyboard-open="true"] [data-classic-task-shel
/* Properties-pane maximize/restore glide (left animates between docked and
sidebar-flush while the pane is position:fixed). */
.tc-pane-glide { transition: left var(--motion-pane-glide) var(--motion-ease-standard); }
[data-plan-pane-attention]:focus {
outline: var(--sz-2px) solid transparent;
outline-offset: calc(-1 * var(--sz-2px));
animation: plan-pane-attention var(--plan-pane-attention-duration) var(--motion-ease-standard) both;
}
@keyframes plan-pane-attention {
from { outline-color: var(--plan-pane-attention-start, transparent); }
25% { outline-color: var(--ring); }
to { outline-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
[data-plan-pane-attention]:focus {
--plan-pane-attention-start: var(--ring);
animation-timing-function: steps(1, end);
}
}
.properties-panel-docked {
transition: width var(--motion-pane-reveal) var(--motion-ease-pane-reveal),
opacity var(--motion-pane-reveal) var(--motion-ease-pane-reveal);
+14 -4
View File
@@ -3331,7 +3331,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
setOpenSkill((current) => current?.id === skillId ? null : current);
}, []);
const [documentDeepLink, setDocumentDeepLink] = useState<
(IssuePropertiesDocumentDeepLink & { issueId: string }) | null
(IssuePropertiesDocumentDeepLink & { issueId: string; focusActivePlan?: boolean }) | null
>(null);
const [fileViewerPromptOpen, setFileViewerPromptOpen] = useState(false);
const [detailTab, setDetailTab] = useState("chat");
@@ -6648,8 +6648,9 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
// the issue param so navigating to another issue with an identical hash
// still maximizes the destination pane.
const lastMaximizeRequestKeyRef = useRef<string | null>(null);
const planExpandNavigation = useRef<{ pathname: string; hash: string } | null>(null);
const routeIssueDocumentDeepLink = useCallback(
(hash: string) => {
(hash: string, focusActivePlan = false) => {
const resolvedRoute = resolveIssueDocumentDeepLink(hash);
// A handoff is a saved document too. Opening it must not switch the
// conversation to full activity just because it has a legacy hash.
@@ -6692,6 +6693,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
issueId: targetIssueId,
tab: route.tab,
documentKey: route.documentKey,
focusActivePlan,
requestId:
current?.issueId === targetIssueId ? current.requestId + 1 : 1,
}));
@@ -6710,7 +6712,9 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
);
useEffect(() => {
if (!routeIssueDocumentDeepLink(location.hash)) {
const expand = planExpandNavigation.current;
planExpandNavigation.current = null;
if (!routeIssueDocumentDeepLink(location.hash, expand?.pathname === location.pathname && expand.hash === location.hash)) {
setDocumentDeepLink(null);
// The deep link ended (hash cleared or issue changed): drop any
// maximize request the panel never consumed so it cannot maximize a
@@ -6721,6 +6725,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
}, [
issueId,
location.hash,
location.pathname,
routeIssueDocumentDeepLink,
clearPanelMaximizeRequest,
]);
@@ -6764,9 +6769,11 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
event.preventDefault();
// Let link handlers close any hovered task preview. Router links and
// popover triggers honor defaultPrevented and skip their navigation.
const focusActivePlan = anchor.hasAttribute("data-plan-expand") && !isMobile && panelVisible && !suppressPanelUntilPlan;
if (hash === location.hash) {
routeIssueDocumentDeepLink(hash);
routeIssueDocumentDeepLink(hash, focusActivePlan);
} else {
planExpandNavigation.current = focusActivePlan ? { pathname: location.pathname, hash } : null;
navigate(`${location.pathname}${location.search}${hash}`, {
preventScrollReset: true,
state: {
@@ -6785,6 +6792,9 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
issue?.identifier,
issueId,
persistedAgentChat,
isMobile,
panelVisible,
suppressPanelUntilPlan,
navigate,
location.hash,
location.key,