Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/36501-studio-back-to-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(studio): the top bar's left end reads 「‹ Back to app」, the app's name and "Studio"; the Studio-home button, the package switcher and Open app are gone

Clause-②: no
Metadata-protocol: none

Studio's top bar now starts with one way out: 「‹ Back to app · APP · Studio」. Entered from an app, the link names that app and returns to the page the author came from, its query included. Opened directly (a Studio address in a new tab, a reload), it names the package's published app and lands on its first screen; with several apps, the first. A package with no published app (none yet, or only a draft) and the organization flows scope read 「‹ Back to app」 with no name and go to the console's landing. Leaving with unsaved work in a pillar asks first, as every other header departure does.

The home icon, the package switcher and the top-right Open app button are removed. Another package is opened from the app, or from the Studio landing, whose cards also carry package management and New package.

New studio catalogue keys (en, zh): `engine.studio.backToApp`, `engine.studio.backToAppTitle`, `engine.studio.backToAppTitleNoApp`, `engine.studio.mark`. Removed with the Open app button: `engine.studio.openApp`, `engine.studio.openAppTitle`, `engine.studio.openAppPick`. `engine.studio.app.willOpenAfterPublish` now names 「Back to app」. No props or exports of the published packages change.
4 changes: 3 additions & 1 deletion ui/e2e/live/studio-customize-journey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ test('a read-only base is customized, restored and extended through Studio, and
try {
await test.step('Customize a view: the edit lands in the pair, and the server serves its columns', async () => {
await page.goto(`/studio/${BASE}/interfaces?surface=${encodeURIComponent(`view:${VIEW}`)}`);
await expect(page.getByTestId('studio-pkg-readonly')).toBeVisible();
// The read-only base offers Customize (the top bar's read-only chip left
// with the package switcher, objectstack#36501).
await expect(page.getByTestId('studio-customize')).toBeVisible();
await page.getByTestId('studio-customize').click();

const ensured = page.waitForResponse(
Expand Down
42 changes: 2 additions & 40 deletions ui/e2e/live/studio-object-designer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { test, expect, type APIRequestContext, type Page } from '@playwright/tes
* spec-liveness) cannot catch because the break only appears when a real user
* drives the real controlled inputs against the real spec validator:
* F2 — per-keystroke identifier sanitisation (must TYPE, not fill)
* F1 — cross-component reactivity (create package → switcher refresh)
* F1 — retired with the Studio top bar's package switcher (objectstack#36501);
* a package is created on the Studio landing now
* F3 — label→api-name derivation on blur
* F4 — empty picklist row must not trip spec validation, and is not stored
*
Expand All @@ -25,7 +26,6 @@ import { test, expect, type APIRequestContext, type Page } from '@playwright/tes
// The area opens a create page on a WRITABLE package only: the showcase is
// provided by code, so its create URL lands on the type's list, and every
// test that opens the designer authors a package of its own first.
const PKG = 'com.example.showcase';
const newObjectIn = (pkg: string) => `/studio/${pkg}/metadata/object/new?package=${pkg}`;
const API = process.env.LIVE_API_URL || 'http://localhost:3000';

Expand Down Expand Up @@ -124,41 +124,3 @@ test('F4: adding a picklist + an empty option row does not trip spec validation,
await request.delete(`${API}/api/v1/packages/${pkgId}`);
}
});

test('F1: a newly created package appears in the switcher without a reload', async ({ page }) => {
const stamp = Date.now();
const pkgId = `com.e2e.dogfood${stamp}`;
const pkgName = `E2E Dogfood ${stamp}`;
const pkgIdPattern = pkgId.replace(/\./g, '\\.');
// The console's Studio surface (`/studio/:packageId/:tab`) carries the
// package switcher on a stock boot. The sidebar switcher (`package-switcher`)
// renders only for an app that declares `contextSelectors`, and no app a
// stock showcase boot serves declares one.
await page.goto(`/studio/${PKG}/data`);
const chip = page.getByTestId('studio-pkg-chip');
await chip.click();
await page.getByRole('button', { name: /New package/i }).click();
await page.getByRole('dialog').getByLabel(/^Display name/).first().fill(pkgName);
// The id sits in the collapsed Advanced section (objectstack#27833).
await page.getByTestId('package-form-advanced-toggle').click();
await page.getByTestId('package-form-id-input').fill(pkgId);
await page.getByTestId('package-form-submit').click();

// No reload: the surface moves into the new package, and the switcher's chip
// names it from the refreshed list (a stale list falls back to the raw id)…
await expect(page).toHaveURL(new RegExp(`/studio/${pkgIdPattern}/`));
await expect(chip).toContainText(pkgName);
// …and the open switcher lists it by its name, which only the refreshed list
// carries (each entry's accessible name is its name, then its id).
await chip.click();
await expect(page.getByRole('button', { name: new RegExp(`${pkgName}\\s*${pkgIdPattern}`) })).toBeVisible();

// Cleanup so we don't pollute the shared dev stack.
await page.evaluate(async (id) => {
const tok = localStorage.getItem('auth-session-token');
await fetch(`/api/v1/packages/${id}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${tok}` },
}).catch(() => {});
}, pkgId);
});
20 changes: 10 additions & 10 deletions ui/packages/app-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,16 +643,16 @@ package writability stays a server-side concern — a read-only package opens in
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/<object>`), 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 way back is the 「‹ Back to app」 link at the left end of Studio's top bar
(`StudioBackToApp`), followed by the app's name and the "Studio" mark. Entered
from an app, it names that app and returns to the page the author left, query
included (`utils/appReturnPage.ts`, recorded by `ConsoleLayout`, held in module
memory only). Opened directly (a new tab, a reload), it names the package's
first published app and lands on its home. A package with no published app (a
draft-only app counts as none) reads 「‹ Back to app」 with no name and goes to
the console's declared landing (`useHomePath()`). Leaving with unsaved work in a
pillar asks first. Studio's top bar has no package switcher: another package is
opened from its app or from the Studio landing.

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* agent;
* - `console/ai/__tests__/resolveCollapseToDockTarget.test.ts` — the dock
* landing on a cold deep link;
* - `views/studio-design/StudioDesignSurface.packageDeletionInference.test.tsx`
* — eviction when the edited package is deleted;
* - `views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx` — the
* Studio top bar's 「Back to app」 when the package has no published app;
* - `apps/console/src/components/StudioRoute.test.tsx` — the `/studio` entry
* gate and the front door's wordmark;
* - `apps/console/src/pages/auth/__tests__/AcceptInvitationRoute.test.tsx` —
Expand Down Expand Up @@ -139,12 +139,13 @@ const RECOVERY_SITES: ReadonlyArray<{
alsoReads: [
'packages/app-shell/src/views/studio-design/StudioNavItemInspector.tsx',
'packages/app-shell/src/views/studio-design/PackageSwitcher.tsx',
'packages/app-shell/src/views/studio-design/StudioBackToApp.tsx',
'packages/app-shell/src/views/studio-design/InterfacesNavRail.tsx',
'packages/app-shell/src/views/studio-design/AutomationsFlowRail.tsx',
'packages/app-shell/src/views/studio-design/StudioPillarKit.tsx',
'packages/app-shell/src/views/studio-design/DataPillarHelpers.tsx',
],
site: 'Studio: deleted-package eviction + header Home',
site: 'Studio: the header Back to app, with no app to name',
expression: /const homePath = useHomePath\(\)/,
},
{
Expand Down
11 changes: 11 additions & 0 deletions ui/packages/app-shell/src/layout/ConsoleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { PhoneAppNavBar, isPhoneTabRoute } from './PhoneAppNavBar.js';
import { PhoneAppHomeSlotProvider } from './PhoneAppHome.js';
import { PhonePageBarProvider } from './PhonePageBar.js';
import { useLastApp } from '../context/LastAppProvider.js';
import { rememberAppReturnPage } from '../utils/appReturnPage.js';
import { useMetadata } from '../providers/MetadataProvider.js';
import { appAddressSegment } from '../utils/appRoute.js';
import { ShellPageActionsScope, ShellSidebarExpandFallback } from './ShellPageActions.js';
Expand Down Expand Up @@ -202,6 +203,16 @@ export function ConsoleLayout({
useEffect(() => {
if (activeAppName) rememberApp(activeAppName);
}, [activeAppName, rememberApp]);
// objectstack#36501 — and the app page in view, where Studio's 「‹ Back to
// app」 returns: an app → Studio entry leaves from the page recorded last.
useEffect(() => {
if (!activeAppName) return;
rememberAppReturnPage({
path: `${location.pathname}${location.search}${location.hash}`,
app: activeAppName,
label: appLabel,
});
}, [activeAppName, appLabel, location.pathname, location.search, location.hash]);
const { apps: metadataApps } = useMetadata();
const appBasePath = `/apps/${appAddressSegment(metadataApps, activeApp) ?? activeAppName}`;
// objectstack#36362 — the app's design mode, held here so it stays on from
Expand Down
43 changes: 43 additions & 0 deletions ui/packages/app-shell/src/utils/appReturnPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* The app page the person last had open, for Studio's 「‹ Back to app」
* (objectstack#36501).
*
* `ConsoleLayout` records it on every app route; Studio's top bar reads it.
* An app → Studio entry is an in-app navigation, so the record names the page
* the author came from, and the back link returns there.
*
* Held in module memory on purpose, never in browser storage: a Studio URL
* opened directly (a new tab, a pasted link, a reload) starts with no record,
* and the back link then lands on the package's own app instead of on a page
* from some earlier visit.
*/

/** One app page, as the app bar names it. */
export interface AppReturnPage {
/** The route, with its query and hash: where the back link navigates. */
path: string;
/** The app's name (its route key). */
app: string;
/** The app's display label, in the language it was shown in. */
label: string;
}

let lastAppPage: AppReturnPage | null = null;

/** Records `page` as the app page now open. */
export function rememberAppReturnPage(page: AppReturnPage): void {
if (!page.path || !page.app) return;
lastAppPage = { ...page };
}

/** The app page last open in this page load, or `null` when none was. */
export function readAppReturnPage(): AppReturnPage | null {
return lastAppPage;
}

/** Tests only: forget the record, as a fresh page load starts. */
export function resetAppReturnPageForTests(): void {
lastAppPage = null;
}
Loading
Loading