Skip to content

Commit 6cc6177

Browse files
fix(console): on a desktop the Studio refusal and the AI-unreachable sentence name the app start page (#37340)
repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW Fixes #37207 Clause-②: yes (widening) — one new published language-pack key, console.ai.unavailableErrorDesktop, in all eleven packs Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:桌面端无权进入 Studio 时的「返回首页」按钮改为「返回应用起始页」;AI 服务连不上时的提示句末尾也从「返回首页」改为「返回应用起始页」,与下方按钮一致;手机端不变。 - 为什么做:属于「去掉顶栏和平台首页那一层」专题的收尾,补上上一轮同类改动没覆盖到的两处文字。 - 出错会怎样:最坏是某种语言的提示句读起来不顺,跳转目标没有任何改动;可直接撤回。 - 要你做什么:无。 ## What changes Measured first, at `origin/main` fbb62e1 (after #37166 landed): `StudioRoute.tsx` `StudioAccessRequired` read `empty.appAccessDeniedHome` 「Back to home」, and `console.ai.unavailableError` ended "or head back home." on every width. This follows #37204's desktop/phone split (`usePhoneViewport`, under 768 px is a phone). - `ui/apps/console/src/components/StudioRoute.tsx`: the Studio refusal's way-home link reads `layout.appSwitcher.backToHome` 「Back to app start page」 from 768 px up, and `empty.appAccessDeniedHome` 「Back to home」 on a phone. `usePhoneViewport` comes from the `@object-ui/app-shell` barrel, which already exports it. The link target (`useHomePath()`) is unchanged. - `ui/packages/app-shell/src/console/ai/AiUnavailable.tsx`: with `hasError`, the sentence reads the new `console.ai.unavailableErrorDesktop` from 768 px up ("Couldn't reach the AI service. It may be temporarily offline — try again, or go back to the app start page."). A phone keeps `console.ai.unavailableError`. It now names the same place as the button under it. - `@object-ui/i18n`: `console.ai.unavailableErrorDesktop` added once in each of the 11 packs. Each translation reuses that pack's own `layout.appSwitcher.backToHome` wording for "app start page" (zh-Hans 返回应用起始页). No key removed or renamed. Clause-② measured: leaf keys per pack, base fbb62e1 → head, read by importing each pack file: en 5040→5041, zh-Hans 5040→5041, zh-Hant/ja/ko/de 5034→5035, fr/es/pt-BR 5191→5192, ru 5348→5349, ar 5662→5663. The new key is present in 11 of 11 packs and absent from all 11 at base. Only this one key is added. Props, exports and targets are unchanged. Read first, by risk: 1. `ui/packages/app-shell/src/console/ai/AiUnavailable.tsx`: the nested `phone` ternary inside `hasError`. 2. `ui/apps/console/src/components/StudioRoute.tsx`: the link label ternary. 3. `ui/packages/i18n/src/locales/de.ts` (and the other non-en packs): the translated sentence. Two-minute check: at a desktop width, sign in as a user without `studio.access` and open `/studio`. The button reads 「Back to app start page」. Narrow the window under 768 px and it reads 「Back to home」. ## Tests One pin each, at desktop width, with the phone as the CONTROL. Each is a new top-level `describe` in the surface's existing harness: - Studio refusal: `StudioRoute.test.tsx` "/studio refused: the way home names where it goes, by viewport". At 1280 px the link is 「Back to app start page」 and no 「Back to home」 link exists. CONTROL at 375 px: 「Back to home」. - AI unreachable: `RequireAiSurface.test.tsx` "the unreachable-service sentence names where its way home goes, by viewport". It renders `AiUnavailable` with `hasError`. Desktop: `console.ai.unavailableErrorDesktop`, not `console.ai.unavailableError`. CONTROL on a phone: the reverse. Existing pins moved to the desktop wording, because jsdom's window is 1024 px: `StudioRoute.test.tsx` `WAY_HOME`, and `StudioRoute.accessNotice-12035.test.tsx` `wayHomeIn` (now reads `layout.appSwitcher.backToHome` from each pack). <details><summary>Affected suites (vitest, from ui/), head 51f74e6</summary> ``` pnpm exec vitest run --maxWorkers=2 RequireAiSurface StudioRoute console-namespace-3546 all-locales-key-parity en-zh-key-parity AiChatPage Test Files 44 passed (44) Tests 386 passed (386) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Ablations (one-shot, restored to the HEAD blob)</summary> Studio refusal. In `StudioRoute.tsx`, `node scripts/ablation-replace.mjs` swapped the desktop arm's `layout.appSwitcher.backToHome` for `empty.appAccessDeniedHome` (anchor x1 -> x0, blob eb1f535 -> 95423fd7baec): ``` × on a desktop, where home is an app's start page, it reads as the app pill's row does (+ 7 existing desktop refusal cases that read WAY_HOME) Tests 8 failed | 12 passed (20) ablation-replace: ok restored: blob == HEAD (eb1f535) and `git diff HEAD` is empty ``` The phone CONTROL stayed green. AI unreachable. In `AiUnavailable.tsx`, the swap was `console.ai.unavailableErrorDesktop` → `console.ai.unavailableError` (anchor x1 -> x0, blob be89670 -> dada400011a4): ``` × on a desktop, where the button opens an app's start page, the sentence says so Tests 1 failed | 13 passed (14) ablation-replace: ok restored: blob == HEAD (be89670) and `git diff HEAD` is empty ``` Neither ablation needed a build step: both test files import the mutated source directly (console's own file; app-shell by relative path). </details> <details><summary>Type-check, i18n gates, derived gates</summary> ``` pnpm --filter '@object-ui/console^...' build VERDICT command-exit 0 pnpm --filter @object-ui/app-shell --filter @object-ui/console --filter @object-ui/i18n run type-check VERDICT command-exit 0 ui: check:i18n-keys EXIT=0 (5898/5898 literal keys resolve) · check:i18n-drift EXIT=0 (1 key added, 0 en values changed) · check:i18n-dead-keys EXIT=0 node scripts/pm/overlap-check.mjs: VERDICT clean exit 0 (origin/main; #37249 shares the 11 locale packs and merges cleanly) dispatch-gates --commands (after the changeset): 41 derived families; 40 run locally, all 40 exit 0 NOT MEASURED: pnpm --dir ui exec vitest run scripts/ (the ui scripts/ suite). The first run was SIGKILLed by the shared box's OOM killer; two lock retries got queue-timeout (exit 99) behind another session's full dogfood run. This diff edits no ui/scripts file. CI runs the suite. dispatch-gates --ran: 41 derived, 40 run, 1 UNRUN (the line above) ``` </details> ## Acceptance notes - `RequireAiSurface`'s `redirectTo` prop can still send the button somewhere other than `useHomePath()`. #37204 already accepted this for the button label, and the new sentence takes the same assumption. - Stale prose that the card lists as not in scope (`runtime-config.ts` `hideSingleAppSwitcher`, `approvals.json`, `studio-authoring.json:35`): none of those files is in this diff, so none is touched. ## Verification Local: affected suites, both ablations, type-check of the three touched packages, the ui i18n gates, the derived gate families. CI owns the full farm. --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7f62348 commit 6cc6177

17 files changed

Lines changed: 123 additions & 11 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/console': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
fix(console): on a desktop the Studio refusal's way home and the AI-unreachable sentence name the app start page
8+
9+
Clause-②: yes (widening) — one new published language-pack key, console.ai.unavailableErrorDesktop, in all eleven packs
10+
Metadata-protocol: none
11+
12+
From 768 px up the platform home page is retired, and the way home opens an app's start page. Two desktop texts still named a home page:
13+
14+
- A caller without Studio access who opens `/studio` sees a refusal with a 「Back to home」 button. On a desktop it now reads 「Back to app start page」 (zh: 返回应用起始页), the app pill's row label, as the console's other way-home buttons do.
15+
- When the AI service cannot be reached, the `/ai` screen's sentence ended 「…try again, or head back home.」 while its button already read 「Back to app start page」. On a desktop the sentence now ends 「…try again, or go back to the app start page.」, in every language.
16+
17+
A phone, whose Home is still its app list, keeps 「Back to home」 and 「…or head back home.」. No targets change. The new sentence is the language-pack key `console.ai.unavailableErrorDesktop`, added in all eleven packs; no key is removed or renamed, and no props or exports change.

‎ui/apps/console/src/components/StudioRoute.accessNotice-12035.test.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
* The `/studio` entry gate used to send a non-holder home with no word of why,
77
* so a missing capability read exactly like a broken link. It now says, at the
88
* URL that was opened, that Studio access is needed (`console.studio.accessRequired`),
9-
* with a way home that reuses the app refusal screen's label
10-
* (`empty.appAccessDeniedHome`). `StudioRoute.test.tsx` pins the decision and
9+
* with a way home that reuses the app refusal screen's label on a phone
10+
* (`empty.appAccessDeniedHome`) and the app pill's row label from 768 px up
11+
* (`layout.appSwitcher.backToHome`). `StudioRoute.test.tsx` pins the decision and
1112
* where the way home leads; this file pins the LANGUAGE.
1213
*
1314
* ## Why every pack, and why the expected text is read from the pack
@@ -93,8 +94,12 @@ const LANGUAGES = Object.keys(builtInLocales) as Language[];
9394

9495
/** The refusal's sentence, as one pack writes it. */
9596
const sentenceIn = (lang: Language) => builtInLocales[lang].console.studio.accessRequired;
96-
/** The refusal's way home, as one pack writes it (the app refusal screen's label). */
97-
const wayHomeIn = (lang: Language) => builtInLocales[lang].empty.appAccessDeniedHome;
97+
/**
98+
* The refusal's way home, as one pack writes it. jsdom's window is 1024 px, a
99+
* desktop, where home is an app's start page: the app pill's row label. A
100+
* phone keeps the app refusal screen's label; `StudioRoute.test.tsx` pins that.
101+
*/
102+
const wayHomeIn = (lang: Language) => builtInLocales[lang].layout.appSwitcher.backToHome;
98103

99104
function LocationProbe() {
100105
const { pathname } = useLocation();

‎ui/apps/console/src/components/StudioRoute.test.tsx‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ const pathname = () => screen.getByTestId('pathname').textContent;
155155
* file's pin.
156156
*/
157157
const NOTICE = 'You need Studio access to open Studio. An administrator can grant it with a permission set in Setup → Permission Set Assignment.';
158-
const WAY_HOME = 'Back to home';
158+
/** jsdom's window is 1024 px wide: a desktop, whose way home opens an app's start page. */
159+
const WAY_HOME = 'Back to app start page';
160+
/** A phone's way home, to its app list. */
161+
const PHONE_WAY_HOME = 'Back to home';
159162

160163
/**
161164
* The refusal, said at the URL that was opened: the sentence is on screen, the
@@ -467,3 +470,30 @@ describe('/studio/* — the states that are not an answer', () => {
467470
expect(screen.queryByText(NOTICE)).not.toBeInTheDocument();
468471
});
469472
});
473+
474+
describe('/studio refused: the way home names where it goes, by viewport', () => {
475+
const desktopWidth = window.innerWidth;
476+
function atWidth(px: number) {
477+
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: px });
478+
}
479+
afterEach(() => atWidth(desktopWidth));
480+
481+
it('on a desktop, where home is an app\'s start page, it reads as the app pill\'s row does', async () => {
482+
atWidth(1280);
483+
renderStudioDeepLink('/studio/hotcrm/data');
484+
485+
expect(await screen.findByText(NOTICE)).toBeInTheDocument();
486+
expect(screen.getByRole('link', { name: WAY_HOME })).toBeInTheDocument();
487+
expect(screen.queryByRole('link', { name: PHONE_WAY_HOME })).not.toBeInTheDocument();
488+
});
489+
490+
it('CONTROL — on a phone, whose Home is still its app list, it keeps 「Back to home」', async () => {
491+
atWidth(375);
492+
renderStudioDeepLink('/studio/hotcrm/data');
493+
494+
expect(await screen.findByText(NOTICE)).toBeInTheDocument();
495+
expect(screen.getByRole('link', { name: PHONE_WAY_HOME })).toBeInTheDocument();
496+
expect(screen.queryByRole('link', { name: WAY_HOME })).not.toBeInTheDocument();
497+
expect(designSurface).not.toHaveBeenCalled();
498+
});
499+
});

‎ui/apps/console/src/components/StudioRoute.tsx‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
studioMetadataAreaPath,
5151
studioPackagePath,
5252
useHomePath,
53+
usePhoneViewport,
5354
useRecentItems,
5455
useStudioEntryPermissions,
5556
} from '@object-ui/app-shell';
@@ -91,10 +92,13 @@ const StudioEntryRedirect = lazy(() =>
9192
* (`empty.appAccessDenied`): said in place, as the permanent decision it is, so
9293
* no Retry; and the URL stays, so the caller can send it to an administrator
9394
* and reload once access is granted. No header frames this screen, so the way
94-
* home is its own button, as there, and it reuses that screen's label.
95+
* home is its own button, as there, and it reuses that screen's labels.
9596
*/
9697
function StudioAccessRequired({ home }: { home: string }) {
9798
const { t } = useObjectTranslation();
99+
// A phone's Home is its app list; from 768 px up `home` opens an app's start
100+
// page, so the button says so, as the shell's other way-home buttons do.
101+
const phone = usePhoneViewport();
98102
return (
99103
<div className="flex h-screen items-center justify-center p-4">
100104
<Empty data-testid="studio-access-required">
@@ -108,7 +112,11 @@ function StudioAccessRequired({ home }: { home: string }) {
108112
</EmptyTitle>
109113
<div className="mt-4">
110114
<Button asChild>
111-
<Link to={home}>{t('empty.appAccessDeniedHome', { defaultValue: 'Back to home' })}</Link>
115+
<Link to={home}>
116+
{phone
117+
? t('empty.appAccessDeniedHome', { defaultValue: 'Back to home' })
118+
: t('layout.appSwitcher.backToHome', { defaultValue: 'Back to app start page' })}
119+
</Link>
112120
</Button>
113121
</div>
114122
</Empty>

‎ui/packages/app-shell/src/console/__tests__/RequireAiSurface.test.tsx‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import userEvent from '@testing-library/user-event';
55
import { MemoryRouter, Routes, Route } from 'react-router-dom';
66
import { MetadataCtx, type MetadataContextValue } from '@object-ui/react';
77
import { RequireAiSurface } from '../ConsoleShell';
8+
import { AiUnavailable } from '../ai/AiUnavailable';
89
import { useAiSurfaceEnabled } from '../../hooks/useAiSurface';
910

1011
// The guard gates purely on the AI-surface signal (the agent catalog); that
@@ -216,3 +217,37 @@ describe('the no-assistant screen\'s way home names where it goes, by viewport (
216217
expect(home).not.toHaveTextContent('«layout.appSwitcher.backToHome»');
217218
});
218219
});
220+
221+
describe('the unreachable-service sentence names where its way home goes, by viewport', () => {
222+
// `AiChatPage` draws this shape when the agent catalog fails to load: the
223+
// sentence points at the button below it, so it names the same place.
224+
const echo = (key: string) => `«${key}»`;
225+
function renderUnreachable() {
226+
return render(
227+
<MemoryRouter>
228+
<AiUnavailable hasError onRetry={() => {}} onHome={() => {}} t={echo} />
229+
</MemoryRouter>,
230+
);
231+
}
232+
233+
beforeEach(() => {
234+
viewer.phone = false;
235+
});
236+
237+
it('on a desktop, where the button opens an app\'s start page, the sentence says so', () => {
238+
renderUnreachable();
239+
const screenEl = screen.getByTestId('ai-unavailable');
240+
expect(screenEl).toHaveTextContent('«console.ai.unavailableErrorDesktop»');
241+
expect(screenEl).not.toHaveTextContent('«console.ai.unavailableError»');
242+
expect(screen.getByTestId('ai-unavailable-home')).toHaveTextContent('«layout.appSwitcher.backToHome»');
243+
});
244+
245+
it('CONTROL — on a phone, whose Home is still its app list, it keeps 「head back home」', () => {
246+
viewer.phone = true;
247+
renderUnreachable();
248+
const screenEl = screen.getByTestId('ai-unavailable');
249+
expect(screenEl).toHaveTextContent('«console.ai.unavailableError»');
250+
expect(screenEl).not.toHaveTextContent('«console.ai.unavailableErrorDesktop»');
251+
expect(screen.getByTestId('ai-unavailable-home')).toHaveTextContent('«console.ai.unavailableHome»');
252+
});
253+
});

‎ui/packages/app-shell/src/console/ai/AiUnavailable.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function AiUnavailable({
5050
// The way home names where it goes: a phone's Home is its app list; from
5151
// 768 px up the home page is retired (objectstack#36732) and `onHome` opens
5252
// an app's start page, named in the app pill's words (objectstack#37163).
53+
// The error sentence that points at that button says the same on each side.
5354
const phone = usePhoneViewport();
5455
return (
5556
<div className="flex flex-1 items-center justify-center p-6" data-testid="ai-unavailable">
@@ -59,10 +60,15 @@ export function AiUnavailable({
5960
</EmptyTitle>
6061
<EmptyDescription>
6162
{hasError
62-
? t('console.ai.unavailableError', {
63-
defaultValue:
64-
"Couldn't reach the AI service. It may be temporarily offline — try again, or head back home.",
65-
})
63+
? phone
64+
? t('console.ai.unavailableError', {
65+
defaultValue:
66+
"Couldn't reach the AI service. It may be temporarily offline — try again, or head back home.",
67+
})
68+
: t('console.ai.unavailableErrorDesktop', {
69+
defaultValue:
70+
"Couldn't reach the AI service. It may be temporarily offline — try again, or go back to the app start page.",
71+
})
6672
: t('console.ai.unavailableDescription', {
6773
defaultValue:
6874
"This deployment doesn't have an AI assistant enabled. Everything else works as usual.",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,7 @@ const ar = {
27852785
unavailableTitle: "مساعد الذكاء الاصطناعي غير متاح",
27862786
unavailableDescription: "لم يتم تمكين مساعد الذكاء الاصطناعي في هذا النشر. وكل شيء آخر يعمل كالمعتاد.",
27872787
unavailableError: "تعذّر الوصول إلى خدمة الذكاء الاصطناعي. قد تكون غير متصلة مؤقتًا — أعد المحاولة أو عد إلى الرئيسية.",
2788+
unavailableErrorDesktop: "تعذّر الوصول إلى خدمة الذكاء الاصطناعي. قد تكون غير متصلة مؤقتًا — أعد المحاولة أو عد إلى صفحة بدء التطبيق.",
27882789
unavailableRetry: "إعادة المحاولة",
27892790
unavailableHome: "العودة إلى الرئيسية",
27902791
dock: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,7 @@ const de = {
25052505
unavailableTitle: "KI-Assistent nicht verfügbar",
25062506
unavailableDescription: "In dieser Bereitstellung ist kein KI-Assistent aktiviert. Alles andere funktioniert wie gewohnt.",
25072507
unavailableError: "Der KI-Dienst war nicht erreichbar. Er ist möglicherweise vorübergehend offline — versuchen Sie es erneut, oder kehren Sie zur Startseite zurück.",
2508+
unavailableErrorDesktop: "Der KI-Dienst war nicht erreichbar. Er ist möglicherweise vorübergehend offline — versuchen Sie es erneut, oder kehren Sie zur Startseite der App zurück.",
25082509
unavailableRetry: "Erneut versuchen",
25092510
unavailableHome: "Zurück zur Startseite",
25102511
dock: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,6 +3372,7 @@ const en = {
33723372
unavailableTitle: 'AI assistant unavailable',
33733373
unavailableDescription: "This deployment doesn't have an AI assistant enabled. Everything else works as usual.",
33743374
unavailableError: "Couldn't reach the AI service. It may be temporarily offline — try again, or head back home.",
3375+
unavailableErrorDesktop: "Couldn't reach the AI service. It may be temporarily offline — try again, or go back to the app start page.",
33753376
unavailableRetry: 'Try again',
33763377
unavailableHome: 'Back to home',
33773378
dock: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,7 @@ const es = {
25772577
unavailableTitle: "Asistente de IA no disponible",
25782578
unavailableDescription: "Esta implementación no tiene habilitado un asistente de IA. Todo lo demás funciona con normalidad.",
25792579
unavailableError: "No se pudo contactar con el servicio de IA. Puede estar temporalmente sin conexión — reinténtelo o vuelva al inicio.",
2580+
unavailableErrorDesktop: "No se pudo contactar con el servicio de IA. Puede estar temporalmente sin conexión — reinténtelo o vuelva a la página inicial de la app.",
25802581
unavailableRetry: "Reintentar",
25812582
unavailableHome: "Volver al inicio",
25822583
dock: {

0 commit comments

Comments
 (0)