feat(responsibilities): add routine filter and routine agent avatars (#23159)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The experimental Responsibilities dashboard (`outline_v2`) lists a
person's areas and responsibilities as a clean outline.
> - Today, operators cannot filter the Responsibilities outline by
whether a responsibility has routines, and rows do not show which agents
are assigned to those routines.
> - Operators need a quick visual signal of which responsibilities
already have agent-run routines and a fast way to focus on
responsibilities with or without routines.
> - This pull request adds `routineAgentIds` to `ResponsibilityRollup`,
adds the shared toolbar filter icon with "Has routines" and "No
routines" options (defaulting to either), and displays slightly
overlapping agent avatars on the right side of responsibility rows that
have assigned routines.
> - The benefit is faster scanning of routine coverage across
responsibilities without leaving the outline view.

## Linked Issues or Issue Description

**What existing behavior does this improve?**
The Responsibilities dashboard (`outline_v2` view at
`/<prefix>/responsibilities`) and the `ResponsibilityRollup` response
returned by `GET /api/companies/:companyId/responsibilities`.

**Subsystem affected**
Cross-cutting (multiple of the above)

**Current behavior**
The Responsibilities dashboard header shows only a search box, total
counts, and the New area button. Each responsibility row shows only its
bar sentence or title, with no visual indicator of which agents are
assigned to its routines and no filter to narrow by routine presence.

**Proposed behavior**
The header adds the shared toolbar Filter icon button beside the search
box, opening a popover with "Has routines" and "No routines" options
(both unchecked by default so either is shown) and a Clear action. Each
responsibility row with one or more non-archived routines assigned to
agents displays those agents' avatars slightly overlapping on the right
side of the row (up to 4 avatars with a `+N` overflow indicator and a
tooltip listing agent names).

**Reason and benefit**
Operators scanning their responsibilities need to see at a glance which
responsibilities already have agents running routines and quickly filter
to responsibilities that still need routines set up (or only those with
routines).

**Breaking changes**
Additive field `routineAgentIds: string[]` added to
`ResponsibilityRollup`. Existing callers ignore unknown fields.

## What Changed

- Added `routineAgentIds: string[]` to `ResponsibilityRollup` in
`packages/shared/src/types/responsibility.ts` and refreshed the pinned
hash in `tests/runner-e2e/source-sdk-public-inputs.json`.
- Updated `responsibilityService.computeRollups` and
`buildResponsibilityRollup` in `server/src/services/responsibilities.ts`
to select `routines.assigneeAgentId` (ordered deterministically by title
and id) and deduplicate non-null assignees across non-archived member
routines (direct and project-linked) with no extra queries.
- Added `OutlineV2RoutineFilter` and `filterOutlineV2Groups` in
`ui/src/lib/responsibility-outline-v2.ts`.
- Added the shared toolbar `Filter` icon popover ("Has routines" / "No
routines", default either) and live filtered counts to
`ui/src/pages/Responsibilities.tsx`.
- Updated `ui/src/components/responsibilities/DashboardOutlineV2.tsx` to
filter groups, unfold matching areas while filtered, show an empty-match
state with a Clear filter button, and render slightly overlapping
routine-agent avatars (`size={20}`, `-space-x-1.5`, capped at 4 with
`+N`) on the right side of each row that has routines with assigned
agents.
- Added unit, embedded-Postgres integration, jsdom UI, and Storybook
coverage (`server/src/__tests__/responsibilities-rollup.test.ts`,
`server/src/__tests__/responsibilities.test.ts`,
`ui/src/lib/responsibility-outline-v2.test.ts`,
`ui/src/components/responsibilities/DashboardOutlineV2.test.tsx`,
`ui/src/pages/Responsibilities.outline-v2.test.tsx`, and
`ui/storybook/stories/activity/responsibilities.stories.tsx`).

## Verification

- `pnpm --filter @paperclipai/shared build` — passed.
- `pnpm --filter @paperclipai/server typecheck` — passed (all 7 layers).
- `pnpm --filter @paperclipai/ui typecheck` — passed.
- `pnpm check:token-gates` — passed (all 4 gates clean).
- Focused Vitest suites (194 tests across 10 files) — passed:
  - `server/src/__tests__/responsibilities-rollup.test.ts` (18/18)
- `server/src/__tests__/responsibilities.test.ts` (37/37, embedded
PostgreSQL)
- `server/src/__tests__/responsibility-summaries.test.ts`,
`responsibility-summary-generator.test.ts`,
`responsibility-tools.test.ts`
- `ui/src/lib/responsibilities.test.ts` (41/41),
`responsibility-views.test.ts` (35/35),
`responsibility-outline-v2.test.ts` (15/15)
- `ui/src/components/responsibilities/DashboardOutlineV2.test.tsx` (2/2)
  - `ui/src/pages/Responsibilities.outline-v2.test.tsx` (1/1)
- Manually verified live Storybook preview (`Dashboard view: Outline v2,
routine avatars & filter`) in dark mode across default, "Has routines",
"No routines", and "Clear" states, confirming avatar overlap for 1, 2,
and 3 agents and empty states for rows without routines.
- Note: `pnpm verify` exited with code `2` because
`tests/runner-e2e/source-sdk-public-inputs.json` changed; CI supplies
the full broad suite.

## Risks

- Low risk. `routineAgentIds` is computed from the existing
`memberRoutines` query in `computeRollups` (adding one column selection
and deterministic ordering, no new queries or schema migrations).

## Model Used

- Google Gemini 4 Neon (High) via Antigravity with tool use and code
execution.

## 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
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any 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: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-11-28 12:53:18 +00:00
1 parent c1bb0e80b3
commit c57471459f
17 files changed
+864 -40

No files matched your search

@@ -105,6 +105,22 @@ describe("responsibility attainment and status", () => {
expect(rollup.overdueProjects).toEqual([{ id: "p1", name: "Deck", targetDate: "2026-11-01", daysOverdue: 12 }]);
});
it("collects distinct routineAgentIds from non-archived routines only", () => {
const work = noWork();
work.routines.push(
{ id: "r1", title: "A", status: "active", assigneeAgentId: "agent-1", lastRunStatus: null, lastRunAt: null, nextRunAt: null },
{ id: "r2", title: "B", status: "paused", assigneeAgentId: "agent-2", lastRunStatus: null, lastRunAt: null, nextRunAt: null },
{ id: "r3", title: "C", status: "active", assigneeAgentId: "agent-1", lastRunStatus: null, lastRunAt: null, nextRunAt: null },
{ id: "r4", title: "D", status: "active", assigneeAgentId: null, lastRunStatus: null, lastRunAt: null, nextRunAt: null },
{ id: "r5", title: "E", status: "archived", assigneeAgentId: "agent-3", lastRunStatus: null, lastRunAt: null, nextRunAt: null },
);
const rollup = buildResponsibilityRollup({
responsibilityId: "r1", metric: metric(), healthOverride: null, counts: noCounts, work, now: NOW,
});
expect(rollup.routines).toBe(4);
expect(rollup.routineAgentIds).toEqual(["agent-1", "agent-2"]);
});
it("lists what an active responsibility is missing", () => {
expect(missingForActive({ standard: " ", metricName: null, metricTarget: null })).toEqual(["standard", "metricName", "metricTarget"]);
expect(missingForActive({ standard: "Bar", metricName: "Reply time", metricTarget: 0 })).toEqual([]);
@@ -1338,5 +1338,50 @@ describeEmbeddedPostgres("responsibility routes", () => {
const [row] = await db.select().from(responsibilities).where(eq(responsibilities.id, item.id));
expect(row?.areaId).toBe(to.body.id);
});
it("returns distinct routineAgentIds on overview rollups for direct and project-linked non-archived routines", async () => {
await enable();
const company = await seedCompany();
const agentA = await seedAgent(company.id, "Alpha");
const agentB = await seedAgent(company.id, "Beta");
const agentArchived = await seedAgent(company.id, "ArchivedAgent");
const board = createApp(db, localBoardActor());
const withRoutines = await createResponsibility(board, company.id, { title: "Has routines" });
const withoutRoutines = await createResponsibility(board, company.id, { title: "No routines" });
const [project] = await db.insert(projects).values({ companyId: company.id, name: "Ops", status: "in_progress" }).returning();
const [directRoutineA] = await db.insert(routines).values({
companyId: company.id, title: "A direct", status: "active", assigneeAgentId: agentA.id,
}).returning();
const [directRoutineDup] = await db.insert(routines).values({
companyId: company.id, title: "B duplicate agent", status: "paused", assigneeAgentId: agentA.id,
}).returning();
const [archivedRoutine] = await db.insert(routines).values({
companyId: company.id, title: "C archived", status: "archived", assigneeAgentId: agentArchived.id,
}).returning();
await db.insert(routines).values({
companyId: company.id, title: "D via project", status: "active", assigneeAgentId: agentB.id, projectId: project!.id,
});
await db.insert(responsibilityLinks).values([
{ companyId: company.id, responsibilityId: withRoutines.id, routineId: directRoutineA!.id },
{ companyId: company.id, responsibilityId: withRoutines.id, routineId: directRoutineDup!.id },
{ companyId: company.id, responsibilityId: withRoutines.id, routineId: archivedRoutine!.id },
{ companyId: company.id, responsibilityId: withRoutines.id, projectId: project!.id },
]);
const overview = await request(board).get(`/api/companies/${company.id}/responsibilities`);
expect(overview.status).toBe(200);
const byId = new Map(
(overview.body.responsibilities as Array<{ id: string; rollup: { routines: number; routineAgentIds: string[] } }>)
.map((item) => [item.id, item.rollup]),
);
expect(byId.get(withRoutines.id)).toMatchObject({
routines: 3,
routineAgentIds: [agentA.id, agentB.id],
});
expect(byId.get(withoutRoutines.id)).toMatchObject({
routines: 0,
routineAgentIds: [],
});
});
});
});
@@ -102,6 +102,7 @@ function row(input: RowInput): ResponsibilityWithRollup {
workSummary: input.signals ?? [],
projects: input.projects ?? 0,
routines: input.routines ?? 0,
routineAgentIds: [],
openTasks: input.open ?? 0,
blockedTasks: input.blocked ?? 0,
agentTasks: 0,
@@ -207,6 +208,7 @@ function detail(input: DetailInput = {}): ResponsibilityDetail {
workSummary: input.signals ?? [],
projects: input.counts?.projects ?? input.projects?.length ?? 0,
routines: input.counts?.routines ?? input.routines?.length ?? 0,
routineAgentIds: [],
openTasks: input.counts?.openTasks ?? 0,
blockedTasks: input.counts?.blockedTasks ?? 0,
agentTasks: 0,
@@ -110,7 +110,7 @@ function overview(): ResponsibilityOverview {
metric: { kind: "volume", name: "Investors contacted", unit: null, target: 20, low: null, high: null, current: 4,
direction: "at_least", attainment: 0.2, statusRule: null, updatedAt: new Date(), stale: false },
statusSentence: "4 of 20 investors contacted, 20% of target", workSummary: [],
projects: 0, routines: 0, openTasks: 2, blockedTasks: 0, agentTasks: 0, userTasks: 2, doneTasks: 0, nextDueAt: null, overdueProjects: [],
projects: 0, routines: 0, routineAgentIds: [], openTasks: 2, blockedTasks: 0, agentTasks: 0, userTasks: 2, doneTasks: 0, nextDueAt: null, overdueProjects: [],
},
}] as unknown as ResponsibilityOverview["responsibilities"],
proposed: [],
@@ -11,7 +11,7 @@ function rollup(overrides: Record<string, unknown> = {}) {
return {
health: "on_track", computedHealth: "on_track", healthOverridden: false, metric: null,
statusSentence: "12 of 20 investors contacted, 60% of target", workSummary: [{ text: "2 tasks blocked" }],
projects: 1, routines: 2, openTasks: 3, blockedTasks: 2, agentTasks: 1, userTasks: 2, doneTasks: 4,
projects: 1, routines: 2, routineAgentIds: [], openTasks: 3, blockedTasks: 2, agentTasks: 1, userTasks: 2, doneTasks: 4,
nextDueAt: null, overdueProjects: [], ...overrides,
};
}
+16 -2
View File
@@ -281,6 +281,7 @@ export interface ResponsibilityWorkRoutine {
id: string;
title: string;
status: string;
assigneeAgentId?: string | null;
lastRunStatus: string | null;
lastRunAt: Date | null;
nextRunAt: Date | null;
@@ -471,6 +472,15 @@ export function buildResponsibilityRollup(input: {
: null;
const unfinished = input.work.projects.filter(isUnfinishedProject).map((project) => project.targetDate)
.filter((date): date is string => date !== null).sort();
const nonArchivedRoutines = input.work.routines.filter((routine) => routine.status !== "archived");
const routineAgentIds: string[] = [];
const seenRoutineAgents = new Set<string>();
for (const routine of nonArchivedRoutines) {
if (routine.assigneeAgentId && !seenRoutineAgents.has(routine.assigneeAgentId)) {
seenRoutineAgents.add(routine.assigneeAgentId);
routineAgentIds.push(routine.assigneeAgentId);
}
}
return {
health: override ?? computedHealth,
computedHealth,
@@ -479,7 +489,8 @@ export function buildResponsibilityRollup(input: {
statusSentence: buildStatusSentence(metric),
workSummary: buildWorkSummary({ responsibilityId: input.responsibilityId, metric, work: input.work, now }),
projects: input.work.projects.length,
routines: input.work.routines.filter((routine) => routine.status !== "archived").length,
routines: nonArchivedRoutines.length,
routineAgentIds,
openTasks: input.counts.openTasks,
blockedTasks: input.counts.blockedTasks,
agentTasks: input.counts.agentTasks,
@@ -767,12 +778,14 @@ export function responsibilityService(db: Db, deps: { routines?: ReturnType<type
id: routines.id,
title: routines.title,
status: routines.status,
assigneeAgentId: routines.assigneeAgentId,
lastRunStatus,
lastRunAt,
nextRunAt,
}).from(memberRoutineRows)
.innerJoin(routines, eq(routines.id, memberRoutineRows.routineId))
.where(sql`${routines.status} <> 'archived'`),
.where(sql`${routines.status} <> 'archived'`)
.orderBy(asc(routines.title), asc(routines.id)),
]);
const counts = new Map<string, RollupCounts>();
@@ -819,6 +832,7 @@ export function responsibilityService(db: Db, deps: { routines?: ReturnType<type
id: row.id,
title: row.title,
status: row.status,
assigneeAgentId: row.assigneeAgentId,
lastRunStatus: row.lastRunStatus,
lastRunAt: row.lastRunAt ? new Date(row.lastRunAt) : null,
nextRunAt: row.nextRunAt ? new Date(row.nextRunAt) : null,