From 3884cc6df4675b7475b340b620bbdb19bd1defe7 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Mon, 30 Nov 2026 14:12:46 -0800 Subject: [PATCH] fix(ui): open Needs You on Assigned to you, keep saved filters (#23321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Coordinator Inbox (Needs You, `/decisions`) shows the decisions and problems that wait for a person > - #22964 made the page open on "All assignees" for a board member who has no saved assignee choice > - The page title and badge read as personal, so a board member sees other people's decisions and thinks they are theirs to act on > - This pull request opens the page on "Assigned to you" again when no choice is saved, and keeps the saved toolbar from #22964 > - The benefit is that each person opens on their own work, and a board member who wants the company-wide queue picks "All assignees" once and keeps it ## Linked Issues or Issue Description Refs #22964 **What existing behavior does this improve?** The opening assignee filter on the Coordinator Inbox / Needs You page (`/decisions`). **Current behavior** A board member with no saved assignee choice opens Needs You on "All assignees". The page shows decisions that are for other people (for example, a question an agent asked the person who created the task), with no signal that the list is not personal. **Proposed behavior** Every person with no saved assignee choice opens Needs You on "Assigned to you". The assignee, agent, project, and grouping choices stay saved per company and person, as in #22964. A board member who picks "All assignees" or one person still reopens on that choice. **Reason and benefit** A page named "Needs you" must open on the work that needs this person. The saved toolbar already removes the repeated clicks that #22964 set out to remove, so the company-wide default is not necessary. ## What Changed - `ui/src/lib/coordinator-attention.ts`: `openingCoordinatorAssignee` returns "Assigned to you" when no usable choice is saved, also for board members. A saved choice that the person may open still wins. - `ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx`: Tests now start from "Assigned to you", prove that "All assignees" sticks after a person picks it, and prove that the page loads the personal feed at once when nothing is saved. The board-access wait test now covers a saved "All assignees" choice. - `ui/src/lib/coordinator-attention.test.ts`: Update the unit expectations for the opening filter. - `tests/e2e/coordinator-inbox-views.spec.ts`: Assert "Assigned to you" on open, then pick "All assignees" and prove that it and the grouping persist across navigation and reload. - `doc/PRODUCT.md`: Document the opening filter and the saved choices. ## Verification - `cd ui && npx vitest run src/components/coordinator/ src/lib/coordinator-attention.test.ts src/hooks/useAttentionViews.test.tsx src/lib/attention-views.test.ts` → 7 files, 49 tests passed. - RED check: with the old `everyone ? "all" : "me"` fallback restored, 13 tests in the toolbar and coordinator-attention suites fail. - `pnpm --filter @paperclipai/ui typecheck` → pass. - `PAPERCLIP_E2E_PORT=3257 npx playwright test --config tests/e2e/playwright.config.ts tests/e2e/coordinator-inbox-views.spec.ts` against a freshly built UI → 2 passed (desktop and mobile). ## Risks - Behavioral shift: board members who relied on the #22964 default open on "Assigned to you" until they pick "All assignees" once. After that, the saved choice applies. - A board member who already picked a filter keeps it. No saved data changes. - The classic (non-Coordinator) Decisions page is unchanged. > 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 - Claude Opus 5.5 (`claude-opus-5-5`) by Anthropic, in Claude Code with tool use, shell execution, Vitest, and Playwright. ## 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 - [ ] All Paperclip CI gates are green - [ ] 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 --- doc/PRODUCT.md | 8 +- tests/e2e/coordinator-inbox-views.spec.ts | 16 ++-- .../CoordinatorNeedsYou.toolbar.test.tsx | 87 ++++++++++++------- ui/src/lib/coordinator-attention.test.ts | 5 +- ui/src/lib/coordinator-attention.ts | 2 +- 5 files changed, 73 insertions(+), 45 deletions(-) diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index c15acb7c242..029165224ca 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -540,10 +540,10 @@ Coordinator navigation uses **Chat**, **Tasks**, and **Inbox**. Inbox uses the inbox icon and keeps the existing decision feed, its count, and decision history at `/decisions`. The previous Inbox destination under More is removed. -Inbox opens to **Needs you** with **All assignees** selected for a board member -and **Assigned to you** for a viewer. The assignee, agent, project, and grouping -choices are saved per person and company, so the next visit opens the same way; -a link that names a view still opens that view. Its badge counts +Inbox opens to **Needs you** with **Assigned to you** selected. The assignee, +agent, project, and grouping choices are saved per person and company, so the +next visit opens the same way (a board member who picks **All assignees** keeps +it); a link that names a view still opens that view. Its badge counts personal actions. **Waiting** shows scheduled provider retries and personal snoozes. A provider limit with a known account and reset appears once per recipient, with the affected tasks, agents and run logs inside. When the account or diff --git a/tests/e2e/coordinator-inbox-views.spec.ts b/tests/e2e/coordinator-inbox-views.spec.ts index 9710f51771e..785661d50fe 100644 --- a/tests/e2e/coordinator-inbox-views.spec.ts +++ b/tests/e2e/coordinator-inbox-views.spec.ts @@ -94,22 +94,22 @@ for (const mobile of [false, true]) test(`Mine retains Inbox behavior inside Tas await page.getByRole("link", { name: "Inbox", exact: true }).click(); const inbox = page.getByRole("region", { name: "Inbox", exact: true }); await expect(inbox.getByRole("toolbar", { name: "Decisions controls" })).toBeVisible(); - await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true })).toBeVisible(); - await inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true }).click(); - await page.getByRole("menuitem", { name: "Assigned to you", exact: true }).click(); await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true })).toBeVisible(); + await inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true }).click(); + await page.getByRole("menuitem", { name: "All assignees", exact: true }).click(); + await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true })).toBeVisible(); await inbox.getByRole("button", { name: "Group decisions, By type", exact: true }).click(); await page.getByRole("menuitem", { name: "By project", exact: true }).click(); await expect(inbox.getByRole("button", { name: "Group decisions, By project", exact: true })).toBeVisible(); await page.goto(`/${company.issuePrefix}/decisions`); - await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true })).toBeVisible(); + await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true })).toBeVisible(); await expect(inbox.getByRole("button", { name: "Group decisions, By project", exact: true })).toBeVisible(); await page.reload(); - await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true })).toBeVisible(); - await expect(inbox.getByRole("button", { name: "Group decisions, By project", exact: true })).toBeVisible(); - await inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true }).click(); - await page.getByRole("menuitem", { name: "All assignees", exact: true }).click(); await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true })).toBeVisible(); + await expect(inbox.getByRole("button", { name: "Group decisions, By project", exact: true })).toBeVisible(); + await inbox.getByRole("button", { name: "Filter decisions by assignee, All assignees", exact: true }).click(); + await page.getByRole("menuitem", { name: "Assigned to you", exact: true }).click(); + await expect(inbox.getByRole("button", { name: "Filter decisions by assignee, Assigned to you", exact: true })).toBeVisible(); await page.setViewportSize({ width: 1024, height: 720 }); const search = await inbox.locator("[data-toolbar-search]").boundingBox(); const firstFilter = await inbox.getByRole("button", { name: /^Filter decisions by agent,/ }).boundingBox(); diff --git a/ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx b/ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx index beecb5ac178..2a210747810 100644 --- a/ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx +++ b/ui/src/components/coordinator/CoordinatorNeedsYou.toolbar.test.tsx @@ -113,33 +113,40 @@ const location = () => container.querySelector("[data-location]")?.textContent; const listedViews = () => fixture.listCalls.map((call) => call.view); describe("Needs You keeps its toolbar between visits", () => { - it("opens All assignees for a board member, and keeps the chosen assignee, agent, project and grouping on the next visit", async () => { + it("opens Assigned to you for a board member with no kept choice, and keeps the chosen assignee, agent, project and grouping on the next visit", async () => { fixture.boardAccess = member("admin"); const ours = card("ours", 1, { agentId: "agent-cos", project: website }); - fixture.byView = { all: [ours, card("dottas", 2, { userId: "dotta" })], mine: [ours] }; - await visit("/decisions"); - await vi.waitFor(() => expect(assignee().value).toBe("all")); - expect(assignee().textContent).toBe("All assignees"); - expect(assignee().getAttribute("aria-label")).toBe("Filter decisions by assignee, All assignees"); - expect(location()).toBe(""); - expect(listedViews()).toEqual(["all"]); - expect(cards()).toEqual(["ours", "dottas"]); - - await choose("Filter decisions by agent", "Chief of Staff"); - await choose("Filter decisions by project", "Website"); - await choose("Group decisions", "By project"); - await choose("Filter decisions by assignee", "Assigned to you"); - expect(location()).toBe("?view=mine"); - expect(cards()).toEqual(["ours"]); - + fixture.byView = { all: [ours, card("dottas", 2, { userId: "dotta", agentId: "agent-cos", project: website })], mine: [ours] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours"])); expect(assignee().value).toBe("me"); + expect(assignee().textContent).toBe("Assigned to you"); + expect(assignee().getAttribute("aria-label")).toBe("Filter decisions by assignee, Assigned to you"); + expect(location()).toBe(""); + expect(listedViews()).toEqual(["mine"]); + + await choose("Filter decisions by assignee", "All assignees"); + expect(location()).toBe("?view=all"); + await vi.waitFor(() => expect(cards()).toEqual(["ours", "dottas"])); + await choose("Filter decisions by agent", "Chief of Staff"); + await choose("Filter decisions by project", "Website"); + await choose("Group decisions", "By project"); + + await visit("/decisions"); + await vi.waitFor(() => expect(cards()).toEqual(["ours", "dottas"])); + expect(assignee().value).toBe("all"); expect(filterButton("Filter decisions by agent").value).toBe("agent-cos"); expect(filterButton("Filter decisions by project").value).toBe("project-web"); expect(filterButton("Group decisions").value).toBe("project"); expect([...container.querySelectorAll("h2")].map((heading) => heading.textContent)).toContain("Website"); expect(location()).toBe(""); + expect(listedViews()).toEqual(["all"]); + + await choose("Filter decisions by assignee", "Assigned to you"); + expect(location()).toBe("?view=mine"); + await visit("/decisions"); + await vi.waitFor(() => expect(cards()).toEqual(["ours"])); + expect(assignee().value).toBe("me"); expect(listedViews()).toEqual(["mine"]); }); @@ -147,7 +154,7 @@ describe("Needs You keeps its toolbar between visits", () => { fixture.boardAccess = member("admin"); fixture.byView = { all: [card("ours", 1), card("dottas", 2, { userId: "dotta" })], company: [card("alert", 3, { userId: "dotta" })] }; await visit("/decisions"); - await vi.waitFor(() => expect(assignee().value).toBe("all")); + await vi.waitFor(() => expect(assignee().value).toBe("me")); await choose("Filter decisions by assignee", "Dotta"); expect(location()).toBe("?view=all&for=dotta"); expect(cards()).toEqual(["dottas"]); @@ -170,7 +177,7 @@ describe("Needs You keeps its toolbar between visits", () => { fixture.boardAccess = member("admin"); fixture.byView = { all: [card("ours", 1), card("dottas", 2, { userId: "dotta" })], mine: [card("ours", 1)] }; await visit("/decisions"); - await vi.waitFor(() => expect(assignee().value).toBe("all")); + await vi.waitFor(() => expect(assignee().value).toBe("me")); await choose("Filter decisions by assignee", "Dotta"); fixture.boardAccess = member("viewer"); @@ -190,12 +197,32 @@ describe("Needs You keeps its toolbar between visits", () => { expect(listedViews()).toEqual(["mine"]); }); - it("reads no feed until board access is known, so Assigned to you never shows first", async () => { + it("loads Assigned to you without waiting for board access when nothing is kept", async () => { let release!: () => void; fixture.boardAccessGate = new Promise((resolve) => { release = resolve; }); fixture.boardAccess = member("admin"); fixture.byView = { all: [card("ours", 1), card("dottas", 2, { userId: "dotta" })], mine: [card("ours", 1)] }; await visit("/decisions"); + await vi.waitFor(() => expect(cards()).toEqual(["ours"])); + expect(assignee().value).toBe("me"); + expect(assignee().disabled).toBe(false); + + await act(async () => release()); await flush(); await flush(); + expect(assignee().value).toBe("me"); + expect(cards()).toEqual(["ours"]); + expect(listedViews()).toEqual(["mine"]); + }); + + it("reads no feed until board access is known when All assignees is kept, so Assigned to you never shows first", async () => { + fixture.boardAccess = member("admin"); + fixture.byView = { all: [card("ours", 1), card("dottas", 2, { userId: "dotta" })], mine: [card("ours", 1)] }; + await visit("/decisions"); + await vi.waitFor(() => expect(assignee().value).toBe("me")); + await choose("Filter decisions by assignee", "All assignees"); + + let release!: () => void; + fixture.boardAccessGate = new Promise((resolve) => { release = resolve; }); + await visit("/decisions"); expect(listedViews()).toEqual([]); expect(container.querySelector('[role="status"]')?.textContent).toContain("Loading decisions"); expect(cards()).toEqual([]); @@ -212,13 +239,13 @@ describe("Needs You keeps its toolbar between visits", () => { it("still names a kept project with no open cards, so the filter never reads as All projects", async () => { fixture.boardAccess = member("admin"); - fixture.byView = { all: [card("ours", 1, { project: website }), card("other", 2)] }; + fixture.byView = { mine: [card("ours", 1, { project: website }), card("other", 2)] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours", "other"])); await choose("Filter decisions by project", "Website"); expect(cards()).toEqual(["ours"]); - fixture.byView = { all: [card("other", 2)] }; + fixture.byView = { mine: [card("other", 2)] }; await visit("/decisions"); await vi.waitFor(() => expect(container.textContent).toContain("No open decisions match these filters.")); expect(filterButton("Filter decisions by project").value).toBe("project-web"); @@ -230,7 +257,7 @@ describe("Needs You keeps its toolbar between visits", () => { it("stops filtering by a kept agent the company no longer has", async () => { fixture.agents = [{ id: "agent-cos", name: "Chief of Staff" }, { id: "agent-old", name: "Old agent" }] as Agent[]; fixture.boardAccess = member("admin"); - fixture.byView = { all: [card("ours", 1, { agentId: "agent-old" }), card("other", 2)] }; + fixture.byView = { mine: [card("ours", 1, { agentId: "agent-old" }), card("other", 2)] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours", "other"])); await choose("Filter decisions by agent", "Old agent"); @@ -244,7 +271,7 @@ describe("Needs You keeps its toolbar between visits", () => { it("shows every agent's cards while the agent list cannot be read, then filters by the kept agent again", async () => { fixture.boardAccess = member("admin"); - fixture.byView = { all: [card("ours", 1, { agentId: "agent-cos" }), card("other", 2)] }; + fixture.byView = { mine: [card("ours", 1, { agentId: "agent-cos" }), card("other", 2)] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours", "other"])); await choose("Filter decisions by agent", "Chief of Staff"); @@ -266,7 +293,7 @@ describe("Needs You keeps its toolbar between visits", () => { Object.defineProperty(HTMLElement.prototype, "scrollIntoView", { configurable: true, writable: true, value: vi.fn() }); fixture.boardAccess = member("admin"); const linked = { ...card("linked", 3), sourceKind: "decision", subject: { id: "target", kind: "decision", title: "Linked decision" } } as unknown as AttentionItem; - fixture.byView = { all: [card("ours", 1, { agentId: "agent-cos", project: website }), linked] }; + fixture.byView = { mine: [card("ours", 1, { agentId: "agent-cos", project: website }), linked] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours", "linked"])); await choose("Filter decisions by agent", "Chief of Staff"); @@ -292,7 +319,7 @@ describe("Needs You keeps its toolbar between visits", () => { Object.defineProperty(HTMLElement.prototype, "scrollIntoView", { configurable: true, writable: true, value: vi.fn() }); fixture.boardAccess = member("admin"); const linked = { ...card("linked", 3), sourceKind: "decision", subject: { id: "target", kind: "decision", title: "Linked decision" } } as unknown as AttentionItem; - fixture.byView = { all: [card("ours", 1, { agentId: "agent-cos" }), linked] }; + fixture.byView = { mine: [card("ours", 1, { agentId: "agent-cos" }), linked] }; await visit("/decisions"); await vi.waitFor(() => expect(cards()).toEqual(["ours", "linked"])); await choose("Filter decisions by agent", "Chief of Staff"); @@ -312,7 +339,7 @@ describe("Needs You keeps its toolbar between visits", () => { fixture.boardAccess = member("admin"); fixture.byView = { all: [card("ours", 1), card("dottas", 2, { userId: "dotta" })], unassigned: [card("pool", 4)], archived: [] }; await visit("/decisions"); - await vi.waitFor(() => expect(assignee().value).toBe("all")); + await vi.waitFor(() => expect(assignee().value).toBe("me")); await choose("Filter decisions by assignee", "No owner yet"); await vi.waitFor(() => expect(cards()).toEqual(["pool"])); @@ -331,11 +358,11 @@ describe("Needs You keeps its toolbar between visits", () => { const waiting = card("waiting-1", 3); fixture.byView = { all: [dottas, other], waiting: [waiting] }; await visit("/decisions"); - await vi.waitFor(() => expect(assignee().value).toBe("all")); - await choose("Filter decisions by agent", "Chief of Staff"); - await choose("Filter decisions by project", "Website"); + await vi.waitFor(() => expect(assignee().value).toBe("me")); await choose("Filter decisions by assignee", "Dotta"); await vi.waitFor(() => expect(cards()).toEqual(["dottas"])); + await choose("Filter decisions by agent", "Chief of Staff"); + await choose("Filter decisions by project", "Website"); const waitingTab = [...container.querySelectorAll('[aria-label="Inbox views"] button')].find((button) => button.textContent?.startsWith("Waiting"))!; await act(async () => waitingTab.click()); await flush(); diff --git a/ui/src/lib/coordinator-attention.test.ts b/ui/src/lib/coordinator-attention.test.ts index 2107cbc2151..e8c1d62d39c 100644 --- a/ui/src/lib/coordinator-attention.test.ts +++ b/ui/src/lib/coordinator-attention.test.ts @@ -130,14 +130,15 @@ describe("who a card is for (PAP-775)", () => { expect(coordinatorAssigneeTarget("unassigned", "scott")).toEqual({ view: "unassigned", forUserId: null }); }); - it("opens on All assignees for board members, Assigned to you for viewers, and honors kept choices they can open", () => { + it("opens on Assigned to you without a kept choice, and honors kept choices the person can open", () => { expect(coordinatorAssigneeNeedsEveryone("all")).toBe(true); expect(coordinatorAssigneeNeedsEveryone("user:dotta")).toBe(true); expect(coordinatorAssigneeNeedsEveryone("me")).toBe(false); expect(coordinatorAssigneeNeedsEveryone("unassigned")).toBe(false); expect(coordinatorAssigneeNeedsEveryone("company")).toBe(false); - expect(openingCoordinatorAssignee(null, true)).toBe("all"); + expect(openingCoordinatorAssignee(null, true)).toBe("me"); + expect(openingCoordinatorAssignee("all", true)).toBe("all"); expect(openingCoordinatorAssignee(null, false)).toBe("me"); expect(openingCoordinatorAssignee("me", true)).toBe("me"); expect(openingCoordinatorAssignee("user:dotta", true)).toBe("user:dotta"); diff --git a/ui/src/lib/coordinator-attention.ts b/ui/src/lib/coordinator-attention.ts index 86247060b94..02cbc3a9825 100644 --- a/ui/src/lib/coordinator-attention.ts +++ b/ui/src/lib/coordinator-attention.ts @@ -159,7 +159,7 @@ export function coordinatorAssigneeNeedsEveryone(assignee: CoordinatorAssignee) export function openingCoordinatorAssignee(kept: CoordinatorAssignee | null, everyone: boolean): CoordinatorAssignee { if (kept && (everyone || !coordinatorAssigneeNeedsEveryone(kept))) return kept; - return everyone ? "all" : "me"; + return "me"; } export type NeedsYouGroup = "type" | "none" | "task" | "agent" | "project";