Skip to content

Commit 447fc31

Browse files
committed
fix(app-shell): About names the ObjectStack version from discovery first
Claude-Session: https://claude.ai/code/session_01FEkQ5oK4fFfnLADcipbEeT Co-authored-by: Claude <noreply@anthropic.com>
1 parent c30ce97 commit 447fc31

13 files changed

Lines changed: 165 additions & 20 deletions

File tree

‎ui/packages/app-shell/src/layout/AboutDialog.tsx‎

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

33
/**
4-
* AboutDialog — the help menu's About entry (objectui#12970).
4+
* AboutDialog — the help menu's About entry (objectui#12970, objectstack#35280).
55
*
6-
* Names the build this console was compiled from, so a reviewer can tell which
7-
* objectui build a deployment serves. The value is the shared build identity
8-
* (`buildIdentity.ts`), the same read Sentry's release falls back to. A console
9-
* built without one says so in words; the field is never left empty.
6+
* Two rows, the version first:
107
*
11-
* The runtime's own build identity is deliberately not shown here: the shell
12-
* has no request that reads it today, and adding one is outside this dialog.
8+
* 1. **ObjectStack version** — the `version` the runtime's discovery document
9+
* answers (`DiscoverySchema`'s System Identity field, resolved server-side
10+
* by `resolveDiscoveryVersion()`; an operator's `OS_RUNTIME_VERSION` stamp
11+
* where one is set). It is read through the shell's adapter
12+
* (`getDiscovery()`), which hands back the document its `connect()` already
13+
* holds from the console's one shared discovery read — no second request.
14+
* The value is shown exactly as discovery answers it, never trimmed.
15+
* 2. **Console build** — the build this console was compiled from: the shared
16+
* build identity (`buildIdentity.ts`), the same read Sentry's release falls
17+
* back to, so a deployment can still be traced to a commit.
18+
*
19+
* Neither field is ever left empty: while the read is in flight the version
20+
* row says it is loading, a discovery that cannot be read or answers no
21+
* version says so in words, and a console built without an identity says so
22+
* too.
1323
* @module
1424
*/
1525

26+
import { useEffect, useState } from 'react';
1627
import {
1728
Dialog,
1829
DialogContent,
@@ -21,6 +32,7 @@ import {
2132
DialogDescription,
2233
} from '@object-ui/components';
2334
import { useObjectTranslation } from '@object-ui/i18n';
35+
import { useAdapter } from '../providers/AdapterProvider.js';
2436

2537
export interface AboutDialogProps {
2638
open: boolean;
@@ -29,18 +41,71 @@ export interface AboutDialogProps {
2941
build: string | null;
3042
}
3143

44+
/** The discovery document's `version`, or `null` when it names none. */
45+
function discoveryVersion(discovery: unknown): string | null {
46+
const version = (discovery as { version?: unknown } | null)?.version;
47+
return typeof version === 'string' && version !== '' ? version : null;
48+
}
49+
50+
/**
51+
* The runtime's version as discovery answers it, read each time the dialog
52+
* opens: `undefined` before the first answer, `null` when discovery could not
53+
* be read or named no version. A later open keeps the last answer on screen
54+
* while it reads again.
55+
*/
56+
function useRuntimeVersion(open: boolean): string | null | undefined {
57+
const adapter = useAdapter();
58+
const [version, setVersion] = useState<string | null | undefined>(undefined);
59+
useEffect(() => {
60+
if (!open) return;
61+
if (!adapter) {
62+
setVersion(null);
63+
return;
64+
}
65+
let cancelled = false;
66+
// `getDiscovery()` answers `null` when the adapter cannot connect; it does
67+
// not reject.
68+
void adapter.getDiscovery().then((discovery) => {
69+
if (!cancelled) setVersion(discoveryVersion(discovery));
70+
});
71+
return () => {
72+
cancelled = true;
73+
};
74+
}, [open, adapter]);
75+
return version;
76+
}
77+
3278
export function AboutDialog({ open, onOpenChange, build }: AboutDialogProps) {
3379
const { t } = useObjectTranslation();
80+
const version = useRuntimeVersion(open);
3481
return (
3582
<Dialog open={open} onOpenChange={onOpenChange}>
3683
<DialogContent className="sm:max-w-md" data-testid="overlay:about">
3784
<DialogHeader>
3885
<DialogTitle>{t('help.aboutTitle', { defaultValue: 'About this console' })}</DialogTitle>
3986
<DialogDescription>
40-
{t('help.aboutDescription', { defaultValue: 'The build this console was compiled from.' })}
87+
{t('help.aboutDescription', {
88+
defaultValue: 'The ObjectStack version this console runs on, and the build it was compiled from.',
89+
})}
4190
</DialogDescription>
4291
</DialogHeader>
4392
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 pt-2 text-sm">
93+
<dt className="text-muted-foreground">
94+
{t('help.aboutVersion', { defaultValue: 'ObjectStack version' })}
95+
</dt>
96+
<dd data-testid="about:runtime-version" className="min-w-0 break-all">
97+
{version ? (
98+
<code className="font-mono">{version}</code>
99+
) : (
100+
<span className="text-muted-foreground">
101+
{version === undefined
102+
? t('common.loading', { defaultValue: 'Loading…' })
103+
: t('help.aboutVersionUnknown', {
104+
defaultValue: 'Unknown version (the server did not report one)',
105+
})}
106+
</span>
107+
)}
108+
</dd>
44109
<dt className="text-muted-foreground">
45110
{t('help.aboutBuild', { defaultValue: 'Console build' })}
46111
</dt>

‎ui/packages/app-shell/src/layout/__tests__/AppHeader.aboutBuild-12970.test.tsx‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* the tenant console's `app` bar and the control plane's `home` / `orgs` /
66
* `studio` bars are the one component — the help menu carries 「关于」 / About,
77
* and the dialog it opens names the build this console was compiled from.
8+
* Since objectstack#35280 it names the ObjectStack version first: the
9+
* `version` the discovery document answers, read through the adapter's
10+
* `getDiscovery()`, stubbed here through a mutable answer.
811
*
912
* The build identity is `buildIdentity.ts`'s one read, stubbed here through a
1013
* mutable reading: this repo's Vitest setup cannot put a `VITE_*` value on
@@ -151,8 +154,18 @@ vi.mock('../../providers/MetadataProvider', () => ({
151154
}),
152155
}));
153156

157+
/**
158+
* What the adapter's `getDiscovery()` answers; each case sets it. The adapter
159+
* answers `null` when it cannot connect, and never rejects.
160+
*/
161+
let discoveryAnswer: Promise<unknown> = Promise.resolve(null);
162+
154163
/** Stable identity: the header's readers key their effects on the adapter. */
155-
const fakeAdapter = { find: () => Promise.resolve({ data: [] }), getClient: () => undefined };
164+
const fakeAdapter = {
165+
find: () => Promise.resolve({ data: [] }),
166+
getClient: () => undefined,
167+
getDiscovery: () => discoveryAnswer,
168+
};
156169

157170
vi.mock('../../providers/AdapterProvider', () => ({
158171
useAdapter: () => fakeAdapter,
@@ -209,6 +222,7 @@ function openAbout() {
209222

210223
beforeEach(() => {
211224
consoleBuild = null;
225+
discoveryAnswer = Promise.resolve({ version: '18.5.0' });
212226
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, status: 200, json: async () => ({ data: [] }) })));
213227
});
214228

@@ -257,3 +271,47 @@ describe('AppHeader help menu: About names the console build (objectui#12970)',
257271
},
258272
);
259273
});
274+
275+
describe('About names the ObjectStack version first, read from discovery (objectstack#35280)', () => {
276+
it.each(['18.5.0', '18.6.0-rc.2+deploy.41'])(
277+
'discovery answering `%s` fills the first row with exactly that value; the build row follows',
278+
async (version) => {
279+
consoleBuild = '0707b4ae';
280+
discoveryAnswer = Promise.resolve({ name: 'objectstack', version, services: {} });
281+
renderHeader('app');
282+
283+
const dialog = openAbout();
284+
const value = within(dialog).getByTestId('about:runtime-version');
285+
expect(await within(value).findByText(version)).toBeInTheDocument();
286+
expect(value.textContent).toBe(version);
287+
288+
const terms = Array.from(dialog.querySelectorAll('dt')).map((dt) => dt.textContent);
289+
expect(terms).toEqual(['«help.aboutVersion»', '«help.aboutBuild»']);
290+
const values = Array.from(dialog.querySelectorAll('dd')).map((dd) => dd.getAttribute('data-testid'));
291+
expect(values).toEqual(['about:runtime-version', 'about:console-build']);
292+
expect(within(dialog).getByTestId('about:console-build')).toHaveTextContent('0707b4ae');
293+
},
294+
);
295+
296+
it.each<[string, unknown]>([
297+
['discovery cannot be read (the adapter answers null)', null],
298+
['discovery answers no version', { name: 'objectstack', services: {} }],
299+
['discovery answers an empty version', { version: '' }],
300+
])('%s: the row says so in words, never an empty field', async (_case, answer) => {
301+
discoveryAnswer = Promise.resolve(answer);
302+
renderHeader('home');
303+
304+
const value = within(openAbout()).getByTestId('about:runtime-version');
305+
expect(await within(value).findByText('«help.aboutVersionUnknown»')).toBeInTheDocument();
306+
expect(value.textContent?.trim()).not.toBe('');
307+
});
308+
309+
it('while the read is in flight the row says it is loading, never an empty field', () => {
310+
discoveryAnswer = new Promise(() => {});
311+
renderHeader('app');
312+
313+
const value = within(openAbout()).getByTestId('about:runtime-version');
314+
expect(value).toHaveTextContent('«common.loading»');
315+
expect(within(value).queryByText('«help.aboutVersionUnknown»')).not.toBeInTheDocument();
316+
});
317+
});

‎ui/packages/i18n/src/locales/ar.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3716,7 +3716,9 @@ const ar = {
37163716
diagram: 'مخطط',
37173717
about: 'حول',
37183718
aboutTitle: 'حول وحدة التحكم هذه',
3719-
aboutDescription: 'الإصدار الذي بُنيت منه وحدة التحكم هذه.',
3719+
aboutDescription: 'إصدار ObjectStack الذي تعمل عليه وحدة التحكم هذه، والإصدار الذي بُنيت منه.',
3720+
aboutVersion: 'إصدار ObjectStack',
3721+
aboutVersionUnknown: 'إصدار غير معروف (لم يُبلغ الخادم عن أي إصدار)',
37203722
aboutBuild: 'إصدار وحدة التحكم',
37213723
aboutBuildUnknown: 'إصدار غير معروف (لم يُحدَّد أي إصدار عند بناء وحدة التحكم هذه)',
37223724
},

‎ui/packages/i18n/src/locales/de.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3401,7 +3401,9 @@ const de = {
34013401
diagram: 'Diagramm',
34023402
about: 'Über',
34033403
aboutTitle: 'Über diese Konsole',
3404-
aboutDescription: 'Der Build, aus dem diese Konsole kompiliert wurde.',
3404+
aboutDescription: 'Die ObjectStack-Version, auf der diese Konsole läuft, und der Build, aus dem sie kompiliert wurde.',
3405+
aboutVersion: 'ObjectStack-Version',
3406+
aboutVersionUnknown: 'Unbekannte Version (der Server hat keine gemeldet)',
34053407
aboutBuild: 'Konsolen-Build',
34063408
aboutBuildUnknown: 'Unbekannter Build (beim Erstellen dieser Konsole wurde keine Version gesetzt)',
34073409
},

‎ui/packages/i18n/src/locales/en.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4075,7 +4075,9 @@ const en = {
40754075
diagram: 'Diagram',
40764076
about: 'About',
40774077
aboutTitle: 'About this console',
4078-
aboutDescription: 'The build this console was compiled from.',
4078+
aboutDescription: 'The ObjectStack version this console runs on, and the build it was compiled from.',
4079+
aboutVersion: 'ObjectStack version',
4080+
aboutVersionUnknown: 'Unknown version (the server did not report one)',
40794081
aboutBuild: 'Console build',
40804082
aboutBuildUnknown: 'Unknown build (no version was set when this console was built)',
40814083
},

‎ui/packages/i18n/src/locales/es.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3481,7 +3481,9 @@ const es = {
34813481
diagram: 'Diagrama',
34823482
about: 'Acerca de',
34833483
aboutTitle: 'Acerca de esta consola',
3484-
aboutDescription: 'La compilación a partir de la cual se generó esta consola.',
3484+
aboutDescription: 'La versión de ObjectStack sobre la que se ejecuta esta consola y la compilación a partir de la cual se generó.',
3485+
aboutVersion: 'Versión de ObjectStack',
3486+
aboutVersionUnknown: 'Versión desconocida (el servidor no informó ninguna)',
34853487
aboutBuild: 'Compilación de la consola',
34863488
aboutBuildUnknown: 'Compilación desconocida (no se definió ninguna versión al compilar esta consola)',
34873489
},

‎ui/packages/i18n/src/locales/fr.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,9 @@ const fr = {
34773477
diagram: 'Diagramme',
34783478
about: 'À propos',
34793479
aboutTitle: 'À propos de cette console',
3480-
aboutDescription: 'Le build à partir duquel cette console a été compilée.',
3480+
aboutDescription: 'La version d’ObjectStack sur laquelle cette console s’exécute, et le build à partir duquel elle a été compilée.',
3481+
aboutVersion: 'Version d’ObjectStack',
3482+
aboutVersionUnknown: 'Version inconnue (le serveur n’en a signalé aucune)',
34813483
aboutBuild: 'Build de la console',
34823484
aboutBuildUnknown: 'Build inconnu (aucune version n’a été définie lors de la compilation de cette console)',
34833485
},

‎ui/packages/i18n/src/locales/ja.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3403,7 +3403,9 @@ const ja = {
34033403
diagram: '図',
34043404
about: 'バージョン情報',
34053405
aboutTitle: 'このコンソールについて',
3406-
aboutDescription: 'このコンソールのコンパイル元となったビルドです。',
3406+
aboutDescription: 'このコンソールが動作している ObjectStack のバージョンと、コンパイル元となったビルドです。',
3407+
aboutVersion: 'ObjectStack のバージョン',
3408+
aboutVersionUnknown: '不明なバージョン(サーバーがバージョンを報告しませんでした)',
34073409
aboutBuild: 'コンソールのビルド',
34083410
aboutBuildUnknown: '不明なビルド(このコンソールのビルド時にバージョンが設定されていません)',
34093411
},

‎ui/packages/i18n/src/locales/ko.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3401,7 +3401,9 @@ const ko = {
34013401
diagram: '다이어그램',
34023402
about: '정보',
34033403
aboutTitle: '이 콘솔 정보',
3404-
aboutDescription: '이 콘솔이 컴파일된 빌드입니다.',
3404+
aboutDescription: '이 콘솔이 실행 중인 ObjectStack 버전과 이 콘솔이 컴파일된 빌드입니다.',
3405+
aboutVersion: 'ObjectStack 버전',
3406+
aboutVersionUnknown: '알 수 없는 버전(서버가 버전을 보고하지 않음)',
34053407
aboutBuild: '콘솔 빌드',
34063408
aboutBuildUnknown: '알 수 없는 빌드(이 콘솔을 빌드할 때 버전이 설정되지 않음)',
34073409
},

‎ui/packages/i18n/src/locales/pt-BR.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,9 @@ const pt = {
34763476
diagram: 'Diagrama',
34773477
about: 'Sobre',
34783478
aboutTitle: 'Sobre este console',
3479-
aboutDescription: 'A build a partir da qual este console foi compilado.',
3479+
aboutDescription: 'A versão do ObjectStack em que este console é executado e a build a partir da qual ele foi compilado.',
3480+
aboutVersion: 'Versão do ObjectStack',
3481+
aboutVersionUnknown: 'Versão desconhecida (o servidor não informou nenhuma)',
34803482
aboutBuild: 'Build do console',
34813483
aboutBuildUnknown: 'Build desconhecida (nenhuma versão foi definida ao compilar este console)',
34823484
},

0 commit comments

Comments
 (0)