From f69e0befa7b0f469d1a5f6be785ee870f2a0da2b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:49:45 +0000 Subject: [PATCH 1/6] feat(studio): Open app returns from the workbench to the running app; the switcher hides kernel packages Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz --- .../app-shell/src/layout/AppHeader.tsx | 26 ++- .../views/studio-design/PackageSwitcher.tsx | 23 ++- .../studio-design/StudioDesignSurface.tsx | 35 +++- .../src/views/studio-design/StudioOpenApp.tsx | 151 ++++++++++++++++++ .../src/views/studio-design/packages-io.ts | 20 ++- ui/packages/i18n/src/namespaces/studio/en.ts | 5 + ui/packages/i18n/src/namespaces/studio/zh.ts | 3 + 7 files changed, 238 insertions(+), 25 deletions(-) create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioOpenApp.tsx diff --git a/ui/packages/app-shell/src/layout/AppHeader.tsx b/ui/packages/app-shell/src/layout/AppHeader.tsx index 58464aba442..5062f20b4ab 100644 --- a/ui/packages/app-shell/src/layout/AppHeader.tsx +++ b/ui/packages/app-shell/src/layout/AppHeader.tsx @@ -670,12 +670,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. @@ -1098,19 +1104,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/views/studio-design/PackageSwitcher.tsx b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx index 7cd8348fcda..030b8ff87ba 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,17 @@ export function PackageSwitcher({ }; }, [packageId]); - const listedCurrent = pkgs?.find((p) => p.id === packageId) ?? null; + // 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); + const listedCurrent = offered?.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 +606,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/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index f43d7ad5d10..9ccd9374423 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 4aa83f20d02..ce75aadfff4 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': '已发布本软件包的全部草稿', From 72ff960a680f3b33f8112fffab03339765014b53 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:52:22 +0000 Subject: [PATCH 2/6] test(studio): pin Open app, the kernel-free switcher and the read-only entry's text Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz --- .changeset/34593-studio-open-app.md | 14 ++ ...ditAppFollowsPackagePosture-12615.test.tsx | 30 ++- .../AppHeader.phoneTargets-29075.test.tsx | 12 +- ...StudioDesignSurface.openApp-34593.test.tsx | 211 ++++++++++++++++++ ui/packages/i18n/src/locales/ar.ts | 2 +- ui/packages/i18n/src/locales/de.ts | 2 +- ui/packages/i18n/src/locales/en.ts | 2 +- ui/packages/i18n/src/locales/es.ts | 2 +- ui/packages/i18n/src/locales/fr.ts | 2 +- ui/packages/i18n/src/locales/ja.ts | 2 +- ui/packages/i18n/src/locales/ko.ts | 2 +- ui/packages/i18n/src/locales/pt-BR.ts | 2 +- ui/packages/i18n/src/locales/ru.ts | 2 +- ui/packages/i18n/src/locales/zh-Hans.ts | 2 +- ui/packages/i18n/src/locales/zh-Hant.ts | 2 +- 15 files changed, 272 insertions(+), 17 deletions(-) create mode 100644 .changeset/34593-studio-open-app.md create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx diff --git a/.changeset/34593-studio-open-app.md b/.changeset/34593-studio-open-app.md new file mode 100644 index 00000000000..da3e40bd1da --- /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-②: no +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/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx index 0eb215a1e21..4afeaa8d7cf 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) => @@ -287,7 +289,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 () => { @@ -375,3 +378,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 892abf715ab..7a9d1ab25d4 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 @@ -241,9 +241,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/StudioDesignSurface.openApp-34593.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx new file mode 100644 index 00000000000..045996c8081 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx @@ -0,0 +1,211 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34593 — the Studio workbench and the running app, both ways. + * + * 1. The header offers 「打开应用」/ "Open app", the mirror of the app bar's + * Edit app: from the object in focus (`?surface=object:`, the + * target Edit app hands Studio) it lands on that object's list in the + * app; with no surface in focus it lands on the app's home. A package + * with several published apps offers a choice; a package whose only app + * is still a draft offers nothing (no running front-end yet). + * 2. The package switcher offers business packages only (ADR-0016 §3.8 — + * "you cannot author into a kernel package"): the kernel rows the + * registry half serves with a flat `scope` are hidden too, while the list + * keeps them tagged `kernel` for the app → Studio entry gate. No toggle + * shows them. + * + * The REAL `StudioDesignSurface` and metadata client over a fetch stub that + * serves the package list, the package's apps and objects. The running app is + * a route that prints where the author landed. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; + +const OWN = 'com.example.sales'; +const FLAT_KERNEL = 'sys.env-artifact-cache'; +const MANIFEST_KERNEL = 'com.objectstack.plugin-auth'; + +const srv = vi.hoisted(() => ({ + apps: [] as Array>, + appDrafts: [] as Array>, +})); + +vi.mock('@object-ui/react', async (importOriginal) => { + const actual = await importOriginal>(); + return { ...actual, useAdapter: () => ({}) }; +}); +vi.mock('sonner', () => ({ + toast: { warning: vi.fn(), error: vi.fn(), success: vi.fn(), info: vi.fn(), message: vi.fn(), dismiss: vi.fn() }, + Toaster: () => null, +})); +vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null })); +vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null })); +vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null })); +vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); + +import { StudioDesignSurface } from './StudioDesignSurface'; +import { studioOpenAppPath } from './StudioOpenApp'; +import { offeredPackages } from './PackageSwitcher'; +import { parsePackages } from './packages-io'; + +window.matchMedia = ((query: string) => ({ + matches: false, + media: query, + onchange: null, + addEventListener: () => {}, + removeEventListener: () => {}, + addListener: () => {}, + removeListener: () => {}, + dispatchEvent: () => false, +})) as unknown as typeof window.matchMedia; +(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = + (globalThis as unknown as { ResizeObserver?: unknown }).ResizeObserver ?? + class { + observe() {} + unobserve() {} + disconnect() {} + }; + +function json(body: unknown, status = 200): Response { + return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } }); +} + +/** `GET /api/v1/packages` as both producers serve it: the durable half nested, the registry half flat. */ +const PACKAGE_LIST = { + success: true, + data: [ + { id: FLAT_KERNEL, name: 'Environment artifact cache', scope: 'system', writable: false }, + { manifest: { id: MANIFEST_KERNEL, name: 'Authentication', scope: 'system' }, writable: false }, + { manifest: { id: OWN, name: 'Sales', namespace: 'sales', version: '0.1.0' }, writable: true }, + ], +}; + +const SALES_APP = { name: 'sales', label: 'Sales', navigation: [{ id: 'nav_opp', type: 'object', objectName: 'opportunity' }] }; +const SERVICE_APP = { name: 'service', label: 'Service desk', navigation: [] }; + +beforeEach(() => { + srv.apps = [SALES_APP]; + srv.appDrafts = []; + vi.stubGlobal( + 'fetch', + vi.fn(async (input: unknown) => { + const url = new URL(String(input), 'http://localhost'); + const path = url.pathname; + if (path === '/api/v1/packages') return json(PACKAGE_LIST); + if (path === '/api/v1/meta/_drafts') { + return json({ drafts: url.searchParams.get('type') === 'app' ? srv.appDrafts : [] }); + } + if (path === '/api/v1/meta/app') return json(srv.apps); + if (path === '/api/v1/meta/object') { + return json([ + { name: 'opportunity', label: 'Opportunity', fields: {} }, + { name: 'account', label: 'Account', fields: {} }, + ]); + } + if (path.endsWith('/layers')) return json({ code: null, overlay: null, overlayScope: null, effective: null }); + if (/^\/api\/v1\/meta\/[^/]+\/[^/]+$/.test(path)) return json({}, 404); + return json([]); + }) as unknown as typeof fetch, + ); +}); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); +}); + +function RunningApp() { + const location = useLocation(); + return

{location.pathname}

; +} + +function renderAt(entry: string) { + return render( + + + } /> + } /> + + , + ); +} + +const header = () => screen.getByTestId('studio-shell-header'); + +describe('Open app returns from the workbench to the running app (objectstack#34593)', () => { + it('from the Opportunity in focus, Open app lands back on the Opportunity list', async () => { + renderAt(`/studio/${OWN}/data?surface=object:opportunity`); + const button = await within(header()).findByTestId('studio-open-app', undefined, { timeout: 8000 }); + expect(button).toHaveAccessibleName('Open app'); + fireEvent.click(button); + expect(await screen.findByTestId('running-app')).toHaveTextContent(`/apps/${OWN}/opportunity`); + }); + + it('with no surface in focus, it lands on the app home', async () => { + renderAt(`/studio/${OWN}/access`); + fireEvent.click(await within(header()).findByTestId('studio-open-app', undefined, { timeout: 8000 })); + expect(await screen.findByTestId('running-app')).toHaveTextContent(new RegExp(`^/apps/${OWN.replace(/\./g, '\\.')}$`)); + }); + + it('a package with several apps offers a choice, and each lands under its own address', async () => { + srv.apps = [SALES_APP, SERVICE_APP]; + renderAt(`/studio/${OWN}/data?surface=object:opportunity`); + fireEvent.click(await within(header()).findByTestId('studio-open-app', undefined, { timeout: 8000 })); + const menu = await screen.findByTestId('studio-open-app-menu'); + const rows = within(menu).getAllByTestId('studio-open-app-row'); + expect(rows.map((r) => r.textContent)).toEqual(['Sales', 'Service desk']); + fireEvent.click(rows[1]!); + expect(await screen.findByTestId('running-app')).toHaveTextContent('/apps/service/opportunity'); + }); + + it('a package whose only app is a draft offers no Open app (nothing runs yet)', async () => { + srv.apps = []; + srv.appDrafts = [{ name: 'sales', label: 'Sales', type: 'app' }]; + renderAt(`/studio/${OWN}/data`); + await waitFor(() => expect(within(header()).getByTestId('studio-pkg-chip')).toHaveAttribute('data-pkg-list-state', 'loaded'), { + timeout: 8000, + }); + // The draft app is resolved (the header's create-app slot reads it), and still no way out is drawn. + await waitFor(() => expect(within(header()).queryByRole('button', { name: /Create app/ })).toBeNull()); + expect(within(header()).queryByTestId('studio-open-app')).toBeNull(); + }); + + it('the path mirrors the app bar\'s Edit app targets: object list, interface page, else app home', () => { + const one = [{ name: 'sales', label: 'Sales' }]; + const two = [...one, { name: 'service', label: 'Service' }]; + expect(studioOpenAppPath(OWN, one, 'sales', { type: 'object', name: 'opportunity' })).toBe(`/apps/${OWN}/opportunity`); + expect(studioOpenAppPath(OWN, one, 'sales', { type: 'dashboard', name: 'pipeline' })).toBe(`/apps/${OWN}/dashboard/pipeline`); + expect(studioOpenAppPath(OWN, one, 'sales', { type: 'flow', name: 'close_won' })).toBe(`/apps/${OWN}`); + expect(studioOpenAppPath(OWN, one, 'sales', null)).toBe(`/apps/${OWN}`); + expect(studioOpenAppPath(OWN, two, 'service', { type: 'object', name: 'opportunity' })).toBe('/apps/service/opportunity'); + }); +}); + +describe('the package switcher offers business packages only (objectstack#34593, ADR-0016 §3.8)', () => { + it('no kernel row in the menu — neither the manifest-scoped one nor the one served with a flat `scope`', async () => { + renderAt(`/studio/${OWN}/access`); + const chip = await within(header()).findByTestId('studio-pkg-chip', undefined, { timeout: 8000 }); + await waitFor(() => expect(chip).toHaveAttribute('data-pkg-list-state', 'loaded'), { timeout: 8000 }); + fireEvent.click(chip); + const menu = await screen.findByRole('dialog'); + const rows = within(menu).getAllByTestId('studio-switcher-row').map((r) => r.getAttribute('data-package')); + expect(rows).toEqual([OWN]); + expect(within(menu).queryByText(FLAT_KERNEL)).toBeNull(); + expect(within(menu).queryByText(/show system/i)).toBeNull(); + }); + + it('CONTROL — the list itself keeps the flat kernel row, tagged, for the app → Studio entry gate', () => { + const listed = parsePackages(PACKAGE_LIST); + expect(listed.map((p) => [p.id, p.kernel ?? false])).toEqual([ + [FLAT_KERNEL, true], + [OWN, false], + ]); + expect(offeredPackages(listed)?.map((p) => p.id)).toEqual([OWN]); + expect(offeredPackages(null)).toBeNull(); + }); +}); diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 787c98eac50..eb8bad41949 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -3469,7 +3469,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 4b7939926e3..c5c9eaa6b38 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -3195,7 +3195,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 cc5bb5b7b00..c642dba4145 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -3843,7 +3843,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 3f539fd008e..fbccc3ed025 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -3265,7 +3265,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 77b6c94e8aa..fabf6e41804 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -3261,7 +3261,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 0bea43bfdf8..43831c2f40a 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -3197,7 +3197,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 074dcd5df8a..a333dda6958 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -3195,7 +3195,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 5980b0d5725..656abbedea1 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -3260,7 +3260,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 8185bd8f2f8..e6f696feba8 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -3340,7 +3340,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 2083bb53b1d..a987758133f 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -3261,7 +3261,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 b36646c0c94..a1fb51d816b 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -3261,7 +3261,7 @@ const zhHant = { aiAssistant: 'AI 助手', designInStudio: '在 Studio 中設計', editApp: '編輯應用', - openAppInStudio: '在 Studio 中檢視應用', + openAppInStudio: '在 Studio 中檢視 {{app}}', openAssistant: '開啟{{name}}助手', offline: '離線', usersOnline: '當前線上使用者', From 37c3d4d6011b61685606c52f5331c40e3a45b8c1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:35:51 +0000 Subject: [PATCH 3/6] test(studio): pay the lint module load at collection in the Open app pin Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz --- .../studio-design/StudioDesignSurface.openApp-34593.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx index 045996c8081..5a383a50d75 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx @@ -25,6 +25,9 @@ import * as React from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +// The surface's reach loads `@objectstack/lint` lazily; pay that load during +// collection, not inside a case's clocked window (`check:test-source-alias`). +import '@objectstack/lint'; const OWN = 'com.example.sales'; const FLAT_KERNEL = 'sys.env-artifact-cache'; From bb251e84f331f1002cf7ebf5b8fc1e2be55ad90a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:14:47 +0000 Subject: [PATCH 4/6] fix(studio): the switcher chip still names an open kernel package; English-only comments The chip names the open package from the full listed set (naming is not offering), and the Open app comments and changeset drop the Chinese label. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz --- .changeset/34593-studio-open-app.md | 2 +- .../app-shell/src/views/studio-design/PackageSwitcher.tsx | 4 +++- .../studio-design/StudioDesignSurface.openApp-34593.test.tsx | 2 +- .../app-shell/src/views/studio-design/StudioOpenApp.tsx | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.changeset/34593-studio-open-app.md b/.changeset/34593-studio-open-app.md index da3e40bd1da..4ea727f9583 100644 --- a/.changeset/34593-studio-open-app.md +++ b/.changeset/34593-studio-open-app.md @@ -8,7 +8,7 @@ feat(app-shell): Studio's top bar opens the running app, the package switcher hi Clause-②: no 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. +- 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/src/views/studio-design/PackageSwitcher.tsx b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx index 030b8ff87ba..c6cda50050b 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx @@ -167,7 +167,9 @@ export function PackageSwitcher({ // 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); - const listedCurrent = offered?.find((p) => p.id === packageId) ?? null; + // 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 diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx index 5a383a50d75..324fec265f6 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.openApp-34593.test.tsx @@ -3,7 +3,7 @@ /** * objectstack#34593 — the Studio workbench and the running app, both ways. * - * 1. The header offers 「打开应用」/ "Open app", the mirror of the app bar's + * 1. The header offers "Open app", the mirror of the app bar's * Edit app: from the object in focus (`?surface=object:`, the * target Edit app hands Studio) it lands on that object's list in the * app; with no surface in focus it lands on the app's home. A package diff --git a/ui/packages/app-shell/src/views/studio-design/StudioOpenApp.tsx b/ui/packages/app-shell/src/views/studio-design/StudioOpenApp.tsx index e0a992f5cc2..148f36010b9 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioOpenApp.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioOpenApp.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The Studio header's way back to the running app: 「打开应用」/ "Open app" + * The Studio header's way back to the running app: "Open app" * (objectstack#34593), the mirror of the app bar's Edit app (ADR-0080's * app → Studio bridge, `appStudioRoutePath`). * From 4b6267c5736fb45f7fa7f4b232e72adaccd03565 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:17:09 +0000 Subject: [PATCH 5/6] docs(app-shell): the README names Open app, the D5 read-only entry and the kernel-free switcher Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz --- ui/packages/app-shell/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/README.md b/ui/packages/app-shell/README.md index f467e773a18..6c42de6618b 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, From 572f256ab4f43f41dd2f9c20c5df9d8689e8a0fc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 07:14:35 +0000 Subject: [PATCH 6/6] =?UTF-8?q?chore(changeset):=20declare=20Clause-?= =?UTF-8?q?=E2=91=A1=20yes=20(widening)=20for=20the=20new=20i18n=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat's ruling on this package: new @object-ui/i18n keys and an added interpolation variable widen the published locale surface. Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .changeset/34593-studio-open-app.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/34593-studio-open-app.md b/.changeset/34593-studio-open-app.md index 4ea727f9583..a7005a3c902 100644 --- a/.changeset/34593-studio-open-app.md +++ b/.changeset/34593-studio-open-app.md @@ -5,7 +5,7 @@ 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-②: no +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.