mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 19:00:38 +09:00
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies > - Human operators supervise that work through issue lists, issue detail, comments, inbox groups, markdown references, and profile/activity surfaces > - The branch had many small UI fixes that improve the operator loop but do not need to ship with backend runtime migrations > - These changes belong together as board workflow polish because they affect scanning, navigation, issue context, comment state, and markdown clarity > - This pull request groups the UI-only slice so it can merge independently from runtime/backend changes > - The benefit is a clearer board experience with better issue context, steadier optimistic updates, and more predictable keyboard navigation ## What Changed - Improves issue properties, sub-issue actions, blocker chips, and issue list/detail refresh behavior. - Adds blocker context above the issue composer and stabilizes queued/interrupted comment UI state. - Improves markdown issue/GitHub link rendering and opens external markdown links in a new tab. - Adds inbox group keyboard navigation and fold/unfold support. - Polishes activity/avatar/profile/settings/workspace presentation details. ## Verification - `pnpm exec vitest run ui/src/components/IssueProperties.test.tsx ui/src/components/IssueChatThread.test.tsx ui/src/components/MarkdownBody.test.tsx ui/src/lib/inbox.test.ts ui/src/lib/optimistic-issue-comments.test.ts` ## Risks - Low to medium risk: changes are UI-focused but cover high-traffic issue and inbox surfaces. - This branch intentionally does not include the backend runtime changes from the companion PR; where UI calls newer API filters, unsupported servers should continue to fail visibly through existing API error handling. - Visual screenshots were not captured in this heartbeat; targeted component/helper tests cover the changed behavior. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex, GPT-5-based coding agent runtime, shell/git tool use enabled. Exact hosted model build and context window are not exposed in this Paperclip heartbeat environment. ## 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 run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge
265 lines
7.4 KiB
TypeScript
265 lines
7.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { act } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { OrgChart } from "./OrgChart";
|
|
|
|
const navigateMock = vi.fn();
|
|
const orgMock = vi.fn();
|
|
const listMock = vi.fn();
|
|
|
|
vi.mock("@/lib/router", () => ({
|
|
Link: ({ to, children }: { to: string; children: React.ReactNode }) => <a href={to}>{children}</a>,
|
|
useNavigate: () => navigateMock,
|
|
}));
|
|
|
|
vi.mock("../context/CompanyContext", () => ({
|
|
useCompany: () => ({ selectedCompanyId: "company-1" }),
|
|
}));
|
|
|
|
vi.mock("../context/BreadcrumbContext", () => ({
|
|
useBreadcrumbs: () => ({ setBreadcrumbs: vi.fn() }),
|
|
}));
|
|
|
|
vi.mock("../api/agents", () => ({
|
|
agentsApi: {
|
|
org: () => orgMock(),
|
|
list: () => listMock(),
|
|
},
|
|
}));
|
|
|
|
vi.mock("../components/AgentIconPicker", () => ({
|
|
AgentIcon: () => <span data-testid="agent-icon" />,
|
|
}));
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
const orgTree = [
|
|
{
|
|
id: "agent-1",
|
|
name: "CEO",
|
|
role: "ceo",
|
|
status: "active",
|
|
reports: [
|
|
{
|
|
id: "agent-2",
|
|
name: "Engineer",
|
|
role: "engineer",
|
|
status: "active",
|
|
reports: [],
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
const agents = [
|
|
{
|
|
id: "agent-1",
|
|
companyId: "company-1",
|
|
name: "CEO",
|
|
role: "ceo",
|
|
title: null,
|
|
status: "active",
|
|
reportsTo: null,
|
|
capabilities: null,
|
|
adapterType: "codex_local",
|
|
adapterConfig: {},
|
|
contextMode: "thin",
|
|
budgetMonthlyCents: 0,
|
|
spentMonthlyCents: 0,
|
|
lastHeartbeatAt: null,
|
|
icon: "briefcase",
|
|
metadata: null,
|
|
createdAt: new Date("2026-04-01T00:00:00.000Z"),
|
|
updatedAt: new Date("2026-04-01T00:00:00.000Z"),
|
|
urlKey: "ceo",
|
|
pauseReason: null,
|
|
pausedAt: null,
|
|
permissions: null,
|
|
},
|
|
{
|
|
id: "agent-2",
|
|
companyId: "company-1",
|
|
name: "Engineer",
|
|
role: "engineer",
|
|
title: null,
|
|
status: "active",
|
|
reportsTo: "agent-1",
|
|
capabilities: null,
|
|
adapterType: "codex_local",
|
|
adapterConfig: {},
|
|
contextMode: "thin",
|
|
budgetMonthlyCents: 0,
|
|
spentMonthlyCents: 0,
|
|
lastHeartbeatAt: null,
|
|
icon: "code",
|
|
metadata: null,
|
|
createdAt: new Date("2026-04-01T00:00:00.000Z"),
|
|
updatedAt: new Date("2026-04-01T00:00:00.000Z"),
|
|
urlKey: "engineer",
|
|
pauseReason: null,
|
|
pausedAt: null,
|
|
permissions: null,
|
|
},
|
|
];
|
|
|
|
function createTouchEvent(type: string, touches: Array<{ clientX: number; clientY: number }>) {
|
|
const event = new Event(type, { bubbles: true, cancelable: true });
|
|
Object.defineProperty(event, "touches", {
|
|
value: touches,
|
|
});
|
|
Object.defineProperty(event, "changedTouches", {
|
|
value: touches,
|
|
});
|
|
return event;
|
|
}
|
|
|
|
async function flushReact() {
|
|
await act(async () => {
|
|
await Promise.resolve();
|
|
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
|
});
|
|
}
|
|
|
|
describe("OrgChart mobile gestures", () => {
|
|
let container: HTMLDivElement;
|
|
let root: ReturnType<typeof createRoot>;
|
|
let queryClient: QueryClient;
|
|
|
|
beforeEach(() => {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
queryClient = new QueryClient({
|
|
defaultOptions: { queries: { retry: false } },
|
|
});
|
|
orgMock.mockResolvedValue(orgTree);
|
|
listMock.mockResolvedValue(agents);
|
|
|
|
Object.defineProperty(HTMLElement.prototype, "clientWidth", {
|
|
configurable: true,
|
|
get() {
|
|
return this.getAttribute("data-testid") === "org-chart-viewport" ? 360 : 0;
|
|
},
|
|
});
|
|
Object.defineProperty(HTMLElement.prototype, "clientHeight", {
|
|
configurable: true,
|
|
get() {
|
|
return this.getAttribute("data-testid") === "org-chart-viewport" ? 520 : 0;
|
|
},
|
|
});
|
|
vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function getRect(this: HTMLElement) {
|
|
if (this.getAttribute("data-testid") === "org-chart-viewport") {
|
|
return {
|
|
x: 0,
|
|
y: 0,
|
|
left: 0,
|
|
top: 0,
|
|
right: 360,
|
|
bottom: 520,
|
|
width: 360,
|
|
height: 520,
|
|
toJSON: () => ({}),
|
|
};
|
|
}
|
|
return {
|
|
x: 0,
|
|
y: 0,
|
|
left: 0,
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
width: 0,
|
|
height: 0,
|
|
toJSON: () => ({}),
|
|
};
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
if (root) {
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
}
|
|
container.remove();
|
|
document.body.innerHTML = "";
|
|
vi.restoreAllMocks();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
async function renderOrgChart() {
|
|
root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<OrgChart />
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flushReact();
|
|
await flushReact();
|
|
return {
|
|
viewport: container.querySelector('[data-testid="org-chart-viewport"]') as HTMLDivElement,
|
|
layer: container.querySelector('[data-testid="org-chart-card-layer"]') as HTMLDivElement,
|
|
};
|
|
}
|
|
|
|
it("pans the chart with one-finger touch drag", async () => {
|
|
const { viewport, layer } = await renderOrgChart();
|
|
|
|
await act(async () => {
|
|
viewport.dispatchEvent(createTouchEvent("touchstart", [{ clientX: 100, clientY: 100 }]));
|
|
viewport.dispatchEvent(createTouchEvent("touchmove", [{ clientX: 130, clientY: 145 }]));
|
|
viewport.dispatchEvent(createTouchEvent("touchend", []));
|
|
});
|
|
|
|
expect(layer.style.transform).toBe("translate(50px, 105px) scale(1)");
|
|
});
|
|
|
|
it("suppresses card navigation after a touch pan", async () => {
|
|
const { viewport } = await renderOrgChart();
|
|
const card = container.querySelector("[data-org-card]") as HTMLDivElement;
|
|
|
|
await act(async () => {
|
|
viewport.dispatchEvent(createTouchEvent("touchstart", [{ clientX: 100, clientY: 100 }]));
|
|
viewport.dispatchEvent(createTouchEvent("touchmove", [{ clientX: 130, clientY: 145 }]));
|
|
viewport.dispatchEvent(createTouchEvent("touchend", []));
|
|
card.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
|
});
|
|
|
|
expect(navigateMock).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("allows card navigation after a touch tap without movement", async () => {
|
|
const { viewport } = await renderOrgChart();
|
|
const card = container.querySelector("[data-org-card]") as HTMLDivElement;
|
|
|
|
await act(async () => {
|
|
viewport.dispatchEvent(createTouchEvent("touchstart", [{ clientX: 100, clientY: 100 }]));
|
|
viewport.dispatchEvent(createTouchEvent("touchend", []));
|
|
card.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
|
});
|
|
|
|
expect(navigateMock).toHaveBeenCalledWith("/agents/ceo");
|
|
});
|
|
it("pinch-zooms toward the touch center", async () => {
|
|
const { viewport, layer } = await renderOrgChart();
|
|
|
|
await act(async () => {
|
|
viewport.dispatchEvent(createTouchEvent("touchstart", [
|
|
{ clientX: 100, clientY: 100 },
|
|
{ clientX: 200, clientY: 100 },
|
|
]));
|
|
viewport.dispatchEvent(createTouchEvent("touchmove", [
|
|
{ clientX: 75, clientY: 100 },
|
|
{ clientX: 225, clientY: 100 },
|
|
]));
|
|
viewport.dispatchEvent(createTouchEvent("touchend", []));
|
|
});
|
|
|
|
expect(layer.style.transform).toBe("translate(-45px, 40px) scale(1.5)");
|
|
});
|
|
});
|