From a11552edba75046c20f37a7ecd59ec883529b692 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:12:04 -0800 Subject: [PATCH 1/8] Say INITIAL_ADMIN_EMAILS only on the first organization's People page INITIAL_ADMIN_EMAILS names the admins of the deployment's first organization and of no other, but every organization's People page said "Addresses in INITIAL_ADMIN_EMAILS are always admins. You can't change them here." The line now shows only while the person is working in the first organization. Test: admin-people-remove.test.tsx, the line shows in the first organization and not in another (shown in both before). --- app/src/routes/_authed/admin/people.tsx | 12 ++++++- app/tests/admin-people-remove.test.tsx | 43 +++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app/src/routes/_authed/admin/people.tsx b/app/src/routes/_authed/admin/people.tsx index 28c37fe8e3..924d8b24c2 100644 --- a/app/src/routes/_authed/admin/people.tsx +++ b/app/src/routes/_authed/admin/people.tsx @@ -43,6 +43,7 @@ import { setPersonAccessMutationOptions, setPersonRoleMutationOptions, } from "@/lib/people/mutations"; +import { useCurrentOrganizationId } from "@/lib/organizations/current"; import { useOrganizationChoices } from "@/lib/organizations/queries"; import { type Person, peopleListQueryOptions } from "@/lib/people/queries"; import { queryClient } from "@/query-client"; @@ -122,6 +123,11 @@ function PeoplePage() { const [removing, setRemoving] = useState(null); const [removeOpen, setRemoveOpen] = useState(false); const organization = useRemovalOrganization(); + /* + * INITIAL_ADMIN_EMAILS names the admins of the deployment's first organization (`default`, as the + * API addresses it) and of no other, so only its People page says so. + */ + const inFirstOrganization = useCurrentOrganizationId() === "default"; // The server refuses these too. Disabling them here is so the screen does not offer something it // knows will be refused, not so the rule is enforced in the browser. @@ -133,7 +139,11 @@ function PeoplePage() { title="People" > {failure ? ( diff --git a/app/tests/admin-people-remove.test.tsx b/app/tests/admin-people-remove.test.tsx index a69d4c550f..df57a13a78 100644 --- a/app/tests/admin-people-remove.test.tsx +++ b/app/tests/admin-people-remove.test.tsx @@ -22,6 +22,10 @@ import { within, } from "@testing-library/react"; import { deploymentKeys } from "@/lib/deployment/queries"; +import { + currentOrganizationId, + setCurrentOrganization, +} from "@/lib/organizations/current"; import { queryClient } from "@/query-client"; import { Route } from "@/routes/_authed/admin/people"; import { ME_PATH, meResponse, PEOPLE_PATH, personBody } from "./accounts-api"; @@ -72,12 +76,15 @@ let refusal: string | null = null; * and has no list of them to answer (the address is not served), as before organizations. */ let severalOrganizations = false; +/** Which of the person's organizations they are working in, where there are several. */ +let activeOrganization = "default"; beforeEach(() => { removed.clear(); writes.length = 0; refusal = null; severalOrganizations = false; + activeOrganization = "default"; queryClient.clear(); queryClient.setQueryData(deploymentKeys.capabilities(), { generativeUi: true, @@ -99,7 +106,7 @@ beforeEach(() => { name: "Acme Freight", role: "admin", personal: false, - active: true, + active: activeOrganization === "default", }, { id: "org_dana", @@ -107,7 +114,7 @@ beforeEach(() => { name: "Dana's organization", role: "owner", personal: true, - active: false, + active: activeOrganization === "org_dana", }, ], canCreate: true, @@ -254,6 +261,38 @@ test("with several organizations, Remove says it takes them out of this one alon ).toBeTruthy(); }); +/* + * INITIAL_ADMIN_EMAILS names the admins of the deployment's first organization, `default`, and + * nowhere else. On another organization's People page the line saying those addresses are always + * admins was false there. + */ +test("the INITIAL_ADMIN_EMAILS line shows in the first organization only", async () => { + const LINE = + "Addresses in INITIAL_ADMIN_EMAILS are always admins. You can't change them here."; + severalOrganizations = true; + const first = await draw(); + expect(await first.findByText(LINE)).toBeTruthy(); + cleanup(); + + activeOrganization = "org_dana"; + queryClient.clear(); + queryClient.setQueryData(deploymentKeys.capabilities(), { + generativeUi: true, + selfHostBanner: false, + localEvaluation: false, + edition: "team", + }); + try { + const second = await draw(); + await second.findByText("Who is here"); + await waitFor(() => expect(currentOrganizationId()).toBe("org_dana")); + await settleReactWork(); + expect(second.queryByText(LINE)).toBeNull(); + } finally { + setCurrentOrganization("default"); + } +}); + test("a removal the server refuses is said in the dialog, and the person stays", async () => { refusal = "You can't remove the only admin."; const view = await draw(); From ded17837e30da79d536b8cb87e03326807cc4489 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:12:26 -0800 Subject: [PATCH 2/8] Say an answered task request was answered, not where The needs-you line in the conversation that asked said "You answered this in its thread" even when the answer came from the Bots page's Needs you board. The card can't tell where the answer was given, so it no longer says. --- app/src/components/tasks/task-thread.tsx | 16 ++++++++++------ app/tests/task-thread.test.tsx | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/src/components/tasks/task-thread.tsx b/app/src/components/tasks/task-thread.tsx index 748a22372d..337b885b4d 100644 --- a/app/src/components/tasks/task-thread.tsx +++ b/app/src/components/tasks/task-thread.tsx @@ -515,13 +515,17 @@ export function TaskReport({ ); } -/** What a needs-you line says once the person has answered, by where the task is now. */ +/** + * What a needs-you line says once the person has answered, by where the task is now. Never where + * they answered: the thread, the Bots page's Needs you board and the inbox all answer it, and the + * line can't tell which. + */ const ANSWERED: Record = { - working: "You answered this in its thread. It's carrying on.", - needs: "You answered this in its thread. It needs you again there.", - done: "You answered this in its thread, and it's done.", - failed: "You answered this in its thread, but it couldn't finish.", - stopped: "You answered this in its thread, and stopped it after.", + working: "You answered this. It's carrying on.", + needs: "You answered this. It needs you again in its thread.", + done: "You answered this, and it's done.", + failed: "You answered this, but it couldn't finish.", + stopped: "You answered this, and stopped it after.", }; /** diff --git a/app/tests/task-thread.test.tsx b/app/tests/task-thread.test.tsx index 573d406008..928e842202 100644 --- a/app/tests/task-thread.test.tsx +++ b/app/tests/task-thread.test.tsx @@ -235,7 +235,7 @@ test("a needs-you line asks while the task waits, and changes in place once it i expect(waiting.getByRole("button", { name: /Go to thread/ })).toBeTruthy(); cleanup(); - // Answered in the thread: the task carries on, and the line no longer says it is waiting. + // Answered: the task carries on, and the line no longer says it is waiting. task = { ...task, status: "working", next: null }; const answered = draw( @@ -244,7 +244,7 @@ test("a needs-you line asks while the task waits, and changes in place once it i ); await answered.findByText("Needed you"); expect( - answered.getByText("You answered this in its thread. It's carrying on."), + answered.getByText("You answered this. It's carrying on."), ).toBeTruthy(); expect(answered.queryByText(WAITING)).toBeNull(); expect(answered.getByRole("button", { name: /Open thread/ })).toBeTruthy(); @@ -266,6 +266,23 @@ test("a needs-you line asks while the task waits, and changes in place once it i expect(askedAgain.queryByText(WAITING)).toBeNull(); }); +/* + * Found on the re-test: a person pressed Allow on the Bots page's Needs you board, and the line in + * the conversation that asked read "You answered this in its thread, and it's done." The card can't + * know where the answer was given (the thread, the board, the inbox), so it never says. + */ +test("an answered needs-you line never claims the answer was given in the thread", async () => { + task = { ...task, status: "ready_for_review", next: null as never }; + const view = draw( + +

{WAITING}

+
, + ); + await view.findByText("Needed you"); + expect(view.getByText("You answered this, and it's done.")).toBeTruthy(); + expect(view.queryByText(/in its thread/)).toBeNull(); +}); + test("a Bot's link to a task thread opens in the app, not in a new tab", async () => { expect(inAppPath("/channel/channel_task", "http://openbot.invalid")).toBe( "/channel/channel_task", From 2a4d2cf2583e47f28717ba169a1a7a41418769b4 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:08:46 -0800 Subject: [PATCH 3/8] Read the Bots badge again as soon as an approval is decided Allow or Deny on the Needs you board left the sidebar badge on its old count until its next poll, seconds after the board showed the new one. Deciding an approval now reads the badge again at once, as answering a question already did. --- app/src/lib/approvals.ts | 11 ++++++++- app/tests/bots-nav-badge.test.tsx | 38 ++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/app/src/lib/approvals.ts b/app/src/lib/approvals.ts index 0bd5b1bf43..fec830f2a5 100644 --- a/app/src/lib/approvals.ts +++ b/app/src/lib/approvals.ts @@ -486,7 +486,16 @@ export const decideApprovalMutationOptions = (queryClient: QueryClient) => mutationOptions({ mutationFn: ({ id, choice }: { id: string; choice: ApprovalDecision }) => decideApproval(id, choice), - onSuccess: settle(queryClient), + /* + * The badge that counted it is read again at once, as for an answered question: left to its + * poll, it kept the old count for seconds beside a board that already showed the new one. + */ + onSuccess: () => { + void queryClient.invalidateQueries({ + queryKey: botLifecycleKeys.attention, + }); + return settle(queryClient)(); + }, }); /** Answer a question a Bot asked mid-run; the run resumes with the answer. */ export const answerPersonQuestionMutationOptions = (queryClient: QueryClient) => diff --git a/app/tests/bots-nav-badge.test.tsx b/app/tests/bots-nav-badge.test.tsx index be1c189ec3..9d836b4661 100644 --- a/app/tests/bots-nav-badge.test.tsx +++ b/app/tests/bots-nav-badge.test.tsx @@ -1,8 +1,13 @@ import { afterAll, afterEach, beforeAll, expect, test } from "bun:test"; import { GlobalRegistrator } from "@happy-dom/global-registrator"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { + MutationObserver, + QueryClient, + QueryClientProvider, +} from "@tanstack/react-query"; import { act, cleanup, render, waitFor } from "@testing-library/react"; import { BotsNavBadge } from "@/components/bot-profile/attention"; +import { decideApprovalMutationOptions } from "@/lib/approvals"; import { botLifecycleKeys } from "@/lib/bot-lifecycle/queries"; import { answerBotAttention, attentionOf } from "./bots-api"; import { awayFromOpenBot } from "./desktop-notifications.fixture"; @@ -123,6 +128,37 @@ test("the badge adds up what waits on the person across every Bot", async () => expect(badge.getAttribute("aria-label")).toBe("3 things need you"); }); +test("allowing or denying an action reads the badge again at once, as answering a question does", async () => { + serving([attention("expenses", { approvals: 1 })]); + const answered = global.fetch; + const decided: string[] = []; + // The decision, at the API's address, and every other read as before. + global.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { + if (/\/approvals\/[^/]+\/decide$/.test(pathOf(input))) { + decided.push(pathOf(input)); + return Response.json({ id: "approval-1", status: "completed" }); + } + return answered(input, init); + }) as unknown as typeof fetch; + const { view, client } = draw(); + await view.findByText("1"); + + // Decided on the Needs you board: the server no longer counts it. + served = [attention("expenses", {})]; + await act(async () => { + await new MutationObserver( + client, + decideApprovalMutationOptions(client), + ).mutate({ id: "approval-1", choice: "deny" }); + }); + expect(decided).toHaveLength(1); + // Well inside the badge's own poll, which is 15 seconds away. + await waitFor(() => expect(view.queryByText("1")).toBeNull(), { + timeout: 2_000, + }); + expect(view.container.innerHTML).toBe(""); +}); + test("with only unread messages the badge is a dot, not a number", async () => { serving([attention("expenses", { unread: 2 })]); const { view } = draw(); From 3657a5a106fa83834f4779dbfaa4951fc64b57a9 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:08:49 -0800 Subject: [PATCH 4/8] Say why a task couldn't finish once, and offer Try again only where it can help A task card in the conversation that asked repeated the reason its failure line under it already gives, with the next step. The card now says Couldn't finish and leaves the reason to that line. Tasks gain canTryAgain: false when the task couldn't finish for a reason asking again gets the same answer to, such as a Bot it asked that isn't shared with the person. The Needs you board and the Activity rows then offer Open and Mark done, not Try again. The board also names the state as the card does, Couldn't finish, with the reason as its line. --- api/openapi.yaml | 3 ++ api/openapi/conversations.yaml | 3 ++ app/src/components/tasks/task-row.tsx | 33 +++++++++--- app/src/components/tasks/task-thread.tsx | 22 ++++---- app/src/lib/api/generated/model/task.ts | 2 + app/src/lib/api/generated/tasks/tasks.zod.ts | 30 +++++++++++ app/src/lib/tasks/queries.ts | 29 ++++++++-- app/tests/needs-you.test.tsx | 56 ++++++++++++++++---- app/tests/task-thread.test.tsx | 39 ++++++++++---- mobile/src/api/generated/model/task.ts | 2 + 10 files changed, 176 insertions(+), 43 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index e7279feb85..6b3ed60cbb 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -23950,6 +23950,9 @@ components: - 'null' format: date-time description: When the person stopped its run. Its status is failed while this is set. Null or absent otherwise, and once it carries on. + canTryAgain: + type: boolean + description: Whether trying a failed task again could change how it ends. False when it couldn't finish for a reason asking again gets the same answer to, such as a Bot it asked that isn't shared with the person, or this Bot no longer being shared with them. Absent from a server that does not say, which reads as true. workingSince: type: - string diff --git a/api/openapi/conversations.yaml b/api/openapi/conversations.yaml index 42247c3c9e..e9696f26f9 100644 --- a/api/openapi/conversations.yaml +++ b/api/openapi/conversations.yaml @@ -2451,6 +2451,9 @@ components: - 'null' format: date-time description: When the person stopped its run. Its status is failed while this is set. Null or absent otherwise, and once it carries on. + canTryAgain: + type: boolean + description: Whether trying a failed task again could change how it ends. False when it couldn't finish for a reason asking again gets the same answer to, such as a Bot it asked that isn't shared with the person, or this Bot no longer being shared with them. Absent from a server that does not say, which reads as true. workingSince: type: - string diff --git a/app/src/components/tasks/task-row.tsx b/app/src/components/tasks/task-row.tsx index ad2e6ae97a..e788a71e0f 100644 --- a/app/src/components/tasks/task-row.tsx +++ b/app/src/components/tasks/task-row.tsx @@ -27,9 +27,12 @@ import { tryTaskAgainMutationOptions, } from "@/lib/tasks/mutations"; import { + canTryAgain, couldNotFinish, + failureSentence, stoppedByYou, TASK_DONE_LABEL, + TASK_FAILED_LABEL, TASK_STATUS_LABEL, TASK_STOPPED, TASK_STOPPED_LABEL, @@ -112,6 +115,23 @@ function nextLine(listed: ListedTask): string | null { return status === "working" ? "Just started." : null; } +/** + * A task's status and line on the Needs you board. One that couldn't finish says so in its card's + * words, Couldn't finish, and its line is why, said once: the board read "Failed" beside a card + * that said "Couldn't finish", and "Couldn't finish: …" beside "Failed". + */ +function boardStatus( + listed: ListedTask, + settled = false, +): { label: string; line: string | null } { + if (listed.status === "failed" && !stopped(listed)) + return { + label: TASK_FAILED_LABEL, + line: listed.task.failure ? failureSentence(listed.task.failure) : null, + }; + return { label: statusLabel(listed, settled), line: nextLine(listed) }; +} + /** * Whether a row offers Mark done: only where it does something. Not while the task is working: * there is nothing finished to mark, and its conversation would carry on behind a row that said it @@ -210,7 +230,7 @@ export function TaskRow({ ) : null} - {status === "failed" ? ( + {canTryAgain({ ...task, status }) ? ( } - detail={nextLine(listed)} + detail={said.line} // What a waiting task waits for is what the person has to answer: read in full, never cut. readDetail={status === "needs_input"} icon={} meta={[ - {statusLabel(listed, settled)}, + {said.label}, {relativeTime(task.updatedAt)}, error ? ( diff --git a/app/src/components/tasks/task-thread.tsx b/app/src/components/tasks/task-thread.tsx index 337b885b4d..646f43556d 100644 --- a/app/src/components/tasks/task-thread.tsx +++ b/app/src/components/tasks/task-thread.tsx @@ -19,11 +19,11 @@ import { elapsed, useNow } from "@/lib/elapsed"; import { relativeTime } from "@/lib/relative-time"; import { type BotTask, - failureSentence, type Reaction, reactionsQueryOptions, stoppedByYou, TASK_DONE_LABEL, + TASK_FAILED_LABEL, TASK_STOPPED, TASK_STOPPED_LABEL, type TaskStatus, @@ -85,7 +85,7 @@ const STATE: Record< text: "text-emerald-700 dark:text-emerald-400", }, failed: { - label: "Couldn't finish", + label: TASK_FAILED_LABEL, icon: IconAlertTriangle, dot: "bg-destructive", text: "text-destructive", @@ -276,18 +276,16 @@ export function TaskCard({ ); /* * What it waits for is said once, on the needs-you line the task posts, not here as well: the - * card says only that it needs the person, and leads into the thread. + * card says only that it needs the person, and leads into the thread. Why it couldn't finish is + * said once too, on the line it reports under the card, which also says what to do about it: the + * card said the same reason a second time just above it. */ const next = - state === "failed" - ? task.data?.failure - ? failureSentence(task.data.failure) - : null - : state === "stopped" - ? TASK_STOPPED - : state === "working" && !taskId - ? "Starting…" - : null; + state === "stopped" + ? TASK_STOPPED + : state === "working" && !taskId + ? "Starting…" + : null; return ( @@ -481,9 +480,7 @@ test("tasks list what to read, answer and retry first, and each acts from its ro }), ); await waitFor(() => - expect( - bots.queryByText("Couldn't finish: Gmail stopped answering."), - ).toBeNull(), + expect(bots.queryByText("Gmail stopped answering.")).toBeNull(), ); const ready = bots @@ -567,21 +564,58 @@ test("a task the person stopped reads Stopped on the board, in its card's words, row("File the expense report").querySelector(".bg-amber-50"), ).not.toBeNull(); - // One that couldn't finish on its own still says so. + // One that couldn't finish on its own still says so, in its card's words, and why. const failed = within( surface .getByText("File the expense report") .closest("[data-slot=item]") as HTMLElement, ); - expect(failed.getByText("Failed")).toBeTruthy(); - expect( - failed.getByText("Couldn't finish: Gmail stopped answering."), - ).toBeTruthy(); + expect(failed.getByText("Couldn't finish")).toBeTruthy(); + expect(failed.getByText("Gmail stopped answering.")).toBeTruthy(); expect(failed.queryByText("Stopped")).toBeNull(); expect(failed.getByRole("button", { name: "Try again" })).toBeTruthy(); } }); +test("a task refused for good reads Couldn't finish, as its card does, and is offered no Try again", async () => { + tasks = [ + task({ + id: "h", + title: "Deals closing this week", + origin: "delegated", + status: "failed", + failure: "Pipeline Bot isn't shared with you", + failedAt: now, + // Asking again gets the same answer, and the server says so. + canTryAgain: false, + }), + ]; + waitingBots = [ + attentionOf("inbox", "Inbox Bot", { + tasks: { needsInput: 0, ready: 0, failed: 1 }, + }), + ]; + serving(); + const { region } = await drawAll(); + for (const name of ["Bots page", "Bot page"]) { + const row = within( + (await region(name).findByText("Deals closing this week")).closest( + "[data-slot=item]", + ) as HTMLElement, + ); + // Its state in the card's words, and why once, as a sentence. + expect(row.getByText("Couldn't finish")).toBeTruthy(); + expect(row.getByText("Pipeline Bot isn't shared with you.")).toBeTruthy(); + expect(row.queryByText("Failed")).toBeNull(); + // What can still be done with it: read it, or put it away. + expect(row.queryByRole("button", { name: "Try again" })).toBeNull(); + expect(row.getByRole("button", { name: "Mark done" })).toBeTruthy(); + expect(row.getByRole("button", { name: "Open" }).getAttribute("href")).toBe( + "/channel/c-h", + ); + } +}); + test("the board says a task's line as plain text, and a working task is not offered Mark done", async () => { tasks = [ task({ diff --git a/app/tests/task-thread.test.tsx b/app/tests/task-thread.test.tsx index 928e842202..a9f7898e0b 100644 --- a/app/tests/task-thread.test.tsx +++ b/app/tests/task-thread.test.tsx @@ -498,7 +498,7 @@ test("a card that had stopped reading its task reads it again when the conversat await view.findByText("Working", {}, { timeout: 2_000 }); expect(stateOf(view)).toBe("working"); - // It runs out of tries: Couldn't finish, with why, and not Stopped. + // It runs out of tries: Couldn't finish, and not Stopped. Why is said on the line it reports. task = { ...task, status: "failed", @@ -509,7 +509,6 @@ test("a card that had stopped reading its task reads it again when the conversat }; await view.findByText("Couldn't finish", {}, { timeout: 6_000 }); expect(stateOf(view)).toBe("failed"); - expect(view.getByText("A service didn't answer.")).toBeTruthy(); }, 20_000); test("last activity moves when the task does something, and keeps ageing when it does not", async () => { @@ -716,16 +715,18 @@ test("a stopped task's line in the conversation reads Stopped, and its link row ).toBe("stopped"); }); -test("a task that couldn't finish says why on its card as a sentence of its own", async () => { - // The server words the reason to follow "Couldn't finish:", so it starts in lower case. - for (const [failure, said] of [ +test("a task that couldn't finish says why once, on the line it reports, not on its card as well", async () => { + // What the server says on each, and the line it reports under the card with the next step. + for (const [failure, reported, reason] of [ [ "this Bot isn't shared with you any more", - "This Bot isn't shared with you any more.", + "This Bot isn't shared with you any more, so it stopped this task. Its owner or an admin can share it again.", + /isn't shared with you any more/, ], [ "Pipeline Bot isn't shared with you", - "Pipeline Bot isn't shared with you.", + "I couldn't ask Pipeline Bot because it isn't shared with you. Its owner or an admin can share it with you.", + /isn't shared with you/, ], ] as const) { task = { @@ -737,12 +738,28 @@ test("a task that couldn't finish says why on its card as a sentence of its own" stoppedAt: null, workingSince: null, }; + // As the conversation that asked draws them: the card, and the line under it. const view = draw( - , + <> + + +

{reported}

+
+ , ); - await view.findByText("Couldn't finish"); - expect(view.getByText(said)).toBeTruthy(); - expect(view.queryByText(failure)).toBeNull(); + const card = await view.findByRole("region", { name: /^Task: / }); + await waitFor(() => expect(card.textContent).toContain("Couldn't finish")); + // The card says that it couldn't finish; why, and what to do, is said once, on the line. + expect(card.textContent).not.toMatch(reason); + const line = view.getByRole("region", { name: "A task couldn't finish" }); + expect(line.textContent).toContain(reported); + expect( + view.getAllByText(reason, { exact: false, selector: "p" }), + ).toHaveLength(1); cleanup(); } }); diff --git a/mobile/src/api/generated/model/task.ts b/mobile/src/api/generated/model/task.ts index 265dcc15af..a4e8d92663 100644 --- a/mobile/src/api/generated/model/task.ts +++ b/mobile/src/api/generated/model/task.ts @@ -65,6 +65,8 @@ export interface Task { * @nullable */ stoppedAt?: string | null; + /** Whether trying a failed task again could change how it ends. False when it couldn't finish for a reason asking again gets the same answer to, such as a Bot it asked that isn't shared with the person, or this Bot no longer being shared with them. Absent from a server that does not say, which reads as true. */ + canTryAgain?: boolean; /** * When the work it is doing now began. Null or absent unless it is working. * @nullable From 6cbceacb0a15c72589fe646c709c3416dd249bbb Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:21:56 -0800 Subject: [PATCH 5/8] Say why a task couldn't finish once its Request access was dismissed With the reason said once, on the line a failed task reports, the card says only Couldn't finish. A task whose admin dismissed the Request access it waited on has no such line: its result was already said, with the app's card under it, and the result's link still read as done. The result now says why under its link ("Couldn't finish An admin didn't give this Bot Slack."), and the link reads as failed. Test: task-thread.test.tsx, a result whose task then couldn't finish says why once and doesn't read as done (link read done, reason nowhere, before). --- app/src/components/tasks/task-thread.tsx | 31 +++++++++++++++++++-- app/tests/task-thread.test.tsx | 35 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/app/src/components/tasks/task-thread.tsx b/app/src/components/tasks/task-thread.tsx index 646f43556d..87a9af8b01 100644 --- a/app/src/components/tasks/task-thread.tsx +++ b/app/src/components/tasks/task-thread.tsx @@ -19,6 +19,7 @@ import { elapsed, useNow } from "@/lib/elapsed"; import { relativeTime } from "@/lib/relative-time"; import { type BotTask, + failureSentence, type Reaction, reactionsQueryOptions, stoppedByYou, @@ -406,7 +407,21 @@ export function TaskReport({ * it) is not finished: its link reads as needing them, as the task's card does, not as done. */ const waiting = live === "needs"; - const ResultIcon = waiting ? IconHandStop : IconCircleCheck; + /* + * A result whose task then couldn't finish (an admin dismissed the Request access it waited on) + * has no failed line under it, and the card says only that it couldn't finish: why is said here, + * once, and the link doesn't read as done. + */ + const failedSince = live === "failed"; + const reason = + failedSince && task.data?.failure + ? failureSentence(task.data.failure) + : null; + const ResultIcon = waiting + ? IconHandStop + : failedSince + ? IconAlertTriangle + : IconCircleCheck; return (
@@ -429,13 +444,23 @@ export function TaskReport({ "size-3.5 shrink-0", waiting ? STATE.needs.text - : "text-emerald-600 dark:text-emerald-400", + : failedSince + ? STATE.failed.text + : "text-emerald-600 dark:text-emerald-400", )} /> {title ?? "Task"} ) : null} + {reason ? ( +

+ + {TASK_FAILED_LABEL} + {" "} + {reason} +

+ ) : null} {children}
); diff --git a/app/tests/task-thread.test.tsx b/app/tests/task-thread.test.tsx index a9f7898e0b..619baeadf0 100644 --- a/app/tests/task-thread.test.tsx +++ b/app/tests/task-thread.test.tsx @@ -764,6 +764,41 @@ test("a task that couldn't finish says why once, on the line it reports, not on } }); +/* + * An admin dismissing the Request access a task waited on ends it as couldn't finish, after its + * result was already said: no failed line is reported under it. The card says only that it couldn't + * finish, so the result above the app's card says why, once, and does not read as done. + */ +test("a result whose task then couldn't finish says why, once, and doesn't read as done", async () => { + task = { + ...task, + status: "failed", + next: null, + failure: "an admin didn't give this Bot Slack", + failedAt: ago(1), + stoppedAt: null, + workingSince: null, + }; + const view = draw( + <> + + +

+ “refunds batch done” was not posted because I haven't been granted + Slack access. +

+
+ , + ); + const link = await view.findByRole("link", { + name: /Order heirloom tomato seeds/, + }); + await waitFor(() => expect(link.getAttribute("data-state")).toBe("failed")); + expect( + view.container.textContent?.match(/an admin didn't give this Bot Slack/gi), + ).toHaveLength(1); +}); + test("a result whose task now needs the person doesn't read as done above its card", async () => { task = { ...task, From f4d81b6b0928e8049e68346370f23f2904646037 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:28:40 -0800 Subject: [PATCH 6/8] Separate the dismissed request's status from its reason --- app/src/components/tasks/task-thread.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/components/tasks/task-thread.tsx b/app/src/components/tasks/task-thread.tsx index 87a9af8b01..9c6e0e762c 100644 --- a/app/src/components/tasks/task-thread.tsx +++ b/app/src/components/tasks/task-thread.tsx @@ -457,8 +457,8 @@ export function TaskReport({

{TASK_FAILED_LABEL} - {" "} - {reason} + + · {reason}

) : null} {children} From 753f64fd5f0b2cfc4f850d1406393213b412340c Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:58:37 -0800 Subject: [PATCH 7/8] Say an owner gives their Bot an app, not that they share it Activity named a Bot's owner switching an app on for their own Bot "Share an app", and off "Stop sharing an app". Nothing was shared with anybody. The rows now read "Give a Bot an app" and "Take an app from a Bot". Test: audit-event-words.test.tsx, the owner's on and off rows read as giving and taking (Share an app before). --- app/tests/audit-event-words.test.tsx | 31 ++++++++++++++++++++++++++++ shared/audit-words.ts | 5 +++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/tests/audit-event-words.test.tsx b/app/tests/audit-event-words.test.tsx index 98afc4781e..6546007ffa 100644 --- a/app/tests/audit-event-words.test.tsx +++ b/app/tests/audit-event-words.test.tsx @@ -256,6 +256,37 @@ test("what happened to an organization reads in words, and none of it as blocked } }); +/* + * Found in testing: a Bot's owner switching an app on for their own Bot read "Share an app", and + * off "Stop sharing an app". Nothing was shared with anybody: they gave their Bot the app. + */ +test("an owner giving their Bot an app, and taking it back, reads as that", async () => { + const view = await renderAs("team", [ + row( + "a1", + 41, + "app_access.owner_granted", + "mcp_server", + {}, + "composio-gmail", + ), + row( + "a2", + 40, + "app_access.owner_revoked", + "mcp_server", + {}, + "composio-gmail", + ), + ]); + const lines = whats(view.container); + expect(lines.map((line) => line.textContent)).toEqual([ + "Give a Bot an app", + "Take an app from a Bot", + ]); + expect(view.container.textContent).not.toContain("Share"); +}); + /** * A real-product pass read "Started by a person" on every row a person started, with nobody named, * and searching the person's email found nothing. The server sends who in `payload.by`. diff --git a/shared/audit-words.ts b/shared/audit-words.ts index 9b8e1f0e0f..e409b5a62b 100644 --- a/shared/audit-words.ts +++ b/shared/audit-words.ts @@ -97,8 +97,9 @@ export const AUDIT_EVENT_WORDS: Readonly> = { "app_access.approved": "Approve a request for an app", "app_access.dismissed": "Dismiss a request for an app", "app_access.refused": "Ask for an app", - "app_access.owner_granted": "Share an app", - "app_access.owner_revoked": "Stop sharing an app", + // A Bot's owner switching an app on or off for their own Bot: nothing is shared with anybody. + "app_access.owner_granted": "Give a Bot an app", + "app_access.owner_revoked": "Take an app from a Bot", "plugin.grants_translated": "Choose a Bot's actions from a description", "plugin.grants_changed": "Change a Bot's actions in an app", "computer.action_allowed": "Use the computer", From e73cf69348271ee16e35acd7abf04f5851f85111 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 15 Nov 2026 22:59:43 -0800 Subject: [PATCH 8/8] Show an organization's owner as an admin on People An owner's Admin switch read off and greyed: the switch read role === "admin", and an owner's role is owner. An owner governs the organization as an admin does, so the switch now reads on, and it can't be changed there, nor is Remove offered: only an owner gives ownership away, in Organization settings, and the server keeps the owner. Test: admin-people-roles.test.tsx, an owner's switch reads on, can't be changed, and sends nothing (off before). --- app/src/routes/_authed/admin/people.tsx | 17 ++++++++++++++--- app/tests/admin-people-roles.test.tsx | 24 +++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/src/routes/_authed/admin/people.tsx b/app/src/routes/_authed/admin/people.tsx index 924d8b24c2..44871387d0 100644 --- a/app/src/routes/_authed/admin/people.tsx +++ b/app/src/routes/_authed/admin/people.tsx @@ -191,6 +191,13 @@ function PeoplePage() { {rows.map((person, index) => { const isSelf = person.id === currentUser.data?.id; const busy = setRole.isPending || setAccess.isPending; + /* + * An owner governs the organization as an admin does, so their Admin switch reads on. + * Their role is not this switch's to change (only an owner gives ownership away, in + * Organization settings), and the server keeps the owner, so neither switch nor + * Remove is offered for them. + */ + const owner = person.role === "owner"; return ( @@ -227,7 +234,9 @@ function PeoplePage() { setRole.mutate({ userId: person.id, diff --git a/app/tests/admin-people-roles.test.tsx b/app/tests/admin-people-roles.test.tsx index 367ba950ef..a2ecfc560f 100644 --- a/app/tests/admin-people-roles.test.tsx +++ b/app/tests/admin-people-roles.test.tsx @@ -51,7 +51,7 @@ const sam = { name: "Sam Ortiz", role: "member" as const, }; -const roles: Record = {}; +const roles: Record = {}; const sent: unknown[] = []; beforeEach(() => { @@ -123,3 +123,25 @@ test("the admin switch gives a member admin and back, by the member role names", expect((await switchFor()).getAttribute("aria-checked")).toBe("false"), ); }); + +/* + * Found in testing: an organization's owner showed with the Admin switch off. An owner governs the + * organization as an admin does, and their role is not one this switch changes (only the owner + * gives ownership away, in Organization settings), so it reads on and can't be changed here. + */ +test("an owner's admin switch reads on and can't be changed, and nothing is sent", async () => { + roles.sam = "owner"; + const view = await draw(); + const owner = await view.findByRole("switch", { + name: "Admin: sam@acme.test", + }); + await waitFor(() => expect(owner.getAttribute("aria-checked")).toBe("true")); + expect( + owner.hasAttribute("disabled") || + owner.getAttribute("aria-disabled") === "true" || + owner.hasAttribute("data-disabled"), + ).toBe(true); + fireEvent.click(owner); + await new Promise((resolve) => setTimeout(resolve, 50)); + expect(sent).toEqual([]); +});