mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +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>
395 lines
21 KiB
TypeScript
395 lines
21 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { act, type ReactNode } from "react";
|
|
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 {
|
|
areaFundraising,
|
|
homeAutomationFixture,
|
|
proposedDealFlow,
|
|
RESPONSIBILITY_DETAIL_FIXTURES,
|
|
RESPONSIBILITY_FIXTURE_GUIDE_AGENT_ID,
|
|
RESPONSIBILITY_FIXTURE_NOW,
|
|
responsibilityDetailFixture,
|
|
} from "../../storybook/fixtures/responsibilities";
|
|
import { METRIC_SET_FIXTURES, statusReportFixture } from "../../storybook/fixtures/responsibility-metrics";
|
|
import { ResponsibilityDetail } from "./ResponsibilityDetail";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
responsibilityId: "resp-fundraising",
|
|
search: "",
|
|
api: { get: vi.fn(), update: vi.fn(), unlink: vi.fn(), remove: vi.fn(), link: vi.fn(), summary: vi.fn(), automation: vi.fn(), statusReport: vi.fn(), requestStatusUpdate: vi.fn() },
|
|
suggestions: { accept: vi.fn(), decline: vi.fn(), repeatAsRoutine: vi.fn() },
|
|
conversations: { start: vi.fn() },
|
|
navigate: vi.fn(),
|
|
areas: { list: vi.fn() },
|
|
agents: { list: vi.fn() },
|
|
activity: { list: vi.fn() },
|
|
auth: { getSession: vi.fn() },
|
|
settings: { getExperimental: vi.fn() },
|
|
metrics: { metrics: vi.fn(), removeMetric: vi.fn() },
|
|
}));
|
|
vi.mock("@/api/responsibilities", () => ({ responsibilitiesApi: mocks.api, responsibilityAreasApi: mocks.areas }));
|
|
vi.mock("@/api/agents", () => ({ agentsApi: mocks.agents }));
|
|
vi.mock("@/api/routine-suggestions", () => ({ routineSuggestionsApi: mocks.suggestions }));
|
|
vi.mock("@/api/automation-conversations", () => ({ automationConversationsApi: mocks.conversations }));
|
|
vi.mock("@/api/activity", () => ({ activityApi: mocks.activity }));
|
|
vi.mock("@/api/auth", () => ({ authApi: mocks.auth }));
|
|
vi.mock("@/api/instanceSettings", () => ({ instanceSettingsApi: mocks.settings }));
|
|
vi.mock("@/api/responsibility-metrics", () => ({ responsibilityMetricsApi: mocks.metrics }));
|
|
vi.mock("@/context/CompanyContext", () => ({ useCompany: () => ({ selectedCompanyId: "company-storybook" }) }));
|
|
vi.mock("@/context/BreadcrumbContext", () => ({ useBreadcrumbs: () => ({ setBreadcrumbs: vi.fn() }) }));
|
|
vi.mock("@/components/InlineEditor", () => ({
|
|
InlineEditor: ({ value, as: Tag = "p", placeholder }: { value: string; as?: "h1" | "p"; placeholder?: string }) => (
|
|
<Tag data-inline-editor>{value || placeholder}</Tag>
|
|
),
|
|
}));
|
|
vi.mock("@/lib/router", () => ({
|
|
Link: ({ to, children, disableIssueQuicklook: _skip, ...props }: { to: string; children: ReactNode; disableIssueQuicklook?: boolean }) => (
|
|
<a href={to} {...props}>{children}</a>
|
|
),
|
|
useNavigate: () => mocks.navigate,
|
|
useParams: () => ({ responsibilityId: mocks.responsibilityId }),
|
|
useLocation: () => ({ pathname: "/responsibilities", search: mocks.search, hash: "", state: null, key: "default" }),
|
|
}));
|
|
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
let root: Root;
|
|
let host: HTMLDivElement;
|
|
let client: QueryClient;
|
|
const flush = () => act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); });
|
|
const view = () => host.querySelector("[data-responsibility-view]")?.getAttribute("data-responsibility-view") ?? "full";
|
|
const proposedDetail = responsibilityDetailFixture(proposedDealFlow);
|
|
|
|
async function render(id = "resp-fundraising") {
|
|
mocks.responsibilityId = id;
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={client}>
|
|
<TooltipProvider>
|
|
<ResponsibilityDetail />
|
|
</TooltipProvider>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
}
|
|
|
|
async function remount(id?: string) {
|
|
await act(async () => root.unmount());
|
|
root = createRoot(host);
|
|
await render(id);
|
|
}
|
|
|
|
beforeEach(() => {
|
|
vi.useFakeTimers({ toFake: ["Date"] });
|
|
vi.setSystemTime(RESPONSIBILITY_FIXTURE_NOW);
|
|
vi.clearAllMocks();
|
|
localStorage.clear();
|
|
mocks.search = "";
|
|
mocks.api.get.mockImplementation(async (id: string) => (id === proposedDetail.id ? proposedDetail : RESPONSIBILITY_DETAIL_FIXTURES[id]));
|
|
mocks.areas.list.mockResolvedValue([areaFundraising]);
|
|
mocks.api.automation.mockResolvedValue(homeAutomationFixture);
|
|
mocks.api.summary.mockResolvedValue({
|
|
text: "Two things are holding the number back: the investor update deck is late and the cap table task is blocked.",
|
|
source: "computed",
|
|
generatedAt: RESPONSIBILITY_FIXTURE_NOW.toISOString(),
|
|
refreshing: false,
|
|
});
|
|
mocks.agents.list.mockResolvedValue([
|
|
{ id: "agent-codex", companyId: "company-storybook", name: "CodexCoder", status: "idle" },
|
|
{ id: RESPONSIBILITY_FIXTURE_GUIDE_AGENT_ID, companyId: "company-storybook", name: "CTO", status: "idle" },
|
|
]);
|
|
mocks.activity.list.mockResolvedValue([]);
|
|
mocks.auth.getSession.mockResolvedValue({ user: { id: "user-storybook" } });
|
|
mocks.settings.getExperimental.mockResolvedValue({ enableArtifactsV1: false, managedKeys: { enableArtifactsV1: true } });
|
|
mocks.metrics.metrics.mockRejectedValue(new Error("Not found"));
|
|
mocks.api.statusReport.mockRejectedValue(new Error("Not found"));
|
|
host = document.createElement("div");
|
|
document.body.append(host);
|
|
root = createRoot(host);
|
|
client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await act(async () => root.unmount());
|
|
host.remove();
|
|
client.clear();
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
describe("ResponsibilityDetail views", () => {
|
|
it("is One screen v2, with no switch between views", async () => {
|
|
await render();
|
|
expect(view()).toBe("one_screen_v2");
|
|
expect(host.querySelector('[role="radiogroup"][aria-label="Responsibility view"]')).toBeNull();
|
|
expect(host.querySelector("[data-responsibility-back]")).toBeNull();
|
|
});
|
|
|
|
it("ignores a choice an earlier build remembered, and an address naming no view", async () => {
|
|
localStorage.setItem("paperclip:responsibilities:page-view", "scorecard");
|
|
mocks.search = "?view=timeline";
|
|
await render();
|
|
expect(view()).toBe("one_screen_v2");
|
|
});
|
|
|
|
it("shows an earlier exploration only while the address names it", async () => {
|
|
mocks.search = "?view=full";
|
|
await render();
|
|
expect(view()).toBe("full");
|
|
expect(host.querySelector("#responsibility-bar")).not.toBeNull();
|
|
mocks.search = "?view=scorecard";
|
|
await remount("resp-portfolio");
|
|
expect(view()).toBe("scorecard");
|
|
expect(host.querySelector("#responsibility-bar")).toBeNull();
|
|
expect(host.querySelector("h1")?.textContent).toBe("Founder support");
|
|
|
|
// Nothing was remembered.
|
|
mocks.search = "";
|
|
await remount();
|
|
expect(view()).toBe("one_screen_v2");
|
|
expect(localStorage.getItem("paperclip:responsibilities:page-view")).toBeNull();
|
|
});
|
|
|
|
it("Scorecard: the number against its target, the status, and three counts with one exception each", async () => {
|
|
mocks.search = "?view=scorecard";
|
|
await render();
|
|
const card = host.querySelector<HTMLElement>('[data-responsibility-view="scorecard"]')!;
|
|
expect(card.querySelector("#responsibility-score")?.textContent).toContain("9of 20");
|
|
expect(card.textContent).toContain("9 of 20 investors contacted, 45% of target");
|
|
const counts = Object.fromEntries(
|
|
[...card.querySelectorAll("[data-count]")].map((cell) => [cell.getAttribute("data-count"), cell.textContent]),
|
|
);
|
|
expect(counts).toEqual({
|
|
projects: "Projects21 late",
|
|
tasks: "Tasks41 blocked, 2 with agents",
|
|
routines: "Routines1None failed or paused",
|
|
skills: "Skills 2Investor research, Deck builder",
|
|
artifacts: "Artifacts 63Newest: November investor update",
|
|
});
|
|
expect(card.textContent).not.toContain("Get the cap table from counsel");
|
|
expect(card.querySelectorAll("button")).toHaveLength(0);
|
|
});
|
|
|
|
it("What's moving: the summary attention first, then one list of the work, attention first, each marked with its kind", async () => {
|
|
mocks.search = "?view=moving";
|
|
await render();
|
|
const page = host.querySelector<HTMLElement>('[data-responsibility-view="moving"]')!;
|
|
expect(page.querySelector('[data-signal-group="attention"]')?.textContent).toContain("Investor update deck is 3 days past its target date");
|
|
expect(page.querySelector('[data-signal-group="moving"]')?.textContent).toContain("2 open tasks with CodexCoder");
|
|
const rows = [...page.querySelectorAll<HTMLElement>("li[data-work-id]")];
|
|
expect(rows.map((row) => [row.getAttribute("data-work-kind"), row.getAttribute("data-work-id"), row.hasAttribute("data-attention")])).toEqual([
|
|
["project", "project-deck", true],
|
|
["task", "task-blocked", true],
|
|
["project", "project-pipeline", false],
|
|
["task", "task-draft", false],
|
|
["task", "task-intro", false],
|
|
["routine", "routine-weekly", false],
|
|
]);
|
|
expect(rows[0]!.textContent).toBe("ProjectInvestor update deckLate · Nov 10");
|
|
expect(rows[1]!.querySelector("a")?.getAttribute("href")).toBe("/issues/PAP-41");
|
|
expect(page.textContent).toContain("1 finished item is not listed.");
|
|
expect(page.querySelector('[data-testid="responsibility-strip"]')?.querySelectorAll("li")).toHaveLength(4);
|
|
expect(page.textContent).toContain("And 61 more artifacts.");
|
|
});
|
|
|
|
it("One screen: the bar beside short capped lists of the work, each item marked with how it bears on the number", async () => {
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const page = host.querySelector<HTMLElement>('[data-responsibility-view="one_screen"]')!;
|
|
const bar = page.querySelector<HTMLElement>("#responsibility-bar-summary")!;
|
|
expect(bar.textContent).toContain(RESPONSIBILITY_DETAIL_FIXTURES["resp-fundraising"]!.standard!);
|
|
const affecting = bar.querySelector<HTMLElement>("[data-affecting-summary]")!;
|
|
expect(affecting.querySelector("h3")?.textContent).toBe("What is affecting the number");
|
|
expect(affecting.textContent).toContain("the cap table task is blocked");
|
|
expect(affecting.textContent).toContain("Summarized from the numbers");
|
|
|
|
expect(page.querySelector("[data-bearing-key]")?.textContent).toBe("Holding the number backMoving it");
|
|
const rows = (kind: string) =>
|
|
[...page.querySelectorAll<HTMLElement>(`[data-work-list="${kind}"] li[data-work-id]`)].map((row) => [
|
|
row.getAttribute("data-work-id"),
|
|
row.getAttribute("data-bearing"),
|
|
row.querySelector("[data-bearing-reason]")?.textContent,
|
|
]);
|
|
expect(rows("project")).toEqual([
|
|
["project-deck", "holding", "Holding the number back: 3 days late (due Nov 10)"],
|
|
["project-pipeline", "neutral", "Not started, due Dec 15"],
|
|
]);
|
|
const tasks = page.querySelector<HTMLElement>('[data-work-list="task"]')!;
|
|
expect(tasks.querySelector("h2")?.textContent).toBe("Tasks 4");
|
|
expect(rows("task")).toEqual([
|
|
["task-blocked", "holding", "Holding the number back: Blocked"],
|
|
["task-draft", "moving", "Moving the number: In progress with CodexCoder"],
|
|
["task-intro", "neutral", "With you"],
|
|
]);
|
|
expect(tasks.textContent).toContain("and 1 more");
|
|
expect(rows("routine")).toEqual([
|
|
["routine-weekly", "moving", "Moving the number: Active, last run succeeded on 2026-11-10, next run 2026-11-17"],
|
|
]);
|
|
});
|
|
|
|
it("One screen: routines and skills first, then projects and tasks, then artifacts, as lists and cards", async () => {
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const column = host.querySelector<HTMLElement>("[data-work-order]")!;
|
|
const order = [...column.querySelectorAll<HTMLElement>("[data-work-list], [data-card-list]")]
|
|
.map((node) => node.dataset.workList ?? `${node.dataset.cardList} cards`);
|
|
expect(order).toEqual(["routine", "skill cards", "project", "task", "artifact cards"]);
|
|
expect(column.querySelectorAll('[data-testid="responsibility-skill-cards"] [data-slot="card"]')).toHaveLength(2);
|
|
const artifacts = column.querySelector<HTMLElement>('[data-card-list="artifact"]')!;
|
|
expect(artifacts.querySelector("h2")?.textContent).toBe("Artifacts 63");
|
|
expect(artifacts.querySelectorAll("li")).toHaveLength(3);
|
|
expect(artifacts.textContent).toContain("and 60 more artifacts");
|
|
});
|
|
|
|
it("One screen: the bar's metrics stacked in their forms, with the agent's written status leading", async () => {
|
|
mocks.metrics.metrics.mockResolvedValue(METRIC_SET_FIXTURES.chosen);
|
|
mocks.api.statusReport.mockResolvedValue(statusReportFixture());
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const bar = host.querySelector<HTMLElement>("#responsibility-bar-summary")!;
|
|
expect([...bar.querySelectorAll<HTMLElement>("[data-metric-key]")].map((tile) => tile.dataset.metricDisplay)).toEqual(["line", "bar", "percent"]);
|
|
expect(bar.querySelector('[data-metric-layout="stack"]')).not.toBeNull();
|
|
const lead = bar.querySelector<HTMLElement>("[data-agent-status]")!;
|
|
expect(lead.textContent).toContain("replies are slipping");
|
|
expect(lead.compareDocumentPosition(bar.querySelector("[data-bar-metrics]")!) & Node.DOCUMENT_POSITION_FOLLOWING).not.toBe(0);
|
|
});
|
|
|
|
it("One screen: without the metric set or a written status, the bar looks as before", async () => {
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const bar = host.querySelector<HTMLElement>("#responsibility-bar-summary")!;
|
|
expect(bar.querySelector("[data-metric-key]")).toBeNull();
|
|
expect(bar.querySelector('[role="meter"]')?.getAttribute("aria-valuenow")).toBe("45");
|
|
expect(bar.querySelector("[data-agent-status]")).toBeNull();
|
|
expect(bar.textContent).toContain("9 of 20 investors contacted, 45% of target");
|
|
});
|
|
|
|
it("One screen: says how automated it is, and offers to automate each manual task with the agent or by hand, quietly", async () => {
|
|
mocks.suggestions.repeatAsRoutine.mockResolvedValue({
|
|
routine: { id: "routine-new", title: "Ask Dana for an intro to the lead", assigneeAgentId: "agent-codex", projectId: null, status: "active" },
|
|
cadenceLabel: "Every Monday at 9 AM",
|
|
timezone: "UTC",
|
|
responsibilityIds: ["resp-fundraising"],
|
|
acceptedOfferId: null,
|
|
});
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const page = host.querySelector<HTMLElement>('[data-responsibility-view="one_screen"]')!;
|
|
expect(mocks.api.automation).toHaveBeenCalledWith("company-storybook", { ownerUserId: RESPONSIBILITY_DETAIL_FIXTURES["resp-fundraising"]!.ownerUserId });
|
|
expect(page.querySelector("#responsibility-bar-summary [data-automation-line]")?.textContent).toBe("1 automation · 5 manual tasks · 17% automated");
|
|
|
|
// Every manual task row gets the actions; projects and routines do not.
|
|
const actionable = [...page.querySelectorAll<HTMLElement>("li[data-work-id]")]
|
|
.filter((row) => row.querySelector("[data-make-routine]"))
|
|
.map((row) => row.getAttribute("data-work-id"));
|
|
expect(actionable).toEqual(["task-blocked", "task-intro"]);
|
|
// The row still opens the task; the actions sit beside the link, not inside it.
|
|
const intro = page.querySelector<HTMLElement>('li[data-work-id="task-intro"]')!;
|
|
expect(intro.querySelector("a [data-make-routine]")).toBeNull();
|
|
expect(intro.querySelector("a [data-automate-with-agent]")).toBeNull();
|
|
// First the conversation with the agent, then the form.
|
|
const talk = intro.querySelector<HTMLButtonElement>("[data-automate-with-agent]")!;
|
|
expect(talk.getAttribute("aria-label")).toBe("Automate with CodexCoder: “Ask Dana for an intro to the lead”");
|
|
mocks.conversations.start.mockResolvedValue({
|
|
sourceIssueId: "task-intro", state: "discussing", defaultAgentId: "agent-codex",
|
|
conversation: { issueId: "conversation-intro", identifier: "PAP-91", title: "Automate", status: "todo", agentId: "agent-codex", createdAt: new Date() },
|
|
proposal: null,
|
|
});
|
|
await act(async () => talk.click());
|
|
await flush();
|
|
expect(mocks.conversations.start).toHaveBeenCalledWith("task-intro", { agentId: "agent-codex", responsibilityId: "resp-fundraising" });
|
|
expect(mocks.navigate).toHaveBeenCalledWith("/issues/PAP-91");
|
|
const button = intro.querySelector<HTMLButtonElement>("[data-make-routine]")!;
|
|
expect(button.getAttribute("aria-label")).toBe("Set up “Ask Dana for an intro to the lead” by hand");
|
|
|
|
await act(async () => button.click());
|
|
await flush();
|
|
const dialog = document.querySelector<HTMLElement>("[data-make-routine-dialog]")!;
|
|
expect(dialog.querySelector<HTMLInputElement>('input[aria-label="What repeats"]')?.value).toBe("Ask Dana for an intro to the lead");
|
|
// No agent on the task: the organization's first agent runs it.
|
|
expect(dialog.querySelector<HTMLSelectElement>('select[aria-label="Who runs it"]')?.value).toBe("agent-codex");
|
|
expect(dialog.querySelector("[data-routine-filing-note]")?.textContent).toContain("filed under Seed extension");
|
|
const submit = [...dialog.querySelectorAll<HTMLButtonElement>("button")].find((candidate) => candidate.textContent === "Make it a routine")!;
|
|
await act(async () => submit.click());
|
|
await flush();
|
|
expect(mocks.suggestions.repeatAsRoutine).toHaveBeenCalledWith("task-intro", expect.objectContaining({ assigneeAgentId: "agent-codex" }));
|
|
expect(mocks.api.automation.mock.calls.length).toBeGreaterThan(1);
|
|
});
|
|
|
|
it("One screen: no automation line or row actions when the automation cannot be read", async () => {
|
|
mocks.api.automation.mockRejectedValue(new Error("down"));
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
const page = host.querySelector<HTMLElement>('[data-responsibility-view="one_screen"]')!;
|
|
expect(page.querySelector("[data-automation-line]")).toBeNull();
|
|
expect(page.querySelector("[data-make-routine]")).toBeNull();
|
|
expect(page.querySelectorAll('[data-work-list="task"] li[data-work-id]')).toHaveLength(3);
|
|
});
|
|
|
|
it("One screen: has the full page's header actions and opens the full layout's bar editor", async () => {
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
expect(view()).toBe("one_screen");
|
|
const actions = host.querySelector<HTMLElement>("[data-responsibility-header-actions]")!;
|
|
expect(actions.querySelector("button")?.textContent).toBe("New task for an agent");
|
|
expect(actions.querySelector('button[aria-label="More actions for this responsibility"]')).not.toBeNull();
|
|
expect(document.body.querySelector('[role="dialog"]')).toBeNull();
|
|
await act(async () => actions.querySelector("button")!.click());
|
|
expect(document.body.querySelector('[role="dialog"]')?.textContent).toContain("New task for an agent");
|
|
|
|
await remount();
|
|
const edit = [...host.querySelectorAll<HTMLButtonElement>("#responsibility-bar-summary button")].find((button) => button.textContent === "Edit the bar")!;
|
|
await act(async () => edit.click());
|
|
await act(async () => { await new Promise((resolve) => requestAnimationFrame(() => resolve(null))); });
|
|
await flush();
|
|
expect(view()).toBe("full");
|
|
expect(document.body.querySelector('[role="dialog"]')?.textContent).toContain("Edit the bar");
|
|
// It is a visit: "Back" is offered while the full layout shows.
|
|
expect(host.querySelector("[data-responsibility-back]")?.textContent).toBe("Back");
|
|
});
|
|
|
|
it("One screen: no paragraph when the summary cannot be read", async () => {
|
|
mocks.api.summary.mockRejectedValue(new Error("down"));
|
|
mocks.search = "?view=one_screen";
|
|
await render();
|
|
await flush();
|
|
expect(host.querySelector("[data-affecting-summary]")).toBeNull();
|
|
expect(host.querySelector("#responsibility-bar-summary")).not.toBeNull();
|
|
});
|
|
|
|
it("shows the empty work in every view", async () => {
|
|
for (const choice of ["scorecard", "moving", "one_screen"]) {
|
|
mocks.search = `?view=${choice}`;
|
|
await remount("resp-hiring");
|
|
expect(view()).toBe(choice);
|
|
expect(host.querySelector("h1")?.textContent).toBe("Hiring");
|
|
}
|
|
expect(host.textContent).toContain("No open tasks.");
|
|
expect(host.textContent).toContain("No skills yet.");
|
|
expect(host.textContent).toContain("Nothing produced yet.");
|
|
});
|
|
|
|
it("does not hide that it is proposed: a notice takes the person to review it", async () => {
|
|
mocks.search = "?view=moving";
|
|
await render(proposedDetail.id);
|
|
const notice = host.querySelector<HTMLElement>("[data-proposals-notice]")!;
|
|
expect(notice.textContent).toContain("This responsibility was proposed for you and is waiting for your review.");
|
|
await act(async () => notice.querySelector("button")!.click());
|
|
expect(view()).toBe("full");
|
|
expect(host.textContent).toContain("Proposed for you");
|
|
// The review is a visit: "Back" returns to where the person was.
|
|
await act(async () => host.querySelector<HTMLButtonElement>("[data-responsibility-back]")!.click());
|
|
expect(view()).toBe("moving");
|
|
expect(host.querySelector("[data-responsibility-back]")).toBeNull();
|
|
});
|
|
});
|