Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ jobs:
app/tests/conversation-reply-toolbar-layout.test.tsx
app/tests/conversation-switch.test.tsx
app/tests/delete-account-layout.test.tsx
app/tests/desktop-versions.test.tsx
app/tests/desktop-window-sign-in.test.tsx
app/tests/finished-run-no-stopped-notice-browser.test.tsx
app/tests/first-message-thinking.test.tsx
Expand Down
11 changes: 7 additions & 4 deletions app/src/components/app-sidebar/account-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "@/components/ui/tooltip";
import { currentUserQueryOptions } from "@/lib/auth/queries";
import { deploymentCapabilitiesQueryOptions } from "@/lib/deployment/queries";
import { desktopShell } from "@/lib/desktop/shell";
import { useOrganizationChoices } from "@/lib/organizations/queries";
import { cn } from "@/lib/utils";
import { OpenBotVersion } from "../layout/openbot-version";
Expand Down Expand Up @@ -175,9 +176,11 @@ export function AccountMenu({ children }: { children: ReactNode }) {
}

/**
* On OpenBot Cloud (`hostedSignIn`, OpenBot Desktop signed in to it too), the release the server
* runs, under the strip's avatar: on screen on every page, so a screenshot sent with a bug report
* says which release it was taken on. Elsewhere only the account menu says it.
* On OpenBot Cloud in a browser (`hostedSignIn`), the release the server runs, under the strip's
* avatar: on screen on every page, so a screenshot sent with a bug report says which release it
* was taken on. Inside OpenBot Desktop, on this computer or connected anywhere, the app's own
* version there instead (`useShownVersion`), the version its update banner moves on from. Elsewhere
* only the account menu says it.
*
* The strip is narrow, so a build's `main-20261113-9` or `internal-<commit>` wraps, centred, at its
* hyphens and then wherever it must, and reads whole on two or three lines. A release's `v1.0.2`
Expand All @@ -193,7 +196,7 @@ export function AccountMenu({ children }: { children: ReactNode }) {
export function StripVersion() {
const cloud =
useQuery(deploymentCapabilitiesQueryOptions()).data?.hostedSignIn === true;
if (!cloud) return null;
if (!cloud && desktopShell() === null) return null;
return (
<OpenBotVersion
className={cn(
Expand Down
16 changes: 9 additions & 7 deletions app/src/components/app-sidebar/help-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { IconHelpCircle } from "@/components/icons";
import { useQuery } from "@tanstack/react-query";
import { accountSubmenuClassName } from "@/components/organizations/organization-menu";
import {
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
} from "@/components/ui/dropdown-menu";
import { currentUserQueryOptions } from "@/lib/auth/queries";
import { OpenBotVersion } from "../layout/openbot-version";
import { OpenBotVersion, useShownVersion } from "../layout/openbot-version";
import { DesktopAppMenuItem } from "./desktop-app-item";
import { ReportBugMenuItem } from "./report-bug-item";
import { TroubleshootingLogsMenuItem } from "./troubleshooting-logs-item";
Expand All @@ -35,18 +33,22 @@ export function HelpMenu({ itemClassName }: { itemClassName: string }) {
);
}

/** The release the server runs, at Help's foot. Nothing where the server gives none, as in development. */
/**
* The version this window shows, at Help's foot, named for what it is: the release the server runs
* in a browser, and OpenBot Desktop's own inside the app (`useShownVersion`). Nothing where there is
* none, as in development.
*/
function HelpVersion() {
const { data: user } = useQuery(currentUserQueryOptions());
if (!user?.openbotVersion) return null;
const { version, name } = useShownVersion();
if (!version) return null;
return (
<>
<DropdownMenuSeparator />
<div
className="flex items-baseline gap-1 px-2 py-1.5 text-muted-foreground text-xs"
data-slot="help-version"
>
OpenBot
{name}
<OpenBotVersion />
</div>
</>
Expand Down
44 changes: 38 additions & 6 deletions app/src/components/layout/openbot-version.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
import { useQuery } from "@tanstack/react-query";
import { currentUserQueryOptions } from "@/lib/auth/queries";
import { desktopAppUpdateQueryOptions } from "@/lib/desktop/queries";
import { desktopShell } from "@/lib/desktop/shell";
import { cn } from "@/lib/utils";

/**
* The OpenBot release the server runs, in tiny type: to the right of the person's name in the
* account menu, under the strip's avatar on OpenBot Cloud (`StripVersion`), and under the name in
* the OpenDots skin. The server's own answer, so it names what is deployed rather than what this
* bundle was built from. Nothing at all when the server has no version to give, as in development.
* The version this window shows, and the name of what runs it.
*
* In a browser, the OpenBot release the server runs: the server's own answer, so it names what is
* deployed rather than what this bundle was built from.
*
* Inside OpenBot Desktop, always the app's own version, never the server's, whether the window
* shows OpenBot on this computer or an OpenBot it is connected to. Reported from Desktop connected
* to OpenBot Cloud: the strip said Cloud's v1.2.10 while the app's banner offered its own update to
* 1.2.9, which read as an update down. The OpenBot's release is in About OpenBot, beside the app's.
* The app says its version with its update offer (`update_offer`'s `current`); a desktop app from
* before that command says none here.
*
* Null when there is no version to give, as on a server built without one.
*/
export function useShownVersion(): {
version: string | null;
name: "OpenBot" | "OpenBot Desktop";
} {
const inDesktop = desktopShell() !== null;
const { data: user } = useQuery(currentUserQueryOptions());
const { data: offer } = useQuery(desktopAppUpdateQueryOptions());
if (inDesktop) {
const current = offer?.current;
return {
version: typeof current === "string" && current.trim() ? current : null,
name: "OpenBot Desktop",
};
}
return { version: user?.openbotVersion ?? null, name: "OpenBot" };
}

/**
* The version this window shows (`useShownVersion`), in tiny type: to the right of the person's
* name in the account menu, at the strip's foot (`StripVersion`), and under the name in the
* OpenDots skin. Nothing at all when there is no version to give, as in development.
*
* Never cut short: a build names itself `main-20261113-9` or `internal-<commit>`, longer than a
* release's `v1.0.2`, and half of it says nothing. Where room runs out, the name beside it gives
* way; on the strip, too narrow for it, it wraps.
*/
export function OpenBotVersion({ className }: { className?: string }) {
const { data: user } = useQuery(currentUserQueryOptions());
const version = user?.openbotVersion;
const { version } = useShownVersion();
if (!version) return null;
return (
<span
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/layout/update-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export function UpdateBanner() {
const progress = offer.data?.installing ?? null;
const busy = install.isPending || progress !== null;

const said = updateOffered(version, offer.data?.ready);
// Named for the app it updates: the page above can be an OpenBot elsewhere, on its own release.
const said = updateOffered(version, offer.data?.ready, "OpenBot Desktop");

return (
<aside
Expand Down
94 changes: 94 additions & 0 deletions app/tests/desktop-versions.fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { QueryClientProvider } from "@tanstack/react-query";
import { RouterProvider } from "@tanstack/react-router";
import { createRoot } from "react-dom/client";
import { queryClient } from "@/query-client";
import { router } from "@/router";

/**
* The whole app as main.tsx mounts it, on the real route tree (app/src/routeTree.gen.ts), for
* desktop-versions.test.tsx to bundle and load in a real browser. The server is a stand-in for an
* OpenBot that runs `window.openbotServer.version`: OpenBot Cloud (`hostedSignIn`), or OpenBot on
* this computer (`localEvaluation`). Whether a desktop app is around the page is the test's
* `__TAURI_INTERNALS__`. Anything else the server is asked is the API's plain not found, and its
* path is kept in `window.unanswered` for the test to print.
*/
type Server = { version: string; cloud: boolean };
const server = (window as unknown as { openbotServer: Server }).openbotServer;
const ORGANIZATION = "/api/v2/organizations/default";
const unanswered: string[] = [];
(window as unknown as { unanswered: string[] }).unanswered = unanswered;

function problem(status: number, code: string): Response {
return new Response(JSON.stringify({ status, code, title: code }), {
status,
headers: { "content-type": "application/problem+json" },
});
}

const realFetch = globalThis.fetch;
globalThis.fetch = Object.assign(answer, { preconnect: realFetch.preconnect });

async function answer(
input: RequestInfo | URL,
init?: RequestInit,
): Promise<Response> {
const url = new URL(
input instanceof Request ? input.url : String(input),
location.origin,
);
const method = (
init?.method ?? (input instanceof Request ? input.method : "GET")
).toUpperCase();
const path = url.pathname;
if (path === `${ORGANIZATION}/deployment`)
return Response.json({
generativeUi: true,
selfHostBanner: false,
localEvaluation: !server.cloud,
hostedSignIn: server.cloud,
edition: "personal",
});
if (path === `${ORGANIZATION}/people/me`)
return Response.json({
person: {
id: "per_sofia",
email: server.cloud ? "sofia@example.com" : "dev@openbot.local",
name: "Sofía",
needsName: false,
image: null,
role: "admin",
onboarding: { completedAt: "2026-11-01T00:00:00.000Z", step: 0 },
},
openbotVersion: server.version,
});
if (method === "GET" && path === `${ORGANIZATION}/bots`)
return Response.json({ bots: [], nextCursor: null });
if (method === "GET" && path === `${ORGANIZATION}/conversations`)
return Response.json({ conversations: [], nextCursor: null });
unanswered.push(`${method} ${path}`);
return problem(404, "NOT_FOUND");
}

/** No socket: nothing here answers one. */
class OfflineWebSocket extends EventTarget {
static readonly CONNECTING = 0;
static readonly OPEN = 1;
static readonly CLOSING = 2;
static readonly CLOSED = 3;
readyState = 3;
onclose = null;
onerror = null;
onmessage = null;
onopen = null;
close() {}
send() {}
}
globalThis.WebSocket = OfflineWebSocket as unknown as typeof WebSocket;

const root = document.getElementById("root");
if (root)
createRoot(root).render(
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} context={{ queryClient }} />
</QueryClientProvider>,
);
Loading
Loading