Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Add a mark-all-read control to the inbox
quang.tranminhed5d8be7d8a4
diff --git a/server/host/person-inbox.ts b/server/host/person-inbox.tsindex 9fa48ee3b4..c1adc586ce 100644--- a/server/host/person-inbox.ts+++ b/server/host/person-inbox.ts@@ -502,6 +502,15 @@ export function createPersonInbox(deps: PersonInboxDeps) {if (!item.seen) { item.seen = true; save(); touch(item.threadId); }return true;},+ /** The person read every line of their inbox that still waits on them; an ask stays open, only unmarked as new. */+ markAllRead(person: string): number {+ const unread = items.filter((item) => item.person === person && !item.seen && !settled(item));+ if (!unread.length) return 0;+ for (const item of unread) item.seen = true;+ save();+ for (const inbox of new Set(unread.map((item) => item.threadId))) touch(inbox);+ return unread.length;+ },/** The person wrote in a conversation: their inbox's list changes when a message from there waited on them. */wrote(person: string, threadId: string): void {const inboxes = new Set(items.filter((item) => item.person === person && item.kind === "message" && item.origin?.threadId === threadId && !item.answered && !item.done)diff --git a/server/host/place-inbox.test.ts b/server/host/place-inbox.test.tsindex 9738925672..151b7bf162 100644--- a/server/host/place-inbox.test.ts+++ b/server/host/place-inbox.test.ts@@ -230,6 +230,23 @@ describe("the inbox of a place that is no team's", () => {expect(f.inbox.markDone(OWNER, "not-a-line")).toBe("unknown");});+ it("reads every line and open ask at once for the viewer who has them, answers nothing, and repeats harmlessly", () => {+ const f = setup();+ f.guests.set("guest-chat", "p_guest");+ f.ask("eli-main", "q");+ f.inbox.message("eli", "eli-main", "News");+ f.inbox.message("eli", "guest-chat", "For the guest");+ expect(f.inbox.markAllRead(OWNER)).toBe(2);+ expect(f.inbox.view(OWNER).rows.map((row) => [row.kind, row.tab, row.unread])).toEqual(expect.arrayContaining([["ask", "needs-you", false], ["message", "info", false]]));+ expect(f.inbox.count(OWNER), "the ask still waits on them").toBe(1);+ expect(f.inbox.markDone(OWNER, "card-q")).toBe("an ask");+ expect(f.inbox.view(GUEST).rows.map((row) => row.unread), "the guest's line is not the owner's to read").toEqual([true]);+ expect(f.inbox.markAllRead(OWNER)).toBe(0);+ expect(f.inbox.markAllRead(SHELL)).toBe(0);+ const again = setup({ openCards: () => f.cards, store: f.store as unknown as PlaceInboxDeps["store"] }, f.dataDir);+ expect(again.inbox.view(OWNER).rows.every((row) => !row.unread)).toBe(true);+ });+it("opening a conversation reads what waited there", () => {const f = setup();f.inbox.message("eli", "eli-main", "News");diff --git a/server/host/place-inbox.ts b/server/host/place-inbox.tsindex 23dea3fed3..89f1d8297a 100644--- a/server/host/place-inbox.ts+++ b/server/host/place-inbox.ts@@ -251,6 +251,14 @@ export function createPlaceInbox(deps: PlaceInboxDeps) {if (!seenAsks.has(lineId)) { seenAsks.add(lineId); save(); }return true;},+ /** Every line and open ask this viewer lists is read; an ask is only marked read, never answered. */+ markAllRead(auth: RequestAuth): number {+ let changed = 0;+ for (const line of lines) if (!line.seen && lineFor(auth, line)) { line.seen = true; changed++; }+ for (const row of askRows(auth)) if (!seenAsks.has(row.id)) { seenAsks.add(row.id); changed++; }+ if (changed) save();+ return changed;+ },markDone(auth: RequestAuth, lineId: string): "done" | "unknown" | "an ask" {const line = lines.find((one) => one.id === lineId && lineFor(auth, one));if (line) {diff --git a/server/host/team-messages.ts b/server/host/team-messages.tsindex 0e0667307b..ea244b8722 100644--- a/server/host/team-messages.ts+++ b/server/host/team-messages.ts@@ -393,6 +393,12 @@ export function createTeamMessages(deps: TeamMessagesDeps) {const me = sessionPerson(auth);return Boolean(team && me && inbox.markRead(me.key, id));},+ /** The viewer read every line of their inbox; null for someone on a team without one. */+ markAllRead(auth: RequestAuth): number | null {+ if (!team && deps.place) return deps.place.markAllRead(auth);+ const me = sessionPerson(auth);+ return team && me ? inbox.markAllRead(me.key) : null;+ },/** This person's Needs you lines: the messages in their inbox they have not opened, newest first. */needsYou(auth: RequestAuth): NeedsYouItem[] {const me = sessionPerson(auth);diff --git a/server/request-auth.test.ts b/server/request-auth.test.tsindex 87b1b68e67..ec27b017b0 100644--- a/server/request-auth.test.ts+++ b/server/request-auth.test.ts@@ -137,7 +137,7 @@ describe("scopes", () => {["PATCH", "/api/bots/x/cards/m"], ["POST", "/api/groups/g/messages"], ["PATCH", "/api/groups/g"],["PATCH", "/api/bots/x"], ["PATCH", "/api/bots/x/profile"], ["POST", "/api/attachments"], ["PUT", "/api/bots/order"],["GET", "/api/attachments/a.png"], ["POST", "/api/routines"], ["POST", "/api/routines/r/run"],- ["POST", "/api/routine-runs/seen-all"],+ ["POST", "/api/routine-runs/seen-all"], ["POST", "/api/inbox/read-all"],["GET", "/api/bots"], ["GET", "/api/threads/t/messages"], ["GET", "/api/search"], ["GET", "/api/events"],["GET", "/api/config"], ["GET", "/api/webhooks"], ["POST", "/api/tts/speak"],["GET", "/api/auth/session"], ["POST", "/api/auth/stream-ticket"], ["POST", "/api/auth/logout"],@@ -172,7 +172,7 @@ describe("scopes", () => {["POST", "/api/bots/x/apps/m/rpc/extra"], ["DELETE", "/api/bots/x/apps/m/context"],["PATCH", "/api/logins/1password/vaults/v1"], ["GET", "/api/bots/x/sign-in-cards/m/done"],["GET", "/api/bots/x/queue/q/steer"], ["POST", "/api/bots/x/queue/q/steer/more"], ["POST", "/api/groups/g/queue/q/steer/more"],- ["POST", "/api/tts/voices/add"],+ ["POST", "/api/tts/voices/add"], ["GET", "/api/inbox/read-all"], ["PUT", "/api/inbox/read-all"], ["POST", "/api/inbox/read-all/extra"],] as const) expect(requiredScope(method, path), `${method} ${path}`).toBe("admin");});diff --git a/server/request-auth.ts b/server/request-auth.tsindex b4e677282d..201e10c9a6 100644--- a/server/request-auth.ts+++ b/server/request-auth.ts@@ -434,6 +434,7 @@ export const CLIENT_ALLOW: ReadonlyArray<{ methods: readonly string[]; path: Reg{ methods: ["GET"], path: /^\/api\/needs-you$/ },// a person's own inbox: its lines, how many wait, and one of them read or done; the handler serves the session's own alone{ methods: ["GET"], path: /^\/api\/inbox(?:\/count)?$/ },+ { methods: ["POST"], path: /^\/api\/inbox\/read-all$/ },{ methods: ["POST"], path: /^\/api\/inbox\/[\w-]+\/(?:read|done)$/ },// who a Team Cloud bot can report to, and handing over a bot the member owns: the handler checks who may{ methods: ["GET"], path: /^\/api\/team\/people$/ },diff --git a/server/routes/inbox.test.ts b/server/routes/inbox.test.tsindex 2908285e9d..a33b8c8549 100644--- a/server/routes/inbox.test.ts+++ b/server/routes/inbox.test.ts@@ -58,3 +58,41 @@ it("has no inbox off a team", async () => {const { call } = setup({ team: false });expect(await call("GET", "/api/inbox")).toMatchObject({ status: 404, body: { error: "There is no inbox here.", errorKey: "serverError.inbox.missing" } });});++it("reads every unread line at once for the caller alone, leaves an ask waiting on its card, and repeats harmlessly", async () => {+ const { f, call } = setup();+ f.bots.find((bot) => bot.id === "reporter")!.tasks.push({ threadId: "rep-shared", title: "Weekly numbers" });+ f.team.pass("scout", "cleo-private", "Ben", "The launch moved to Friday.");+ f.team.pass("scout", "ben-private", "Cleo", "Cleo, the draft is ready.");+ f.store.appendMessage("rep-shared", { role: "bot", kind: "options", text: "Run a command?", card: { title: "Run a command?", subtitle: "rm -rf ./build", options: ["Allow", "Deny"], requestId: "req-1", tool: "Bash", requestType: "permission" } });+ f.team.route({ kind: "approval", botId: "reporter", botName: "Reporter", threadId: "rep-shared", title: "Reporter needs approval", body: "Run: rm -rf ./build" });+ const before = (await call("GET", "/api/inbox")).body.rows as Array<{ id: string; tab: string; unread: boolean; card?: unknown }>;+ expect(before.length).toBeGreaterThanOrEqual(2);+ expect(before.every((row) => row.unread)).toBe(true);+ const cleoBefore = (await call("GET", "/api/inbox", session(CLEO.email))).body.rows as Array<{ unread: boolean }>;+ expect(cleoBefore.some((row) => row.unread)).toBe(true);++ const first = await call("POST", "/api/inbox/read-all");+ expect(first.status).toBe(200);+ expect(first.body.rows.map((row: { id: string }) => row.id).sort()).toEqual(before.map((row) => row.id).sort());+ expect(first.body.rows.every((row: { unread: boolean }) => !row.unread)).toBe(true);+ expect(first.body.rows.map((row: { id: string; tab: string }) => [row.id, row.tab]).sort()).toEqual(before.map((row) => [row.id, row.tab]).sort());+ const ask = first.body.rows.find((row: { kind: string }) => row.kind === "ask");+ expect(ask, "the ask is still listed, on the needs-you tab, with its card unanswered").toMatchObject({ tab: "needs-you", unread: false, card: { requestId: "req-1" } });+ expect(ask.card.answered).toBeUndefined();+ expect(f.store.messagesFor("rep-shared").find((message) => message.kind === "options")!.card).not.toHaveProperty("answered");++ expect(await call("POST", "/api/inbox/read-all")).toMatchObject({ status: 200, body: first.body });+ expect((await call("GET", "/api/inbox/count")).body.count, "only the ask still waits on them").toBe(1);+ expect(f.team.markAllRead(session(BEN.email))).toBe(0);++ expect((await call("GET", "/api/inbox", session(CLEO.email))).body.rows, "another person's rows stay unread").toEqual(cleoBefore);+ expect(await call("GET", "/api/inbox/read-all")).toMatchObject({ status: 405 });+ expect(await call("POST", "/api/inbox/read-all", session("[email protected]"))).toMatchObject({ status: 404, body: { errorKey: "serverError.inbox.missing" } });+ expect(requiredScope("POST", "/api/inbox/read-all")).toBe("client");+});++it("has no bulk read off a team", async () => {+ const { call } = setup({ team: false });+ expect(await call("POST", "/api/inbox/read-all")).toMatchObject({ status: 404, body: { errorKey: "serverError.inbox.missing" } });+});diff --git a/server/routes/inbox.ts b/server/routes/inbox.tsindex fa1a240b88..ccb65ff371 100644--- a/server/routes/inbox.ts+++ b/server/routes/inbox.ts@@ -10,9 +10,11 @@ export interface InboxRouteDeps {count(auth: RequestAuth): number | null;markDone(auth: RequestAuth, id: string): "done" | "unknown" | "an ask";markRead(auth: RequestAuth, id: string): boolean;+ /** Every line of this viewer's inbox read, asks included but none answered; null for someone on a team without one. */+ markAllRead(auth: RequestAuth): number | null;}-/** GET /api/inbox: this viewer's inbox as its panel lists it. GET /api/inbox/count: how many of its lines wait on them. POST /api/inbox/<line>/read and /done: one of its+/** GET /api/inbox: this viewer's inbox as its panel lists it. GET /api/inbox/count: how many of its lines wait on them. POST /api/inbox/read-all: all of its lines read, and POST /api/inbox/<line>/read and /done: one of its* lines read, or news they need nothing more from; each answers with the inbox as it lists them now. */export function createInboxRoutes(deps: InboxRouteDeps): RouteHandler {return async ({ res, path, method, auth, json }) => {@@ -26,6 +28,12 @@ export function createInboxRoutes(deps: InboxRouteDeps): RouteHandler {const count = deps.count(auth);return count === null ? json(res, 404, { error: "There is no inbox here." }) : json(res, 200, { count });}+ if (path === "/api/inbox/read-all") {+ if (method !== "POST") return json(res, 405, { error: "method not allowed" });+ if (deps.markAllRead(auth) === null) return json(res, 404, { ...userError("serverError.inbox.missing") });+ const view = deps.view(auth);+ return view ? json(res, 200, view) : json(res, 404, { ...userError("serverError.inbox.missing") });+ }const m = /^\/api\/inbox\/([\w-]+)\/(read|done)$/.exec(path);if (!m) return PASS;if (method !== "POST") return json(res, 405, { error: "method not allowed" });diff --git a/src/components/inbox/InboxPanel.dom.test.ts b/src/components/inbox/InboxPanel.dom.test.tsindex 12cc35c94d..88a2d4eb87 100644--- a/src/components/inbox/InboxPanel.dom.test.ts+++ b/src/components/inbox/InboxPanel.dom.test.ts@@ -10,13 +10,14 @@ vi.mock("../../state/api", () => ({server.calls.push({ path, method: init?.method ?? "GET", ...(init?.body ? { body: JSON.parse(String(init.body)) } : {}) });const done = /^\/api\/inbox\/([\w-]+)\/done$/.exec(path);if (done && server.view) server.view = { ...server.view, rows: server.view.rows.map((row) => (row.id === done[1] ? { ...row, tab: "done", unread: false } : row)) };+ if (path === "/api/inbox/read-all" && server.view) server.view = { ...server.view, rows: server.view.rows.map((row) => ({ ...row, unread: false })) };return server.view;}),}));import { initialState, StoreContext, type AppState, type Bot } from "@/state/store";import { BOT_BUTTON, botButtonTone } from "@/lib/bot-button";-import { closeInbox, currentInboxPanel, inboxVersion, openInbox, setInboxView, useInboxLoader } from "@/state/inbox";+import { closeInbox, currentInbox, currentInboxPanel, inboxVersion, openInbox, setInboxView, useInboxLoader } from "@/state/inbox";import { approvalRow, inboxView, messageRow, questionRow, reportRow, settledRow } from "@/testing/inbox-fixture";import type { InboxView } from "../../../shared/inbox";import { InboxCardSlot } from "./InboxCard";@@ -78,6 +79,32 @@ describe("the inbox panel", () => {expect(document.querySelector(`[data-inbox-row="${reportRow.id}"]`), "it leaves the list at once").toBeNull();});+ it("marks every unread line read from one control that only shows while something is unread, and answers no ask", async () => {+ openInbox();+ await mount(createElement(InboxPanel));+ const rowIds = () => [...document.querySelectorAll<HTMLElement>("[data-inbox-row]")].map((row) => row.dataset.inboxRow);+ const unreadIds = () => [...document.querySelectorAll<HTMLElement>("[data-inbox-row][data-unread]")].map((row) => row.dataset.inboxRow);+ expect(unreadIds()).toEqual([approvalRow.id, messageRow.id]);+ expect(document.querySelector("[data-inbox-mark-all]")!.textContent).toBe("Mark all as read");+ await click("[data-inbox-mark-all]");+ expect(server.calls).toContainEqual({ path: "/api/inbox/read-all", method: "POST" });+ expect(unreadIds()).toEqual([]);+ expect(rowIds(), "every row is still listed").toEqual([approvalRow.id, questionRow.id, messageRow.id, reportRow.id]);+ expect(document.querySelector(`[data-inbox-row="${approvalRow.id}"] [data-inbox-action="allow"]`), "the ask still waits on its answer").not.toBeNull();+ expect(dispatch).not.toHaveBeenCalledWith(expect.objectContaining({ type: "decideRequest" }));+ expect(server.calls.filter((call) => /\/(done)$/.test(call.path))).toEqual([]);+ expect(currentInbox()!.rows.map((row) => [row.id, row.tab])).toEqual(inboxView().rows.map((row) => [row.id, row.tab]));+ expect(document.querySelector("[data-inbox-mark-all]"), "nothing is unread").toBeNull();+ });++ it("keeps the control out of an inbox with nothing unread", async () => {+ shown(inboxView([{ ...approvalRow, unread: false }, { ...messageRow, unread: false }]));+ openInbox();+ await mount(createElement(InboxPanel));+ expect(document.querySelector("[data-inbox-row]")).not.toBeNull();+ expect(document.querySelector("[data-inbox-mark-all]")).toBeNull();+ });+it("is a sheet at phone width", async () => {vi.stubGlobal("matchMedia", (query: string) => ({ matches: query.includes("max-width"), addEventListener() {}, removeEventListener() {} }));openInbox();diff --git a/src/components/inbox/InboxPanel.tsx b/src/components/inbox/InboxPanel.tsxindex 1bad6cd6dd..0f35f14e89 100644--- a/src/components/inbox/InboxPanel.tsx+++ b/src/components/inbox/InboxPanel.tsx@@ -6,7 +6,7 @@ import { cn } from "@/lib/cn";import { useAdvancedMode } from "@/lib/interface-mode";import { t } from "@/lib/i18n";import { PHONE_LAYOUT, useMediaQuery } from "@/lib/use-media-query";-import { closeInbox, readInboxLine, readInboxRow, useInboxPanel, useInboxView, widenInbox } from "@/state/inbox";+import { closeInbox, markAllInboxRead, readInboxLine, readInboxRow, useInboxMarkingAll, useInboxPanel, useInboxView, widenInbox } from "@/state/inbox";import { InboxActive } from "./InboxActive";import { InboxReading } from "./InboxReading";import { InboxRowItem } from "./InboxRow";@@ -19,6 +19,7 @@ import { roundButtonCls } from "../bot-panel/rows";export function InboxPanel() {const view = useInboxView();const panel = useInboxPanel();+ const markingAll = useInboxMarkingAll();const phone = useMediaQuery(PHONE_LAYOUT);const simple = !useAdvancedMode();const { run } = useInboxActions(view);@@ -67,6 +68,12 @@ export function InboxPanel() {<span className="min-w-0 truncate font-medium text-ink">{t("inbox.panel.title")}</span>{count > 0 && <span data-inbox-tab-count className="shrink-0 tabular-nums text-ink-tertiary">{count}</span>}</div>+ {view?.rows.some((row) => row.unread) && (+ <button type="button" data-inbox-mark-all onClick={markAllInboxRead} disabled={markingAll}+ className="mt-[9px] shrink-0 whitespace-nowrap text-[12px] text-accent hover:underline disabled:opacity-50 disabled:hover:no-underline">+ {t("inbox.markAllRead")}+ </button>+ )}{!phone && (<button type="button" onClick={() => widenInbox(!panel.wide)} aria-pressed={Boolean(panel.wide)} aria-label={t(panel.wide ? "inbox.action.narrow" : "inbox.action.widen")}title={t(panel.wide ? "inbox.action.narrow" : "inbox.action.widen")} className={roundButtonCls}>diff --git a/src/locales/de.json b/src/locales/de.jsonindex e067bd6265..04d06e9ee1 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -2852,6 +2852,7 @@"ask.error": "Deine Antwort konnte nicht gesendet werden. Versuch es noch einmal.","ask.detail.more": "Alles anzeigen","inbox.action.closeQuestion": "Ohne Antwort schließen",+ "inbox.markAllRead": "Alle als gelesen markieren","question.somethingElse": "Etwas anderes…","question.answerPlaceholder": "Deine Antwort","question.status.closed": "Ohne Antwort geschlossen",diff --git a/src/locales/en.json b/src/locales/en.jsonindex 1354da1a07..c9d53a2ab4 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -2268,6 +2268,7 @@"inbox.headline.signIn": "Sign in to {site}","inbox.headline.connect": "Connect {app}","inbox.youReplied": "You replied",+ "inbox.markAllRead": "Mark all as read","sidebar.people.mention": "Write to {name}","orgChart.mode.departments": "Departments","orgChart.chief": "Chief of Staff",diff --git a/src/locales/es.json b/src/locales/es.jsonindex 4eb21c3ce6..3cabab5fb2 100644--- a/src/locales/es.json+++ b/src/locales/es.json@@ -5726,6 +5726,7 @@"ask.error": "No se pudo enviar tu respuesta. Inténtalo de nuevo.","ask.detail.more": "Mostrar todo","inbox.action.closeQuestion": "Cerrar sin responder",+ "inbox.markAllRead": "Marcar todo como leído","question.somethingElse": "Otra cosa…","question.done": "Listo","common.done": "Listo",diff --git a/src/locales/fr.json b/src/locales/fr.jsonindex 8ed61b7576..62426d8460 100644--- a/src/locales/fr.json+++ b/src/locales/fr.json@@ -2784,6 +2784,7 @@"ask.error": "Impossible d’envoyer votre réponse. Réessayez.","ask.detail.more": "Tout afficher","inbox.action.closeQuestion": "Fermer sans répondre",+ "inbox.markAllRead": "Tout marquer comme lu","question.somethingElse": "Autre chose…","question.done": "Terminé","common.done": "Terminé",diff --git a/src/locales/hi.json b/src/locales/hi.jsonindex 551428823d..c6609e9e39 100644--- a/src/locales/hi.json+++ b/src/locales/hi.json@@ -2784,6 +2784,7 @@"ask.error": "आपका जवाब नहीं भेजा जा सका। फिर से कोशिश करें।","ask.detail.more": "सब दिखाएँ","inbox.action.closeQuestion": "बिना जवाब दिए बंद करें",+ "inbox.markAllRead": "सभी को पढ़ा हुआ चिह्नित करें","question.somethingElse": "कुछ और…","question.done": "हो गया","common.done": "हो गया",diff --git a/src/locales/it.json b/src/locales/it.jsonindex a392be238a..24b7e4c76a 100644--- a/src/locales/it.json+++ b/src/locales/it.json@@ -6383,6 +6383,7 @@"ask.error": "Impossibile inviare la risposta. Riprova.","ask.detail.more": "Mostra tutto","inbox.action.closeQuestion": "Chiudi senza rispondere",+ "inbox.markAllRead": "Segna tutto come letto","question.somethingElse": "Altro…","question.done": "Fatto","approval.status.timedOut": "Nessuna risposta in tempo: non eseguito",diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex 53a386f3f2..87537a1c0f 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -7417,6 +7417,7 @@"ask.error": "回答を送信できませんでした。もう一度お試しください。","ask.detail.more": "すべて表示","inbox.action.closeQuestion": "回答せずに閉じる",+ "inbox.markAllRead": "すべて既読にする","question.somethingElse": "その他…","question.done": "完了","question.yourAnswer": "自分の回答",diff --git a/src/locales/ko.json b/src/locales/ko.jsonindex 0ce06a1c98..1fab32a094 100644--- a/src/locales/ko.json+++ b/src/locales/ko.json@@ -1995,6 +1995,7 @@"inbox.subject.notice": "확인 필요","inbox.reviewInChat": "답하려면 이 내용이 온 채팅에서 확인하세요.","inbox.youReplied": "답장함",+ "inbox.markAllRead": "모두 읽음으로 표시","sidebar.people.mention": "{name}에게 쓰기","orgChart.mode.departments": "부서","orgChart.chief": "비서실장",diff --git a/src/locales/pl.json b/src/locales/pl.jsonindex 692be53fa3..2aa9e53b98 100644--- a/src/locales/pl.json+++ b/src/locales/pl.json@@ -6522,6 +6522,7 @@"ask.error": "Nie udało się wysłać odpowiedzi. Spróbuj ponownie.","ask.detail.more": "Pokaż wszystko","inbox.action.closeQuestion": "Zamknij bez odpowiedzi",+ "inbox.markAllRead": "Oznacz wszystko jako przeczytane","question.somethingElse": "Coś innego…","question.done": "Gotowe","approval.status.timedOut": "Brak odpowiedzi na czas — nie uruchomiono",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 3cc07ce43b..2ff9404715 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -7602,6 +7602,7 @@"ask.error": "Não foi possível enviar a resposta. Tente novamente.","ask.detail.more": "Mostrar tudo","inbox.action.closeQuestion": "Fechar sem responder",+ "inbox.markAllRead": "Marcar tudo como lido","question.somethingElse": "Outra coisa…","question.done": "Concluir","question.yourAnswer": "Sua resposta",diff --git a/src/locales/ru.json b/src/locales/ru.jsonindex bedfb3dcce..314e1350e5 100644--- a/src/locales/ru.json+++ b/src/locales/ru.json@@ -6584,6 +6584,7 @@"ask.error": "Не удалось отправить ответ. Попробуйте ещё раз.","ask.detail.more": "Показать всё","inbox.action.closeQuestion": "Закрыть без ответа",+ "inbox.markAllRead": "Отметить всё как прочитанное","question.somethingElse": "Что-то другое…","question.done": "Готово","approval.status.timedOut": "Нет ответа вовремя — не выполнено",diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex 18c83b2031..b6aa3badfe 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -3442,7 +3442,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"es": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -9533,7 +9536,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"fr": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -12841,7 +12847,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"hi": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -16001,7 +16010,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"ja": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -23769,7 +23781,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"pt-br": {"voice.gemini.keyPlaceholder": "8c87ba2043a4a89d63c90cae8a6dafd5cbd193652e923b97988e381a74773e10",@@ -33678,7 +33693,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"zh": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -41333,7 +41351,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"zh-tw": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -51161,7 +51182,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"uk": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -54762,7 +54786,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"vi": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -60353,7 +60380,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"tr": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -65944,7 +65974,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"pl": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -72797,7 +72830,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"ru": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -79712,7 +79748,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"it": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -86427,7 +86466,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"},"ko": {"connectedWorkspaces.localTitle": "7d6deafeab011d734c3fdd1bfd6f69544fbb746a004019269bdb48544b01164b",@@ -93864,7 +93906,10 @@"settings.simple.more.limits": "dffb64dc70011ecf3ef3ad62cdd271f08f1b86601d7c2bc54f91978a32ca8cf4","settings.simple.more.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942","memory.journal.actor.teamSetup": "f36c1b27c9eb8da8e6f4df8b6b437eb805508fdb04b145ec229102dff39c96e9",- "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3"+ "memory.journal.instructions": "57dca9eafc1de092ccb80dfa72f853edcdb3b3e00f9b103f65e83e12aa7cbbc3",+ "newLook.title": "3c4ded0b090c0a2b897e799d4be4cd0eeec602209ad0851c1ab630dfa6762c09",+ "newLook.body": "c579dd8801158623c79d316c57b335e106281b19e30d3459892441b7bcd54b2e",+ "inbox.markAllRead": "d7592650e1c90a85fc6151e5454c57227d9474f1ce9fdbf184178bea34974c44"}}}diff --git a/src/locales/tr.json b/src/locales/tr.jsonindex 606d69718d..6ae6a5dbb8 100644--- a/src/locales/tr.json+++ b/src/locales/tr.json@@ -5221,6 +5221,7 @@"ask.error": "Yanıtınız gönderilemedi. Tekrar deneyin.","ask.detail.more": "Tümünü göster","inbox.action.closeQuestion": "Yanıtlamadan kapat",+ "inbox.markAllRead": "Tümünü okundu olarak işaretle","question.somethingElse": "Başka bir şey…","question.done": "Tamam","common.done": "Tamam",diff --git a/src/locales/uk.json b/src/locales/uk.jsonindex 07c8598c42..f3159803d1 100644--- a/src/locales/uk.json+++ b/src/locales/uk.json@@ -3225,6 +3225,7 @@"ask.error": "Не вдалося надіслати відповідь. Спробуйте ще раз.","ask.detail.more": "Показати все","inbox.action.closeQuestion": "Закрити без відповіді",+ "inbox.markAllRead": "Позначити все як прочитане","question.somethingElse": "Щось інше…","question.done": "Готово","common.done": "Готово",diff --git a/src/locales/vi.json b/src/locales/vi.jsonindex 30191c506c..cc82d54dfd 100644--- a/src/locales/vi.json+++ b/src/locales/vi.json@@ -5221,6 +5221,7 @@"ask.error": "Không gửi được câu trả lời. Hãy thử lại.","ask.detail.more": "Hiện tất cả","inbox.action.closeQuestion": "Đóng mà không trả lời",+ "inbox.markAllRead": "Đánh dấu tất cả là đã đọc","question.somethingElse": "Điều khác…","question.done": "Xong","common.done": "Xong",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 5fc3eec69f..04df7959a4 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -2248,6 +2248,7 @@"inbox.headline.signIn": "登入 {site}","inbox.headline.connect": "連線 {app}","inbox.youReplied": "你的回覆",+ "inbox.markAllRead": "全部標示為已讀","sidebar.people.mention": "寫給 {name}","orgChart.mode.departments": "部門","orgChart.chief": "幕僚長",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex 425207c199..5f18660127 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -2120,6 +2120,7 @@"inbox.subject.notice": "需要查看","inbox.reviewInChat": "请到它来自的聊天中查看并回复。","inbox.youReplied": "你的回复",+ "inbox.markAllRead": "全部标为已读","sidebar.people.mention": "写给 {name}","orgChart.mode.departments": "部门","orgChart.chief": "总协调机器人",diff --git a/src/state/inbox.ts b/src/state/inbox.tsindex 866808666c..12a4fbd5d5 100644--- a/src/state/inbox.ts+++ b/src/state/inbox.ts@@ -109,6 +109,23 @@ export function readInboxRow(row: Pick<InboxRow, "id" | "unread">): void {void mark(row.id, "read", { unread: true });}+const marking = store(false);+export const useInboxMarkingAll = (): boolean => useSyncExternalStore(marking.subscribe, marking.get, marking.get);++/** The person read every line: none is bold, and no ask is answered or moves tab. */+export function markAllInboxRead(): void {+ if (marking.get()) return;+ const view = list.get();+ if (view) { shown = ++sent; list.set({ ...view, rows: view.rows.map((row) => (row.unread ? { ...row, unread: false } : row)) }); }+ const seq = ++sent;+ marking.set(true);+ void api<InboxView>("/api/inbox/read-all", { method: "POST", background: true }).catch(() => null).then((next) => {+ marking.set(false);+ if (next && Array.isArray(next.rows)) return show(seq, next);+ void refreshInbox();+ });+}+/** An ask the person just answered here: it leaves the list at once, before the server's next read says so. */export const settleInboxRow = (row: Pick<InboxRow, "id">): void => patchRow(row.id, { tab: "done", unread: false });