Skip to content

Commit db8fa2f

Browse files
authored
Desktop shows its own version, and About names both (#2906)
* Desktop shows its own version, and About names both OpenBot Desktop connected to OpenBot Cloud showed Cloud's v1.2.10 at the strip's foot, while its update banner said "OpenBot 1.2.9 is available". Read together, that asked the person to update from 1.2.10 down to 1.2.9. Inside OpenBot Desktop the page now always shows the app's own version (the strip's foot, Help in the account menu, the OpenDots skin), whether OpenBot runs on this computer or elsewhere. It comes from the app's update offer, never from the server. The banner names the app: "OpenBot Desktop 1.2.9 is available." About OpenBot, when connected, names the release the OpenBot it is connected to runs (read from the same people/me answer that names the account) and the app's own version. In a browser nothing changes: OpenBot Cloud's strip shows the server's release. * Format the About test as rustfmt does
1 parent 504455a commit db8fa2f

15 files changed

Lines changed: 887 additions & 60 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ jobs:
726726
app/tests/conversation-reply-toolbar-layout.test.tsx
727727
app/tests/conversation-switch.test.tsx
728728
app/tests/delete-account-layout.test.tsx
729+
app/tests/desktop-versions.test.tsx
729730
app/tests/desktop-window-sign-in.test.tsx
730731
app/tests/finished-run-no-stopped-notice-browser.test.tsx
731732
app/tests/first-message-thinking.test.tsx

‎app/src/components/app-sidebar/account-label.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "@/components/ui/tooltip";
1414
import { currentUserQueryOptions } from "@/lib/auth/queries";
1515
import { deploymentCapabilitiesQueryOptions } from "@/lib/deployment/queries";
16+
import { desktopShell } from "@/lib/desktop/shell";
1617
import { useOrganizationChoices } from "@/lib/organizations/queries";
1718
import { cn } from "@/lib/utils";
1819
import { OpenBotVersion } from "../layout/openbot-version";
@@ -175,9 +176,11 @@ export function AccountMenu({ children }: { children: ReactNode }) {
175176
}
176177

177178
/**
178-
* On OpenBot Cloud (`hostedSignIn`, OpenBot Desktop signed in to it too), the release the server
179-
* runs, under the strip's avatar: on screen on every page, so a screenshot sent with a bug report
180-
* says which release it was taken on. Elsewhere only the account menu says it.
179+
* On OpenBot Cloud in a browser (`hostedSignIn`), the release the server runs, under the strip's
180+
* avatar: on screen on every page, so a screenshot sent with a bug report says which release it
181+
* was taken on. Inside OpenBot Desktop, on this computer or connected anywhere, the app's own
182+
* version there instead (`useShownVersion`), the version its update banner moves on from. Elsewhere
183+
* only the account menu says it.
181184
*
182185
* The strip is narrow, so a build's `main-20261113-9` or `internal-<commit>` wraps, centred, at its
183186
* hyphens and then wherever it must, and reads whole on two or three lines. A release's `v1.0.2`
@@ -193,7 +196,7 @@ export function AccountMenu({ children }: { children: ReactNode }) {
193196
export function StripVersion() {
194197
const cloud =
195198
useQuery(deploymentCapabilitiesQueryOptions()).data?.hostedSignIn === true;
196-
if (!cloud) return null;
199+
if (!cloud && desktopShell() === null) return null;
197200
return (
198201
<OpenBotVersion
199202
className={cn(

‎app/src/components/app-sidebar/help-menu.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { IconHelpCircle } from "@/components/icons";
2-
import { useQuery } from "@tanstack/react-query";
32
import { accountSubmenuClassName } from "@/components/organizations/organization-menu";
43
import {
54
DropdownMenuSeparator,
65
DropdownMenuSub,
76
DropdownMenuSubContent,
87
DropdownMenuSubTrigger,
98
} from "@/components/ui/dropdown-menu";
10-
import { currentUserQueryOptions } from "@/lib/auth/queries";
11-
import { OpenBotVersion } from "../layout/openbot-version";
9+
import { OpenBotVersion, useShownVersion } from "../layout/openbot-version";
1210
import { DesktopAppMenuItem } from "./desktop-app-item";
1311
import { ReportBugMenuItem } from "./report-bug-item";
1412
import { TroubleshootingLogsMenuItem } from "./troubleshooting-logs-item";
@@ -35,18 +33,22 @@ export function HelpMenu({ itemClassName }: { itemClassName: string }) {
3533
);
3634
}
3735

38-
/** The release the server runs, at Help's foot. Nothing where the server gives none, as in development. */
36+
/**
37+
* The version this window shows, at Help's foot, named for what it is: the release the server runs
38+
* in a browser, and OpenBot Desktop's own inside the app (`useShownVersion`). Nothing where there is
39+
* none, as in development.
40+
*/
3941
function HelpVersion() {
40-
const { data: user } = useQuery(currentUserQueryOptions());
41-
if (!user?.openbotVersion) return null;
42+
const { version, name } = useShownVersion();
43+
if (!version) return null;
4244
return (
4345
<>
4446
<DropdownMenuSeparator />
4547
<div
4648
className="flex items-baseline gap-1 px-2 py-1.5 text-muted-foreground text-xs"
4749
data-slot="help-version"
4850
>
49-
OpenBot
51+
{name}
5052
<OpenBotVersion />
5153
</div>
5254
</>

‎app/src/components/layout/openbot-version.tsx‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { currentUserQueryOptions } from "@/lib/auth/queries";
3+
import { desktopAppUpdateQueryOptions } from "@/lib/desktop/queries";
4+
import { desktopShell } from "@/lib/desktop/shell";
35
import { cn } from "@/lib/utils";
46

57
/**
6-
* The OpenBot release the server runs, in tiny type: to the right of the person's name in the
7-
* account menu, under the strip's avatar on OpenBot Cloud (`StripVersion`), and under the name in
8-
* the OpenDots skin. The server's own answer, so it names what is deployed rather than what this
9-
* bundle was built from. Nothing at all when the server has no version to give, as in development.
8+
* The version this window shows, and the name of what runs it.
9+
*
10+
* In a browser, the OpenBot release the server runs: the server's own answer, so it names what is
11+
* deployed rather than what this bundle was built from.
12+
*
13+
* Inside OpenBot Desktop, always the app's own version, never the server's, whether the window
14+
* shows OpenBot on this computer or an OpenBot it is connected to. Reported from Desktop connected
15+
* to OpenBot Cloud: the strip said Cloud's v1.2.10 while the app's banner offered its own update to
16+
* 1.2.9, which read as an update down. The OpenBot's release is in About OpenBot, beside the app's.
17+
* The app says its version with its update offer (`update_offer`'s `current`); a desktop app from
18+
* before that command says none here.
19+
*
20+
* Null when there is no version to give, as on a server built without one.
21+
*/
22+
export function useShownVersion(): {
23+
version: string | null;
24+
name: "OpenBot" | "OpenBot Desktop";
25+
} {
26+
const inDesktop = desktopShell() !== null;
27+
const { data: user } = useQuery(currentUserQueryOptions());
28+
const { data: offer } = useQuery(desktopAppUpdateQueryOptions());
29+
if (inDesktop) {
30+
const current = offer?.current;
31+
return {
32+
version: typeof current === "string" && current.trim() ? current : null,
33+
name: "OpenBot Desktop",
34+
};
35+
}
36+
return { version: user?.openbotVersion ?? null, name: "OpenBot" };
37+
}
38+
39+
/**
40+
* The version this window shows (`useShownVersion`), in tiny type: to the right of the person's
41+
* name in the account menu, at the strip's foot (`StripVersion`), and under the name in the
42+
* OpenDots skin. Nothing at all when there is no version to give, as in development.
1043
*
1144
* Never cut short: a build names itself `main-20261113-9` or `internal-<commit>`, longer than a
1245
* release's `v1.0.2`, and half of it says nothing. Where room runs out, the name beside it gives
1346
* way; on the strip, too narrow for it, it wraps.
1447
*/
1548
export function OpenBotVersion({ className }: { className?: string }) {
16-
const { data: user } = useQuery(currentUserQueryOptions());
17-
const version = user?.openbotVersion;
49+
const { version } = useShownVersion();
1850
if (!version) return null;
1951
return (
2052
<span

‎app/src/components/layout/update-banner.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export function UpdateBanner() {
3434
const progress = offer.data?.installing ?? null;
3535
const busy = install.isPending || progress !== null;
3636

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

3940
return (
4041
<aside
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { QueryClientProvider } from "@tanstack/react-query";
2+
import { RouterProvider } from "@tanstack/react-router";
3+
import { createRoot } from "react-dom/client";
4+
import { queryClient } from "@/query-client";
5+
import { router } from "@/router";
6+
7+
/**
8+
* The whole app as main.tsx mounts it, on the real route tree (app/src/routeTree.gen.ts), for
9+
* desktop-versions.test.tsx to bundle and load in a real browser. The server is a stand-in for an
10+
* OpenBot that runs `window.openbotServer.version`: OpenBot Cloud (`hostedSignIn`), or OpenBot on
11+
* this computer (`localEvaluation`). Whether a desktop app is around the page is the test's
12+
* `__TAURI_INTERNALS__`. Anything else the server is asked is the API's plain not found, and its
13+
* path is kept in `window.unanswered` for the test to print.
14+
*/
15+
type Server = { version: string; cloud: boolean };
16+
const server = (window as unknown as { openbotServer: Server }).openbotServer;
17+
const ORGANIZATION = "/api/v2/organizations/default";
18+
const unanswered: string[] = [];
19+
(window as unknown as { unanswered: string[] }).unanswered = unanswered;
20+
21+
function problem(status: number, code: string): Response {
22+
return new Response(JSON.stringify({ status, code, title: code }), {
23+
status,
24+
headers: { "content-type": "application/problem+json" },
25+
});
26+
}
27+
28+
const realFetch = globalThis.fetch;
29+
globalThis.fetch = Object.assign(answer, { preconnect: realFetch.preconnect });
30+
31+
async function answer(
32+
input: RequestInfo | URL,
33+
init?: RequestInit,
34+
): Promise<Response> {
35+
const url = new URL(
36+
input instanceof Request ? input.url : String(input),
37+
location.origin,
38+
);
39+
const method = (
40+
init?.method ?? (input instanceof Request ? input.method : "GET")
41+
).toUpperCase();
42+
const path = url.pathname;
43+
if (path === `${ORGANIZATION}/deployment`)
44+
return Response.json({
45+
generativeUi: true,
46+
selfHostBanner: false,
47+
localEvaluation: !server.cloud,
48+
hostedSignIn: server.cloud,
49+
edition: "personal",
50+
});
51+
if (path === `${ORGANIZATION}/people/me`)
52+
return Response.json({
53+
person: {
54+
id: "per_sofia",
55+
email: server.cloud ? "sofia@example.com" : "dev@openbot.local",
56+
name: "Sofía",
57+
needsName: false,
58+
image: null,
59+
role: "admin",
60+
onboarding: { completedAt: "2026-11-01T00:00:00.000Z", step: 0 },
61+
},
62+
openbotVersion: server.version,
63+
});
64+
if (method === "GET" && path === `${ORGANIZATION}/bots`)
65+
return Response.json({ bots: [], nextCursor: null });
66+
if (method === "GET" && path === `${ORGANIZATION}/conversations`)
67+
return Response.json({ conversations: [], nextCursor: null });
68+
unanswered.push(`${method} ${path}`);
69+
return problem(404, "NOT_FOUND");
70+
}
71+
72+
/** No socket: nothing here answers one. */
73+
class OfflineWebSocket extends EventTarget {
74+
static readonly CONNECTING = 0;
75+
static readonly OPEN = 1;
76+
static readonly CLOSING = 2;
77+
static readonly CLOSED = 3;
78+
readyState = 3;
79+
onclose = null;
80+
onerror = null;
81+
onmessage = null;
82+
onopen = null;
83+
close() {}
84+
send() {}
85+
}
86+
globalThis.WebSocket = OfflineWebSocket as unknown as typeof WebSocket;
87+
88+
const root = document.getElementById("root");
89+
if (root)
90+
createRoot(root).render(
91+
<QueryClientProvider client={queryClient}>
92+
<RouterProvider router={router} context={{ queryClient }} />
93+
</QueryClientProvider>,
94+
);

0 commit comments

Comments
 (0)