Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Library tab: everything the bot made, across all its threads (#7054)
Milind Soni6ef53dd808ee
diff --git a/server/bot-library.test.ts b/server/bot-library.test.tsnew file mode 100644index 0000000000..16da7d139a--- /dev/null+++ b/server/bot-library.test.ts@@ -0,0 +1,67 @@+import { describe, expect, it } from "vitest";+import { collectBotLibrary, replyFileLinks } from "./bot-library.ts";+import { deleteThread, importThread } from "./message-db.ts";+import type { PublishedPageRecord } from "./pages/store.ts";+import type { Message } from "./store.ts";++const reply = (id: string, at: number, text: string, extra: Partial<Message> = {}): Message =>+ ({ id, parentId: null, at, role: "bot", kind: "text", text, ...extra }) as Message;+const app = (id: string, at: number, title: string, doc = `doc-${id}`): Message =>+ ({ id, parentId: null, at, role: "bot", kind: "app", text: title, app: { v: 1, source: { kind: "html" }, title, doc, rev: 0 } }) as unknown as Message;+const record = (pageId: string, updatedAt: number, cards: Array<[string, string]>, over: Partial<PublishedPageRecord> = {}): PublishedPageRecord => ({+ pageId, url: `https://${pageId}.mausbot.page/`, title: `Page ${pageId}`, botId: "scout", source: `/work/${pageId}`,+ cards: cards.map(([threadId, messageId]) => ({ threadId, messageId })), createdAt: updatedAt, updatedAt, ...over,+});++describe("collectBotLibrary", () => {+ it("lists pages, apps and shared files from every conversation it is given, newest first", () => {+ importThread("lib-a", [app("a1", 100, "Budget"), reply("r1", 110, "Here: [plan](/work/plan.md) and [site](https://example.com)"), app("a2", 300, "Tracker")], "a2");+ importThread("lib-b", [app("b1", 200, "Quiz"), reply("r2", 210, "Attached.", { attachments: [{ path: "/work/out.csv", kind: "file", name: "out.csv", mime: "text/csv" }, { path: "/work/shot.png", kind: "image", mime: "image/png" }] })], "r2");+ importThread("lib-archived", [app("c1", 50, "Old app"), reply("r3", 55, "See [notes][n]\n\n[n]: ./notes.txt")], "r3");+ const pages = [+ record("aaaaaaaaaaaaaaaaaaaa", 400, [["lib-a", "pa"]]),+ record("bbbbbbbbbbbbbbbbbbbb", 500, [["lib-b", "pb"]]),+ record("cccccccccccccccccccc", 600, [["lib-gone", "pc"]]),+ record("dddddddddddddddddddd", 700, [["lib-a", "pd"]], { botId: "someone-else" }),+ ];+ const library = collectBotLibrary({ botId: "scout", threadIds: ["lib-a", "lib-b", "lib-archived"], pages });+ expect(library.pages.map((page) => [page.title, page.threadId])).toEqual([["Page bbbbbbbbbbbbbbbbbbbb", "lib-b"], ["Page aaaaaaaaaaaaaaaaaaaa", "lib-a"]]);+ expect(library.apps.map((each) => [each.title, each.threadId])).toEqual([["Tracker", "lib-a"], ["Quiz", "lib-b"], ["Budget", "lib-a"], ["Old app", "lib-archived"]]);+ expect(library.files).toEqual([+ { threadId: "lib-b", messageId: "r2", at: 210, attachments: [{ path: "/work/out.csv", kind: "file", name: "out.csv" }, { path: "/work/shot.png", kind: "image" }], links: [] },+ { threadId: "lib-a", messageId: "r1", at: 110, attachments: [], links: ["/work/plan.md"] },+ { threadId: "lib-archived", messageId: "r3", at: 55, attachments: [], links: ["./notes.txt"] },+ ]);+ });++ it("leaves out a deleted conversation's items and pages taken down, and names a page once in its newest conversation", () => {+ importThread("del-a", [app("x1", 10, "Kept")], "x1");+ importThread("del-b", [app("x2", 20, "Deleted with its conversation")], "x2");+ deleteThread("del-b");+ const pages = [record("eeeeeeeeeeeeeeeeeeee", 30, [["del-a", "p1"], ["del-b", "p2"], ["del-c", "p3"]])];+ const library = collectBotLibrary({ botId: "scout", threadIds: ["del-a", "del-c"], pages });+ expect(library.apps.map((each) => each.title)).toEqual(["Kept"]);+ expect(library.pages).toEqual([{ threadId: "del-c", messageId: "p3", at: 30, title: "Page eeeeeeeeeeeeeeeeeeee", url: "https://eeeeeeeeeeeeeeeeeeee.mausbot.page/" }]);+ expect(collectBotLibrary({ botId: "scout", threadIds: ["del-a"], pages: [] }).pages).toEqual([]);+ });++ it("counts a fork's copies once, as the original, and skips an app with nothing stored", () => {+ importThread("fork-src", [app("f1", 10, "Shared app"), reply("fr", 11, "[deck](/work/deck.key)")], "fr");+ importThread("fork-copy", [app("f1", 10, "Shared app"), reply("fr", 11, "[deck](/work/deck.key)"), app("f2", 12, "Blocked", "")], "f2");+ const library = collectBotLibrary({ botId: "scout", threadIds: ["fork-src", "fork-copy"], pages: [] });+ expect(library.apps.map((each) => [each.messageId, each.threadId])).toEqual([["f1", "fork-src"]]);+ expect(library.files.map((each) => [each.messageId, each.threadId])).toEqual([["fr", "fork-src"]]);+ });++ it("answers nothing for no conversations", () => {+ expect(collectBotLibrary({ botId: "scout", threadIds: [], pages: [record("ffffffffffffffffffff", 1, [["x", "y"]])] })).toEqual({ pages: [], apps: [], files: [] });+ });+});++describe("replyFileLinks", () => {+ it("keeps local links and reference links as authored, never web links, anchors or images", () => {+ const text = "[a](/Users/me/a.md) [b](<./b c.txt>) [web](https://x.dev/a.md) [top](#top)  [](/work/b.html)"+ + " [w](C:\\work\\w.docx) [f](file:///tmp/f.txt) [r][ref]\n\n[ref]: ../r.pdf";+ expect(replyFileLinks(text).sort()).toEqual(["../r.pdf", "./b c.txt", "/Users/me/a.md", "C:\\work\\w.docx", "file:///tmp/f.txt"].sort());+ });+});diff --git a/server/bot-library.ts b/server/bot-library.tsnew file mode 100644index 0000000000..b2630f1197--- /dev/null+++ b/server/bot-library.ts@@ -0,0 +1,100 @@+// What a bot's Library tab lists across all of its conversations, read without loading any conversation into memory:+// its live published pages from the pages store, and its apps and file-sharing replies straight from messages.db by the+// conversations' index. The panel adds what the open conversation holds in memory on top.+import { fromMarkdown } from "mdast-util-from-markdown";+import { BOT_LIBRARY_MAX, type BotLibrary, type BotLibraryApp, type BotLibraryFileMessage, type BotLibraryPage } from "../shared/bot-library.ts";+import { windowsPathDestinations } from "../shared/markdown-windows-paths.ts";+import { prepared } from "./message-db.ts";+import type { PublishedPageRecord } from "./pages/store.ts";++/** Replies read for file links, newest first; most replies share nothing, so this reads well past the files shown. */+const FILE_REPLIES_READ = 600;++export interface BotLibraryRows {+ apps(threadIds: readonly string[], limit: number): Array<{ threadId: string; messageId: string; at: number; title: unknown }>;+ fileReplies(threadIds: readonly string[], limit: number): Array<{ threadId: string; messageId: string; at: number; text: unknown; attachments: unknown }>;+}++const IN_THREADS = "thread_id IN (SELECT value FROM json_each(?))";++export const messageRows: BotLibraryRows = {+ apps: (threadIds, limit) => prepared(+ `SELECT thread_id AS threadId, id AS messageId, at, json_extract(json, '$.app.title') AS title FROM messages+ WHERE ${IN_THREADS} AND kind = 'app' AND coalesce(json_extract(json, '$.app.doc'), '') <> '' ORDER BY at DESC, rowid LIMIT ?`,+ ).all(JSON.stringify(threadIds), limit) as ReturnType<BotLibraryRows["apps"]>,+ fileReplies: (threadIds, limit) => prepared(+ `SELECT thread_id AS threadId, id AS messageId, at, text, json_extract(json, '$.attachments') AS attachments FROM messages+ WHERE ${IN_THREADS} AND role = 'bot' AND kind = 'text'+ AND (instr(text, '](') > 0 OR instr(text, ']:') > 0 OR instr(text, '<file:') > 0 OR json_extract(json, '$.attachments') IS NOT NULL)+ ORDER BY at DESC, rowid LIMIT ?`,+ ).all(JSON.stringify(threadIds), limit) as ReturnType<BotLibraryRows["fileReplies"]>,+};++type MarkdownNode = { type: string; url?: string; identifier?: string; children?: MarkdownNode[] };++/** The local file links a reply's text shows as file chips, as authored: links and link references that do not wrap an+ * image, the same nodes as the panel's collectMessageFiles (src/components/AttachmentGallery.tsx), which makes the final+ * call on each one. */+export function replyFileLinks(text: string): string[] {+ const tree: MarkdownNode = fromMarkdown(text, { mdastExtensions: [windowsPathDestinations] });+ const definitions = new Map<string, string>(), links: MarkdownNode[] = [], pending = [tree];+ while (pending.length) {+ const node = pending.pop()!;+ if (node.type === "definition" && node.identifier && node.url && !definitions.has(node.identifier)) definitions.set(node.identifier, node.url);+ else if ((node.type === "link" || node.type === "linkReference") && !node.children?.some((child) => child.type === "image" || child.type === "imageReference")) links.push(node);+ if (node.children) pending.push(...node.children);+ }+ const hrefs = links.flatMap((node) => {+ const href = node.url ?? (node.identifier ? definitions.get(node.identifier) : undefined);+ return href && !href.startsWith("#") && !href.startsWith("//") && (/^[a-z]:[\\/]/i.test(href) || /^file:/i.test(href) || !/^[a-z][a-z\d+.-]*:/i.test(href)) ? [href] : [];+ });+ return [...new Set(hrefs)];+}++function attachmentsOf(raw: unknown): BotLibraryFileMessage["attachments"] {+ let parsed: unknown;+ try { parsed = typeof raw === "string" ? JSON.parse(raw) : null; } catch { return []; }+ if (!Array.isArray(parsed)) return [];+ return parsed.flatMap((entry: { path?: unknown; kind?: unknown; name?: unknown }) => typeof entry?.path === "string" && entry.path+ ? [{ path: entry.path, ...(typeof entry.kind === "string" ? { kind: entry.kind } : {}), ...(typeof entry.name === "string" && entry.name ? { name: entry.name } : {}) }]+ : []);+}++/** The bot's live pages, apps and file-sharing replies in these conversations, newest first. A page counts once, in the+ * newest of these conversations that shows its card; a fork's copy of an app or a reply counts once, as the original.+ * Pages taken down are not in the pages store, and a deleted conversation is not among `threadIds`. */+export function collectBotLibrary(input: { botId: string; threadIds: readonly string[]; pages: readonly PublishedPageRecord[]; rows?: BotLibraryRows }): BotLibrary {+ const rows = input.rows ?? messageRows, threads = new Set(input.threadIds);+ if (!threads.size) return { pages: [], apps: [], files: [] };+ const seenUrls = new Set<string>();+ const pages: BotLibraryPage[] = [...input.pages].filter((page) => page.botId === input.botId)+ .sort((a, b) => b.updatedAt - a.updatedAt)+ .flatMap((page) => {+ const card = page.cards.findLast((each) => threads.has(each.threadId));+ if (!card || !page.url || seenUrls.has(page.url)) return [];+ seenUrls.add(page.url);+ return [{ threadId: card.threadId, messageId: card.messageId, at: page.updatedAt, title: page.title || page.url, url: page.url }];+ })+ .slice(0, BOT_LIBRARY_MAX);+ const ids = [...threads];+ const seenApps = new Set<string>();+ const apps: BotLibraryApp[] = rows.apps(ids, BOT_LIBRARY_MAX * 2).flatMap((row) => {+ if (seenApps.has(row.messageId)) return [];+ seenApps.add(row.messageId);+ return [{ threadId: row.threadId, messageId: row.messageId, at: row.at, title: typeof row.title === "string" ? row.title : "" }];+ }).slice(0, BOT_LIBRARY_MAX);+ const seenReplies = new Set<string>();+ const files: BotLibraryFileMessage[] = [];+ let shared = 0;+ for (const row of rows.fileReplies(ids, FILE_REPLIES_READ)) {+ if (shared >= BOT_LIBRARY_MAX * 2) break;+ if (seenReplies.has(row.messageId)) continue;+ seenReplies.add(row.messageId);+ const attachments = attachmentsOf(row.attachments);+ const links = typeof row.text === "string" ? replyFileLinks(row.text) : [];+ if (!links.length && !attachments.some((attachment) => attachment.kind === "file")) continue;+ shared += links.length + attachments.length;+ files.push({ threadId: row.threadId, messageId: row.messageId, at: row.at, attachments, links });+ }+ return { pages, apps, files };+}diff --git a/server/cloud-team-privacy-holes.e2e.test.ts b/server/cloud-team-privacy-holes.e2e.test.tsindex 299a9e79c5..0ac1b323d5 100644--- a/server/cloud-team-privacy-holes.e2e.test.ts+++ b/server/cloud-team-privacy-holes.e2e.test.ts@@ -157,7 +157,7 @@ const SUFFIXES = ["", "/tasks", "/tasks/t1", "/tasks/t1/title", "/tasks/delete","/computer/exec", "/computer/control", "/computer/viewer-close", "/local-computer", "/local-computer/run", "/local-computer/join", "/local-computer/screenshot","/browser/live", "/browser/action", "/browser/upload", "/browser/download/d1", "/browser/stream", "/browser/desktop", "/cards/c1", "/command-allowlist", "/command-allowlist/x","/connector-cards/c1/status", "/connector-cards/c1/authorize", "/secret-cards/c1/provide", "/secret-cards/c1/save", "/sign-in-cards/c1/done", "/saved-steps/s1",- "/requests/aaaaaaaaaaaaaaaaaaaa", "/requests/aaaaaaaaaaaaaaaaaaaa/interrupt", "/apps/a1/rpc", "/apps/a1/context", "/avatar/generate", "/slack-management", "/webhooks", "/routines", "/files", "/no-such-route"];+ "/requests/aaaaaaaaaaaaaaaaaaaa", "/requests/aaaaaaaaaaaaaaaaaaaa/interrupt", "/apps/a1/rpc", "/apps/a1/context", "/avatar/generate", "/slack-management", "/library", "/webhooks", "/routines", "/files", "/no-such-route"];const METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];/** Every route under a bot's id, asked of two ids at once. */diff --git a/server/index.ts b/server/index.tsindex 9b8819b85f..0bd6c1da6f 100644--- a/server/index.ts+++ b/server/index.ts@@ -575,7 +575,7 @@ import { holdBodyDeadline } from "./body-deadline.ts";import { createNoAiNotice } from "./host/no-ai-notice.ts"; import { PASS, ROUTES, dispatchRoutes } from "./routes/table.ts"; import { createBotLinkHost } from "./host/bot-link-host.ts"; import { followRoomMentions } from "./host/bot-link-rooms.ts"; import { standInAmong, standInWriteRefusal } from "./host/stand-in-guard.ts"; import { isBotLinkHeldPath, linkSessionRefusal } from "./routes/bot-link.ts"; import { createSecretCards } from "./host/secret-cards.ts"; import { createInternalCredentialRequestRoutes, createSecretCardRoutes } from "./routes/secret-cards.ts"; import { applyIncludedPagesMessage, pagesAccess, pagesNotOffered } from "./pages/access.ts"; import { createPublishedPages } from "./pages/service.ts"; import { createInternalToolRoutes } from "./routes/internal-tools.ts"; import { createHelperSuggestionRoutes } from "./routes/helper-suggestion.ts"; import { createXConnectorRoutes } from "./routes/x-connector.ts"; import { createMoveFreeze, switchAutomationsOff } from "./move-freeze.ts"; import { createMoveFreezeRoutes } from "./routes/move-freeze.ts"; import { createMoveWaits } from "./move-waits.ts"; import { assertBotHere, botMoveRefusal, createBotMoves } from "./bot-moves.ts"; import { createBotMoveRoutes } from "./routes/bot-moves.ts"; import { createTeamMoveIn, moveInRefusal } from "./team-move-in.ts";import { createHostedSlackRoutes } from "./routes/hosted-slack.ts";import { createBotPresetRoutes } from "./routes/bot-presets.ts"; import { createWorkspaceBannerRoutes, workspaceBannerStore, workspaceBannerSummary } from "./routes/workspace-banner.ts";-import { createBotMemoryRoutes } from "./routes/bot-memory.ts";+import { createBotMemoryRoutes } from "./routes/bot-memory.ts"; import { createBotLibraryRoutes } from "./routes/bot-library.ts";import { createBotCreateRoutes } from "./routes/bots-create.ts"; import { privateUntilShared } from "./new-bot-sharing.ts"; import { createShareNotice } from "./host/share-notice.ts"; import { memberDeleteRefusal } from "./host/member-bots.ts";import { createTeamOwnerRoutes } from "./routes/team-owners.ts";import { createBotSettingsRoutes } from "./routes/bot-settings.ts";@@ -11971,7 +11971,7 @@ const { react } = createReactions({store, reply: (input) => teamMessages.reactedIn(input.auth, input.threadId, input.target.id, input.answer, { sendId: input.sendId, sender: messageSender(input.auth) }) ?? personReplies.deliver({ ...input, about: "message" }),answerCard: (input) => respondToCard({ ...input, via: "reaction" }), withdraw: personReplies.withdraw,});-const publishedPages = createPublishedPages({ dataDir: DATA_DIR, cloudHome: CLOUD_HOME, selfHosted: !CLOUD_HOME && !HOSTED_WORKSPACE && utilityParentPort === undefined, patch: (threadId, messageId, text, publishedPage) => void store.patchMessage(threadId, messageId, { text, publishedPage }), liveRoots: (botId, threadId) => liveRoots(threadId, botId), paused: () => workspaceMaintenance.active || moveFreeze.frozen(), apps: { chat: chatApps, store } }); ROUTES.push(createReactionRoutes({ react, reactorFor, cloudGuestSendRefusal }), publishedPages.routes, savedSteps.routes, createPlacesElsewhereRoutes({ elsewhere: placesElsewhere, owner: (auth) => !sharedMembership() && !HOSTED_WORKSPACE && (auth.kind === "loopback" || ownHome.owner(auth) || (CLOUD_PERSONAL && cloudOwnerSession(auth))) }));+const publishedPages = createPublishedPages({ dataDir: DATA_DIR, cloudHome: CLOUD_HOME, selfHosted: !CLOUD_HOME && !HOSTED_WORKSPACE && utilityParentPort === undefined, patch: (threadId, messageId, text, publishedPage) => void store.patchMessage(threadId, messageId, { text, publishedPage }), liveRoots: (botId, threadId) => liveRoots(threadId, botId), paused: () => workspaceMaintenance.active || moveFreeze.frozen(), apps: { chat: chatApps, store } }); ROUTES.push(createReactionRoutes({ react, reactorFor, cloudGuestSendRefusal }), publishedPages.routes, createBotLibraryRoutes({ bot: (id) => store.bot(id), visibleFor: (auth) => visibleTo(viewerFor(auth)), pages: () => publishedPages.store.list() }), savedSteps.routes, createPlacesElsewhereRoutes({ elsewhere: placesElsewhere, owner: (auth) => !sharedMembership() && !HOSTED_WORKSPACE && (auth.kind === "loopback" || ownHome.owner(auth) || (CLOUD_PERSONAL && cloudOwnerSession(auth))) }));// `let` slots are read per request.const keptAttachments = () => { const routineFiles = routines?.attachmentPaths(); return routineFiles && calendarCalls ? keptAttachmentNames([...store.bots.map((bot) => bot.avatarUrl), cfg.profile?.avatarUrl], [workspaceBannerStore.current()?.name, ...routineFiles, ...calendarCalls.list().flatMap((call) => call.attachments?.map((file) => file.path) ?? []), ...[...turnAttachmentsByTurn.values()].flat().map((file) => file.path)]) : null; }; createDeleteLeftovers({ dataDir: DATA_DIR, store, checkpointsQuiet: checkpoints.quiet, threadsReferencing, keptAttachments, deleteAttachment: (name) => deleteAttachment(join(ATTACHMENTS_DIR, name)), engineFolders: () => engineSessionFolders(DATA_DIR, [process.env, ...Object.values(providerConfigs()).map((instance) => instanceEnvironment(process.env, instance))].flatMap((env) => engineHomes.everyHome(env))), layers: memoryLayerRecords });ROUTES.push(createThreadRoutes({diff --git a/server/request-auth.test.ts b/server/request-auth.test.tsindex 69d5d45859..d5a7b762a7 100644--- a/server/request-auth.test.ts+++ b/server/request-auth.test.ts@@ -180,7 +180,7 @@ describe("scopes", () => {["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"],- ["GET", "/api/bots/x/slack-management"],+ ["GET", "/api/bots/x/slack-management"], ["GET", "/api/bots/x/library"],["POST", "/api/bots/x/sign-in-cards/m/done"], ["POST", "/api/bots/x/sign-in-cards/m/cancel"], ["POST", "/api/bots/x/sign-in-cards/m/save-login"],["GET", "/api/bots/x/sign-in-cards/m/save-login"],["GET", "/api/bots/x/browser/live"], ["POST", "/api/bots/x/browser/action"],@@ -197,7 +197,7 @@ describe("scopes", () => {["POST", "/api/team-library/github"], ["GET", "/api/setup-import/grok"],["GET", "/api/bots/x/memory"], ["PUT", "/api/bots/x/memory"], ["PUT", "/api/section-context"], ["PUT", "/api/groups/order"], ["GET", "/api/threads/t/events"],["GET", "/api/mcp/servers"], ["POST", "/api/mcp/servers"], ["GET", "/api/bots/x/mcp-servers"], ["POST", "/api/connectors/slack/authorize"],- ["POST", "/api/bots/x/slack-management"], ["GET", "/api/bots/x/slack-management/extra"],+ ["POST", "/api/bots/x/slack-management"], ["GET", "/api/bots/x/slack-management/extra"], ["POST", "/api/bots/x/library"], ["GET", "/api/bots/x/library/extra"],["PUT", "/api/config"], ["POST", "/api/auth/pairing"], ["GET", "/api/auth/sessions"], ["DELETE", "/api/auth/sessions/abc"],["POST", "/api/live/session"], ["POST", "/api/live/call/end"], ["GET", "/api/live/call"], ["PATCH", "/api/live/settings"],["POST", "/api/live/device-revoked"],diff --git a/server/request-auth.ts b/server/request-auth.tsindex 2b67a311f6..f54720fc10 100644--- a/server/request-auth.ts+++ b/server/request-auth.ts@@ -340,6 +340,8 @@ export const CLIENT_ALLOW: ReadonlyArray<{ methods: readonly string[]; path: Reg{ methods: ["GET"], path: /^\/api\/team-map$/ },// a link into the organisation's Admin: identifiers only, and Admin authorizes its own visitor{ methods: ["GET"], path: /^\/api\/bots\/[\w-]+\/slack-management$/ },+ // what a bot made in the conversations this viewer can read, the same rows those conversations' messages show (routes/bot-library.ts)+ { methods: ["GET"], path: /^\/api\/bots\/[\w-]+\/library$/ },{ methods: ["GET"], path: /^\/api\/search$/ },{ methods: ["GET"], path: /^\/api\/threads\/[\w-]+\/messages$/ },{ methods: ["GET"], path: /^\/api\/threads\/[\w-]+\/messages\/[\w-]+\/image$/ },diff --git a/server/routes/bot-library.test.ts b/server/routes/bot-library.test.tsnew file mode 100644index 0000000000..15b06e76fc--- /dev/null+++ b/server/routes/bot-library.test.ts@@ -0,0 +1,88 @@+import { createServer, type Server } from "node:http";+import type { AddressInfo } from "node:net";+import { afterEach, describe, expect, it } from "vitest";++import type { BotLibrary } from "../../shared/bot-library.ts";+import type { BotLibraryRows } from "../bot-library.ts";+import { json, readBody } from "../harness/http.ts";+import type { PublishedPageRecord } from "../pages/store.ts";+import { requiredScope, type RequestAuth } from "../request-auth.ts";+import { createBotLibraryRoutes } from "./bot-library.ts";+import { dispatchRoutes } from "./table.ts";++const servers: Server[] = [];+afterEach(async () => { await Promise.all(servers.splice(0).map((server) => new Promise((done) => server.close(done)))); });++const ADA = { kind: "session", scopes: ["client"], session: { id: "s1", email: "[email protected]" } } as unknown as RequestAuth;+const BOT = { id: "scout", threadId: "open", tasks: [{ threadId: "open" }, { threadId: "archived", archivedAt: 5 }, { threadId: "rui-private" }] };+const PAGE: PublishedPageRecord = { pageId: "aaaaaaaaaaaaaaaaaaaa", url: "https://aaaaaaaaaaaaaaaaaaaa.mausbot.page/", title: "Menu", botId: "scout", source: "/w/menu",+ cards: [{ threadId: "rui-private", messageId: "p1" }], createdAt: 1, updatedAt: 1 };++async function fixture(seen: { bot: boolean; hidden: readonly string[] }) {+ const asked: string[][] = [];+ const rows: BotLibraryRows = {+ apps: (threadIds) => {+ asked.push([...threadIds]);+ return threadIds.map((threadId, index) => ({ threadId, messageId: `app-${threadId}`, at: 10 - index, title: `App in ${threadId}` }));+ },+ fileReplies: () => [],+ };+ const routes = [createBotLibraryRoutes({+ bot: (id) => (id === BOT.id ? BOT : null),+ visibleFor: (auth) => {+ expect(auth).toBe(ADA);+ return { bot: () => seen.bot, thread: (threadId: string) => !seen.hidden.includes(threadId) };+ },+ pages: () => [PAGE],+ rows,+ })];+ const server = createServer((req, res) => {+ const url = new URL(req.url ?? "/", "http://127.0.0.1");+ void dispatchRoutes(routes, { req, res, url, path: url.pathname, method: req.method ?? "GET", auth: ADA, json, readBody })+ .then((answered) => { if (!answered) json(res, 404, { error: "not routed" }); });+ });+ servers.push(server);+ await new Promise<void>((done) => server.listen(0, "127.0.0.1", done));+ const base = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;+ const call = async (method: string, path: string) => {+ const response = await fetch(`${base}${path}`, { method });+ return { status: response.status, body: await response.json() as BotLibrary & { error?: string } };+ };+ return { call, asked };+}++describe("GET /api/bots/:id/library", () => {+ it("is open to a client session, as the conversations' messages are", () => {+ expect(requiredScope("GET", "/api/bots/scout/library")).toBe("client");+ expect(requiredScope("POST", "/api/bots/scout/library")).toBe("admin");+ });++ it("lists what the bot made in all of its conversations, the archived one included", async () => {+ const { call, asked } = await fixture({ bot: true, hidden: [] });+ const answer = await call("GET", "/api/bots/scout/library");+ expect(answer.status).toBe(200);+ expect(asked).toEqual([["open", "archived", "rui-private"]]);+ expect(answer.body.apps.map((app) => app.threadId)).toEqual(["open", "archived", "rui-private"]);+ expect(answer.body.pages.map((page) => page.title)).toEqual(["Menu"]);+ });++ it("never names anything from a conversation this viewer cannot read", async () => {+ const { call, asked } = await fixture({ bot: true, hidden: ["rui-private"] });+ const answer = await call("GET", "/api/bots/scout/library");+ expect(asked).toEqual([["open", "archived"]]);+ expect(answer.body).toEqual({ pages: [], apps: [+ { threadId: "open", messageId: "app-open", at: 10, title: "App in open" },+ { threadId: "archived", messageId: "app-archived", at: 9, title: "App in archived" },+ ], files: [] });+ });++ it("answers a bot the viewer cannot see, or one that does not exist, as not found, and leaves other paths alone", async () => {+ const hidden = await fixture({ bot: false, hidden: [] });+ expect(await hidden.call("GET", "/api/bots/scout/library")).toEqual({ status: 404, body: { error: "no such bot" } });+ expect(hidden.asked).toEqual([]);+ const shown = await fixture({ bot: true, hidden: [] });+ expect((await shown.call("GET", "/api/bots/nobody/library")).status).toBe(404);+ expect(await shown.call("POST", "/api/bots/scout/library")).toEqual({ status: 404, body: { error: "not routed" } });+ expect(await shown.call("GET", "/api/bots/scout/library/extra")).toEqual({ status: 404, body: { error: "not routed" } });+ });+});diff --git a/server/routes/bot-library.ts b/server/routes/bot-library.tsnew file mode 100644index 0000000000..0914f34273--- /dev/null+++ b/server/routes/bot-library.ts@@ -0,0 +1,30 @@+import type { BotLibrary } from "../../shared/bot-library.ts";+import type { VisibleSet } from "../bot-visibility.ts";+import { collectBotLibrary, type BotLibraryRows } from "../bot-library.ts";+import type { PublishedPageRecord } from "../pages/store.ts";+import type { RequestAuth } from "../request-auth.ts";+import { PASS, type RouteHandler } from "./table.ts";++export interface BotLibraryRouteDeps {+ bot(id: string): { id: string; threadId: string; tasks?: ReadonlyArray<{ threadId: string }> } | null | undefined;+ /** The same filter the GET /api/bots listing applies to this caller. */+ visibleFor(auth: RequestAuth): Pick<VisibleSet, "bot" | "thread">;+ pages(): readonly PublishedPageRecord[];+ rows?: BotLibraryRows;+}++const LIBRARY = /^\/api\/bots\/([\w-]+)\/library$/;++/** GET /api/bots/:id/library: the pages, apps and files the bot made in all of its conversations (shared/bot-library.ts).+ * Security: only conversations this viewer can read are searched, so on a Team Cloud another person's private+ * conversation names nothing here; a bot they cannot see reads as one that does not exist. */+export function createBotLibraryRoutes(deps: BotLibraryRouteDeps): RouteHandler {+ return async ({ res, path, method, auth, json }) => {+ const match = method === "GET" ? LIBRARY.exec(path) : null;+ if (!match) return PASS;+ const bot = deps.bot(match[1]!), visible = deps.visibleFor(auth);+ if (!bot || !visible.bot(bot.id)) return json(res, 404, { error: "no such bot" });+ const threadIds = [...new Set([bot.threadId, ...(bot.tasks ?? []).map((task) => task.threadId)])].filter((threadId) => visible.thread(threadId));+ return json(res, 200, collectBotLibrary({ botId: bot.id, threadIds, pages: deps.pages(), ...(deps.rows ? { rows: deps.rows } : {}) }) satisfies BotLibrary);+ };+}diff --git a/shared/bot-library.ts b/shared/bot-library.tsnew file mode 100644index 0000000000..a117e361d8--- /dev/null+++ b/shared/bot-library.ts@@ -0,0 +1,23 @@+/** What one bot made across its conversations, newest first (GET /api/bots/:id/library): its live published pages, its+ * apps, and the files it shared. Each item names the conversation and message it came from. */+export interface BotLibrary {+ pages: BotLibraryPage[];+ apps: BotLibraryApp[];+ files: BotLibraryFileMessage[];+}++export interface BotLibraryPage { threadId: string; messageId: string; at: number; title: string; url: string }++export interface BotLibraryApp { threadId: string; messageId: string; at: number; title: string }++/** One bot reply that shares files: its attached files, and the local file links in its text, as authored. */+export interface BotLibraryFileMessage {+ threadId: string;+ messageId: string;+ at: number;+ attachments: Array<{ path: string; kind?: string; name?: string }>;+ links: string[];+}++/** The most of each group the server sends; the panel shows the newest few and expands in place. */+export const BOT_LIBRARY_MAX = 200;diff --git a/src/components/AttachmentGallery.tsx b/src/components/AttachmentGallery.tsxindex f6f453a544..71fb37ad7b 100644--- a/src/components/AttachmentGallery.tsx+++ b/src/components/AttachmentGallery.tsx@@ -53,9 +53,13 @@ export function collectMessageFiles(text: string, existingPaths: readonly string}if (node.children) pending.push(...[...node.children].reverse());}+ return linkedFiles(links.map((node) => node.url ?? (node.identifier ? definitions.get(node.identifier) : undefined)), existingPaths);+}++/** The local files among link targets, as their chips show them, once each; never one of `existingPaths`. */+export function linkedFiles(hrefs: ReadonlyArray<string | undefined>, existingPaths: readonly string[] = []): GalleryFile[] {const seen = new Set(existingPaths.map(fileIdentity));- return links.flatMap((node) => {- const href = node.url ?? (node.identifier ? definitions.get(node.identifier) : undefined);+ return hrefs.flatMap((href) => {const path = localFilePath(href);if (!path || !href) return [];const identity = fileIdentity(href);diff --git a/src/components/AttachmentPreview.tsx b/src/components/AttachmentPreview.tsxindex 35845c2cb0..259911248f 100644--- a/src/components/AttachmentPreview.tsx+++ b/src/components/AttachmentPreview.tsx@@ -882,12 +882,12 @@ export function MarkdownImagePreview({);}-export function AttachedFileChip({ file, message, linked = false, compact = false, className }: {+export function AttachedFileChip({ file, message, linked = false, compact = false, className, note }: {file: TranscriptFileAttachment;message?: MessageAttachmentContext;linked?: boolean;compact?: boolean;- className?: string;+ className?: string; note?: string; // note: a quiet word after the name, such as the conversation it came from}) {const save = useLocalFileSave(file.path, file.name, message);const preview = useHtmlPreview(file.path, file.name, message);@@ -914,7 +914,7 @@ export function AttachedFileChip({ file, message, linked = false, compact = falsclassName="flex min-h-10 min-w-0 flex-1 items-center gap-2 px-2.5 py-2 text-left transition-colors hover:bg-raised/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60 disabled:cursor-wait disabled:hover:bg-transparent"><FileText size={14} className="shrink-0" aria-hidden="true" />- <span className="min-w-0 flex-1 truncate text-ink">{file.name}</span>+ <span className="min-w-0 flex-1 truncate text-ink">{file.name}</span>{note && <span className="min-w-0 max-w-[45%] shrink truncate text-[11px] text-ink-tertiary">{note}</span>}{preview.opens ? <Eye size={13} className="shrink-0" /> : save.state === "saving" ? (<LoaderCircle size={13} className="shrink-0 animate-spin" />) : save.state === "saved" ? (diff --git a/src/components/bot-panel/LibraryTab.dom.test.ts b/src/components/bot-panel/LibraryTab.dom.test.tsnew file mode 100644index 0000000000..ea658a8ab9--- /dev/null+++ b/src/components/bot-panel/LibraryTab.dom.test.ts@@ -0,0 +1,132 @@+// @vitest-environment happy-dom+import { act, createElement } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, expect, it, vi } from "vitest";++import type { BotLibrary } from "../../../shared/bot-library";+import type { Bot, Message } from "@/state/store";++const fixture = vi.hoisted(() => ({ dispatch: vi.fn(), opened: [] as string[] }));+vi.mock("@/state/store-select", async (importOriginal) => ({+ ...await importOriginal<typeof import("@/state/store-select")>(),+ useStoreDispatch: () => fixture.dispatch,+}));+vi.mock("./use-memory-doc", () => ({ useMemoryDoc: () => ({ docs: null, error: false }) }));+vi.mock("../bot-settings/SkillsSection", async (importOriginal) => ({+ ...await importOriginal<typeof import("../bot-settings/SkillsSection")>(),+ useManagedSkills: () => ({ skills: [], loading: false }),+}));+vi.mock("@/lib/page-open", () => ({ usePageOpener: () => (url: string) => fixture.opened.push(url) }));++const { LibraryTab, LIBRARY_SHOWN } = await import("./LibraryTab");++(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const page = (id: string, at: number, url: string, state: "live" | "unpublished" = "live"): Message =>+ ({ id, role: "bot", kind: "text", text: "Published", at, publishedPage: { state, title: `Page ${id}`, url } }) as Message;+const app = (id: string, at: number): Message =>+ ({ id, role: "bot", kind: "app", text: "", at, app: { v: 1, source: { kind: "html" }, title: `App ${id}`, doc: `doc-${id}`, rev: 0 } }) as unknown as Message;+const makeBot = (over: Partial<Bot> = {}): Bot => ({+ id: "scout", threadId: "t1", name: "Scout", title: "", description: "", notifications: true, color: "green", unread: false,+ modelSelection: { instanceId: "x", model: "x" },+ tasks: [+ { threadId: "t1", title: "Launch plan", createdAt: 1 },+ { threadId: "t2", title: "Pricing", createdAt: 2 },+ { threadId: "t3", title: "Old notes", createdAt: 3, archivedAt: 9 },+ ],+ messages: [page("m1", 50, "https://aaaaaaaaaaaaaaaaaaaa.mausbot.page/"), app("m2", 60), page("m3", 70, "https://cccccccccccccccccccc.mausbot.page/", "unpublished")],+ ...over,+}) as Bot;++let library: BotLibrary;+const requests: string[] = [];+let host: HTMLDivElement;+let root: Root;++beforeEach(() => {+ fixture.dispatch.mockReset();+ fixture.opened.length = 0;+ requests.length = 0;+ library = {+ pages: [+ { threadId: "t2", messageId: "p2", at: 90, title: "Price sheet", url: "https://bbbbbbbbbbbbbbbbbbbb.mausbot.page/" },+ // Unpublished in the open conversation since the server answered: the loaded message wins.+ { threadId: "t1", messageId: "m3", at: 70, title: "Page m3", url: "https://cccccccccccccccccccc.mausbot.page/" },+ { threadId: "t3", messageId: "p3", at: 10, title: "Old page", url: "https://dddddddddddddddddddd.mausbot.page/" },+ // From a conversation deleted since: the panel no longer knows it.+ { threadId: "t9", messageId: "p9", at: 99, title: "Gone page", url: "https://eeeeeeeeeeeeeeeeeeee.mausbot.page/" },+ ],+ apps: [{ threadId: "t2", messageId: "a2", at: 80, title: "Quote calculator" }, { threadId: "t1", messageId: "m2", at: 60, title: "App m2" }],+ files: [{ threadId: "t3", messageId: "f3", at: 5, attachments: [{ path: "/work/report.pdf", kind: "file", name: "report.pdf" }], links: ["/work/notes.md"] }],+ };+ vi.stubGlobal("fetch", vi.fn(async (input: string) => {+ const url = new URL(input, "http://x");+ requests.push(url.pathname);+ const body = url.pathname === "/api/bots/scout/library" ? library : { error: "not here" };+ return new Response(JSON.stringify(body), { status: url.pathname === "/api/bots/scout/library" ? 200 : 404, headers: { "content-type": "application/json" } });+ }));+ host = document.createElement("div");+ document.body.append(host);+ root = createRoot(host);+});+afterEach(() => {+ act(() => root.unmount());+ host.remove();+ vi.unstubAllGlobals();+});++const settle = () => act(async () => { for (let i = 0; i < 5; i += 1) await new Promise((resolve) => setTimeout(resolve, 0)); });+const rows = (kind: string) => [...host.querySelectorAll<HTMLElement>(`[data-panel-row="${kind}"]`)];+const render = async (bot: Bot) => {+ await act(async () => root.render(createElement(LibraryTab, { bot, onOpen: () => {} })));+ await settle();+};++it("lists what the bot made in every conversation, newest first, each with the conversation it came from", async () => {+ await render(makeBot());+ expect(requests).toContain("/api/bots/scout/library");+ expect(rows("page").map((row) => row.textContent)).toEqual(["Price sheetPricing", "Page m1Launch plan", "Old pageOld notes"]);+ expect(rows("app").map((row) => row.textContent)).toEqual(["Quote calculatorPricing", "App m2Launch plan"]);+ const files = host.querySelector('[data-panel-card="files"]')!.textContent;+ expect(files).toContain("report.pdf");+ expect(files).toContain("notes.md");+ expect(files).toContain("Old notes");+ expect(host.textContent).not.toContain("Gone page");+ expect(host.textContent).not.toContain("From this conversation");+ expect(host.querySelector('[data-panel-page="memory"]')).not.toBeNull();+});++it("opens a page by its link, and an app from another conversation at its message there", async () => {+ await render(makeBot());+ await act(async () => rows("page")[0]!.querySelector("button")?.click() ?? rows("page")[0]!.click());+ expect(fixture.opened).toEqual(["https://bbbbbbbbbbbbbbbbbbbb.mausbot.page/"]);+ await act(async () => (rows("app")[0]!.querySelector("button") ?? rows("app")[0]!).click());+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "scout", threadId: "t2" });+ expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "focusMessage", threadId: "t2", messageId: "a2" });+ fixture.dispatch.mockClear();+ await act(async () => (rows("app")[1]!.querySelector("button") ?? rows("app")[1]!).click());+ expect(fixture.dispatch.mock.calls).toEqual([[{ type: "focusMessage", threadId: "t1", messageId: "m2" }]]);+});++it("names no conversation while the bot has only one, and shows what is loaded when the server cannot answer", async () => {+ library = { pages: [], apps: [], files: [] };+ await render(makeBot({ tasks: [{ threadId: "t1", title: "Launch plan", createdAt: 1 }] }));+ expect(rows("page").map((row) => row.textContent)).toEqual(["Page m1https://aaaaaaaaaaaaaaaaaaaa.mausbot.page/"]);+ expect(rows("app").map((row) => row.textContent)).toEqual(["App m2"]);+ vi.stubGlobal("fetch", vi.fn(async () => new Response("{}", { status: 500 })));+ await render(makeBot({ id: "other" }));+ expect(rows("app").map((row) => row.textContent)).toEqual(["App m2Launch plan"]);+});++it("shows the newest few of a long group, then Show all opens the rest in place", async () => {+ library = { pages: [], files: [], apps: Array.from({ length: 30 }, (_, index) => ({ threadId: "t2", messageId: `a${index}`, at: 1_000 - index, title: `App ${index}` })) };+ await render(makeBot({ messages: [] }));+ expect(rows("app")).toHaveLength(LIBRARY_SHOWN);+ expect(rows("app")[0]!.textContent).toContain("App 0");+ const more = host.querySelector<HTMLButtonElement>('[data-library-more="apps"]')!;+ expect(more.textContent).toBe("Show all");+ await act(async () => more.click());+ expect(rows("app")).toHaveLength(30);+ expect(host.querySelector('[data-library-more="apps"]')).toBeNull();+ expect(host.querySelector('[data-library-more="pages"]')).toBeNull();+});diff --git a/src/components/bot-panel/LibraryTab.tsx b/src/components/bot-panel/LibraryTab.tsxindex 9b9ef15748..0d5e248edc 100644--- a/src/components/bot-panel/LibraryTab.tsx+++ b/src/components/bot-panel/LibraryTab.tsx@@ -1,13 +1,13 @@-import { AppWindow, Brain, FileText, Folder, Globe, Zap } from "lucide-react";-import { useMemo } from "react";+import { AppWindow, Brain, ChevronDown, FileText, Folder, Globe, Zap } from "lucide-react";+import { useMemo, useState, type ReactNode } from "react";import { t } from "@/lib/i18n";import { usePageOpener } from "@/lib/page-open";import { shortPath } from "@/lib/short-path";+import { useShowThreads } from "@/lib/thread-preferences";import { SIDEBAR_INLINE, useMediaQuery } from "@/lib/use-media-query";-import { visibleMessages, type Bot, type Message } from "@/state/store";+import { openBotThread, type Bot } from "@/state/store";import { AttachedFileChip } from "../AttachmentPreview";-import { recentChangedFiles, sharedFileReferences } from "../ComputerFilesPane";import { useDesktopCapabilities } from "../DesktopCapabilities";import { skillSwitchOn, useManagedSkills } from "../bot-settings/SkillsSection";import type { SimplePageId } from "./page-registry";@@ -15,41 +15,24 @@ import { Card, CardLabel, NavRow } from "./rows";import { panelMemoryNotes } from "./memory-notes";import { useMemoryDoc } from "./use-memory-doc";import { useStoreDispatch } from "@/state/store-select";+import { allLibraryItems, libraryItems, threadLabel } from "./library-items";+import { useBotLibrary } from "./use-bot-library";-export interface LibraryItems {- pages: Array<{ messageId: string; title: string; url: string }>;- apps: Array<{ messageId: string; title: string }>;- shared: Array<NonNullable<ReturnType<ReturnType<typeof sharedFileReferences>["get"]>>>;- unshared: string[];-}--/** What the bot made in the open conversation, newest first: its live published pages, its apps, and its files. */-export function libraryItems(bot: Bot, messages: readonly Message[] = visibleMessages(bot)): LibraryItems {- const pages: LibraryItems["pages"] = [];- const apps: LibraryItems["apps"] = [];- const seenPages = new Set<string>();- for (const message of [...messages].reverse()) {- const page = message.publishedPage;- if (page?.state === "live" && page.url && !seenPages.has(page.url)) {- seenPages.add(page.url);- pages.push({ messageId: message.id, title: page.title || page.url, url: page.url });- }- if (message.kind === "app" && message.app?.doc) apps.push({ messageId: message.id, title: message.app.title });- }- const references = sharedFileReferences(bot);- const shared: LibraryItems["shared"] = [];- const seenFiles = new Set<string>();- for (const reference of references.values()) {- if (seenFiles.has(reference.file.path)) continue;- seenFiles.add(reference.file.path);- shared.push(reference);- }- const unshared = recentChangedFiles(bot).filter((path) => !references.has(path));- return { pages, apps, shared, unshared };-}+/** Each group shows its newest few; Show all opens the rest in place. */+export const LIBRARY_SHOWN = 20;const fileName = (path: string) => path.slice(Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1);+function ShowAll({ group, onClick }: { group: string; onClick: () => void }) {+ return (+ <button type="button" data-library-more={group} aria-expanded={false} onClick={onClick}+ className="mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink">+ <ChevronDown size={14} aria-hidden="true" />+ {t("botPanel.library.showAll")}+ </button>+ );+}+export function LibraryTab({ bot, onOpen }: { bot: Bot; onOpen: (page: SimplePageId) => void }) {const dispatch = useStoreDispatch();const { capabilities } = useDesktopCapabilities();@@ -57,9 +40,17 @@ export function LibraryTab({ bot, onOpen }: { bot: Bot; onOpen: (page: SimplePagconst phone = !useMediaQuery(SIDEBAR_INLINE, true);const skills = useManagedSkills(bot);const memory = useMemoryDoc(bot);- const { pages, apps, shared, unshared } = useMemo(() => libraryItems(bot), [bot]);- const showInChat = (messageId: string) => {- dispatch({ type: "focusMessage", threadId: bot.threadId, messageId });+ const showThreads = useShowThreads();+ const remote = useBotLibrary(bot);+ const local = useMemo(() => libraryItems(bot), [bot]);+ const { pages, apps, shared, unshared } = useMemo(() => allLibraryItems(bot, local, remote), [bot, local, remote]);+ const [open, setOpen] = useState<ReadonlySet<string>>(() => new Set());+ const shown = <T,>(group: string, items: T[]) => (open.has(group) ? items : items.slice(0, LIBRARY_SHOWN));+ const more = (group: string, items: readonly unknown[]): ReactNode => !open.has(group) && items.length > LIBRARY_SHOWN+ ? <ShowAll group={group} onClick={() => setOpen((groups) => new Set(groups).add(group))} /> : null;+ const showInChat = (threadId: string, messageId: string) => {+ if (threadId !== bot.threadId) openBotThread(dispatch, bot, threadId, showThreads);+ dispatch({ type: "focusMessage", threadId, messageId });if (phone) dispatch({ type: "toggleSettings", open: false });};const skillsOn = skills.skills.filter(skillSwitchOn).length;@@ -102,28 +93,33 @@ export function LibraryTab({ bot, onOpen }: { bot: Bot; onOpen: (page: SimplePag<div data-panel-tabpanel="library">{pages.length > 0 && (<Card label={t("botPanel.library.pages")} anchor="pages">- {pages.map((page) => (- <NavRow key={page.url} data-panel-row="page" icon={Globe} title={<span className="block truncate">{page.title}</span>} hint={<span className="block truncate">{page.url}</span>} onClick={() => openPage(page.url)} />+ {shown("pages", pages).map((page) => (+ <NavRow key={page.url} data-panel-row="page" icon={Globe} title={<span className="block truncate">{page.title}</span>}+ hint={<span className="block truncate">{threadLabel(bot, page.threadId, showThreads) ?? page.url}</span>} onClick={() => openPage(page.url)} />))}</Card>)}+ {more("pages", pages)}{apps.length > 0 && (<Card label={t("botPanel.library.apps")} anchor="apps">- {apps.map((app) => (- <NavRow key={app.messageId} data-panel-row="app" icon={AppWindow} title={<span className="block truncate">{app.title}</span>} onClick={() => showInChat(app.messageId)} />- ))}+ {shown("apps", apps).map((app) => {+ const label = threadLabel(bot, app.threadId, showThreads);+ return <NavRow key={`${app.threadId}:${app.messageId}`} data-panel-row="app" icon={AppWindow} title={<span className="block truncate">{app.title}</span>}+ hint={label && <span className="block truncate">{label}</span>} onClick={() => showInChat(app.threadId, app.messageId)} />;+ })}</Card>)}+ {more("apps", apps)}{shared.length + unshared.length > 0 && (<section data-panel-card="files"><CardLabel>{t("botPanel.library.files")}</CardLabel><ul className="flex flex-col gap-1.5">- {shared.map((reference) => (- <li key={`${reference.message.messageId}:${reference.file.path}`} className="min-w-0">- <AttachedFileChip file={reference.file} message={reference.message} linked={reference.file.linked} className="w-full max-w-none" />+ {shown("files", shared).map((item) => (+ <li key={`${item.threadId}:${item.messageId}:${item.file.path}`} className="min-w-0">+ <AttachedFileChip file={item.file} message={{ threadId: item.threadId, messageId: item.messageId }} linked={item.file.linked} note={threadLabel(bot, item.threadId, showThreads)} className="w-full max-w-none" /></li>))}- {unshared.map((path) => (+ {(open.has("files") ? unshared : unshared.slice(0, Math.max(0, LIBRARY_SHOWN - shared.length))).map((path) => (<li key={path} title={t("computer.files.notSharedHint")} className="flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2"><FileText size={14} className="shrink-0 text-ink-secondary" aria-hidden="true" /><span className="min-w-0 flex-1 truncate text-[13px] text-ink">{fileName(path)}</span>@@ -131,9 +127,9 @@ export function LibraryTab({ bot, onOpen }: { bot: Bot; onOpen: (page: SimplePag</li>))}</ul>+ {more("files", [...shared, ...unshared])}</section>)}- <p className="mt-3 text-center text-[12px] text-ink-tertiary">{t("botPanel.library.scope")}</p>{keeps}</div>);diff --git a/src/components/bot-panel/library-items.test.ts b/src/components/bot-panel/library-items.test.tsnew file mode 100644index 0000000000..0bffc52c81--- /dev/null+++ b/src/components/bot-panel/library-items.test.ts@@ -0,0 +1,57 @@+import { describe, expect, it } from "vitest";++import type { BotLibrary } from "../../../shared/bot-library";+import type { Bot, Message } from "@/state/store";+import { allLibraryItems, libraryItems, threadLabel } from "./library-items";++const bot = (messages: Message[], over: Partial<Bot> = {}) => ({+ id: "scout", threadId: "t1", messages,+ tasks: [{ threadId: "t1", title: "Launch", createdAt: 1 }, { threadId: "t2", title: "Pricing", createdAt: 2 }, { threadId: "t3", title: "Archived", createdAt: 3, archivedAt: 4 }],+ ...over,+}) as unknown as Bot;+const live = (id: string, at: number, url: string): Message => ({ id, role: "bot", kind: "text", text: "", at, publishedPage: { state: "live", title: id, url } }) as Message;+const reply = (id: string, at: number, text: string): Message => ({ id, role: "bot", kind: "text", text, at }) as Message;++describe("allLibraryItems", () => {+ it("puts the open conversation's loaded items with the other conversations', newest first, each thing once", () => {+ const open = bot([live("m1", 20, "https://one.mausbot.page/"), reply("m2", 30, "[plan](/work/plan.md)")]);+ const remote: BotLibrary = {+ pages: [+ { threadId: "t2", messageId: "p2", at: 50, title: "Two", url: "https://two.mausbot.page/" },+ // The same page shown again in an older conversation: listed once, newest first.+ { threadId: "t3", messageId: "p3", at: 5, title: "One again", url: "https://one.mausbot.page/" },+ ],+ apps: [+ { threadId: "t3", messageId: "a3", at: 1, title: "Archived app" },+ { threadId: "t2", messageId: "a2", at: 40, title: "Quote" },+ { threadId: "gone", messageId: "a9", at: 99, title: "Deleted conversation's app" },+ ],+ files: [+ { threadId: "t2", messageId: "f2", at: 60, attachments: [{ path: "/work/out.csv", kind: "file", name: "out.csv" }, { path: "/work/pic.png", kind: "image" }], links: ["/work/pic.png", "/work/plan.md"] },+ { threadId: "t3", messageId: "f3", at: 10, attachments: [], links: ["https://example.com/x.md", "./notes.txt"] },+ ],+ };+ const items = allLibraryItems(open, libraryItems(open), remote);+ expect(items.pages.map((page) => [page.title, page.threadId])).toEqual([["Two", "t2"], ["m1", "t1"]]);+ expect(items.apps.map((app) => app.title)).toEqual(["Quote", "Archived app"]);+ expect(items.shared.map((item) => [item.file.name, item.threadId])).toEqual([["out.csv", "t2"], ["plan.md", "t2"], ["notes.txt", "t3"]]);+ });++ it("trusts the open conversation's loaded messages over the server's answer about them, and has only them without one", () => {+ const open = bot([{ ...live("m1", 20, "https://one.mausbot.page/"), publishedPage: { state: "unpublished", title: "m1", url: "https://one.mausbot.page/" } } as Message]);+ const remote: BotLibrary = { pages: [{ threadId: "t1", messageId: "m1", at: 20, title: "m1", url: "https://one.mausbot.page/" }], apps: [], files: [] };+ expect(allLibraryItems(open, libraryItems(open), remote).pages).toEqual([]);+ const local = libraryItems(bot([live("m5", 5, "https://five.mausbot.page/")]));+ expect(allLibraryItems(bot([]), local, null)).toBe(local);+ });+});++describe("threadLabel", () => {+ it("names the conversation, with threads hidden the main one as such, and nothing while there is only one", () => {+ expect(threadLabel(bot([]), "t2", true)).toBe("Pricing");+ expect(threadLabel(bot([], { mainThreadId: "t1" }), "t1", false)).toBe("Main thread");+ expect(threadLabel(bot([], { mainThreadId: "t1" }), "t1", true)).toBe("Launch");+ expect(threadLabel(bot([], { mainThreadId: "t1" }), "t2", false)).toBe("Pricing");+ expect(threadLabel(bot([], { tasks: [{ threadId: "t1", title: "Launch", createdAt: 1 }] }), "t1", false)).toBeUndefined();+ });+});diff --git a/src/components/bot-panel/library-items.ts b/src/components/bot-panel/library-items.tsnew file mode 100644index 0000000000..bd7681fadd--- /dev/null+++ b/src/components/bot-panel/library-items.ts@@ -0,0 +1,96 @@+import type { BotLibrary } from "../../../shared/bot-library";+import { t } from "@/lib/i18n";+import { visibleMessages, type Bot, type Message } from "@/state/store";+import { fileIdentity, linkedFiles, splitMessageAttachments, type GalleryFile } from "../AttachmentGallery";+import { recentChangedFiles, sharedFileReferences } from "../ComputerFilesPane";++/** Where an item was made: the conversation and the message that shows it. */+interface Made { threadId: string; messageId: string; at: number }+export interface LibraryPage extends Made { title: string; url: string }+export interface LibraryApp extends Made { title: string }+export interface LibraryFile extends Made { file: GalleryFile }++export interface LibraryItems {+ pages: LibraryPage[];+ apps: LibraryApp[];+ shared: LibraryFile[];+ /** Files the open conversation changed and no reply shared, as paths. */+ unshared: string[];+}++const fileKey = (file: GalleryFile) => file.private ? file.path : fileIdentity(file.path);++/** What the bot made in the open conversation's loaded messages, newest first: its live published pages, its apps, and+ * its files. */+export function libraryItems(bot: Bot, messages: readonly Message[] = visibleMessages(bot)): LibraryItems {+ const pages: LibraryPage[] = [];+ const apps: LibraryApp[] = [];+ const seenPages = new Set<string>();+ for (const message of [...messages].reverse()) {+ const made = { threadId: bot.threadId, messageId: message.id, at: message.at };+ const page = message.publishedPage;+ if (page?.state === "live" && page.url && !seenPages.has(page.url)) {+ seenPages.add(page.url);+ pages.push({ ...made, title: page.title || page.url, url: page.url });+ }+ if (message.kind === "app" && message.app?.doc) apps.push({ ...made, title: message.app.title });+ }+ const references = sharedFileReferences(bot);+ const at = new Map(messages.map((message) => [message.id, message.at]));+ const shared: LibraryFile[] = [];+ const seenFiles = new Set<string>();+ for (const reference of references.values()) {+ if (seenFiles.has(reference.file.path)) continue;+ seenFiles.add(reference.file.path);+ shared.push({ ...reference.message, at: at.get(reference.message.messageId) ?? 0, file: reference.file });+ }+ const unshared = recentChangedFiles(bot).filter((path) => !references.has(path));+ return { pages, apps, shared, unshared };+}++/** The files the server's replies share, as the open conversation's own replies show them (sharedFileReferences). */+function sharedFiles(replies: BotLibrary["files"]): LibraryFile[] {+ return replies.flatMap((reply) => {+ const attached = splitMessageAttachments(reply.attachments);+ const files = [...attached.files, ...linkedFiles(reply.links, [...attached.images, ...attached.files.map((file) => file.path)])];+ return files.map((file) => ({ threadId: reply.threadId, messageId: reply.messageId, at: reply.at, file }));+ });+}++function newestOnce<T extends Made>(items: T[], key: (item: T) => string): T[] {+ const seen = new Set<string>();+ return items.sort((a, b) => b.at - a.at).filter((item) => {+ const id = key(item);+ if (seen.has(id)) return false;+ seen.add(id);+ return true;+ });+}++/** The bot's conversations the panel knows; a conversation deleted since the server answered is not among them. */+export function knownThreads(bot: Pick<Bot, "threadId" | "tasks">): Set<string> {+ return new Set([bot.threadId, ...(bot.tasks ?? []).map((task) => task.threadId)]);+}++/** Everything the bot made in all of its conversations, newest first: the server's list across them, with the open+ * conversation's loaded messages over it, since they are newer than any answer (a page just unpublished there is gone at+ * once). Without the server's list, the open conversation's alone. */+export function allLibraryItems(bot: Bot, local: LibraryItems, remote: BotLibrary | null): LibraryItems {+ if (!remote) return local;+ const known = knownThreads(bot), loaded = new Set(bot.messages.map((message) => message.id));+ const keep = (item: Made) => known.has(item.threadId) && !(item.threadId === bot.threadId && loaded.has(item.messageId));+ return {+ pages: newestOnce([...local.pages, ...remote.pages.filter(keep)], (page) => page.url),+ apps: newestOnce([...local.apps, ...remote.apps.filter(keep)], (app) => app.messageId),+ shared: newestOnce([...local.shared, ...sharedFiles(remote.files.filter(keep))], (item) => fileKey(item.file)),+ unshared: local.unshared,+ };+}++/** The quiet line naming the conversation an item came from, none while the bot has only one: its title, or with threads+ * hidden (Simple mode) "Main thread" for the one the bot opens to. */+export function threadLabel(bot: Pick<Bot, "threadId" | "mainThreadId" | "tasks">, threadId: string, threadsShown: boolean): string | undefined {+ if (knownThreads(bot).size < 2) return undefined;+ if (!threadsShown && threadId === bot.mainThreadId) return t("sidebar.bot.simple.mainThread");+ return bot.tasks?.find((task) => task.threadId === threadId)?.title || t("task.newShort");+}diff --git a/src/components/bot-panel/use-bot-library.ts b/src/components/bot-panel/use-bot-library.tsnew file mode 100644index 0000000000..fe7037f7b8--- /dev/null+++ b/src/components/bot-panel/use-bot-library.ts@@ -0,0 +1,20 @@+import { useEffect, useState } from "react";+import type { BotLibrary } from "../../../shared/bot-library";+import { api } from "@/state/api";+import type { Bot } from "@/state/store";+import { knownThreads } from "./library-items";++/** What the bot made in all of its conversations (GET /api/bots/:id/library), read when the Library tab opens and again+ * when the bot gains, loses or switches a conversation; null until it answers, or if it cannot. */+export function useBotLibrary(bot: Pick<Bot, "id" | "threadId" | "tasks">): BotLibrary | null {+ const [library, setLibrary] = useState<{ botId: string; library: BotLibrary } | null>(null);+ const key = `${bot.id}:${bot.threadId}:${[...knownThreads(bot)].sort().join(",")}`;+ useEffect(() => {+ let cancelled = false;+ api<BotLibrary>(`/api/bots/${encodeURIComponent(bot.id)}/library`)+ .then((answer) => { if (!cancelled && Array.isArray(answer?.pages) && Array.isArray(answer.apps) && Array.isArray(answer.files)) setLibrary({ botId: bot.id, library: answer }); })+ .catch(() => {});+ return () => { cancelled = true; };+ }, [bot.id, key]);+ return library?.botId === bot.id ? library.library : null;+}diff --git a/src/locales/de.json b/src/locales/de.jsonindex e855894fb7..125809aed3 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -4128,5 +4128,6 @@"sidebar.threads.hide": "{title} ausblenden","sidebar.threads.hideShort": "Ausblenden","sidebar.threads.running": "+{count} laufen",- "sidebar.threads.more": "{count} weitere"+ "sidebar.threads.more": "{count} weitere",+ "botPanel.library.showAll": "Alle anzeigen"}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 4a62b6686e..b40b7035e4 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -4668,7 +4668,7 @@"botPanel.library.pages": "Pages","botPanel.library.apps": "Apps","botPanel.library.files": "Files",- "botPanel.library.scope": "From this conversation",+ "botPanel.library.showAll": "Show all","botPanel.thisConversation": "In this conversation","botPanel.advanced.title": "More in Advanced mode","botPanel.advanced.hint": "Sending on your behalf and app access are set there.",diff --git a/src/locales/es.json b/src/locales/es.jsonindex 4b5b168d07..e1dbf4bc9b 100644--- a/src/locales/es.json+++ b/src/locales/es.json@@ -6428,5 +6428,6 @@"sidebar.threads.hide": "Ocultar {title}","sidebar.threads.hideShort": "Ocultar","sidebar.threads.running": "+{count} en curso",- "sidebar.threads.more": "{count} más"+ "sidebar.threads.more": "{count} más",+ "botPanel.library.showAll": "Mostrar todo"}diff --git a/src/locales/fr.json b/src/locales/fr.jsonindex 97b1e0ed0e..a19031352d 100644--- a/src/locales/fr.json+++ b/src/locales/fr.json@@ -3831,5 +3831,6 @@"sidebar.threads.hide": "Masquer {title}","sidebar.threads.hideShort": "Masquer","sidebar.threads.running": "+{count} en cours",- "sidebar.threads.more": "{count} de plus"+ "sidebar.threads.more": "{count} de plus",+ "botPanel.library.showAll": "Tout afficher"}diff --git a/src/locales/hi.json b/src/locales/hi.jsonindex 84ea15619b..af6b5b1240 100644--- a/src/locales/hi.json+++ b/src/locales/hi.json@@ -3683,5 +3683,6 @@"sidebar.threads.hide": "{title} छिपाएँ","sidebar.threads.hideShort": "छिपाएँ","sidebar.threads.running": "+{count} चल रहे",- "sidebar.threads.more": "{count} और"+ "sidebar.threads.more": "{count} और",+ "botPanel.library.showAll": "सभी दिखाएँ"}diff --git a/src/locales/it.json b/src/locales/it.jsonindex 305838293e..2fa112cc01 100644--- a/src/locales/it.json+++ b/src/locales/it.json@@ -4643,7 +4643,7 @@"botPanel.library.pages": "Pagine","botPanel.library.apps": "Apps","botPanel.library.files": "File",- "botPanel.library.scope": "Da questa conversazione",+ "botPanel.library.showAll": "Mostra tutto","botPanel.thisConversation": "In questa conversazione","botPanel.advanced.title": "Più in modalità avanzata","botPanel.advanced.hint": "L'invio per vostro conto e l'accesso alle app è impostato lì.",diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex 17f1571d60..e42e473617 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -3982,7 +3982,7 @@"botPanel.library.pages": "ページ","botPanel.library.apps": "アプリ","botPanel.library.files": "ファイル",- "botPanel.library.scope": "この会話から",+ "botPanel.library.showAll": "すべて表示","botPanel.thisConversation": "この会話で","botPanel.acts.customHint": "詳細モードで変更できます","botPanel.section.settings": "設定",diff --git a/src/locales/ko.json b/src/locales/ko.jsonindex b2df1fa617..9ffe3a6bd9 100644--- a/src/locales/ko.json+++ b/src/locales/ko.json@@ -3788,7 +3788,7 @@"botPanel.library.pages": "페이지","botPanel.library.apps": "앱","botPanel.library.files": "파일",- "botPanel.library.scope": "이 대화에서",+ "botPanel.library.showAll": "모두 보기","botPanel.thisConversation": "이 대화에서","botPanel.acts.customHint": "고급 모드에서 바꾸세요","botPanel.section.settings": "설정",diff --git a/src/locales/pl.json b/src/locales/pl.jsonindex b7a3b05d95..4cd6c66e00 100644--- a/src/locales/pl.json+++ b/src/locales/pl.json@@ -7124,5 +7124,6 @@"sidebar.threads.hide": "Ukryj {title}","sidebar.threads.hideShort": "Ukryj","sidebar.threads.running": "+{count} w toku",- "sidebar.threads.more": "jeszcze {count}"+ "sidebar.threads.more": "jeszcze {count}",+ "botPanel.library.showAll": "Pokaż wszystkie"}diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex bfe6c2c50a..7df6ca3063 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -7939,7 +7939,7 @@"botPanel.library.pages": "Páginas","botPanel.library.apps": "Apps","botPanel.library.files": "Arquivos",- "botPanel.library.scope": "Desta conversa",+ "botPanel.library.showAll": "Mostrar tudo","botPanel.thisConversation": "Nesta conversa","botPanel.advanced.title": "Mais no modo avançado","botPanel.advanced.hint": "Enviar em seu nome e o acesso a apps ficam lá.",diff --git a/src/locales/ru.json b/src/locales/ru.jsonindex 8c43168a01..38c7548749 100644--- a/src/locales/ru.json+++ b/src/locales/ru.json@@ -7178,5 +7178,6 @@"sidebar.threads.hide": "Скрыть {title}","sidebar.threads.hideShort": "Скрыть","sidebar.threads.running": "+{count} в работе",- "sidebar.threads.more": "ещё {count}"+ "sidebar.threads.more": "ещё {count}",+ "botPanel.library.showAll": "Показать все"}diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex 92e8d23b50..8c17d3cfe8 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -4126,7 +4126,8 @@"settings.vault.bitwardenSecrets.guide": "a9cde30c280181181cdcc7f07ecf5bac7e8c50399b4ad010555cc091e55a69fb","settings.vault.bitwardenSecrets.token": "9a911b08feb9d2928240dda42c6efa8794ab3457f8b59a7cfb5187e817f948e3","settings.vault.bitwardenSecrets.note": "cb98c043ae54f73b55e675c6791759f93421cc65d2a3080b12d8af988997ef13",- "settings.vault.bitwardenSecrets.error": "393d6d3cb4d0776647976c6288ff1dac2198db77e9eb2613b6c389bca082694f"+ "settings.vault.bitwardenSecrets.error": "393d6d3cb4d0776647976c6288ff1dac2198db77e9eb2613b6c389bca082694f",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"es": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -10553,7 +10554,8 @@"routines.botPausedSwap": "f3ba4b0a76a16a26a75be5dabbe0b1440b416a83983f17a79eeb937d5b0e42d1","model.unreadable.failed": "992ebb278264c3cbf937046ef84a1afdd0d5a1bf50da8926187e28f8fd6b1965","model.unreadable.signedOut": "fbb9251c3437926ddce45580e946b751ae1aa8d9e5b689a39b6a51958c06e2d1",- "model.unreadable.timedOut": "d15b91980ff8a0db2fb194f82b235e8c1cfca944320281b324e76632eb989898"+ "model.unreadable.timedOut": "d15b91980ff8a0db2fb194f82b235e8c1cfca944320281b324e76632eb989898",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"fr": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -14383,7 +14385,8 @@"composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9","server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645","server.starter.routineRanPaused": "8e764711d6e5e39ee5620de0788fd03f39fc7818b9eabebdb8e1e37809e7931c",- "server.starter.routineWoke": "185957aa957f02f22a311ad4854698482210925bbe9fcb18e38b8e77a02ad668"+ "server.starter.routineWoke": "185957aa957f02f22a311ad4854698482210925bbe9fcb18e38b8e77a02ad668",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"hi": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",@@ -18065,7 +18068,8 @@"decider.provider.line": "b74959fffc682f78c90fde2eb8e8d2c0a40eebac0d11000c8def7ae4db389462","computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9",- "server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645"+ "server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"ja": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -24800,7 +24804,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.acts.customHint": "310e55204091030f78b208a2ce0e448ed5cc5c6e2ec0daa20461efb6bece42f9","botPanel.section.settings": "74a883a037bc227f91891ab654a753d3a99f31ab06ae5b5d2b6e594a692b41f8",@@ -33086,7 +33090,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.acts.customHint": "310e55204091030f78b208a2ce0e448ed5cc5c6e2ec0daa20461efb6bece42f9","botPanel.section.settings": "74a883a037bc227f91891ab654a753d3a99f31ab06ae5b5d2b6e594a692b41f8",@@ -42739,7 +42743,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.acts.customHint": "310e55204091030f78b208a2ce0e448ed5cc5c6e2ec0daa20461efb6bece42f9","botPanel.section.settings": "74a883a037bc227f91891ab654a753d3a99f31ab06ae5b5d2b6e594a692b41f8",@@ -53749,7 +53753,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.acts.customHint": "310e55204091030f78b208a2ce0e448ed5cc5c6e2ec0daa20461efb6bece42f9","botPanel.section.settings": "74a883a037bc227f91891ab654a753d3a99f31ab06ae5b5d2b6e594a692b41f8",@@ -61973,7 +61977,8 @@"decider.provider.line": "b74959fffc682f78c90fde2eb8e8d2c0a40eebac0d11000c8def7ae4db389462","computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9",- "server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645"+ "server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"vi": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -67895,7 +67900,8 @@"computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9","server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",- "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572"+ "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"tr": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -73817,7 +73823,8 @@"computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9","server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",- "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572"+ "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"pl": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -80940,7 +80947,8 @@"computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9","server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",- "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572"+ "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"ru": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -88117,7 +88125,8 @@"computer.worksOnHintServer": "2c3302d501a67067774aedcacfff8d16a80ea8238e2f14d8af97e3fd593f690b","composer.dictation.hintKey": "ad34499eb8ecf3174898c031bb1e45b63f46045a1105be0bffafb82368323de9","server.teammates.noLongerWaiting": "49259fb62a6e8687efa6a6e69da294c81bd67a19c57687d0724ee4bdd5cc4645",- "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572"+ "browser.input.notReaching": "f9f70cbf8a66e3c8dc64443b9a11a273c24b39cf2f824fa65639e6cd73d88572",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0"},"it": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -96182,7 +96191,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.advanced.title": "d823803689ad1713989d7cd80dde661392f93c2a6a5690e748ab88ed10c98237","botPanel.advanced.hint": "434ef07a7c8eafd2789a2fc936f8d050b62d7658d6777b0494db07e3c7d6294f",@@ -102860,7 +102869,7 @@"botPanel.library.pages": "9046da16aea909ba75a36cec13b56cb2144dc2ede45cde361e99a8d79802eabf","botPanel.library.apps": "89dd748442c194857825848e1500abbbc5f52fb067ad27fb05dc9fb23eebba3b","botPanel.library.files": "abc7e9892806b047b4d4786b3685285543f76ca314c4c76246d5f6544c7856c9",- "botPanel.library.scope": "ccb3484334f80d18e57e6d21f45819795d249122a76b6b293b1ca23c5df2f604",+ "botPanel.library.showAll": "2150d8df37e489573fb8f0f19ef89d2eda2ba4b49b3beb36333e5096a99a6dc0","botPanel.thisConversation": "9e131d429cc96e7b146549ca5ac81a4e72426ce6dea3e7ee22b09191933d3083","botPanel.acts.customHint": "310e55204091030f78b208a2ce0e448ed5cc5c6e2ec0daa20461efb6bece42f9","botPanel.section.settings": "74a883a037bc227f91891ab654a753d3a99f31ab06ae5b5d2b6e594a692b41f8",diff --git a/src/locales/tr.json b/src/locales/tr.jsonindex 169b98621f..7d1bcaa9be 100644--- a/src/locales/tr.json+++ b/src/locales/tr.json@@ -5923,5 +5923,6 @@"sidebar.threads.hide": "{title} gizle","sidebar.threads.hideShort": "Gizle","sidebar.threads.running": "+{count} çalışıyor",- "sidebar.threads.more": "{count} tane daha"+ "sidebar.threads.more": "{count} tane daha",+ "botPanel.library.showAll": "Tümünü göster"}diff --git a/src/locales/uk.json b/src/locales/uk.jsonindex 9fd31b60c8..66d27b787a 100644--- a/src/locales/uk.json+++ b/src/locales/uk.json@@ -4103,5 +4103,6 @@"sidebar.threads.hide": "Сховати {title}","sidebar.threads.hideShort": "Сховати","sidebar.threads.running": "+{count} у роботі",- "sidebar.threads.more": "ще {count}"+ "sidebar.threads.more": "ще {count}",+ "botPanel.library.showAll": "Показати всі"}diff --git a/src/locales/vi.json b/src/locales/vi.jsonindex 5c4de7b472..2d3decbef9 100644--- a/src/locales/vi.json+++ b/src/locales/vi.json@@ -5923,5 +5923,6 @@"sidebar.threads.hide": "Ẩn {title}","sidebar.threads.hideShort": "Ẩn","sidebar.threads.running": "+{count} đang chạy",- "sidebar.threads.more": "thêm {count}"+ "sidebar.threads.more": "thêm {count}",+ "botPanel.library.showAll": "Hiển thị tất cả"}diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 1a13c22fb4..faf8fa8ac1 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -4130,7 +4130,7 @@"botPanel.library.pages": "頁面","botPanel.library.apps": "應用程式","botPanel.library.files": "檔案",- "botPanel.library.scope": "來自這個對話",+ "botPanel.library.showAll": "顯示全部","botPanel.thisConversation": "在這個對話中","botPanel.acts.customHint": "在進階模式中變更","botPanel.section.settings": "設定",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex bbcfaa1bfd..d3e18a45bc 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -4164,7 +4164,7 @@"botPanel.library.pages": "页面","botPanel.library.apps": "应用","botPanel.library.files": "文件",- "botPanel.library.scope": "来自这个对话",+ "botPanel.library.showAll": "显示全部","botPanel.thisConversation": "在这个对话中","botPanel.acts.customHint": "在高级模式中修改","botPanel.section.settings": "设置",