Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Publish a bot from its ⋯ menus
milind-soni9739b9b94057
diff --git a/scripts/testing/store-read-ratchet.test.ts b/scripts/testing/store-read-ratchet.test.tsindex 9142052b26..b527ee3c9f 100644--- a/scripts/testing/store-read-ratchet.test.ts+++ b/scripts/testing/store-read-ratchet.test.ts@@ -142,7 +142,7 @@ const READS: Record<string, number> = {"src/components/TeamSettingsDialog.tsx": 1,"src/components/TeamSideSwitch.tsx": 2,"src/components/TeamWelcome.tsx": 1,- "src/components/TemplateCard.tsx": 4,+ "src/components/TemplateCard.tsx": 2,"src/components/ThreadChip.tsx": 1,"src/components/ThreadRefs.tsx": 1,"src/components/TrialCreditNotice.tsx": 1,diff --git a/src/App.tsx b/src/App.tsxindex f09cdafaa0..ab32b15e81 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -69,6 +69,7 @@ import { CloudSetup } from "@/components/CloudSetup";import { CloudWelcome } from "@/components/cloud-welcome/CloudWelcome";import { TeamWelcome } from "@/components/TeamWelcome";import { ConversationShareDialogs } from "@/components/conversation-share/ConversationShareDialogs";+import { PublishTemplateHost } from "@/components/publish-template";import { invitedToTeam, teamWelcomeDue, useTeamWelcomeRecord } from "@/lib/team-welcome";import { WelcomeKeeper } from "@/components/cloud-welcome/WelcomeKeeper";import { EmptyChatShell } from "@/components/onboarding/EmptyChatShell";@@ -400,6 +401,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {<WindowFrameBar notifications={notificationTray} sidebarUpdate={!advanced && sidebarShown} /><BotLimitPopup /><ConversationShareDialogs />+ <PublishTemplateHost />{!framed && strips}<div className="relative flex min-h-0 flex-1 overflow-x-clip">{!calendarFocus && <buttondiff --git a/src/components/ChatMoreMenu.test.ts b/src/components/ChatMoreMenu.test.tsindex 3ee6f9f449..f883db7252 100644--- a/src/components/ChatMoreMenu.test.ts+++ b/src/components/ChatMoreMenu.test.ts@@ -95,7 +95,7 @@ describe("ChatMoreMenu, the round ⋯ for the bot panel", () => {it("offers threads in Simple mode, and Usage and the Inspector unlocked", () => {const menu = menuOf(createElement(ChatMoreMenu, { bot }));- expect(keys(menu.items)).toEqual(["find", "new-thread", "threads", "start-fresh", "as-template", "copy", "download", "activity", "inspector"]);+ expect(keys(menu.items)).toEqual(["find", "new-thread", "threads", "start-fresh", "publish", "copy", "download", "activity", "inspector"]);for (const item of menu.items) {expect(item.disabled, item.key).toBeFalsy();expect(item.heading ?? "", item.key).not.toBe("In Advanced mode");@@ -157,7 +157,7 @@ describe("ChatMoreMenu, the round ⋯ for the bot panel", () => {it("leaves All threads out while the bot has one thread", () => {const single = { ...bot, threadId: "main", tasks: [task("main", "Our chat", 1), task("routine", "Morning digest", 5, { routineRunId: "run-1" })] };- expect(keys(menuOf(createElement(ChatMoreMenu, { bot: single })).items)).toEqual(["find", "new-thread", "start-fresh", "as-template", "copy", "download", "activity", "inspector"]);+ expect(keys(menuOf(createElement(ChatMoreMenu, { bot: single })).items)).toEqual(["find", "new-thread", "start-fresh", "publish", "copy", "download", "activity", "inspector"]);expect(keys(menuOf(createElement(ChatMoreMenu, { bot: { ...bot, tasks: undefined } })).items)).not.toContain("threads");});@@ -208,7 +208,7 @@ describe("the phone header's ⋯", () => {describe("ChatShareMenu, the bot panel's Share", () => {it("shares the bot as a template, or copies or downloads the conversation, in those words", () => {const menu = menuOf(createElement(ChatShareMenu, { bot, className: "" }));- expect(menu.items.map((item) => [item.key, item.label])).toEqual([["as-template", "Share as template"], ["copy", "Copy conversation"], ["download", "Download conversation"]]);+ expect(menu.items.map((item) => [item.key, item.label])).toEqual([["publish", "Publish"], ["copy", "Copy conversation"], ["download", "Download conversation"]]);});});@@ -216,7 +216,7 @@ describe("ChatHeaderMenu, Advanced mode's header ⋯", () => {it("keeps main's items, trigger and hover menu below the header", () => {fixture.advanced = true;const menu = menuOf(createElement(ChatHeaderMenu, { bot }));- expect(keys(menu.items)).toEqual(["find", "start-fresh", "as-template", "copy", "download", "activity", "inspector"]);+ expect(keys(menu.items)).toEqual(["find", "start-fresh", "publish", "copy", "download", "activity", "inspector"]);expect(menu.items.find((item) => item.key === "inspector")).toMatchObject({ separatorBefore: true });expect(menu.items.every((item) => !item.disabled && item.heading !== "In Advanced mode")).toBe(true);expect(menu).toMatchObject({ placement: "below", openOnHover: true });@@ -303,3 +303,23 @@ describe("sharing the conversation on screen, on a team", () => {expect(shareKeys(withSide({ private: true }))).toEqual([]);});});++describe("Publish's choices", () => {+ const choices = () => menuOf(createElement(ChatMoreMenu, { bot })).items.find((item) => item.key === "publish")!.submenu!.map((item) => item.key);+ afterAll(() => { (window as { ogb?: unknown }).ogb = undefined; });++ it("offers the team's templates to its admins only, and the repository to no member", () => {+ fixture.team = true;+ fixture.ownerOrAdmin = true;+ expect(choices()).toEqual(["publish:community", "publish:repo", "publish:team", "publish:download"]);+ fixture.ownerOrAdmin = false;+ expect(choices()).toEqual(["publish:community", "publish:download"]);+ });++ it("offers Save folder… on the desktop, not to a remote client", () => {+ (window as { ogb?: unknown }).ogb = { pickFolder: vi.fn() };+ expect(choices()).toEqual(["publish:community", "publish:repo", "publish:save", "publish:download"]);+ (window as { ogb?: unknown }).ogb = { pickFolder: vi.fn(), remoteClient: { active: true } };+ expect(choices()).toEqual(["publish:community", "publish:repo", "publish:download"]);+ });+});diff --git a/src/components/ChatMoreMenu.tsx b/src/components/ChatMoreMenu.tsxindex 9c642c7ea0..d257a0da14 100644--- a/src/components/ChatMoreMenu.tsx+++ b/src/components/ChatMoreMenu.tsx@@ -1,5 +1,5 @@import { useMemo, useState, type JSX } from "react";-import { Bug, Copy, Cpu, Download, Gauge, LayoutTemplate, ListChecks, MessagesSquare, Monitor, MoreHorizontal, RotateCcw, Search, Share, SquarePen, Star, UserPlus, UserRound, Users } from "lucide-react";+import { Bug, Copy, Cpu, Download, Gauge, ListChecks, MessagesSquare, Monitor, MoreHorizontal, RotateCcw, Search, Share, SquarePen, Star, UserPlus, UserRound, Users } from "lucide-react";import { currentTaskBot, openBotThread, visibleMessages, type Bot } from "@/state/store";import { useAdvancedMode } from "@/lib/interface-mode";import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";@@ -27,12 +27,11 @@ import { UsageBars } from "./EngineUsage";import { useConversationSide } from "./TeamSideSwitch";import { tasksOfSide } from "@/state/team-side";import { openConversationDialog, shareChoices } from "./conversation-share/conversation-share";-import { askBot } from "@/lib/template-share";-import { TEMPLATE_SHARE_MESSAGE } from "../../shared/share-card";+import { PUBLISH_ITEM, usePublishItem } from "./publish-template";import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select";/** One item list for the chat's ⋯ menu wherever it sits; it lists the threads whenever the sidebar hides them. The- * Simple bot panel draws the same items as rows, and its Share button holds the two that export. */+ * Simple bot panel draws the same items as rows, and its Share button holds Publish and the two that export. */export function useChatMoreItems(profile: Bot, phoneHeader = false): { items: SidebarMenuItem[]; on: boolean } {const bot = useMemo(() => currentTaskBot(profile), [profile]);const messages = useMemo(() => visibleMessages(bot), [bot]);@@ -55,9 +54,9 @@ export function useChatMoreItems(profile: Bot, phoneHeader = false): { items: Siconst canSetMain = ownerOrAdmin === true && !remoteClient && openTask !== undefined&& !openTask.routineRunId && !openTask.private && !openTask.openedBy && !isArchived(openTask);const isMain = bot.threadId === profile.mainThreadId;+ const publish = usePublishItem(profile);const shareItems: SidebarMenuItem[] = [- { key: TEMPLATE_ITEM, label: t("template.shareAsTemplate"), icon: <LayoutTemplate size={16} />,- onSelect: () => askBot(dispatch, profile.id, bot.threadId, TEMPLATE_SHARE_MESSAGE) },+ ...(publish ? [publish] : []),...(sharing.team ? [{ key: "share-team", label: t("conversationShare.withTeam"), icon: <Users size={16} />,onSelect: () => openConversationDialog({ kind: "team", botId: profile.id, threadId: bot.threadId }) }] : []),...(sharing.person ? [{ key: "share-person", label: t("conversationShare.withPerson"), icon: <UserPlus size={16} />,@@ -233,8 +232,6 @@ export function ChatMoreMenu({ bot, phoneHeader = false }: { bot: Bot; phoneHead}export const EXPORT_ITEMS = ["copy", "download"];-/** Asks the bot to make a shareable template of itself. */-export const TEMPLATE_ITEM = "as-template";/** The bot panel's round Share button: on a team who has access, with copying or downloading this conversation under* the ⋯ of its header; anywhere else a menu of those two. */@@ -243,15 +240,15 @@ export function ChatShareMenu({ bot, className }: { bot: Bot; className: string: <ShareMenu key={bot.threadId} bot={bot} className={className} />;}-/** The Share button's items: the bot as a template, then this conversation copied or downloaded. */+/** The Share button's items: Publish, then this conversation copied or downloaded. */const exportItems = (items: SidebarMenuItem[]): SidebarMenuItem[] => [- ...items.filter((item) => item.key === TEMPLATE_ITEM).map((item) => ({ ...item, separatorBefore: false })),+ ...items.filter((item) => item.key === PUBLISH_ITEM).map((item) => ({ ...item, separatorBefore: false })),...items.filter((item) => EXPORT_ITEMS.includes(item.key)).map((item, index) => ({...item, heading: undefined, separatorBefore: index === 0, label: t(item.key === "copy" ? "chat.export.copyConversation" : "chat.export.downloadConversation"),})),];-/** The ⋯ in a team bot's Share dialog: the bot as a template, and this conversation copied or downloaded. */+/** The ⋯ in a team bot's Share dialog: Publish, and this conversation copied or downloaded. */export function ExportMore({ bot }: { bot: Bot }) {const { items } = useChatMoreItems(bot);return (diff --git a/src/components/ChatView.controls.test.ts b/src/components/ChatView.controls.test.tsindex 793d5869f2..4ceaafd152 100644--- a/src/components/ChatView.controls.test.ts+++ b/src/components/ChatView.controls.test.ts@@ -101,7 +101,7 @@ describe("the header's right side", () => {expect(markup).toContain('data-tour="computer"');expect(markup).toContain('data-testid="chat-more"');const more = fixture.menus.find((menu) => menu.ariaLabel === "More")!;- expect(more.items.map((item) => item.key)).toEqual(["find", "new-thread", "start-fresh", "as-template", "copy", "download"]);+ expect(more.items.map((item) => item.key)).toEqual(["find", "new-thread", "start-fresh", "publish", "copy", "download"]);} finally {delete window.ogb;fixture.advanced = true;@@ -136,7 +136,7 @@ describe("the header's right side", () => {expect(markup).toContain('data-tour="computer"');expect(markup).toContain('data-testid="chat-more"');const more = fixture.menus.find((menu) => menu.ariaLabel === "More")!;- expect(more.items.map((item) => item.key)).toEqual(["find", "start-fresh", "as-template", "copy", "download", "activity", "inspector"]);+ expect(more.items.map((item) => item.key)).toEqual(["find", "start-fresh", "publish", "copy", "download", "activity", "inspector"]);const inspector = more.items.find((item) => item.key === "inspector")!;expect(inspector.disabled).toBeFalsy();expect(inspector.heading).toBeUndefined();diff --git a/src/components/ImportDialog.test.ts b/src/components/ImportDialog.test.tsindex 409663f2ea..321584cca0 100644--- a/src/components/ImportDialog.test.ts+++ b/src/components/ImportDialog.test.ts@@ -16,7 +16,7 @@ vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => place.adminconst openLink = vi.fn(async (_url: string) => {});vi.mock("@/lib/app-links", () => ({ openExternalLink: (url: string) => openLink(url) }));const { ImportDialog } = await import("./ImportDialog");-const { ShareDepartmentDialog } = await import("./ShareDepartmentDialog");+const { ShareTemplateDialog } = await import("./ShareTemplateDialog");const details: TemplateDetails = {scope: "bot", name: "Quill", tagline: "Writes outreach.", bots: [{ key: "quill", name: "Quill", color: "purple", skills: [] }],@@ -129,7 +129,7 @@ describe("a department's Share", () => {it("makes the template at once and publishes it to the community, then shows the link and the pull request", async () => {api.mockImplementation(async (path: string) => path === "/api/share/export" ? card: { ...card, status: "published", link: LINK, prUrl: "https://github.com/milind-soni/openmausbot-teams/pull/9" });- const view = mount(createElement(ShareDepartmentDialog, { department: "Sales desk", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Sales desk" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(document.body.textContent).toContain("2 bots · 1 skill · 1 routine (paused)"));expect(api).toHaveBeenCalledWith("/api/share/export", { method: "POST", body: JSON.stringify({ department: "Sales desk" }) });@@ -150,7 +150,7 @@ describe("a department's Share", () => {replaced = true;return answer;});- const view = mount(createElement(ShareDepartmentDialog, { department: "Sales desk", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Sales desk" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(button("Add to Acme's templates")).toBeTruthy());button("Add to Acme's templates")!.click();@@ -166,7 +166,7 @@ describe("a department's Share", () => {api.mockImplementation(async (path: string) => path === "/api/share/export" ? card: path === "/api/share/github" ? (connected ? { connected: true } : { connected: false, reason: "not_connected", error: "Connect GitHub in Apps first." }): { kind: "pull_request", url: "https://github.com/acme/playbooks/pull/3", link: "https://github.com/acme/playbooks/tree/mausbot-sales-desk-abc123/sales-desk", branch: "mausbot-sales-desk-abc123" });- const view = mount(createElement(ShareDepartmentDialog, { department: "Sales desk", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Sales desk" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(button("Your GitHub repo…")).toBeTruthy());expect(button("Add to Acme's templates")).toBeUndefined();@@ -193,7 +193,7 @@ describe("a department's Share", () => {it("shows the server's own sentence when GitHub is refused here, with no Open Apps", async () => {api.mockImplementation(async (path: string) => path === "/api/share/export" ? card: { connected: false, reason: "refused", error: "Acme's rules turn GitHub off." });- const view = mount(createElement(ShareDepartmentDialog, { department: "Sales desk", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Sales desk" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(button("Your GitHub repo…")).toBeTruthy());button("Your GitHub repo…")!.click();@@ -207,7 +207,7 @@ describe("a department's Share", () => {place.state = { config: { team: { id: "t1", name: "Acme" } } };place.admin = false;api.mockResolvedValue(card);- const view = mount(createElement(ShareDepartmentDialog, { department: "Sales desk", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Sales desk" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(button("Publish to community")).toBeTruthy());expect(button("Your GitHub repo…")).toBeUndefined();@@ -217,7 +217,7 @@ describe("a department's Share", () => {it("says why it couldn't be made, with Try again", async () => {api.mockRejectedValueOnce(new Error("This department has no bots to share.")).mockResolvedValueOnce(card);- const view = mount(createElement(ShareDepartmentDialog, { department: "Empty", onClose: vi.fn() }));+ const view = mount(createElement(ShareTemplateDialog, { target: { department: "Empty" }, onClose: vi.fn() }));try {await vi.waitFor(() => expect(document.body.textContent).toContain("This department has no bots to share."));button("Try again")!.click();diff --git a/src/components/ShareDepartmentDialog.tsx b/src/components/ShareTemplateDialog.tsxsimilarity index 57%rename from src/components/ShareDepartmentDialog.tsxrename to src/components/ShareTemplateDialog.tsxindex 7aed86167f..05393805c6 100644--- a/src/components/ShareDepartmentDialog.tsx+++ b/src/components/ShareTemplateDialog.tsx@@ -1,16 +1,32 @@-import { useEffect, useId, useState } from "react";+import { useEffect, useId, useRef, useState } from "react";import { Loader2 } from "lucide-react";import type { TemplateCard } from "../../shared/share-card";import { t } from "@/lib/i18n";-import { exportDepartment } from "@/lib/template-share";+import { exportTemplate } from "@/lib/template-share";+import type { PublishAction } from "./publish-template";import { TemplateButtons, TemplateCardBody, TemplateModal, TemplateNotes, TemplateRepoPublishDialog, useRepoPublishOffered, useTeamTemplatesOwner, useTemplateActions } from "./TemplateCard";-function Shared({ card }: { card: TemplateCard }) {+/** The template's card and its buttons. `action` is the one chosen from a bot's Publish menu, run once the card is here;+ * Publish waits for the name Published by starts with, and never runs for a card that can't be published. */+function Shared({ card, action }: { card: TemplateCard; action?: PublishAction }) {const actions = useTemplateActions(card);const team = useTeamTemplatesOwner();const repoOffered = useRepoPublishOffered();- const [repo, setRepo] = useState(false);+ const [repo, setRepo] = useState(action === "repo");+ const pending = useRef(action === "repo" ? undefined : action);+ const { authorKnown } = actions;+ useEffect(() => {+ const chosen = pending.current;+ if (!chosen || (chosen === "community" && !authorKnown)) return;+ pending.current = undefined;+ if (chosen === "community") {+ if (!card.fallback && !card.secret && card.status !== "published") void actions.publish();+ } else if (chosen === "team") {+ if (team) void actions.addToTeam(team);+ } else if (chosen === "save") void actions.save();+ else void actions.download();+ });return <><div className="rounded-xl border border-hairline/40 px-3 py-2.5"><TemplateCardBody card={actions.card} />@@ -34,24 +50,30 @@ function Shared({ card }: { card: TemplateCard }) {</>;}-/** A department's Share: its template, made at once, with Publish to community and Save folder…. No fields, nothing to tick. */-export function ShareDepartmentDialog({ department, onClose }: { department: string; onClose: () => void }) {+export type ShareTemplateTarget = { department: string } | { botId: string; name: string; action: PublishAction };++/** A department's Share, or what a bot's Publish chose: its template, made at once, with Publish to community and Save+ * folder…. No fields, nothing to tick. */+export function ShareTemplateDialog({ target, onClose }: { target: ShareTemplateTarget; onClose: () => void }) {const [card, setCard] = useState<TemplateCard | null>(null);const [error, setError] = useState("");const [attempt, setAttempt] = useState(0);const titleId = useId();+ const department = "department" in target ? target.department : null;+ const botId = "botId" in target ? target.botId : null;useEffect(() => {let live = true;setError("");- exportDepartment(department).then((made) => { if (live) setCard(made); },+ exportTemplate(department !== null ? { department } : { botId: botId! }).then((made) => { if (live) setCard(made); },(cause: unknown) => { if (live) setError(cause instanceof Error && cause.message ? cause.message : t("template.failed")); });return () => { live = false; };- }, [department, attempt]);+ }, [department, botId, attempt]);return (- <TemplateModal title={t("template.shareDepartment", { name: department })} labelledBy={titleId} onClose={onClose}+ <TemplateModal title={department !== null ? t("template.shareDepartment", { name: department }) : t("template.publishTitle", { name: "name" in target ? target.name : "" })}+ labelledBy={titleId} onClose={onClose}footer={<button type="button" className="ui-button ui-button-md" onClick={onClose}>{t("common.close")}</button>}>- <div data-share-department={department}>- {card ? <Shared card={card} />+ <div data-share-department={department ?? undefined} data-publish-bot={botId ?? undefined}>+ {card ? <Shared card={card} action={"action" in target ? target.action : undefined} />: error ? <div role="alert" className="text-[13px] text-danger"><p dir="auto">{error}</p><button type="button" className="ui-button ui-button-md mt-2" onClick={() => setAttempt((value) => value + 1)}>{t("common.tryAgain")}</button>diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsxindex 4cdf7417eb..16f9ecaebd 100644--- a/src/components/Sidebar.tsx+++ b/src/components/Sidebar.tsx@@ -28,7 +28,7 @@ import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";import { nextRename } from "@/lib/rename";import { useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";import { MIN_QUERY, SearchResults } from "./SearchResults";-import { ImportDialog, ShareDepartmentDialog, TeamDialog, TeamLibraryPanel, TeamSettingsDialog } from "./lazy-screens";+import { ImportDialog, ShareTemplateDialog, TeamDialog, TeamLibraryPanel, TeamSettingsDialog } from "./lazy-screens";import { SidebarNewChatPanel } from "./SidebarNewChatPanel";import { openCommandPalette } from "./CommandPalette";import { RenameTitle } from "./RenameTitle";@@ -1542,7 +1542,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =.finally(() => { teamDeleteRunning.current = false; setTeamDeletePending(false); });}} />{moveToTeam && <TeamDialog section={moveToTeam} onClose={() => setMoveToTeam(null)} />}- {shareTeam !== null && <ShareDepartmentDialog department={shareTeam} onClose={() => setShareTeam(null)} />}+ {shareTeam !== null && <ShareTemplateDialog target={{ department: shareTeam }} onClose={() => setShareTeam(null)} />}{teamSettings !== null && <TeamSettingsDialog team={teamSettings} onClose={() => setTeamSettings(null)} />}<SectionPickercurrent={sectionPicker ? state.bots.find((b) => b.id === sectionPicker.botId)?.section : undefined}diff --git a/src/components/SidebarBotMenu.tsx b/src/components/SidebarBotMenu.tsxindex 3953176c34..d7ec77ab95 100644--- a/src/components/SidebarBotMenu.tsx+++ b/src/components/SidebarBotMenu.tsx@@ -1,6 +1,6 @@import { useEffect, useLayoutEffect, useRef, useState } from "react";import { createPortal } from "react-dom";-import { Archive, BellDot, Check, CheckCheck, ChevronRight, ClipboardCopy, Copy, Crown, FolderMinus, FolderOpen, FolderPlus, Loader2, MessagesSquare, MoreHorizontal, Pause, Pencil, Pin, PinOff, Play, SquarePen, Star, Trash2, Users } from "lucide-react";+import { Archive, BellDot, Check, CheckCheck, ChevronRight, ClipboardCopy, Copy, Crown, FolderMinus, FolderOpen, FolderPlus, Loader2, MessagesSquare, MoreHorizontal, Pause, Pencil, Pin, PinOff, Play, SquarePen, Star, Trash2, Upload, Users } from "lucide-react";import { isBotHeld, isEveryBotPaused, isPausedHere, setEveryBotPaused, setPaused } from "@/lib/bot-pause";import { api, useStore, openBot, type Bot } from "@/state/store";import { cn } from "@/lib/cn";@@ -28,8 +28,9 @@ import { departmentNames, moveBotsToSection, useMayMoveBots } from "./bot-sectioimport { openBotSettings } from "./bot-panel/panel-link";import { ShortcutHint } from "./ShortcutHint";import { isArchived } from "./SidebarThreadRow";+import { usePublishChoices } from "./publish-template";-type Flyout = "more" | "move";+type Flyout = "more" | "move" | "publish";export function BotContextMenu({menu,@@ -57,6 +58,7 @@ export function BotContextMenu({const simpleMenu = !useAdvancedMode();const moreRef = useRef<HTMLButtonElement>(null);const moveRef = useRef<HTMLButtonElement>(null);+ const publishRef = useRef<HTMLButtonElement>(null);const flyoutRef = useRef<HTMLDivElement>(null);const hoveredRow = useRef<Element | null>(null);const [flyout, setFlyout] = useState<Flyout | null>(null);@@ -67,8 +69,9 @@ export function BotContextMenu({close: () => { setFlyout(null); setMoreEngaged(false); },submenuBox: () => flyoutRef.current?.getBoundingClientRect() ?? null,});- const flyoutRow = (key: Flyout | null) => (key === "more" ? moreRef.current : key === "move" ? moveRef.current : null);- const rowFlyout = (row: Element | null): Flyout | null => (row && row === moreRef.current ? "more" : row && row === moveRef.current ? "move" : null);+ const flyoutRows = { more: moreRef, move: moveRef, publish: publishRef };+ const flyoutRow = (key: Flyout | null) => (key ? flyoutRows[key].current : null);+ const rowFlyout = (row: Element | null): Flyout | null => (row && (Object.keys(flyoutRows) as Flyout[]).find((key) => flyoutRows[key].current === row)) || null;const more = moreIntent.current;const shown = motion.value;const { state, dispatch } = useStore();@@ -78,6 +81,7 @@ export function BotContextMenu({const mayMove = useMayMoveBots();const clearThreads = useDeleteAllThreads(simpleMenu), moveToTeam = useMoveToTeam({ blocked: (bot) => (bot.defaultBot ? t("teamMove.blockedDefault", { name: bot.name }) : bot.chiefOfStaff ? t("teamMove.blockedChief") : state.bots.filter((candidate) => !candidate.hidden).length <= 1 ? t("teamMove.blockedLast") : undefined) });const moveToCloud = useMoveToMyCloud();+ const publishChoices = usePublishChoices();const remoteClient = window.ogb?.remoteClient?.active === true;const bot = shown ? state.bots.find((b) => b.id === shown.botId) : undefined;const team = useTeamPeople();@@ -222,11 +226,86 @@ export function BotContextMenu({const newThreadHint = state.selectedId === bot.id ? <ShortcutHint id="new-thread" /> : undefined;+ const showFlyout = (key: Flyout, focus: boolean) => {+ more.openNow(key);+ if (focus) requestAnimationFrame(() => flyoutRef.current?.querySelector<HTMLButtonElement>("button:not([disabled])")?.focus());+ };+ const flyoutButton = (key: Flyout, ref: React.RefObject<HTMLButtonElement | null>, icon: React.ReactNode, label: string) => (+ <button+ key={key}+ ref={ref}+ type="button"+ role="menuitem"+ data-bot-menu-more={key === "more" ? "" : undefined}+ data-bot-menu-move={key === "move" ? "" : undefined}+ data-bot-menu-publish={key === "publish" ? "" : undefined}+ aria-haspopup="menu"+ aria-expanded={flyout === key}+ onClick={(event) => (flyout === key ? more.closeNow() : showFlyout(key, event.detail === 0))}+ onKeyDown={(event) => {+ if (event.key !== "ArrowRight") return;+ event.preventDefault();+ showFlyout(key, true);+ }}+ className={cn(MENU_ITEM, "text-ink hover:bg-menu-hover", flyout === key && moreEngaged && "bg-menu-active")}+ >+ {icon}+ <span className="flex-1">{label}</span>+ <ChevronRight size={15} aria-hidden="true" className="text-ink-secondary rtl:-scale-x-100" />+ </button>+ );+ const publishItems = publishChoices(bot).map((choice) => item(<span className="flex text-ink-secondary">{choice.icon}</span>, choice.label, choice.onSelect));+ const publishRow = publishItems.length ? flyoutButton("publish", publishRef, <Upload size={16} className="text-ink-secondary" />, t("template.publish")) : null;+ const flyoutPointer = {+ onPointerOver: (event: React.PointerEvent) => {+ const row = event.target instanceof Element ? event.target.closest('[role="menuitem"]') : null;+ if (!row || row === hoveredRow.current) return;+ const left = rowFlyout(hoveredRow.current);+ if (left) more.leaveRow(left);+ hoveredRow.current = row;+ const key = rowFlyout(row);+ more.enterRow(key ?? "row", key !== null, { x: event.clientX, y: event.clientY });+ },+ onPointerMove: (event: React.PointerEvent) => more.move({ x: event.clientX, y: event.clientY }, flyoutRow(flyout)?.contains(event.target as Node) === true),+ onPointerLeave: () => {+ const left = rowFlyout(hoveredRow.current);+ if (left) more.leaveRow(left);+ hoveredRow.current = null;+ more.leaveMenu();+ },+ };+ const flyoutSheet = (rows: Partial<Record<Flyout, React.ReactNode[]>>) => flyout && createPortal(+ <div+ ref={flyoutRef}+ data-bot-menu+ data-bot-menu-flyout={flyout}+ data-sidebar+ role="menu" data-look="menu"+ aria-label={flyout === "more" ? t("sidebar.bot.more") : flyout === "move" ? t("sidebar.bot.moveToSection") : t("template.publish")}+ onPointerEnter={() => { more.enterSubmenu(); setMoreEngaged(true); }}+ onPointerLeave={() => setMoreEngaged(false)}+ onFocus={() => setMoreEngaged(true)}+ onBlur={(event) => { if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) setMoreEngaged(false); }}+ onKeyDown={(event) => {+ if (event.key === "ArrowLeft" || event.key === "Escape") {+ event.preventDefault();+ event.stopPropagation();+ const row = flyoutRow(flyout);+ more.closeNow();+ row?.focus();+ return;+ }+ navigateThreadMenu(event);+ }}+ style={{ top: shown.y, left: shown.x }}+ className={cn("fixed z-40 max-h-[calc(100dvh-16px)] w-max min-w-[180px] max-w-[calc(100vw-16px)] animate-pop-in overflow-y-auto overscroll-contain", MENU_SHEET)}+ >+ {rows[flyout]}+ </div>,+ document.body,+ );+if (simpleMenu) {- const showFlyout = (key: Flyout, focus: boolean) => {- more.openNow(key);- if (focus) requestAnimationFrame(() => flyoutRef.current?.querySelector<HTMLButtonElement>("button:not([disabled])")?.focus());- };const copyId = item(<ClipboardCopy size={16} className="text-ink-secondary" />, t("sidebar.copyConversationId"), () => { void copyText(bot.threadId); });const current = bot.section?.trim() ?? "";const departments = departmentNames(state);@@ -239,29 +318,6 @@ export function BotContextMenu({...(onNewSection ? [item(<FolderPlus size={16} className="text-ink-secondary" />, t("sidebar.section.newContext"), () => onNewSection(bot.id))] : []),...(current ? [item(<FolderMinus size={16} className="text-ink-secondary" />, t("sidebar.section.removeFromDepartment"), () => moveBotsToSection(dispatch, [bot.id], ""))] : []),];- const flyoutButton = (key: Flyout, ref: React.RefObject<HTMLButtonElement | null>, icon: React.ReactNode, label: string) => (- <button- key={key}- ref={ref}- type="button"- role="menuitem"- data-bot-menu-more={key === "more" ? "" : undefined}- data-bot-menu-move={key === "move" ? "" : undefined}- aria-haspopup="menu"- aria-expanded={flyout === key}- onClick={(event) => (flyout === key ? more.closeNow() : showFlyout(key, event.detail === 0))}- onKeyDown={(event) => {- if (event.key !== "ArrowRight") return;- event.preventDefault();- showFlyout(key, true);- }}- className={cn(MENU_ITEM, "text-ink hover:bg-menu-hover", flyout === key && moreEngaged && "bg-menu-active")}- >- {icon}- <span className="flex-1">{label}</span>- <ChevronRight size={15} aria-hidden="true" className="text-ink-secondary rtl:-scale-x-100" />- </button>- );const moveToSection = mayMove ? flyoutButton("move", moveRef, <FolderPlus size={16} className="text-ink-secondary" />, t("sidebar.bot.moveToSection")) : null;const rename = onRename && (team ? mayRename(bot, team) : !state.config?.team) && item(<SquarePen size={16} className="text-ink-secondary" />, t("sidebar.bot.rename"), () => onRename(bot.id));const editProfile = item(<Pencil size={16} className="text-ink-secondary" />, t("sidebar.bot.simple.editProfile"), () => {@@ -320,26 +376,11 @@ export function BotContextMenu({role="menu" data-look="menu"aria-label={t("sidebar.bot.actions", { name: bot.name })}onKeyDown={navigateThreadMenu}- onPointerOver={(event) => {- const row = event.target instanceof Element ? event.target.closest('[role="menuitem"]') : null;- if (!row || row === hoveredRow.current) return;- const left = rowFlyout(hoveredRow.current);- if (left) more.leaveRow(left);- hoveredRow.current = row;- const key = rowFlyout(row);- more.enterRow(key ?? "row", key !== null, { x: event.clientX, y: event.clientY });- }}- onPointerMove={(event) => more.move({ x: event.clientX, y: event.clientY }, flyoutRow(flyout)?.contains(event.target as Node) === true)}- onPointerLeave={() => {- const left = rowFlyout(hoveredRow.current);- if (left) more.leaveRow(left);- hoveredRow.current = null;- more.leaveMenu();- }}+ {...flyoutPointer}style={{ top: shown.y, left: shown.x }}className={cn("fixed z-40 max-h-[calc(100dvh-16px)] w-max min-w-[198px] max-w-[calc(100vw-16px)] overflow-y-auto overscroll-contain", MENU_SHEET, motion.className)} {...motion.exitProps}>- {remoteClient ? [moveToSection, ...threads, ...(rename ? [divider("rename"), rename] : []), divider("copy"), copyId, moreRow] : [+ {remoteClient ? [moveToSection, ...threads, ...(rename ? [divider("rename"), rename] : []), divider("copy"), publishRow, copyId, moreRow] : [item(bot.pinned ? <PinOff size={16} className="text-ink-secondary" /> : <Pin size={16} className="text-ink-secondary" />,bot.pinned ? t("sidebar.bot.unpin") : t("sidebar.bot.pin"),@@ -350,6 +391,7 @@ export function BotContextMenu({...threads,...(rename ? [divider("rename"), rename] : []),divider("copy"),+ publishRow,copyId,moreRow,...(leave.length ? [divider("leave"), ...leave] : []),@@ -357,36 +399,7 @@ export function BotContextMenu({{readError?.botId === bot.id && <p role="alert" className="px-2 py-1.5 text-[12px] text-danger">{readError.message}</p>}</div>,document.body,- )}{flyout && createPortal(- <div- ref={flyoutRef}- data-bot-menu- data-bot-menu-flyout={flyout}- data-sidebar- role="menu" data-look="menu"- aria-label={flyout === "more" ? t("sidebar.bot.more") : t("sidebar.bot.moveToSection")}- onPointerEnter={() => { more.enterSubmenu(); setMoreEngaged(true); }}- onPointerLeave={() => setMoreEngaged(false)}- onFocus={() => setMoreEngaged(true)}- onBlur={(event) => { if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) setMoreEngaged(false); }}- onKeyDown={(event) => {- if (event.key === "ArrowLeft" || event.key === "Escape") {- event.preventDefault();- event.stopPropagation();- const row = flyoutRow(flyout);- more.closeNow();- row?.focus();- return;- }- navigateThreadMenu(event);- }}- style={{ top: shown.y, left: shown.x }}- className={cn("fixed z-40 max-h-[calc(100dvh-16px)] w-max min-w-[180px] max-w-[calc(100vw-16px)] animate-pop-in overflow-y-auto overscroll-contain", MENU_SHEET)}- >- {flyout === "more" ? moreItems : moveItems}- </div>,- document.body,- )}</>;+ )}{flyoutSheet({ more: moreItems, move: moveItems, publish: publishItems })}</>;}return <>{clearThreads.dialog}{moveToTeam.dialog}{moveToCloud.dialog}{createPortal(@@ -397,6 +410,7 @@ export function BotContextMenu({role="menu" data-look="menu"aria-label={t("sidebar.bot.actions", { name: bot.name })}onKeyDown={navigateThreadMenu}+ {...flyoutPointer}style={{ top: shown.y, left: shown.x }}className={cn("fixed z-40 max-h-[calc(100dvh-16px)] w-max min-w-[198px] max-w-[calc(100vw-16px)] overflow-y-auto overscroll-contain", MENU_SHEET, motion.className)} {...motion.exitProps}>@@ -418,6 +432,7 @@ export function BotContextMenu({openForSettings();if (!state.settingsOpen) dispatch({ type: "toggleSettings", open: true });}),+ publishRow,item(<ClipboardCopy size={16} className="text-ink-secondary" />, t("sidebar.copyConversationId"), () => {void copyText(bot.threadId);}),@@ -452,6 +467,7 @@ export function BotContextMenu({pause,pauseAll,divider("d2"),+ publishRow,item(<ClipboardCopy size={16} className="text-ink-secondary" />, t("sidebar.copyConversationId"), () => {void copyText(bot.threadId);}),@@ -464,5 +480,5 @@ export function BotContextMenu({{readError?.botId === bot.id && <p role="alert" className="px-2 py-1.5 text-[12px] text-danger">{readError.message}</p>}</div>,document.body,- )}</>;+ )}{flyoutSheet({ publish: publishItems })}</>;}diff --git a/src/components/SidebarBotRead.test.ts b/src/components/SidebarBotRead.test.tsindex d246187737..af18554641 100644--- a/src/components/SidebarBotRead.test.ts+++ b/src/components/SidebarBotRead.test.ts@@ -168,13 +168,13 @@ describe("Simple mode's bot menu", () => {const point = (target: Element, y: number) => target.dispatchEvent(new MouseEvent("pointerover", { bubbles: true, clientX: 60, clientY: y }));beforeEach(() => { mode.advanced = false; });- it("leads with Pin, Move and Mark as read, then the thread items, then Rename, then Copy conversation ID and More, and ends with Archive and Delete", () => {+ it("leads with Pin, Move and Mark as read, then the thread items, then Rename, then Publish, Copy conversation ID and More, and ends with Archive and Delete", () => {draw();expect([...sheet().querySelectorAll("button")].map((node) => node.textContent)).toEqual([- "Pin", "Move to department", "Mark as read", "New thread", "View threads", "Rename", "Copy conversation ID", "More", "Archive", "Delete",+ "Pin", "Move to department", "Mark as read", "New thread", "View threads", "Rename", "Publish", "Copy conversation ID", "More", "Archive", "Delete",]);expect([...sheet().children].map((node) => node.getAttribute("role") === "separator" ? "|" : node.textContent)).toEqual([- "Pin", "Move to department", "Mark as read", "|", "New thread", "View threads", "|", "Rename", "|", "Copy conversation ID", "More", "|", "Archive", "Delete",+ "Pin", "Move to department", "Mark as read", "|", "New thread", "View threads", "|", "Rename", "|", "Publish", "Copy conversation ID", "More", "|", "Archive", "Delete",]);flushSync(() => button("Rename").click());expect(onRename).toHaveBeenCalledWith(bot.id);diff --git a/src/components/TemplateCard.tsx b/src/components/TemplateCard.tsxindex 4067a77d59..92a932e34f 100644--- a/src/components/TemplateCard.tsx+++ b/src/components/TemplateCard.tsx@@ -1,5 +1,5 @@-// A shareable template of a bot or a department: its card (in the chat and in the department's Share), what it brings-// (the Details sheet, also Import's preview), and the card's actions.+// A shareable template of a bot or a department: its card (in the chat, in a department's Share and after a bot's Publish),+// what it brings (the Details sheet, also Import's preview), and the card's actions.import { useEffect, useId, useRef, useState, type ReactNode } from "react";import { createPortal } from "react-dom";import { ArrowUpRight, Check, ChevronDown, Copy, FolderDown, Github, Library, Loader2, MoreHorizontal, RefreshCw, Trash2, Upload } from "lucide-react";@@ -11,7 +11,7 @@ import { openExternalLink } from "@/lib/app-links";import { cn } from "@/lib/cn";import { useCopyFeedback } from "@/lib/copy-text";import { t } from "@/lib/i18n";-import { addToTeamTemplates, askBot, countsLine, creditShown, deleteTemplate, githubConnection, publishTemplate, publishToRepo, saveTemplateFolder, scrubbedLine, templateDetails } from "@/lib/template-share";+import { addToTeamTemplates, askBot, countsLine, creditShown, deleteTemplate, downloadTemplate, githubConnection, publishTemplate, publishToRepo, saveTemplateFolder, scrubbedLine, templateDetails } from "@/lib/template-share";import { profileForSession, readSessionState, type SessionState } from "@/lib/session";import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";import { useModalDialog } from "@/hooks/use-modal-dialog";@@ -85,8 +85,8 @@ export function TemplateCardBody({ card }: { card: TemplateCard }) {);}-/** The profile's name when the profile is this person's own (not a shared workspace's owner's). */-function useOwnProfileName(): string {+/** The profile's name when the profile is this person's own (not a shared workspace's owner's); null until known. */+function useOwnProfileName(): string | null {const profile = useStoreSelector((state) => state.config?.profile);const [session, setSession] = useState<SessionState | null>(null);useEffect(() => {@@ -94,19 +94,20 @@ function useOwnProfileName(): string {void readSessionState().then((next) => { if (live) setSession(next); });return () => { live = false; };}, []);- return profileForSession(profile, session)?.name?.trim() ?? "";+ return session ? profileForSession(profile, session)?.name?.trim() ?? "" : null;}/** What the card's buttons do. The card shown is the latest the server answered, until the message brings a newer one. */export function useTemplateActions(initial: TemplateCard) {const [card, setCard] = useState(initial);- const [busy, setBusy] = useState<"publish" | "save" | "delete" | "team" | null>(null);+ const [busy, setBusy] = useState<"publish" | "save" | "download" | "delete" | "team" | null>(null);const [error, setError] = useState("");const [saved, setSaved] = useState<string | null>(null);+ const [downloaded, setDownloaded] = useState<string | null>(null);const [teamNote, setTeamNote] = useState<string | null>(null);const profileName = useOwnProfileName();const [typed, setAuthor] = useState<string | null>(null);- const author = typed ?? card.author ?? profileName;+ const author = typed ?? card.author ?? profileName ?? "";useEffect(() => setCard(initial), [initial]);const run = async (kind: NonNullable<typeof busy>, work: () => Promise<void>) => {if (busy) return;@@ -121,7 +122,9 @@ export function useTemplateActions(initial: TemplateCard) {}};return {- card, busy, error, saved, teamNote, author, setAuthor,+ card, busy, error, saved, downloaded, teamNote, author, setAuthor,+ /** Whether `author` is settled: the profile's name, which Published by starts with, is read once. */+ authorKnown: typed !== null || card.author !== undefined || profileName !== null,/** Adds it to the Team Cloud's own templates, replacing one of the same name there. */addToTeam: (team: string) => run("team", async () => {setTeamNote(null);@@ -137,6 +140,7 @@ export function useTemplateActions(initial: TemplateCard) {}}),save: () => run("save", async () => setSaved(await saveTemplateFolder(card))),+ download: () => run("download", async () => setDownloaded(await downloadTemplate(card))),remove: () => run("delete", async () => {await deleteTemplate(card.id);setCard((current) => ({ ...current, status: "gone" }));@@ -214,30 +218,30 @@ function PublishedByField({ actions }: { actions: TemplateActions }) {/** One line under the buttons: why Publish isn't offered, the publish error, the last action's error, or where the folder went. */export function TemplateNotes({ actions }: { actions: TemplateActions }) {- const { card, error, saved, teamNote } = actions;+ const { card, error, saved, downloaded, teamNote } = actions;return <>{card.fallback && <p className="mt-1.5 text-[12px] text-ink-secondary">{t(card.fallback === "sign_in" ? "template.signInToPublish" : "template.publishUnavailable")}</p>}{card.secret && card.status !== "gone" && card.status !== "published" && !card.fallback && <p role="alert" data-template-secret className="mt-1.5 text-[12px] text-danger">{t("template.secretFound")}</p>}{card.status === "failed" && card.error && !card.secret && <p role="alert" dir="auto" className="mt-1.5 text-[12px] text-danger">{card.error}</p>}{error && <p role="alert" dir="auto" className="mt-1.5 text-[12px] text-danger">{error}</p>}{saved && <p role="status" dir="auto" className="mt-1.5 truncate text-[12px] text-ink-secondary" title={saved}>{t("template.savedTo", { path: saved })}</p>}+ {downloaded && <p role="status" dir="auto" className="mt-1.5 truncate text-[12px] text-ink-secondary" title={downloaded}>{t("template.downloaded", { file: downloaded })}</p>}{teamNote && <p role="status" dir="auto" className="mt-1.5 text-[12px] text-ink-secondary">{teamNote}</p>}</>;}/** On a Team Cloud, its name when the person is its owner or an admin, who add templates to its library; else null. */export function useTeamTemplatesOwner(): string | null {- const { state } = useStore();+ const team = useStoreSelector((state) => state.config?.team?.name);const admin = useOwnerOrAdmin();- const team = state.config?.team?.name;return team && admin === true ? team : null;}/** Publishing to one's own repository goes through Share's routes, which a Team Cloud keeps for its owner and admins. */export function useRepoPublishOffered(): boolean {- const { state } = useStore();+ const onTeam = useStoreSelector((state) => Boolean(state.config?.team));const admin = useOwnerOrAdmin();- return !state.config?.team || admin === true;+ return !onTeam || admin === true;}/** The template card a bot posts in its chat. `botId` and `threadId` are this chat's, for Update; a group chat leaves them out. */diff --git a/src/components/bot-panel/PanelShell.dom.test.ts b/src/components/bot-panel/PanelShell.dom.test.tsindex c04984a752..adfe6fb27c 100644--- a/src/components/bot-panel/PanelShell.dom.test.ts+++ b/src/components/bot-panel/PanelShell.dom.test.ts@@ -196,7 +196,7 @@ describe("the panel's top", () => {expect(top.map((button) => button.getAttribute("aria-label") ?? button.getAttribute("title"))).toEqual(["Share", "Bot settings", "Close settings"]);for (const button of [moreButton()!, top[1]!, top[2]!]) expect(button.querySelector("span, svg")).not.toBeNull();click(moreButton());- expect([...menu()!.querySelectorAll("[data-menu-key]")].map((row) => row.getAttribute("data-menu-key"))).toEqual(["as-template", "copy", "download"]);+ expect([...menu()!.querySelectorAll("[data-menu-key]")].map((row) => row.getAttribute("data-menu-key"))).toEqual(["publish", "copy", "download"]);press(moreButton(), "Escape");click(top[2]!);expect(onClose).toHaveBeenCalledOnce();diff --git a/src/components/lazy-screens.test.ts b/src/components/lazy-screens.test.tsindex cc5aa90d0c..003e6e785d 100644--- a/src/components/lazy-screens.test.ts+++ b/src/components/lazy-screens.test.ts@@ -203,7 +203,7 @@ describe("preloadScreens", () => {preloadScreens("cloud.example");for (const preload of preloads) expect(preload).not.toHaveBeenCalled();await vi.advanceTimersByTimeAsync(60_000);- const rarelyOpened = [screens.CloudAddDialog, screens.GrokMoveDialog, screens.PhoneAppDialog, screens.ShareDepartmentDialog, screens.ImportDialog, screens.TeamLibraryPanel, screens.TeamFilesPage, screens.AnnouncementsPage];+ const rarelyOpened = [screens.CloudAddDialog, screens.GrokMoveDialog, screens.PhoneAppDialog, screens.ShareTemplateDialog, screens.ImportDialog, screens.TeamLibraryPanel, screens.TeamFilesPage, screens.AnnouncementsPage];const stubbed = Object.values(screens).filter(isScreen);for (const screen of stubbed) expect(screen.preload).toHaveBeenCalledTimes(rarelyOpened.includes(screen as never) ? 0 : 1);expect(preloads.length).toBe(stubbed.length);@@ -266,7 +266,7 @@ describe("launch bundle", () => {const deferred = ["ActivityPanel", "BotSettingsDialog", "CloudAddDialog", "ComputerPanel", "InspectorPanel", "KeyboardShortcutsModal","LocalVmWorkspace", "NewBotDialog", "PhoneAppDialog", "PhoneSetupFlow", "PluginsPanel", "published-apps/PublishedAppsPage", "skill-burger/SkillBurgersPage", "RemoteAgentSettingsPanel", "remote-desktop-panel", "RoutineCalendarPage",- "RoutinesPage", "SettingsModal", "ShareDepartmentDialog", "ImportDialog", "TeamLibraryPanel", "TeamMapPage", "team-files/TeamFilesPage", "TriggersPage", "WebhookTrigger", "room-panel/RoomPanel",+ "RoutinesPage", "SettingsModal", "ShareTemplateDialog", "ImportDialog", "TeamLibraryPanel", "TeamMapPage", "team-files/TeamFilesPage", "TriggersPage", "WebhookTrigger", "room-panel/RoomPanel","inbox/InboxPanel", "TeamDialog", "TeamSettingsDialog", "VoiceSetupDialog", "usage/TraceView", "bot-access/ShareBotDialog", "CommandAllowlistDialog", "WorkspaceBackupSettings",].map((name) => `components/${name}.tsx`);expect(deferred.filter((file) => reached.has(file))).toEqual([]);diff --git a/src/components/lazy-screens.tsx b/src/components/lazy-screens.tsxindex c0b1936278..e4d346979b 100644--- a/src/components/lazy-screens.tsx+++ b/src/components/lazy-screens.tsx@@ -105,7 +105,7 @@ export const CommandAllowlistDialog = lazyScreen("CommandAllowlistDialog", async// Rarely opened, so never fetched ahead. The team library is what brings the YAML parser in.export const CloudAddDialog = lazyScreen("CloudAddDialog", async () => (await import("./CloudAddDialog")).CloudAddDialog);export const PhoneAppDialog = lazyScreen("PhoneAppDialog", async () => (await import("./PhoneAppDialog")).PhoneAppDialog);-export const ShareDepartmentDialog = lazyScreen("ShareDepartmentDialog", async () => (await import("./ShareDepartmentDialog")).ShareDepartmentDialog);+export const ShareTemplateDialog = lazyScreen("ShareTemplateDialog", async () => (await import("./ShareTemplateDialog")).ShareTemplateDialog);export const ImportDialog = lazyScreen("ImportDialog", async () => (await import("./ImportDialog")).ImportDialog);export const GrokMoveDialog = lazyScreen("GrokMoveDialog", async () => (await import("./GrokMoveDialog")).GrokMoveDialog);export const TeamLibraryPanel = lazyScreen("TeamLibraryPanel", async () => (await import("./TeamLibraryPanel")).TeamLibraryPanel);diff --git a/src/components/publish-template.dom.test.ts b/src/components/publish-template.dom.test.tsnew file mode 100644index 0000000000..3e0b424f0f--- /dev/null+++ b/src/components/publish-template.dom.test.ts@@ -0,0 +1,177 @@+// @vitest-environment happy-dom+// A bot's Publish, from the chat's ⋯ and from the sidebar row's menu: each choice makes the bot's template at once and+// runs on it, with no message to the bot.+import { createElement } from "react";+import { flushSync } from "react-dom";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { Bot } from "@/state/store";+import type { TemplateCard } from "../../shared/share-card";++const fixture = vi.hoisted(() => ({+ dispatch: vi.fn(),+ advanced: false,+ bots: [] as Bot[],+ api: vi.fn(async (_path: string, _init?: RequestInit): Promise<unknown> => ({})),+}));+vi.mock("@/state/store", async (importOriginal) => {+ const original = await importOriginal<typeof import("@/state/store")>();+ return {+ ...original,+ api: (path: string, init?: RequestInit) => fixture.api(path, init),+ useStore: () => ({ state: { ...original.initialState, bots: fixture.bots, config: { profile: { name: "Sam Rivera" } } }, dispatch: fixture.dispatch }),+ };+});+vi.mock("@/lib/session", async (importOriginal) => ({+ ...await importOriginal<typeof import("@/lib/session")>(),+ readSessionState: async () => ({ kind: "loopback" }),+}));+vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => fixture.advanced, readAdvancedMode: () => fixture.advanced, setAdvancedMode: vi.fn() }));+vi.mock("@/lib/thread-preferences", () => ({ useShowThreads: () => fixture.advanced }));+vi.mock("./Avatar", () => ({ BotAvatar: () => null, MausAvatar: () => null }));++const { ChatMoreMenu } = await import("./ChatMoreMenu");+const { BotContextMenu } = await import("./SidebarBotMenu");+const { PublishTemplateHost } = await import("./publish-template");++const bot: Bot = {+ id: "scout", threadId: "thread-scout", name: "Scout", title: "", description: "", soul: "",+ notifications: true, color: "green", unread: false, messages: [{ id: "hi", role: "bot", kind: "text", text: "Hello", at: 1 }],+ modelSelection: { instanceId: "claude", model: "claude-opus-5-5" },+};+const card: TemplateCard = {+ id: "tpl1", scope: "bot", name: "Scout", tagline: "Finds things.", avatars: [{ key: "scout", name: "Scout", color: "green" }],+ counts: { bots: 1, skills: 2, routines: 0, apps: 0 }, redacted: 0, skipped: [], status: "draft", scrubbed: { paths: 1, emails: 0, phones: 0, names: 0 },+};+const PR = "https://github.com/milind-soni/openmausbot-teams/pull/12";++let host: HTMLDivElement;+let root: Root;+const settle = async () => {+ for (let i = 0; i < 3; i++) await new Promise((resolve) => setTimeout(resolve, 0));+};+const click = (element: Element | null | undefined) => {+ if (!element) throw new Error("nothing to click");+ flushSync(() => element.dispatchEvent(new MouseEvent("click", { bubbles: true, detail: 1 })));+};+const labels = (sheet: Element | null) => [...(sheet?.querySelectorAll('[role="menuitem"]') ?? [])].map((row) => row.textContent?.trim());+const calls = () => fixture.api.mock.calls.map(([path, init]) => [path, init?.body ?? null]);+const sent = () => fixture.dispatch.mock.calls.filter(([action]) => (action as { type: string }).type === "send");++beforeEach(() => {+ fixture.dispatch.mockReset();+ fixture.api.mockReset();+ fixture.advanced = false;+ fixture.bots = [bot];+ document.documentElement.dataset.reducedMotion = "true";+ vi.spyOn(HTMLElement.prototype, "scrollIntoView").mockImplementation(() => {});+ host = document.createElement("div");+ document.body.append(host);+ root = createRoot(host);+});+afterEach(() => {+ // The dialog asked for outlives the root; Close clears it before the next test.+ const close = [...document.querySelectorAll("footer button")].find((button) => button.textContent === "Close");+ if (close) click(close);+ flushSync(() => root.unmount());+ document.body.innerHTML = "";+ delete (window as { ogb?: unknown }).ogb;+});++describe("Publish in the chat's ⋯", () => {+ const openMenu = (shown: Bot) => {+ flushSync(() => root.render(createElement("div", null, createElement(ChatMoreMenu, { bot: shown }), createElement(PublishTemplateHost))));+ click(host.querySelector('[data-testid="chat-more"]')?.closest("button"));+ return document.querySelector("[data-sidebar-popover-menu]") ?? document.querySelector('[role="menu"]');+ };++ it("lists the publish choices in a submenu, and Publish to community makes the card and publishes it with no message", async () => {+ fixture.api.mockImplementation(async (path: string) => path === "/api/share/export" ? card+ : { ...card, status: "published", link: "https://github.com/milind-soni/openmausbot-teams/tree/abc/teams/scout", prUrl: PR, publishedBy: "Sam Rivera" });+ const menu = openMenu(bot);+ const publish = menu?.querySelector('[data-menu-key="publish"]');+ expect(publish?.getAttribute("aria-haspopup")).toBe("menu");+ expect(publish?.textContent).toContain("Publish");+ expect(menu?.querySelector('[data-menu-key="as-template"]')).toBeNull();+ click(publish);+ const submenu = document.querySelector("[data-sidebar-popover-submenu]");+ expect(labels(submenu)).toEqual(["Publish to community", "Your GitHub repo…", "Download"]);+ click(submenu!.querySelector('[data-menu-key="publish:community"]'));+ await vi.waitFor(() => expect(document.body.textContent).toContain("View pull request"));+ expect(calls()).toEqual([+ ["/api/share/export", JSON.stringify({ botId: "scout" })],+ ["/api/share/tpl1/publish", JSON.stringify({ author: "Sam Rivera" })],+ ]);+ expect(document.querySelector("[data-publish-bot=scout]")).not.toBeNull();+ expect(document.body.textContent).toContain("Publish Scout");+ expect(document.body.textContent).toContain("Published by Sam Rivera");+ expect(document.body.textContent).toContain("We removed 1 local path before publishing");+ expect(sent()).toEqual([]);+ });++ it("offers Save folder… on the desktop, and doesn't publish a template holding a key", async () => {+ (window as { ogb?: unknown }).ogb = { pickFolder: vi.fn(async () => null) };+ fixture.api.mockResolvedValue({ ...card, secret: true });+ const menu = openMenu(bot);+ click(menu?.querySelector('[data-menu-key="publish"]'));+ const submenu = document.querySelector("[data-sidebar-popover-submenu]");+ expect(labels(submenu)).toEqual(["Publish to community", "Your GitHub repo…", "Save folder…", "Download"]);+ click(submenu!.querySelector('[data-menu-key="publish:community"]'));+ await vi.waitFor(() => expect(document.querySelector("[data-template-secret]")).not.toBeNull());+ await settle();+ expect(calls().map(([path]) => path)).toEqual(["/api/share/export"]);+ expect(sent()).toEqual([]);+ });++ it("doesn't publish where nobody is signed in, and says to sign in", async () => {+ fixture.api.mockResolvedValue({ ...card, fallback: "sign_in" });+ const menu = openMenu(bot);+ click(menu?.querySelector('[data-menu-key="publish"]'));+ click(document.querySelector('[data-sidebar-popover-submenu] [data-menu-key="publish:community"]'));+ await vi.waitFor(() => expect(document.body.textContent).toContain("Sign in to MausBot to publish"));+ await settle();+ expect(calls().map(([path]) => path)).toEqual(["/api/share/export"]);+ });++ it("says why the template couldn't be made, and Try again makes it and runs the choice", async () => {+ fixture.api.mockRejectedValueOnce(new Error("That bot no longer exists.")).mockResolvedValueOnce(card).mockResolvedValue({ ...card, status: "published", link: "x", prUrl: PR });+ const menu = openMenu(bot);+ click(menu?.querySelector('[data-menu-key="publish"]'));+ click(document.querySelector('[data-sidebar-popover-submenu] [data-menu-key="publish:community"]'));+ await vi.waitFor(() => expect(document.body.textContent).toContain("That bot no longer exists."));+ click([...document.querySelectorAll("button")].find((button) => button.textContent === "Try again"));+ await vi.waitFor(() => expect(calls().map(([path]) => path)).toEqual(["/api/share/export", "/api/share/export", "/api/share/tpl1/publish"]));+ });++ it("leaves Publish out for a bot this person may only view", () => {+ const menu = openMenu({ ...bot, yourAccess: "view" });+ expect(menu?.querySelector('[data-menu-key="publish"]')).toBeNull();+ });+});++describe("Publish in the sidebar row's menu", () => {+ const openRowMenu = () => {+ flushSync(() => root.render(createElement("div", null,+ createElement(BotContextMenu, { menu: { botId: bot.id, x: 10, y: 10 }, onClose: vi.fn(), onArchive: vi.fn(), onDelete: vi.fn(), onMoveToSection: vi.fn(), onNewFolder: vi.fn(), onNewTaskFolder: vi.fn() }),+ createElement(PublishTemplateHost))));+ click(document.querySelector("[data-bot-menu-publish]"));+ return document.querySelector('[data-bot-menu-flyout="publish"]');+ };++ for (const advanced of [false, true]) {+ it(`opens the same choices in ${advanced ? "Advanced" : "Simple"} mode, and Download makes the card and downloads it`, async () => {+ fixture.advanced = advanced;+ fixture.api.mockResolvedValue(card);+ const download = vi.fn(async () => new Response("zip"));+ vi.stubGlobal("fetch", download);+ const flyout = openRowMenu();+ expect(labels(flyout)).toEqual(["Publish to community", "Your GitHub repo…", "Download"]);+ click([...flyout!.querySelectorAll("button")].find((button) => button.textContent === "Download"));+ await vi.waitFor(() => expect(document.body.textContent).toContain("Downloaded Scout.zip"));+ expect(calls()).toEqual([["/api/share/export", JSON.stringify({ botId: "scout" })]]);+ expect(String((download.mock.calls[0] as unknown[])[0])).toContain("/api/share/tpl1/download");+ expect(sent()).toEqual([]);+ vi.unstubAllGlobals();+ });+ }+});diff --git a/src/components/publish-template.tsx b/src/components/publish-template.tsxnew file mode 100644index 0000000000..f945095809--- /dev/null+++ b/src/components/publish-template.tsx@@ -0,0 +1,65 @@+import { useSyncExternalStore, type ReactNode } from "react";+import { Download, FolderDown, Github, Globe, Library, Upload } from "lucide-react";++import { t } from "@/lib/i18n";+import type { Bot } from "@/state/store";+import { ShareTemplateDialog } from "./lazy-screens";+import type { SidebarMenuItem } from "./SidebarPopoverMenu";+import { useRepoPublishOffered, useTeamTemplatesOwner } from "./TemplateCard";++export type PublishAction = "community" | "repo" | "team" | "save" | "download";+interface PublishRequest { botId: string; name: string; action: PublishAction }++export const PUBLISH_ITEM = "publish";++let request: PublishRequest | null = null;+const listeners = new Set<() => void>();+const changed = () => { for (const listener of listeners) listener(); };+const subscribe = (listener: () => void) => { listeners.add(listener); return () => { listeners.delete(listener); }; };++export function openPublish(next: PublishRequest): void {+ request = next;+ changed();+}++function closePublish(): void {+ request = null;+ changed();+}++export interface PublishChoice { key: PublishAction; label: string; icon: ReactNode; onSelect: () => void }++/** A bot's Publish choices here, in order: each makes its template at once and runs on it, no chat message. None for+ * a bot this person may only look at, who can't ask it to share itself either. */+export function usePublishChoices(): (bot: Pick<Bot, "id" | "name" | "yourAccess">) => PublishChoice[] {+ const team = useTeamTemplatesOwner();+ const repo = useRepoPublishOffered();+ return (bot) => {+ if (bot.yourAccess === "view") return [];+ const desktop = Boolean(window.ogb?.pickFolder) && window.ogb?.remoteClient?.active !== true;+ const choices: Array<Omit<PublishChoice, "onSelect">> = [+ { key: "community", label: t("template.publishToCommunity"), icon: <Globe size={16} /> },+ ...(repo ? [{ key: "repo" as const, label: t("template.publishToRepo"), icon: <Github size={16} /> }] : []),+ ...(team ? [{ key: "team" as const, label: t("template.addToTeam", { team }), icon: <Library size={16} /> }] : []),+ ...(desktop ? [{ key: "save" as const, label: t("template.saveFolder"), icon: <FolderDown size={16} /> }] : []),+ { key: "download", label: t("template.download"), icon: <Download size={16} /> },+ ];+ return choices.map((choice) => ({ ...choice, onSelect: () => openPublish({ botId: bot.id, name: bot.name, action: choice.key }) }));+ };+}++/** Publish, with its choices as a submenu; null when there are none. */+export function usePublishItem(bot: Pick<Bot, "id" | "name" | "yourAccess">): SidebarMenuItem | null {+ const choices = usePublishChoices()(bot);+ if (!choices.length) return null;+ return {+ key: PUBLISH_ITEM, label: t("template.publish"), icon: <Upload size={16} />, onSelect: () => {},+ submenu: choices.map((choice) => ({ key: `${PUBLISH_ITEM}:${choice.key}`, label: choice.label, icon: choice.icon, onSelect: choice.onSelect })),+ };+}++/** Where a bot's Publish shows what it did. */+export function PublishTemplateHost() {+ const open = useSyncExternalStore(subscribe, () => request, () => request);+ return open && <ShareTemplateDialog key={`${open.botId}:${open.action}`} target={open} onClose={closePublish} />;+}diff --git a/src/lib/crash-area.ts b/src/lib/crash-area.tsindex 25d3b77472..f547b2b6a5 100644--- a/src/lib/crash-area.ts+++ b/src/lib/crash-area.ts@@ -9,7 +9,7 @@ export const CRASH_AREAS = ["LiveDesktop", "LocalVmWorkspace", "MacLocalControl", "MarkdownFilePreview", "MenuMotion", "NewBotDialog","PhoneAppDialog", "PlacesRail", "PluginsPanel", "ProIntroduction", "PublishedAppsPage","RemoteAgentSettingsPanel", "RoomPanel", "RoutinesPage", "SavedWorkflowsCard", "ServerPairingCard",- "SettingsModal", "ShareBotDialog", "ShareDepartmentDialog", "SignedInSites", "SkillBurgersPage",+ "SettingsModal", "ShareBotDialog", "ShareTemplateDialog", "SignedInSites", "SkillBurgersPage","TailnetComputers", "TeamDialog", "TeamFilesPage", "TeamLibraryPanel", "TeamMapPage", "TeamSettingsDialog","ToolPageShell", "TraceView", "TriggersPage", "VisibilitySection", "VoiceSettings", "VoiceSetupDialog","WebhookTrigger", "WhatChangedView", "WorksOnGrid",diff --git a/src/lib/template-share.ts b/src/lib/template-share.tsindex f3b789e5b2..7a72f50ce1 100644--- a/src/lib/template-share.ts+++ b/src/lib/template-share.ts@@ -28,7 +28,9 @@ export interface ImportedTemplate {const post = (body: unknown) => ({ method: "POST", body: JSON.stringify(body) });-export const exportDepartment = (department: string) => api<TemplateCard>("/api/share/export", post({ department }));+/** What a template is made of: one bot, or every bot in a department. */+export type TemplateTarget = { botId: string } | { department: string };+export const exportTemplate = (target: TemplateTarget) => api<TemplateCard>("/api/share/export", post(target));export const templateDetails = (id: string) => api<{ card: TemplateCard; details: TemplateDetails }>(`/api/share/${encodeURIComponent(id)}`);/** `author` is "Published by": "" publishes it as the community's. */export const publishTemplate = (id: string, author?: string) =>@@ -108,6 +110,12 @@ export async function saveTemplateFolder(card: Pick<TemplateCard, "id" | "name">if (!chosen) return null;return (await api<{ path: string }>(`/api/share/${encodeURIComponent(card.id)}/save`, post({ path: chosen }))).path;}+ await downloadTemplate(card);+ return null;+}++/** Downloads the template's folder as a .zip; the file's name. */+export async function downloadTemplate(card: Pick<TemplateCard, "id" | "name">): Promise<string> {const response = await serverFetch(`/api/share/${encodeURIComponent(card.id)}/download`);if (!response.ok) throw new Error(t("template.failed"));const url = URL.createObjectURL(new Blob([await response.blob()], { type: "application/zip" }));@@ -121,7 +129,7 @@ export async function saveTemplateFolder(card: Pick<TemplateCard, "id" | "name">link.remove();setTimeout(() => URL.revokeObjectURL(url), 1000);}- return null;+ return link.download;}const readText = (file: File) => file.text();diff --git a/src/locales/de.json b/src/locales/de.jsonindex 1a9319c82a..13886562d8 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -4280,6 +4280,9 @@"together.mark.livesOn": "Wohnt auf {place}","together.mark.workingOn": "Arbeitet gerade auf {place}","together.mark.offline": "{place} ist gerade nicht erreichbar. {name} macht weiter, sobald es wieder da ist.",+ "template.download": "Herunterladen",+ "template.downloaded": "Heruntergeladen: {file}",+ "template.publishTitle": "{name} veröffentlichen","server.rooms.linkedAway": "{bot} läuft auf {place}, das gerade aus ist oder schläft. Die Antwort kommt hier, sobald {place} wieder da ist.","server.rooms.linkedGone": "{bot} läuft auf {place}. Die Verbindung zu {place} ist gerade aus; eine Antwort kommt hier erst, wenn sie zurück ist.","server.rooms.linkedNotSent": "{bot} konnte auf {place} nicht an die Reihe kommen. Erwähne {bot} noch einmal, um es erneut zu versuchen.",diff --git a/src/locales/en.json b/src/locales/en.jsonindex 9b38674508..fe50e89e6a 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -11705,7 +11705,9 @@"template.making": "Making the template…","template.publicNote": "Publishing makes it public on GitHub.","template.shareDepartment": "Share {name}",- "template.shareAsTemplate": "Share as template",+ "template.download": "Download",+ "template.downloaded": "Downloaded {file}",+ "template.publishTitle": "Publish {name}","template.addToTeam": "Add to {team}'s templates","template.addedToTeam": "Added to {team}'s templates","template.replacedInTeam": "Replaced in {team}'s templates. The previous one is kept.",diff --git a/src/locales/es.json b/src/locales/es.jsonindex 3680531a5e..33d59228ea 100644--- a/src/locales/es.json+++ b/src/locales/es.json@@ -6558,6 +6558,9 @@"together.mark.livesOn": "Vive en {place}","together.mark.workingOn": "Trabajando ahora en {place}","together.mark.offline": "No se puede acceder a {place} ahora mismo. {name} seguirá cuando vuelva.",+ "template.download": "Descargar",+ "template.downloaded": "Descargado: {file}",+ "template.publishTitle": "Publicar {name}","imageGen.complexity.label": "Nivel de detalle","imageGen.complexity.help": "Cuánto detalle tienen las imágenes de GPT-Image-2.6. Más bajo es más simple y rápido.","imageGen.complexity.low": "Bajo",diff --git a/src/locales/fr.json b/src/locales/fr.jsonindex ec13bd230d..d62f587d29 100644--- a/src/locales/fr.json+++ b/src/locales/fr.json@@ -3971,6 +3971,9 @@"together.mark.livesOn": "Vit sur {place}","together.mark.workingOn": "Travaille sur {place} en ce moment","together.mark.offline": "{place} est injoignable pour le moment. {name} reprendra dès son retour.",+ "template.download": "Télécharger",+ "template.downloaded": "Téléchargé : {file}",+ "template.publishTitle": "Publier {name}","imageGen.complexity.label": "Niveau de détail","imageGen.complexity.help": "Le niveau de détail des images GPT-Image-2.6. Plus bas, c'est plus simple et plus rapide.","imageGen.complexity.low": "Faible",diff --git a/src/locales/hi.json b/src/locales/hi.jsonindex f4c1f9be64..38bbb455fc 100644--- a/src/locales/hi.json+++ b/src/locales/hi.json@@ -3823,6 +3823,9 @@"together.mark.livesOn": "{place} पर रहता है","together.mark.workingOn": "अभी {place} पर काम कर रहा है","together.mark.offline": "{place} तक अभी पहुँचा नहीं जा सकता। इसके वापस आने पर {name} काम जारी रखेगा।",+ "template.download": "डाउनलोड करें",+ "template.downloaded": "डाउनलोड हुआ: {file}",+ "template.publishTitle": "{name} प्रकाशित करें","imageGen.complexity.label": "विवरण स्तर","imageGen.complexity.help": "GPT-Image-2.6 की छवियाँ कितनी विस्तृत हों। कम का मतलब सरल और तेज़।","imageGen.complexity.low": "कम",diff --git a/src/locales/it.json b/src/locales/it.jsonindex 583695f648..4d92a2da54 100644--- a/src/locales/it.json+++ b/src/locales/it.json@@ -11476,7 +11476,9 @@"template.making": "Fare il modello…","template.publicNote": "L'editoria lo rende pubblico su GitHub.","template.shareDepartment": "Condividi {name}",- "template.shareAsTemplate": "Condividi come modello",+ "template.download": "Scarica",+ "template.downloaded": "Scaricato: {file}",+ "template.publishTitle": "Pubblica {name}","template.addToTeam": "Aggiungi a {team}'s modelli","template.addedToTeam": "Aggiunto a {team}'s modelli","template.replacedInTeam": "Sostituito nei template di {team}. La versione precedente viene conservata.",diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex 5a3534ebd1..53def5065b 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -8098,6 +8098,9 @@"together.mark.livesOn": "{place} にいます","together.mark.workingOn": "現在 {place} で作業中","together.mark.offline": "現在 {place} に接続できません。復帰すると {name} は作業を続けます。",+ "template.download": "ダウンロード",+ "template.downloaded": "ダウンロードしました: {file}",+ "template.publishTitle": "{name}を公開","imageGen.complexity.label": "詳細レベル","imageGen.complexity.help": "GPT-Image-2.6 の画像の詳細さ。低いほどシンプルで高速です。","imageGen.complexity.low": "低",diff --git a/src/locales/ko.json b/src/locales/ko.jsonindex d40672941c..173918771f 100644--- a/src/locales/ko.json+++ b/src/locales/ko.json@@ -7789,6 +7789,9 @@"together.mark.livesOn": "{place}에 있음","together.mark.workingOn": "지금 {place}에서 작업 중","together.mark.offline": "지금은 {place}에 연결할 수 없습니다. 다시 연결되면 {name}이(가) 이어서 작업합니다.",+ "template.download": "다운로드",+ "template.downloaded": "다운로드함: {file}",+ "template.publishTitle": "{name} 게시","imageGen.complexity.label": "세부 수준","imageGen.complexity.help": "GPT-Image-2.6 이미지의 세부 정도입니다. 낮을수록 단순하고 빠릅니다.","imageGen.complexity.low": "낮음",diff --git a/src/locales/pl.json b/src/locales/pl.jsonindex 20c8a5c5f0..8acfc51567 100644--- a/src/locales/pl.json+++ b/src/locales/pl.json@@ -7257,6 +7257,9 @@"together.mark.livesOn": "Mieszka na: {place}","together.mark.workingOn": "Pracuje teraz na: {place}","together.mark.offline": "{place} jest teraz nieosiągalne. {name} będzie kontynuować, gdy wróci.",+ "template.download": "Pobierz",+ "template.downloaded": "Pobrano: {file}",+ "template.publishTitle": "Opublikuj {name}","imageGen.complexity.label": "Poziom szczegółowości","imageGen.complexity.help": "Jak szczegółowe są obrazy GPT-Image-2.6. Niższy poziom jest prostszy i szybszy.","imageGen.complexity.low": "Niski",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex b2fb9c2266..f55e9113e5 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -11704,7 +11704,9 @@"template.making": "Criando o modelo…","template.publicNote": "Publicar deixa o modelo público no GitHub.","template.shareDepartment": "Compartilhar {name}",- "template.shareAsTemplate": "Compartilhar como modelo",+ "template.download": "Baixar",+ "template.downloaded": "Baixado: {file}",+ "template.publishTitle": "Publicar {name}","template.addToTeam": "Adicionar aos modelos de {team}","template.addedToTeam": "Adicionado aos modelos de {team}","template.replacedInTeam": "Substituído nos modelos de {team}. O anterior foi mantido.",diff --git a/src/locales/ru.json b/src/locales/ru.jsonindex cf05ffcb20..cad8f0355e 100644--- a/src/locales/ru.json+++ b/src/locales/ru.json@@ -7311,6 +7311,9 @@"together.mark.livesOn": "Где живёт: {place}","together.mark.workingOn": "Сейчас работает: {place}","together.mark.offline": "{place} сейчас недоступно. {name} продолжит, когда оно вернётся.",+ "template.download": "Скачать",+ "template.downloaded": "Скачано: {file}",+ "template.publishTitle": "Опубликовать {name}","imageGen.complexity.label": "Уровень детализации","imageGen.complexity.help": "Насколько детализированы изображения GPT-Image-2.6. Ниже — проще и быстрее.","imageGen.complexity.low": "Низкий",diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex b6a700b1ee..cffaf6809e 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -38645,7 +38645,6 @@"template.making": "6bd6ba90237881a68d67d44e00eb367b954cb012fea0481ff1afe9787d453e6f","template.publicNote": "0c9c89b31d8d311be6ff480cf5e387a4ea65cfc70ca1ad7d34b0abdf23a843d4","template.shareDepartment": "2d3c925f1e0c3efcb8c25024a95b0d5b0690a34aa6c2bdd2c336ac64225457b6",- "template.shareAsTemplate": "78aa054b74685a167b3df5889735120b4c2a68a4a888ba1065a88cf1329b358f","templateImport.title": "2cff9baabf56ca002610e113bc94deb6ededddfc3c130365b6e88ed5195bf774","templateImport.linkLabel": "de1596dedadbe20d415707dfd438bbf9bf63e860794954084c759d3369851ed3","templateImport.open": "ed077f3d8125d60dca1979c7133601bd187d47c73ed9975028f677e49e709942",@@ -104020,7 +104019,6 @@"template.making": "6bd6ba90237881a68d67d44e00eb367b954cb012fea0481ff1afe9787d453e6f","template.publicNote": "0c9c89b31d8d311be6ff480cf5e387a4ea65cfc70ca1ad7d34b0abdf23a843d4","template.shareDepartment": "2d3c925f1e0c3efcb8c25024a95b0d5b0690a34aa6c2bdd2c336ac64225457b6",- "template.shareAsTemplate": "78aa054b74685a167b3df5889735120b4c2a68a4a888ba1065a88cf1329b358f","template.addToTeam": "00975ce1b38f15b896a50ecc47fe1374ebacf0fedd032704f6ae321a5a1f6328","template.addedToTeam": "037070d048df53a027f6b8de563889bc6e071d324efc1fec7a3cd007125d9850","template.replacedInTeam": "e200daef8f26cad624399ac1482728c7bdad84f4fdb4864d042bc17553e16dc5",diff --git a/src/locales/tr.json b/src/locales/tr.jsonindex 1db64e6b63..8bcc5347ed 100644--- a/src/locales/tr.json+++ b/src/locales/tr.json@@ -6053,6 +6053,9 @@"together.mark.livesOn": "Yaşadığı yer: {place}","together.mark.workingOn": "Şu anda çalıştığı yer: {place}","together.mark.offline": "{place} şu anda erişilemiyor. {name} geri geldiğinde devam eder.",+ "template.download": "İndir",+ "template.downloaded": "İndirildi: {file}",+ "template.publishTitle": "Yayınla: {name}","imageGen.complexity.label": "Ayrıntı düzeyi","imageGen.complexity.help": "GPT-Image-2.6 görsellerinin ne kadar ayrıntılı olacağı. Düşük daha basit ve daha hızlıdır.","imageGen.complexity.low": "Düşük",diff --git a/src/locales/uk.json b/src/locales/uk.jsonindex 83999b134a..dd2acde7c1 100644--- a/src/locales/uk.json+++ b/src/locales/uk.json@@ -4240,6 +4240,9 @@"together.mark.livesOn": "Де живе: {place}","together.mark.workingOn": "Зараз працює: {place}","together.mark.offline": "{place} зараз недоступне. {name} продовжить, щойно воно повернеться.",+ "template.download": "Завантажити",+ "template.downloaded": "Завантажено: {file}",+ "template.publishTitle": "Опублікувати {name}","imageGen.complexity.label": "Рівень деталізації","imageGen.complexity.help": "Наскільки детальними є зображення GPT-Image-2.6. Нижчий рівень простіший і швидший.","imageGen.complexity.low": "Низький",diff --git a/src/locales/vi.json b/src/locales/vi.jsonindex 2d8b3a6818..ab007b0e01 100644--- a/src/locales/vi.json+++ b/src/locales/vi.json@@ -6053,6 +6053,9 @@"together.mark.livesOn": "Ở trên {place}","together.mark.workingOn": "Đang làm việc trên {place}","together.mark.offline": "Hiện không kết nối được với {place}. {name} sẽ tiếp tục khi nó trở lại.",+ "template.download": "Tải xuống",+ "template.downloaded": "Đã tải xuống: {file}",+ "template.publishTitle": "Xuất bản {name}","imageGen.complexity.label": "Mức chi tiết","imageGen.complexity.help": "Mức độ chi tiết của ảnh GPT-Image-2.6. Thấp hơn thì đơn giản và nhanh hơn.","imageGen.complexity.low": "Thấp",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex e088e1bc81..7c4b179e02 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -10392,6 +10392,9 @@"together.mark.livesOn": "位於 {place}","together.mark.workingOn": "正在 {place} 上工作","together.mark.offline": "目前無法連線到 {place}。它恢復後 {name} 會繼續。",+ "template.download": "下載",+ "template.downloaded": "已下載:{file}",+ "template.publishTitle": "發佈 {name}","imageGen.complexity.label": "細節等級","imageGen.complexity.help": "GPT-Image-2.6 圖片的細節程度。越低越簡單、越快。","imageGen.complexity.low": "低",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex daa9c8c700..28ac81462b 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -10283,6 +10283,9 @@"sidebar.newBotOn.onlyThere": "只在那里登录:{ais}。","sidebar.newBotOn.onlyHere": "只在这里登录:{ais}。","sidebar.newBotOn.needsUpdate": "My Cloud 需要下一次更新才能这样做。",+ "template.download": "下载",+ "template.downloaded": "已下载:{file}",+ "template.publishTitle": "发布 {name}","server.rooms.linkedAway": "{bot} 所在的 {place} 现在已关闭或休眠。{place} 恢复后它会在这里回复。","server.rooms.linkedGone": "{bot} 位于 {place}。与 {place} 的连接现在已关闭,连接恢复后它才能在这里回复。","server.rooms.linkedNotSent": "无法把 {bot} 的发言机会传给 {place}。再次提及 {bot} 可重试。",