mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 16:29:42 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The dashboard is the first page a person sees in a company > - The classic dashboard shows agents, runs, costs and recent tasks > - It does not show what the person is responsible for, or if that work goes well > - People think in areas, such as Fundraising or Customers, and in the things they own in each area > - This pull request adds a dashboard built on areas and responsibilities, behind an experimental setting that is off by default > - The benefit is that a person sees what they own, how it is going, and what agents do for it, on one page ## Linked Issues or Issue Description No public issue exists for this work. The description follows the feature request template. **Subsystem affected** Dashboard, navigation, the task conversation, routines, and the instance experimental settings. **Problem or motivation** The classic dashboard counts agents and tasks. It does not say what a person owns or if it goes well. People who run a company with agents want to see their areas, the responsibilities in each area, the bar each one must meet, and the agents and routines that serve it. **Proposed solution** A person owns responsibilities. Each responsibility belongs to an area and has a bar, a number to reach. Projects, tasks and routines link to a responsibility, and the page shows its status from those links. An agent can interview the person and draft the dashboard. The person accepts or declines each change, and any change can be undone from a saved version. **Alternatives considered** Add the same data to the classic dashboard. That page is a fixed set of cards for company activity, so a second, person-centred page is clearer. The setting lets a person pick one of the two. **Roadmap alignment** This is an experimental feature behind `enableResponsibilities`. It is off by default and changes nothing for a person who leaves it off. ## What Changed - Add the setting "Areas & Responsibilities dashboard" (`enableResponsibilities`, off by default). On, Dashboard in the sidebar opens the new page, and the classic dashboard link is not shown in the sidebars or the command palette. Off, nothing changes. - Add tables and migrations 0492 to 0497 for areas, responsibilities, links to work, metrics, status reports, saved dashboard versions, and model-call records for summaries. - Add the API: areas, responsibilities, links, bars, metrics, status reports, summaries, runs, automation, and the dashboard conversation with versions and undo. Each route checks company access and writes to the activity log. - Add four task conversations with an agent: about a bar, about an automation, about a routine, and about the whole dashboard. The agent proposes a change. Nothing applies until a person accepts it. - Add standing checks: routines that an agent carries out on its heartbeat and reports. - Add the Dashboard page: search, counts, areas that open and close, a primary New area button, and a message box at the bottom of the page. Add the responsibility page with its bar, metrics, work and routines. - Add the Paperclip skill sections and runner API entries that let an agent use these routes. The runner skill inventory is regenerated (166 to 174 rows). - Keep the new runner API tests in their own file so `runner-api.test.ts` stays at 985 lines. - Onboarding is not changed. The onboarding changes that build on this work are a separate pull request. ## Verification - Type checks pass for `packages/db`, `packages/shared`, `server` (all layers) and `ui`. - `pnpm --filter @paperclipai/db check:migrations` passes. A new `drizzle-kit generate` run produces no further change. - Tests for every changed file pass: 26 server test files (3,009 tests), 116 UI test files (1,991 tests) and 28 shared test files (432 tests). - The runner capability inventory checks pass. - I started the app on a local database that already held earlier data. Master's new migrations and these migrations applied without error. With the setting on, the Dashboard and a responsibility page loaded with no console or server errors. The More menu and the command palette show one Dashboard. - I did not run `pnpm verify`, the full local suite, or the browser suites. Required CI covers them. - The agent conversations are tested with simulated agents. No real model has run them. ## Risks - Medium. The change is large, and the setting is off by default. With it off, the new routes refuse requests and the UI is unchanged. - Migrations only add tables and columns. Two replace a CHECK constraint, and one builds an index `CONCURRENTLY`. These two have the `online_compatible` override with a reason in the file, and the second one is listed in `MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`. - Master can add migrations before this merges. The migrations then need new numbers. - `responsibilities.ts` (1,663 lines), `responsibility-summaries.ts` (1,239 lines) and one Storybook fixture file (1,305 lines) are new files over 1,000 lines. They each keep one cohesive unit together: the service for one table family, the model-call path for summaries, and the fixtures that the stories share. No existing file crosses 1,000 lines. > 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 - Anthropic Claude: Claude Fable 5.2 (`claude-fable-5-2`) wrote most of the change, with Claude Sonnet 5.5 (`claude-sonnet-5-5`) for the final steps. Both used tool use, code execution and browser checks. ## 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 - [ ] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <scott@scottsmbpm5max.lan> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
242 lines
9.4 KiB
TypeScript
242 lines
9.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { act as reactAct } from "react";
|
|
import { flushSync } from "react-dom";
|
|
import { createRoot, type Root } from "react-dom/client";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
ISSUE_THREAD_INTERACTION_KINDS,
|
|
type InteractionResolverGovernance,
|
|
} from "@paperclipai/shared";
|
|
|
|
// Routine offers are always answered by a person, so they have no audience row.
|
|
const INTERACTION_KINDS = ISSUE_THREAD_INTERACTION_KINDS.filter((kind) => kind !== "suggest_routine" && kind !== "propose_responsibility_bar" && kind !== "propose_automation" && kind !== "propose_dashboard_changes");
|
|
import {
|
|
GOVERNANCE_UNSET,
|
|
InteractionGovernancePanel,
|
|
applyGovernanceChange,
|
|
toGovernanceSelectValue,
|
|
} from "./InteractionGovernancePanel";
|
|
import { TooltipProvider } from "./ui/tooltip";
|
|
|
|
let root: Root | null = null;
|
|
let container: HTMLDivElement | null = null;
|
|
|
|
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
async function act(callback: () => void | Promise<void>) {
|
|
if (typeof reactAct === "function") {
|
|
await reactAct(callback);
|
|
return;
|
|
}
|
|
let result: void | Promise<void> = undefined;
|
|
flushSync(() => {
|
|
result = callback();
|
|
});
|
|
await result;
|
|
}
|
|
|
|
function renderPanel(governance: InteractionResolverGovernance = {}, onChange = vi.fn()) {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
root = createRoot(container);
|
|
act(() => {
|
|
root?.render(
|
|
<TooltipProvider>
|
|
<InteractionGovernancePanel governance={governance} onChange={onChange} />
|
|
</TooltipProvider>,
|
|
);
|
|
});
|
|
return { host: container, onChange };
|
|
}
|
|
|
|
/** Exact visible text of a closed select trigger (the chevron contributes none). */
|
|
function triggerText(host: HTMLElement, testId: string): string {
|
|
const trigger = host.querySelector(`[data-testid="${testId}"]`);
|
|
expect(trigger).toBeTruthy();
|
|
return (trigger?.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
}
|
|
|
|
afterEach(() => {
|
|
if (root) {
|
|
act(() => root?.unmount());
|
|
}
|
|
container?.remove();
|
|
root = null;
|
|
container = null;
|
|
});
|
|
|
|
describe("InteractionGovernancePanel", () => {
|
|
it("presents Anyone as the visible default for a company with no overrides", () => {
|
|
const { host } = renderPanel();
|
|
|
|
const defaultSelect = host.querySelector('[data-testid="governance-request_confirmation-default"]');
|
|
expect(defaultSelect?.textContent).toContain("Anyone (default)");
|
|
const cap = host.querySelector('[data-testid="governance-request_confirmation-cap"]');
|
|
expect(cap?.textContent).toContain("No cap");
|
|
});
|
|
|
|
it("describes the open default without presenting it as board-required", () => {
|
|
const { host } = renderPanel();
|
|
const copy = host.textContent ?? "";
|
|
|
|
expect(copy).toContain("Thread interactions are open by default");
|
|
expect(copy).toContain("the board or any agent, including the one that asked");
|
|
expect(copy).not.toContain("Board only");
|
|
expect(copy).not.toContain("always require the board");
|
|
// Governed tool approvals keep their human-only guarantee.
|
|
expect(copy).toContain("Tool-approval confirmations always stay");
|
|
expect(copy).toContain("Human only");
|
|
});
|
|
|
|
it("shows a stored narrowing override on the matching row", () => {
|
|
const { host } = renderPanel({
|
|
request_confirmation: { defaultPolicy: "human_only", cap: "not_creator" },
|
|
});
|
|
|
|
expect(
|
|
host.querySelector('[data-testid="governance-request_confirmation-default"]')?.textContent,
|
|
).toContain("Human only");
|
|
expect(
|
|
host.querySelector('[data-testid="governance-request_confirmation-cap"]')?.textContent,
|
|
).toContain("Anyone except creator");
|
|
// Untouched kinds still read as open.
|
|
expect(
|
|
host.querySelector('[data-testid="governance-suggest_tasks-default"]')?.textContent,
|
|
).toContain("Anyone (default)");
|
|
});
|
|
|
|
/**
|
|
* PAP-17297: an empty `<SelectValue />` lets Radix portal the selected
|
|
* option's whole subtree — label *and* effect sentence — into the closed
|
|
* trigger, where `line-clamp-1` clipped it. `toContain` assertions cannot see
|
|
* that, so these check the trigger's exact text.
|
|
*/
|
|
it("shows only the complete selected label in a closed trigger", () => {
|
|
const { host } = renderPanel();
|
|
|
|
for (const kind of INTERACTION_KINDS) {
|
|
expect(triggerText(host, `governance-${kind}-default`)).toBe("Anyone (default)");
|
|
expect(triggerText(host, `governance-${kind}-cap`)).toBe("No cap");
|
|
}
|
|
});
|
|
|
|
it("keeps a narrowed trigger free of the option effect sentence", () => {
|
|
const { host } = renderPanel({
|
|
request_confirmation: { defaultPolicy: "human_only", cap: "not_creator" },
|
|
});
|
|
|
|
expect(triggerText(host, "governance-request_confirmation-default")).toBe("Human only");
|
|
expect(triggerText(host, "governance-request_confirmation-cap")).toBe("Anyone except creator");
|
|
// The effect prose belongs to the option list, never the trigger.
|
|
expect(host.textContent).not.toContain("New cards wait for a person on the board");
|
|
expect(host.textContent).not.toContain("narrowed to exclude its creator");
|
|
expect(host.textContent).not.toContain("New cards are open");
|
|
});
|
|
|
|
it("still offers the effect sentence inside the open option list", async () => {
|
|
const { host } = renderPanel();
|
|
const trigger = host.querySelector<HTMLElement>(
|
|
'[data-testid="governance-request_confirmation-default"]',
|
|
);
|
|
expect(trigger).toBeTruthy();
|
|
|
|
await act(() => {
|
|
trigger?.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }));
|
|
});
|
|
|
|
const listbox = document.querySelector('[data-slot="select-content"]');
|
|
const listText = listbox?.textContent ?? "";
|
|
expect(listText).toContain("Anyone (default)");
|
|
expect(listText).toContain(
|
|
"New cards are open — the board or any agent can respond, including the one that asked.",
|
|
);
|
|
expect(listText).toContain("New cards wait for a person on the board. Agents are turned away.");
|
|
// Each option keeps a label-only typeahead value so keyboard search does not
|
|
// match the effect prose.
|
|
expect(
|
|
Array.from(listbox?.querySelectorAll('[data-slot="select-item"]') ?? []).length,
|
|
).toBe(3);
|
|
// Reflow guard: the popover is capped so long prose wraps instead of
|
|
// stretching past a narrow viewport.
|
|
expect(listbox?.className).toContain("max-w-(--sz-280px)");
|
|
});
|
|
|
|
it("renders a select for every governable interaction kind", () => {
|
|
const { host } = renderPanel();
|
|
expect(host.querySelector('[data-testid="governance-suggest_routine-default"]')).toBeNull();
|
|
expect(host.querySelector('[data-testid="governance-propose_responsibility_bar-default"]')).toBeNull();
|
|
expect(host.querySelector('[data-testid="governance-propose_automation-default"]')).toBeNull();
|
|
expect(host.querySelector('[data-testid="governance-propose_dashboard_changes-default"]')).toBeNull();
|
|
expect(host.querySelectorAll('[data-testid$="-default"]')).toHaveLength(
|
|
INTERACTION_KINDS.length,
|
|
);
|
|
expect(host.querySelectorAll('[data-testid$="-cap"]')).toHaveLength(
|
|
INTERACTION_KINDS.length,
|
|
);
|
|
});
|
|
|
|
it("surfaces a save failure", () => {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
root = createRoot(container);
|
|
act(() => {
|
|
root?.render(
|
|
<TooltipProvider>
|
|
<InteractionGovernancePanel
|
|
governance={{}}
|
|
onChange={vi.fn()}
|
|
errorMessage="Failed to save interaction governance"
|
|
/>
|
|
</TooltipProvider>,
|
|
);
|
|
});
|
|
expect(container.textContent).toContain("Failed to save interaction governance");
|
|
});
|
|
});
|
|
|
|
describe("toGovernanceSelectValue", () => {
|
|
it("treats an absent override as the open default", () => {
|
|
expect(toGovernanceSelectValue(undefined)).toBe(GOVERNANCE_UNSET);
|
|
});
|
|
|
|
it("treats a stored open audience — canonical or legacy alias — as the default", () => {
|
|
expect(toGovernanceSelectValue("anyone")).toBe(GOVERNANCE_UNSET);
|
|
expect(toGovernanceSelectValue("board_or_agents")).toBe(GOVERNANCE_UNSET);
|
|
});
|
|
|
|
it("canonicalizes stored narrowing values, including the legacy board_only alias", () => {
|
|
expect(toGovernanceSelectValue("not_creator")).toBe("not_creator");
|
|
expect(toGovernanceSelectValue("human_only")).toBe("human_only");
|
|
expect(toGovernanceSelectValue("board_only")).toBe("human_only");
|
|
});
|
|
});
|
|
|
|
describe("applyGovernanceChange", () => {
|
|
it("stores a narrowing override", () => {
|
|
expect(applyGovernanceChange({}, "request_confirmation", "defaultPolicy", "human_only")).toEqual({
|
|
request_confirmation: { defaultPolicy: "human_only" },
|
|
});
|
|
});
|
|
|
|
it("clears the override when the open default is re-selected", () => {
|
|
const current: InteractionResolverGovernance = {
|
|
request_confirmation: { defaultPolicy: "human_only" },
|
|
};
|
|
expect(
|
|
applyGovernanceChange(current, "request_confirmation", "defaultPolicy", GOVERNANCE_UNSET),
|
|
).toEqual({});
|
|
// Immutable: the caller's map is untouched.
|
|
expect(current.request_confirmation?.defaultPolicy).toBe("human_only");
|
|
});
|
|
|
|
it("keeps a sibling field when only one is cleared", () => {
|
|
const current: InteractionResolverGovernance = {
|
|
request_confirmation: { defaultPolicy: "human_only", cap: "not_creator" },
|
|
};
|
|
expect(applyGovernanceChange(current, "request_confirmation", "cap", GOVERNANCE_UNSET)).toEqual({
|
|
request_confirmation: { defaultPolicy: "human_only" },
|
|
});
|
|
});
|
|
});
|