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";