diff --git a/.changeset/34593-studio-open-app.md b/.changeset/34593-studio-open-app.md new file mode 100644 index 00000000000..a7005a3c902 --- /dev/null +++ b/.changeset/34593-studio-open-app.md @@ -0,0 +1,14 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(app-shell): Studio's top bar opens the running app, the package switcher hides kernel packages, and the read-only app bar entry shows its text + +Clause-②: yes (widening) — locale keys only: three new `@object-ui/i18n` studio keys (`engine.studio.openApp`, `engine.studio.openAppTitle`, `engine.studio.openAppPick`) and the added `{{app}}` variable in `topbar.openAppInStudio`; nothing that worked before is refused +Metadata-protocol: none + +- Studio's workbench top bar has an "Open app" button that returns to the package's running app in the same tab. It reads the `?surface=` the workbench has in focus, which is the same target the app bar's Edit app hands Studio. From an object it lands on that object's list in the app. From a dashboard, page or report it lands on that interface. Otherwise it lands on the app's home. When the package has several published apps, the button opens a picker. A package whose only app is still a draft gets no button. Unsaved pillar work asks before leaving, as the Home button does. +- The Studio package switcher no longer lists kernel packages. Before, the rows served with only a top-level `scope` of `system` or `cloud` (such as `sys.env-artifact-cache`) were still listed. ADR-0016 §3.8 keeps kernel packages out of the authoring selector, so there is no toggle to show them. `parsePackages` still returns those rows tagged `kernel`, because the app → Studio entry gate reads the tag. +- In the app bar, the entry for a read-only package shows its text next to the eye: "Open {app} in Studio" (「在 Studio 中查看 {app}」, ADR-0146 D5). Below `sm` it is still not drawn, and the app switcher's Studio row stays the phone's way in. +- New strings `engine.studio.openApp`, `engine.studio.openAppTitle` and `engine.studio.openAppPick` (en, zh). The `topbar.openAppInStudio` text now names the app in every locale. diff --git a/ui/packages/app-shell/README.md b/ui/packages/app-shell/README.md index 5c36ff07225..18b3210f03e 100644 --- a/ui/packages/app-shell/README.md +++ b/ui/packages/app-shell/README.md @@ -616,7 +616,19 @@ The route-type → surface-type decision lives in `appStudioRoutePath`. It is th reverse of the builder's "Open app" bridge (ADR-0080): the entry only renders for admins and only when the app has an owning package (`_packageId`), and package writability stays a server-side concern — a read-only package opens in -Studio as browse-only. +Studio as browse-only. For a read-only package the button draws an eye with the +words "Open {app} in Studio" (ADR-0146 D5) instead of the pencil. + +The way back is Studio's own "Open app" button in the workbench top bar +(`StudioOpenApp`). It reads the `?surface=` Studio has in focus — the same +target "Edit app" hands over — and lands on that object's list +(`/apps/:app/`), on that dashboard, page or report, or else on the +app's home, in the same tab. A package with several published apps gets a +picker; a package whose only app is still a draft gets no button. + +Studio's package switcher never lists a kernel package (ADR-0016 §3.8): neither +one whose manifest carries `scope: system | cloud` nor a row served with that +`scope` flat. There is no toggle that shows them. The sidebar's ⋯ menu offers the same bridge per entry: the **Design** entry of an `object`, `dashboard` or `page` navigation entry, and of the matching favorites, diff --git a/ui/packages/app-shell/src/layout/AppHeader.tsx b/ui/packages/app-shell/src/layout/AppHeader.tsx index 699412eb12f..106cb098652 100644 --- a/ui/packages/app-shell/src/layout/AppHeader.tsx +++ b/ui/packages/app-shell/src/layout/AppHeader.tsx @@ -679,12 +679,18 @@ export function AppHeader({ // // #27356 row 12 — a read-only package's app is not left with no way in: the // same gate answers it with the `view` posture, and this bar and the app - // switcher draw a browse entry (an eye, 「Open app in Studio」) where a + // switcher draw a browse entry (an eye, 「Open {app} in Studio」) where a // writable package's app gets the pencil. The posture is the gate's, read // once; the console's own apps and an unread list still draw neither. const studioEntry = useStudioEntryGate( isApp ? appStudioRoutePath(currentApp, true, { type: routeType, name: pathParts[3] }) : null, ); + // ADR-0146 D5 — the read-only entry's words: 「Open {app} in Studio」, the + // app switcher's row text, named for the app the bar is in. + const viewInStudioText = t('topbar.openAppInStudio', { + defaultValue: 'Open {{app}} in Studio', + app: currentApp ? appLabel(currentApp) : (appName ?? ''), + }); // The crumbs drawn after the app pill from `sm` up: a report or `system/*` // route's. @@ -1123,19 +1129,25 @@ export function AppHeader({ )} {/* #27356 row 12 — a read-only package's app: the same slot, an eye - that opens it in Studio's browse-only posture. */} + that opens it in Studio's browse-only posture. ADR-0146 D5 — it + draws WITH its text, 「Open {app} in Studio」, so a look is not + mistaken for the pencil's edit. The name truncates inside a + capped width, and below `sm` the button is not drawn at all + (objectstack#29075: the app switcher's Studio row carries it). */} {studioEntry?.posture === 'view' && ( )} diff --git a/ui/packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx index 2df6fa62b55..f945c5f8063 100644 --- a/ui/packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx @@ -12,7 +12,7 @@ * * #27356 row 12 (maintainer-ruled B): the read-only package's app is not left * with no entry. The same gate answers it with the `view` posture, and the bar - * draws an eye (「Open app in Studio」) in the pencil's place, the switcher row + * draws an eye (「Open {app} in Studio」, ADR-0146 D5) in the pencil's place, the switcher row * taking the same target in the same posture. Kernel packages, an unlisted * package and an unread list still draw neither. * @@ -41,7 +41,9 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ ...(await importOriginal>()), useObjectTranslation: () => ({ language: 'en', - t: (key: string, options?: Record) => String(options?.defaultValue ?? key), + // i18next's `{{token}}` interpolation, so an app-named entry reads as drawn. + t: (key: string, options?: Record) => + String(options?.defaultValue ?? key).replace(/\{\{(\w+)\}\}/g, (_m, k: string) => String(options?.[k] ?? '')), }), useObjectLabel: () => { const label = (x: { name?: string; label?: string } | string) => @@ -288,7 +290,8 @@ describe('the app bar\'s Edit app follows the owning package\'s posture (objectu }); mountAt(HOTCRM_ROUTE); await settle(); - expect(screen.getByLabelText('Open app in Studio')).toBeInTheDocument(); + // ADR-0146 D5 — the eye is named for the app: 「Open {app} in Studio」. + expect(screen.getByRole('link', { name: 'Open CRM in Studio' })).toHaveAttribute('href', HOTCRM_VIEW); }); it('CONTROL — the pencil for a writable package, deep-linked, and the switcher row to the same target', async () => { @@ -376,3 +379,24 @@ describe('what the posture read costs (objectui#12615)', () => { expect(packageReads(fetchMock)).toBe(1); }); }); + +describe('the read-only entry draws WITH its text, named for the app (objectstack#34593, ADR-0146 D5)', () => { + it('the eye carries the visible words 「Open {app} in Studio」, not an icon alone', async () => { + mountAt(HOTCRM_ROUTE); + await settle(); + const entry = screen.getByTestId('app-view-in-studio-button'); + const words = entry.querySelector('[data-slot="view-in-studio-text"]'); + expect(words).not.toBeNull(); + expect(words).toHaveTextContent(/^Open CRM in Studio$/); + expect(words).not.toHaveClass('sr-only'); + expect(entry.querySelector('svg')).not.toBeNull(); + }); + + it('CONTROL — the writable package keeps the pencil, icon-only, with no browse words', async () => { + mountAt(BASE_ROUTE); + await settle(); + const pencil = screen.getByTestId('app-design-in-studio-button'); + expect(pencil.querySelector('[data-slot="view-in-studio-text"]')).toBeNull(); + expect(screen.queryByText(/in Studio$/)).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx index e2a0f6fd79f..47a11688a89 100644 --- a/ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/AppHeader.phoneTargets-29075.test.tsx @@ -242,9 +242,15 @@ describe('below sm an app\'s bar leaves the product mark and the Studio button t it('the Studio button, in either posture, is not drawn below sm (read from source: it needs a package read)', () => { const src = source('AppHeader.tsx'); - for (const id of ['app-design-in-studio-button', 'app-view-in-studio-button']) { - expect(src, id).toMatch(new RegExp(`className="h-8 w-8 ${PHONE_TARGET} max-sm:hidden shrink-0"\\s*asChild\\s*data-testid="${id}"`)); - } + expect(src, 'app-design-in-studio-button').toMatch( + new RegExp(`className="h-8 w-8 ${PHONE_TARGET} max-sm:hidden shrink-0"\\s*asChild\\s*data-testid="app-design-in-studio-button"`), + ); + // objectstack#34593 (ADR-0146 D5) — the read-only entry draws its words, + // so it is not square: its phone-band target is the 44 px height, the + // words giving it the width, and it is still not drawn below sm. + expect(src, 'app-view-in-studio-button').toMatch( + /className="h-8 max-md:h-11 max-sm:hidden shrink-0[^"]*"\s*asChild\s*data-testid="app-view-in-studio-button"/, + ); }); it('CONTROL — no other bar control is hidden below sm: trigger, search and avatar stay', () => { diff --git a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx index 7cd8348fcda..c6cda50050b 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx @@ -60,6 +60,16 @@ export const PACKAGE_LIST_TOAST_ID = 'studio-package-list'; /** objectui#12513 — the Studio landing (`BuilderLanding`), where the header's first button and the switcher's first row lead. */ export const STUDIO_LANDING_PATH = '/studio'; +/** + * The rows the switcher offers: every listed package but a kernel one + * (ADR-0016 §3.8 — "you cannot author into a kernel package"). `null` while + * the list has not answered. There is no toggle that shows them: a kernel + * package opened by its URL is still named by the chip (`openEntry`). + */ +export function offeredPackages(pkgs: readonly PkgEntry[] | null): PkgEntry[] | null { + return pkgs === null ? null : pkgs.filter((p) => !p.kernel); +} + export function PackageSwitcher({ packageId, tab, @@ -152,12 +162,19 @@ export function PackageSwitcher({ }; }, [packageId]); + // ADR-0016 §3.8 — kernel packages are not offered for authoring. `fetchPackages` + // already leaves out the manifest-scoped ones; a row the registry half serves + // flat with a kernel `scope` stays in that list, tagged `kernel`, because the + // app → Studio entry gate reads the tag. The switcher hides it here. + const offered = offeredPackages(pkgs); + // The trigger NAMES the open package, which is not offering it: a kernel + // package opened by its URL is still named from its listed row. const listedCurrent = pkgs?.find((p) => p.id === packageId) ?? null; // Only once the list has answered, so the three trigger states stay its own. const current = listedCurrent ?? (pkgs !== null && openEntry?.id === packageId ? openEntry : null); // objectstack#28572 (ADR-0146 D3) — a base's paired `.custom` has no // row of its own: it is folded under its base, which names it. - const folded = React.useMemo(() => foldCustomizationPairs(pkgs ?? []), [pkgs]); + const folded = React.useMemo(() => foldCustomizationPairs(offeredPackages(pkgs) ?? []), [pkgs]); /** * Which of the three the trigger is showing (objectui#7368). A failure wins * over a list already in hand: after a failed refresh the names on screen are @@ -591,10 +608,10 @@ export function PackageSwitcher({ {pkgsErr}

)} - {pkgListState === 'loaded' && pkgs?.length === 0 && ( + {pkgListState === 'loaded' && offered?.length === 0 && (

{t('engine.studio.pkg.none', locale)}

)} - {pkgs !== null && folded.rows.map((p) => ( + {offered !== null && folded.rows.map((p) => ( + ); + } + + return ( + + + + + +

+ {t('engine.studio.openAppPick', locale)} +

+ {apps.map((app) => ( + + ))} +
+
+ ); +} diff --git a/ui/packages/app-shell/src/views/studio-design/packages-io.ts b/ui/packages/app-shell/src/views/studio-design/packages-io.ts index 9675c0eed6e..ebede3dcb1b 100644 --- a/ui/packages/app-shell/src/views/studio-design/packages-io.ts +++ b/ui/packages/app-shell/src/views/studio-design/packages-io.ts @@ -23,8 +23,11 @@ * why the client cannot compute this and a "missing scope means read-only" rule * would have flipped every Studio base read-only. * - * Kernel packages (scope `system` / `cloud`) are hidden here whatever their - * verdict says: that filter is about visibility, not writability. + * Kernel packages (scope `system` / `cloud`) are hidden from the switcher + * whatever their verdict says: that filter is about visibility, not + * writability. A manifest-scoped one is left out of this list; a flat-scoped + * one stays in it, tagged `kernel`, and the switcher hides it + * (`offeredPackages` in `PackageSwitcher.tsx`, ADR-0016 §3.8). */ import { EnsureCustomizationPackageResponseSchema } from '@objectstack/spec/api'; @@ -58,10 +61,10 @@ export interface PkgEntry { /** * #27356 row 12 — set (only ever `true`) on a row the registry half serves * flat with a kernel `scope` (`system` / `cloud`) at the top level. Such a - * row stays in the list (the switcher's visibility reads the manifest's - * `scope` alone, see {@link parsePackages}), but the app → Studio entries + * row stays in the list, because the app → Studio entries read this tag to * draw nothing for it (`useStudioEntryGate`), as for the manifest-scoped - * kernel packages this list leaves out. + * kernel packages this list leaves out. The Studio package switcher does + * not offer it (`offeredPackages`, ADR-0016 §3.8). */ kernel?: true; } @@ -88,9 +91,10 @@ export interface PkgEntry { * is the server's own computed verdict (see the module doc), a field the * manifest does not and should not carry. * - * `scope` is deliberately left manifest-only: widening it would change which - * packages the switcher HIDES, which is a different question from what it - * NAMES and is not this card's. + * `scope` is read in both positions, for two different answers: a manifest + * kernel scope drops the row here, while a flat one keeps the row and tags it + * `kernel` — the app → Studio entry gate reads that tag, and the switcher + * hides the tagged row (`offeredPackages` in `PackageSwitcher.tsx`). */ export function parsePackages(payload: unknown): PkgEntry[] { const root = (payload as { data?: unknown })?.data ?? payload; diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 6c1b37e4d93..b6568b52d9e 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -3487,7 +3487,7 @@ const ar = { aiAssistant: "مساعد الذكاء الاصطناعي", designInStudio: "التصميم في Studio", editApp: "تعديل التطبيق", - openAppInStudio: "عرض التطبيق في Studio", + openAppInStudio: "عرض {{app}} في Studio", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index e13a0334a49..723941e34af 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -3213,7 +3213,7 @@ const de = { aiAssistant: "KI-Assistent", designInStudio: "Im Studio gestalten", editApp: "App bearbeiten", - openAppInStudio: "App im Studio ansehen", + openAppInStudio: "{{app}} im Studio ansehen", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 05de0782a93..00d3143a1e3 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -3865,7 +3865,7 @@ const en = { aiAssistant: 'AI Assistant', designInStudio: 'Design in Studio', editApp: 'Edit app', - openAppInStudio: 'Open app in Studio', + openAppInStudio: 'Open {{app}} in Studio', openAssistant: 'Open {{name}} assistant', offline: 'Offline', usersOnline: 'Users currently online', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 29a924f63e9..7e65d536c4b 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -3283,7 +3283,7 @@ const es = { aiAssistant: "Asistente de IA", designInStudio: "Diseñar en Studio", editApp: "Editar aplicación", - openAppInStudio: "Ver la aplicación en Studio", + openAppInStudio: "Ver {{app}} en Studio", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index d8267583b7a..0c3d4d62baf 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -3279,7 +3279,7 @@ const fr = { aiAssistant: "Assistant IA", designInStudio: "Concevoir dans Studio", editApp: "Modifier l'application", - openAppInStudio: "Voir l'application dans Studio", + openAppInStudio: "Voir {{app}} dans Studio", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 69b4c36ae06..5c7594963e3 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -3215,7 +3215,7 @@ const ja = { aiAssistant: "AI アシスタント", designInStudio: "Studio でデザイン", editApp: "アプリを編集", - openAppInStudio: "Studio でアプリを表示", + openAppInStudio: "Studio で {{app}} を表示", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index a390244a8b2..89802c3d9be 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -3213,7 +3213,7 @@ const ko = { aiAssistant: "AI 어시스턴트", designInStudio: "Studio에서 디자인", editApp: "앱 편집", - openAppInStudio: "Studio에서 앱 보기", + openAppInStudio: "Studio에서 {{app}} 보기", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index e229bb8cb57..566da69b0c9 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -3278,7 +3278,7 @@ const pt = { aiAssistant: "Assistente de IA", designInStudio: "Projetar no Studio", editApp: "Editar aplicativo", - openAppInStudio: "Ver aplicativo no Studio", + openAppInStudio: "Ver {{app}} no Studio", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 2b96fe82ee3..e253deab312 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -3358,7 +3358,7 @@ const ru = { aiAssistant: "ИИ-ассистент", designInStudio: "Дизайн в Studio", editApp: "Редактировать приложение", - openAppInStudio: "Открыть приложение в Studio", + openAppInStudio: "Открыть {{app}} в Studio", }, home: { build: { diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index f3936cb8be0..0024f3037e7 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -3279,7 +3279,7 @@ const zh = { aiAssistant: 'AI 助手', designInStudio: '在 Studio 中设计', editApp: '编辑应用', - openAppInStudio: '在 Studio 中查看应用', + openAppInStudio: '在 Studio 中查看 {{app}}', openAssistant: '打开{{name}}助手', offline: '离线', usersOnline: '当前在线用户', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index bb963982c9f..efc3cc06ce0 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -3279,7 +3279,7 @@ const zhHant = { aiAssistant: 'AI 助手', designInStudio: '在 Studio 中設計', editApp: '編輯應用', - openAppInStudio: '在 Studio 中檢視應用', + openAppInStudio: '在 Studio 中檢視 {{app}}', openAssistant: '開啟{{name}}助手', offline: '離線', usersOnline: '當前線上使用者', diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 2387370b143..39ee38a725d 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3337,6 +3337,11 @@ const STUDIO_EN: Record = { 'engine.studio.pillar.metadata': 'All metadata', // Header · package-level publish + app bridge 'engine.studio.changes': 'Changes', + // objectstack#34593 — the header's way back to the package's running app, + // the mirror of the app bar's Edit app; with several apps it opens a picker. + 'engine.studio.openApp': 'Open app', + 'engine.studio.openAppTitle': 'Open {app} — leave Studio for the running app', + 'engine.studio.openAppPick': 'Open which app?', 'engine.studio.publishTitle': 'Review and publish every pending draft in this package together', 'engine.studio.publishNoneTitle': 'No drafts pending publish', 'engine.studio.publishedAll': 'Published all drafts in this package', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index ab5164daba9..d9d28d43e1f 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -2945,6 +2945,9 @@ const STUDIO_ZH: Record = { 'engine.studio.pillar.metadata': '全部元数据', // Header · package-level publish + app bridge 'engine.studio.changes': '变更', + 'engine.studio.openApp': '打开应用', + 'engine.studio.openAppTitle': '打开 {app}:离开 Studio,回到运行中的应用', + 'engine.studio.openAppPick': '打开哪个应用?', 'engine.studio.publishTitle': '检查并一并发布本软件包的全部待发布草稿', 'engine.studio.publishNoneTitle': '没有待发布的草稿', 'engine.studio.publishedAll': '已发布本软件包的全部草稿',