Files
PaperClipAI/ui/src/components/PropertiesPanel.test.tsx
T
7b9334cd10 Draft: Build agent-ready design proposal system (#16875)
## Thinking Path

> - Paperclip helps people manage AI agents and their work.
> - People need consistent UI patterns to review and control that work.
> - The current board uses related layouts and controls with different
spacing, type, and behavior.
> - That drift makes it hard for a designer or an agent to build a new
page from a reliable reference.
> - Storybook can show the shared patterns and the states they need to
support.
> - This pull request adds design proposals, a local sandbox, and
reusable UI controls so people can compare the patterns in context.
> - The benefit is a clearer design system that agents can use to build
consistent UI.

## Linked Issues or Issue Description

**Subsystem affected**

`ui/` — React board UI and Storybook.

**Problem or motivation**

Board pages repeat visual and interaction decisions. Storybook did not
provide a complete reference for task views, conversation states,
typography, toolbars, tabs, and light/dark colors. People could not
compare a proposed pattern with the running board in one place.

**Proposed solution**

Add a staged Design Proposals catalog with foundations, components,
layouts, and page specimens. Add an opt-in sandbox. Reuse production
components where possible. Include synthetic conversation states and
shared controls so reviewers can compare and refine them.

**Alternatives considered**

Separate static mockups would not show keyboard behavior, responsive
layout, or real component states. Rebuilding each page only in Storybook
would allow the reference to drift from the board.

**Roadmap alignment**

This improves existing board UI and Skills Manager surfaces. It does not
add a new control-plane capability.

## What Changed

- Added dark and light color references, typography and conversation
specimens, and component stories for buttons, tabs, toolbars, sidebar,
popovers, activity, and task lists.
- Added a local design sandbox with synthetic task conversation playback
and representative states.
- Shared collection toolbars and navigation patterns across task, agent,
project, routine, skill, connector, and artifact pages.
- Added the streamlined Skills tabs and a My Skills collection that uses
the shared skill cards.
- Restored saved-thread access during synthetic playback, kept connector
searchbox semantics, and updated reproduction checks after moving trial
stories.
- Documented the proposed patterns and added focused UI, catalog, and
browser checks.

## Verification

- `pnpm check:token-gates`, `node scripts/check-maps.mjs`, and `node
scripts/storybook-catalog.mjs --check` passed.
- Full workspace `pnpm -r typecheck` and `pnpm build` passed after
merging master. After the review fixes, focused UI typecheck, `pnpm
build-storybook`, 23 Skills Sources tests, and all 15 Storybook
typography browser tests passed.
- Focused task-thread and system-notice suites passed: 251 tests.
Connector Browse passed 84 tests; the connector, attachment, recovery,
and Storybook flyout browser journeys passed locally.
- A local full Vitest run hit one intermittent chat-channels integration
failure; that test passed in isolation. GitHub CI
[39347996059](https://github.com/paperclipai/paperclip/actions/runs/39347996059)
passed on the exact latest commit: 55 successful checks and two skipped
draft-only Storybook jobs.
- Greptile reviewed the exact latest commit at 5/5 with no new comments
or open review threads. GitHub reports the branch as cleanly mergeable.

## Risks

- This PR changes 206 files and exceeds the repository's 100-file review
target. Review by commit and consider a scoped split before merge.
- Design Proposals are staged references. Fixture interactions do not
prove API behavior, permissions, or provider execution.
- UI changes to shared controls may affect pages outside the proposal
sandbox. Focused browser checks and the full CI matrix passed.

## Model Used

- OpenAI Codex, GPT-6 family. The exact runtime model ID and context
window are not exposed in this session. The model used reasoning, code
execution, browser inspection, and local tests. Earlier branch commits
were also AI-assisted in this Codex conversation.

## 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 available in this session)
- [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 where applicable
- [x] I have either linked existing issues or described the issue in-PR
following the relevant issue template
- [x] I have not referenced internal or instance-local Paperclip issues
or links
- [x] My branch name describes the change and contains no internal
ticket id
- [x] I have run focused tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented risks above
- [x] All Paperclip CI gates are green
- [x] 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 <scott@scotts-mbp-m5-max.local>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-19 17:45:26 -07:00

279 lines
11 KiB
TypeScript

// @vitest-environment jsdom
import { flushSync } from "react-dom";
import { createRoot, type Root } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { TooltipProvider } from "@/components/ui/tooltip";
import { PropertiesPanel } from "./PropertiesPanel";
const mockSandbox = vi.hoisted(() => ({ enabled: false }));
vi.mock("@/context/DesignSandboxContext", () => ({ useDesignSandbox: () => mockSandbox.enabled }));
const mockInstanceSettingsApi = vi.hoisted(() => ({
getExperimental: vi.fn(),
}));
vi.mock("@/api/instanceSettings", () => ({
instanceSettingsApi: mockInstanceSettingsApi,
}));
const mockPanelState = vi.hoisted(() => ({
panelContent: null as unknown,
panelContentMode: "padded" as const,
panelVisible: true,
panelMaximizeRequested: false,
}));
const mockSetPanelVisible = vi.hoisted(() => vi.fn());
const mockClearPanelMaximizeRequest = vi.hoisted(() => vi.fn());
vi.mock("../context/PanelContext", () => ({
usePanel: () => ({
panelContent: mockPanelState.panelContent,
panelContentMode: mockPanelState.panelContentMode,
panelVisible: mockPanelState.panelVisible,
openPanel: vi.fn(),
closePanel: vi.fn(),
setPanelVisible: mockSetPanelVisible,
togglePanelVisible: vi.fn(),
panelMaximizeRequested: mockPanelState.panelMaximizeRequested,
requestPanelMaximize: vi.fn(),
clearPanelMaximizeRequest: mockClearPanelMaximizeRequest,
}),
}));
async function flushReact() {
for (let index = 0; index < 5; index += 1) {
await Promise.resolve();
await new Promise((resolve) => window.setTimeout(resolve, 0));
}
flushSync(() => {});
}
describe("PropertiesPanel", () => {
let container: HTMLDivElement;
let root: Root | null = null;
let originalInnerWidth: number;
async function renderPanel({
panelVisible = true,
taskDetailLayout = false,
}: { panelVisible?: boolean; taskDetailLayout?: boolean } = {}) {
mockPanelState.panelContent = <div data-testid="panel-content">content</div>;
mockPanelState.panelVisible = panelVisible;
root = createRoot(container);
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
flushSync(() => {
root!.render(
<QueryClientProvider client={queryClient}>
<TooltipProvider>
<PropertiesPanel taskDetailLayout={taskDetailLayout} />
</TooltipProvider>
</QueryClientProvider>,
);
});
await flushReact();
}
beforeEach(() => {
originalInnerWidth = window.innerWidth;
Object.defineProperty(window, "innerWidth", { configurable: true, value: 1440 });
container = document.createElement("div");
document.body.appendChild(container);
window.localStorage.clear();
mockSetPanelVisible.mockClear();
mockClearPanelMaximizeRequest.mockClear();
mockPanelState.panelMaximizeRequested = false;
mockSandbox.enabled = false;
});
afterEach(() => {
flushSync(() => {
root?.unmount();
});
root = null;
container.remove();
Object.defineProperty(window, "innerWidth", { configurable: true, value: originalInnerWidth });
vi.clearAllMocks();
document.documentElement.style.removeProperty("--design-page-aside-width");
});
describe("classic task interface on (legacy panel)", () => {
beforeEach(() => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableStreamlinedUi: true,
enableClassicTaskInterface: true,
});
});
it("renders the fixed-width panel with no grip and no maximize button", async () => {
await renderPanel();
const aside = container.querySelector("aside");
expect(aside).not.toBeNull();
expect(aside!.style.width).toBe("320px");
expect(aside!.querySelector('[role="separator"]')).toBeNull();
expect(container.querySelector('[aria-label="Maximize side panel"]')).toBeNull();
// Inner wrapper keeps the hardcoded width classes exactly as today.
expect(aside!.querySelector(".w-80")).not.toBeNull();
});
it("collapses to width 0 when the panel is hidden", async () => {
await renderPanel({ panelVisible: false });
const aside = container.querySelector("aside");
expect(aside!.style.width).toBe("0px");
expect(aside!.style.opacity).toBe("0");
});
});
describe("classic task interface off (default resizable pane)", () => {
beforeEach(() => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableStreamlinedUi: true,
enableClassicTaskInterface: false,
});
});
it("renders the Paper task-detail rail width with a drag grip and a maximize button", async () => {
await renderPanel({ taskDetailLayout: true });
const aside = container.querySelector("aside");
expect(aside).not.toBeNull();
expect(aside!.style.width).toBe("434px");
expect(aside!.querySelector('[role="separator"][aria-label="Resize panel"]')).not.toBeNull();
expect(container.querySelector('[aria-label="Maximize side panel"]')).not.toBeNull();
const inner = aside!.querySelector<HTMLDivElement>(":scope > div:not([role])");
expect(inner!.style.width).toBe("434px");
expect(inner!.style.minWidth).toBe("434px");
expect(aside!.querySelector("header")?.className).toContain(
"h-(--side-panel-header-height)",
);
});
it("uses the proposal width token and resets only the sandbox's saved width", async () => {
mockSandbox.enabled = true;
document.documentElement.style.setProperty("--design-page-aside-width", "320px");
window.localStorage.setItem("taskChatRedesign.taskDetailPropertiesPaneWidth", "434");
window.localStorage.setItem("paperclip.design-proposal.properties-pane-width.task-detail", "480");
await renderPanel({ taskDetailLayout: true });
const aside = container.querySelector("aside")!;
expect(aside.style.width).toBe("480px");
const grip = aside.querySelector('[aria-label="Resize panel"]')!;
grip.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
await flushReact();
expect(aside.style.width).toBe("320px");
expect(window.localStorage.getItem("paperclip.design-proposal.properties-pane-width.task-detail")).toBeNull();
expect(window.localStorage.getItem("taskChatRedesign.taskDetailPropertiesPaneWidth")).toBe("434");
// Reset reads the current token, including subsequent foundation tuning.
document.documentElement.style.setProperty("--design-page-aside-width", "360px");
grip.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
await flushReact();
expect(aside.style.width).toBe("360px");
});
it("removes the left divider only while the sidebar is maximized", async () => {
await renderPanel({ taskDetailLayout: true });
const aside = container.querySelector("aside")!;
const maximize = container.querySelector<HTMLButtonElement>(
'[aria-label="Maximize side panel"]',
)!;
expect(aside.className).toContain("border-l");
maximize.click();
await flushReact();
expect(aside.className).not.toContain("border-l");
expect(container.querySelector("section")?.getAttribute("data-maximized")).toBe("true");
});
it("consumes a pending deep-link maximize request on mount (LOOA-2181)", async () => {
mockPanelState.panelMaximizeRequested = true;
await renderPanel({ taskDetailLayout: true });
expect(mockClearPanelMaximizeRequest).toHaveBeenCalled();
expect(container.querySelector("section")?.getAttribute("data-maximized")).toBe("true");
});
it("holds a deep-link maximize request while the panel is hidden", async () => {
mockPanelState.panelMaximizeRequested = true;
await renderPanel({ panelVisible: false });
expect(mockClearPanelMaximizeRequest).not.toHaveBeenCalled();
expect(container.querySelector("section")?.getAttribute("data-maximized")).not.toBe("true");
});
it("uses an X to close the Streamlined task-detail sidebar", async () => {
await renderPanel({ taskDetailLayout: true });
const close = container.querySelector<HTMLButtonElement>('[aria-label="Close side panel"]');
expect(close).not.toBeNull();
expect(close!.querySelector(".lucide-x")).not.toBeNull();
expect(container.querySelector('[aria-label="Toggle side panel"]')).toBeNull();
close!.click();
expect(mockSetPanelVisible).toHaveBeenCalledWith(false);
});
it("keeps the production toggle control outside Streamlined task detail", async () => {
await renderPanel();
const toggle = container.querySelector<HTMLButtonElement>('[aria-label="Toggle side panel"]');
expect(toggle).not.toBeNull();
expect(toggle!.getAttribute("aria-pressed")).toBe("true");
expect(toggle!.querySelector(".lucide-panel-right-close")).not.toBeNull();
expect(container.querySelector('[aria-label="Close side panel"]')).toBeNull();
});
it("restores a remembered width from localStorage (clamped to the minimum)", async () => {
window.localStorage.setItem("taskChatRedesign.propertiesPaneWidth", "300");
await renderPanel();
expect(container.querySelector("aside")!.style.width).toBe("300px");
});
it("clamps a stored width below the 260px minimum", async () => {
window.localStorage.setItem("taskChatRedesign.propertiesPaneWidth", "100");
await renderPanel();
expect(container.querySelector("aside")!.style.width).toBe("260px");
});
it("falls back to the default width when the stored value is garbage", async () => {
window.localStorage.setItem("taskChatRedesign.propertiesPaneWidth", "not-a-number");
await renderPanel();
expect(container.querySelector("aside")!.style.width).toBe("322px");
});
it("keeps the collapse-to-0 behavior when the panel is hidden", async () => {
await renderPanel({ panelVisible: false });
const aside = container.querySelector("aside");
expect(aside!.style.width).toBe("0px");
expect(aside!.style.opacity).toBe("0");
// No grip while hidden.
expect(aside!.querySelector('[role="separator"]')).toBeNull();
});
});
describe("Streamlined UI off", () => {
beforeEach(() => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableStreamlinedUi: false,
enableClassicTaskInterface: false,
});
});
it("restores master's default resizable panel rather than the classic panel", async () => {
await renderPanel({ taskDetailLayout: true });
const aside = container.querySelector("aside");
expect(aside).not.toBeNull();
expect(aside!.style.width).toBe("322px");
expect(aside!.querySelector('[role="separator"][aria-label="Resize panel"]')).not.toBeNull();
expect(container.querySelector('[aria-label="Maximize side panel"]')).not.toBeNull();
});
it("still honors the independent Classic Task Interface preference", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableStreamlinedUi: false,
enableClassicTaskInterface: true,
});
await renderPanel({ taskDetailLayout: true });
const aside = container.querySelector("aside");
expect(aside!.style.width).toBe("320px");
expect(aside!.querySelector('[role="separator"]')).toBeNull();
});
});
});