Skip to content

Commit cd51dbb

Browse files
feat(studio): the top bar reads ‹ Back to app · APP · Studio; home icon, package switcher and Open app removed (#36519)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JpRoUZGqtwqMU5k7b4C58D)_ Fixes #36501 Clause-②: no Metadata-protocol: none ## 维护者速读 - Studio 的设计人员会看到:左上角从「首页图标 + 应用切换」变成「‹ 返回应用 · 应用名 · Studio」,右上角的「打开应用」没有了,点返回会回到进 Studio 之前那一页。 - 为什么做:外壳专题(去掉顶栏和平台首页)第 12 项,按设计板图 47 让 Studio 的出口只剩一个、回到原来的应用。 - 出错会怎样:设计人员点返回可能到错页面或回到默认首页;改动只在界面层,直接撤回这次合并即可恢复原样。 - 要你做什么:这次改动行数超过三千行(大部分是删掉随切换器一起退场的旧测试),按规则需要你本人批准后才能合并。 ## What changes - `StudioBackToApp` (new) draws the top bar's left end: 「‹ Back to app」, the app's name, and the "Studio" mark. Where it goes, first match wins: 1. **Came from an app** — `ConsoleLayout` records the app page in view on every app route (`utils/appReturnPage.ts`, module memory, never browser storage); the link names that app and returns to that exact page, query and hash kept. 2. **Opened directly** (a Studio URL in a new tab, a reload — module memory starts empty) — the package's first **published** app, on its first screen (`/apps/PACKAGE` for a one-app package, `/apps/APPNAME` for the first of several, the same addressing the removed Open app used). 3. **No published app** (none, or a draft-only app, which has no running front-end) and the organization-flows scope — 「‹ Back to app」 with **no name**, to the console's default landing (`useHomePath()`: the declared default app, else the single app, else the launcher — the same policy `/` resolves). Leaving asks first when a pillar holds unsaved work (`confirmLeavePillar`, the header's existing guard). - Removed from the top bar: the Studio-home button, the package switcher (`PackageSwitcher` component), and the top-right Open app (`StudioOpenApp.tsx`, deleted). `PackageSwitcher.tsx` keeps only the three helpers other code still imports (`PACKAGE_LIST_TOAST_ID`, `STUDIO_LANDING_PATH`, `fetchInstalledPackageRow`); `offeredPackages` and `STUDIO_PKG_READONLY_WORD` had no other reader and went with it. - i18n (studio catalogue, en + zh): `engine.studio.backToApp` (Back to app / 返回应用), `engine.studio.backToAppTitle`, `engine.studio.backToAppTitleNoApp`, `engine.studio.mark`; the three Open app keys are removed; `engine.studio.app.willOpenAfterPublish` names 「Back to app」 instead of Open app. - Untouched: the pillar switcher, the rails, the right slot / AI panel, Changes and Publish. The report/widget publish region (#36420's) is not touched. ## Tests - New `StudioDesignSurface.backToApp-36501.test.tsx` (real surface + real metadata client over a fetch stub): came-from-app names that app and returns to its page with the query; an app other than the package's own is the one named; opened directly names the published app and lands on its home; several apps → the first, by name; no app → no name, to the landing; draft-only app counts as none; the home icon, the switcher and Open app are absent; narrow-bar classes (the name truncates, the link and the mark do not); `studioBackTarget` order unit cases. - `pillarNavGuard`: the Studio-home guard case became 「Back to app」 — dirty → confirm, cancel keeps the matrix edit, confirm leaves; clean → no prompt. - New `fetchInstalledPackageRow-7881.test.ts`: the objectui#7881 / objectui#7938 wire cases, asserted at the helper the Studio landing's Manage still reads. - Updated (each asserted on a removed control): `homeLoop-12513`, `narrowHeader-12509`, `desktopHint-11795`, `entryReadsOnce-11797`, `noAppPackageLabel-12718`, `notFound-26708`, `readOnlyPosture-12453`, `kernelReadOnly-29567`, `packageLessFlows-11553`, `oneSurface-28572`, `autosaveSwitch-11232`, `packageListErrorPosture`; e2e live `studio-customize-journey` (read-only chip line) and `studio-object-designer` (F1, the switcher's create-package refresh, removed). - Deleted (their subject code is deleted): `openApp-34593` (its kernel-row list CONTROL moved into the new file), `narrowChip-12611`, `packageDeletionInference`, `manageSnapshotRefresh` (the switcher's own `onManageChanged`), `packageLookupFailure`, `packageUserMessage` (their wire cases moved to `fetchInstalledPackageRow-7881`). - `homeRecoveryRedirectsFollowDeclaration-7373`: the Studio site now reads `StudioBackToApp.tsx` (where the header's no-app landing reads `useHomePath()`); its behavioural pointer moves from the deleted `packageDeletionInference` to the new back-link test. - Six edited surface tests gained the module-top `import '@objectstack/lint'` that `check:test-source-alias` asks of an edited file reaching the surface. <details><summary>Local gate readings (derived by <code>dispatch-gates.mjs --commands</code>, HEAD a07beaa)</summary> 37 derived `check:*` / self-test commands ran outside the lock: 35 at EXIT=0; `check:test-source-alias` was red (EXIT=1, the six files above) and is green after the fix (`check-test-source-alias OK — ... the source reach judged 36 test file(s) changed since 9abc732`); `check:type-check-debt` exited 3 (its closure build waits on the shared verification lock and did not get it): NOT MEASURED locally, CI runs it. `check:nul-bytes` OK (27026 files, no raw control bytes). </details> - **NOT MEASURED locally: the vitest run of `views/studio-design/`, the 7373 scan, `layout/`, and the app-shell `type-check`.** The shared verification lock was held by a full dogfood battery for over 75 minutes, then by a ten-deep build queue; every acquisition this round timed out. The readings land in the `os-dev-report` comment on #36501 if a later acquisition succeeds; CI's Test UI and type-check runs are the verdict otherwise. ## Acceptance notes - **Size**: +/- lines exceed 3,000 (mostly deletions of the switcher and its pins), so this lands the Tier H way (an authorized approval). - **Lost from the Studio top bar with the switcher** (all still reachable on the Studio landing, which the app sidebar's "Build with AI" opens): New package, Package info and settings, the organization flows entry, and the chip's read-only lock (the item header's read-only mark stays in every pillar) and package-list failure marker (the failure still toasts on the shared id). - Opened directly, the old Open app landed on the surface in focus (`?surface=`, e.g. that object's list); 「Back to app」 lands on the app's first screen, as the card asks. The `app-shell` README paragraph on the way back is rewritten to match. - The package name is no longer printed in the top bar; for a package with no app nothing names it there. - Now-unreferenced switcher catalogue keys (`engine.studio.pkg.switchTitle`, `pkg.heading`, `pkg.none`, `pkg.new`, `pkg.withPair`, `org.hint`, `pkg.manage`) are left in place for a dead-key sweep; `packageApp`'s `icon` / `branding` (read only by the removed chip) are left as well. - **NOT MEASURED: browser before/after screenshots and the 1280 / 1440 no-wrap reading** the card asks for — no browser run in this container this round (the shared verification lock was held by a full dogfood run). The no-wrap contract is pinned by class in the new test. ## Verification Read first: `StudioBackToApp.tsx` (`studioBackTarget`, the three-way order), `ConsoleLayout.tsx` (the one recording effect), the header block in `StudioDesignSurface.tsx`. Two-minute check: open an object's list in an app, enter Studio from it, click 「‹ Back to app」 — you land on the same list; reload Studio and click again — you land on the package app's first screen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRY38EZf38Yy3zthbY <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRY38EZf38Yy3zthbY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0d4f190 commit cd51dbb

37 files changed

Lines changed: 925 additions & 3418 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
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
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
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.
12+
13+
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.
14+
15+
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.

‎ui/e2e/live/studio-customize-journey.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ test('a read-only base is customized, restored and extended through Studio, and
165165
try {
166166
await test.step('Customize a view: the edit lands in the pair, and the server serves its columns', async () => {
167167
await page.goto(`/studio/${BASE}/interfaces?surface=${encodeURIComponent(`view:${VIEW}`)}`);
168-
await expect(page.getByTestId('studio-pkg-readonly')).toBeVisible();
168+
// The read-only base offers Customize (the top bar's read-only chip left
169+
// with the package switcher, objectstack#36501).
170+
await expect(page.getByTestId('studio-customize')).toBeVisible();
169171
await page.getByTestId('studio-customize').click();
170172

171173
const ensured = page.waitForResponse(

‎ui/e2e/live/studio-object-designer.spec.ts‎

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

@@ -124,41 +124,3 @@ test('F4: adding a picklist + an empty option row does not trip spec validation,
124124
await request.delete(`${API}/api/v1/packages/${pkgId}`);
125125
}
126126
});
127-
128-
test('F1: a newly created package appears in the switcher without a reload', async ({ page }) => {
129-
const stamp = Date.now();
130-
const pkgId = `com.e2e.dogfood${stamp}`;
131-
const pkgName = `E2E Dogfood ${stamp}`;
132-
const pkgIdPattern = pkgId.replace(/\./g, '\\.');
133-
// The console's Studio surface (`/studio/:packageId/:tab`) carries the
134-
// package switcher on a stock boot. The sidebar switcher (`package-switcher`)
135-
// renders only for an app that declares `contextSelectors`, and no app a
136-
// stock showcase boot serves declares one.
137-
await page.goto(`/studio/${PKG}/data`);
138-
const chip = page.getByTestId('studio-pkg-chip');
139-
await chip.click();
140-
await page.getByRole('button', { name: /New package/i }).click();
141-
await page.getByRole('dialog').getByLabel(/^Display name/).first().fill(pkgName);
142-
// The id sits in the collapsed Advanced section (objectstack#27833).
143-
await page.getByTestId('package-form-advanced-toggle').click();
144-
await page.getByTestId('package-form-id-input').fill(pkgId);
145-
await page.getByTestId('package-form-submit').click();
146-
147-
// No reload: the surface moves into the new package, and the switcher's chip
148-
// names it from the refreshed list (a stale list falls back to the raw id)…
149-
await expect(page).toHaveURL(new RegExp(`/studio/${pkgIdPattern}/`));
150-
await expect(chip).toContainText(pkgName);
151-
// …and the open switcher lists it by its name, which only the refreshed list
152-
// carries (each entry's accessible name is its name, then its id).
153-
await chip.click();
154-
await expect(page.getByRole('button', { name: new RegExp(`${pkgName}\\s*${pkgIdPattern}`) })).toBeVisible();
155-
156-
// Cleanup so we don't pollute the shared dev stack.
157-
await page.evaluate(async (id) => {
158-
const tok = localStorage.getItem('auth-session-token');
159-
await fetch(`/api/v1/packages/${id}`, {
160-
method: 'DELETE',
161-
headers: { Authorization: `Bearer ${tok}` },
162-
}).catch(() => {});
163-
}, pkgId);
164-
});

‎ui/packages/app-shell/README.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,16 @@ package writability stays a server-side concern — a read-only package opens in
643643
Studio as browse-only. For a read-only package the button draws an eye with the
644644
words "Open {app} in Studio" (ADR-0146 D5) instead of the pencil.
645645

646-
The way back is Studio's own "Open app" button in the workbench top bar
647-
(`StudioOpenApp`). It reads the `?surface=` Studio has in focus — the same
648-
target "Edit app" hands over — and lands on that object's list
649-
(`/apps/:app/<object>`), on that dashboard, page or report, or else on the
650-
app's home, in the same tab. A package with several published apps gets a
651-
picker; a package whose only app is still a draft gets no button.
652-
653-
Studio's package switcher never lists a kernel package (ADR-0016 §3.8): neither
654-
one whose manifest carries `scope: system | cloud` nor a row served with that
655-
`scope` flat. There is no toggle that shows them.
646+
The way back is the 「‹ Back to app」 link at the left end of Studio's top bar
647+
(`StudioBackToApp`), followed by the app's name and the "Studio" mark. Entered
648+
from an app, it names that app and returns to the page the author left, query
649+
included (`utils/appReturnPage.ts`, recorded by `ConsoleLayout`, held in module
650+
memory only). Opened directly (a new tab, a reload), it names the package's
651+
first published app and lands on its home. A package with no published app (a
652+
draft-only app counts as none) reads 「‹ Back to app」 with no name and goes to
653+
the console's declared landing (`useHomePath()`). Leaving with unsaved work in a
654+
pillar asks first. Studio's top bar has no package switcher: another package is
655+
opened from its app or from the Studio landing.
656656

657657
The sidebar's ⋯ menu offers the same bridge per entry: the **Design** entry of an
658658
`object`, `dashboard` or `page` navigation entry, and of the matching favorites,

‎ui/packages/app-shell/src/__tests__/homeRecoveryRedirectsFollowDeclaration-7373.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
* agent;
3737
* - `console/ai/__tests__/resolveCollapseToDockTarget.test.ts` — the dock
3838
* landing on a cold deep link;
39-
* - `views/studio-design/StudioDesignSurface.packageDeletionInference.test.tsx`
40-
* — eviction when the edited package is deleted;
39+
* - `views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx` — the
40+
* Studio top bar's 「Back to app」 when the package has no published app;
4141
* - `apps/console/src/components/StudioRoute.test.tsx` — the `/studio` entry
4242
* gate and the front door's wordmark;
4343
* - `apps/console/src/pages/auth/__tests__/AcceptInvitationRoute.test.tsx` —
@@ -139,12 +139,13 @@ const RECOVERY_SITES: ReadonlyArray<{
139139
alsoReads: [
140140
'packages/app-shell/src/views/studio-design/StudioNavItemInspector.tsx',
141141
'packages/app-shell/src/views/studio-design/PackageSwitcher.tsx',
142+
'packages/app-shell/src/views/studio-design/StudioBackToApp.tsx',
142143
'packages/app-shell/src/views/studio-design/InterfacesNavRail.tsx',
143144
'packages/app-shell/src/views/studio-design/AutomationsFlowRail.tsx',
144145
'packages/app-shell/src/views/studio-design/StudioPillarKit.tsx',
145146
'packages/app-shell/src/views/studio-design/DataPillarHelpers.tsx',
146147
],
147-
site: 'Studio: deleted-package eviction + header Home',
148+
site: 'Studio: the header Back to app, with no app to name',
148149
expression: /const homePath = useHomePath\(\)/,
149150
},
150151
{

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { PhoneAppNavBar, isPhoneTabRoute } from './PhoneAppNavBar.js';
2727
import { PhoneAppHomeSlotProvider } from './PhoneAppHome.js';
2828
import { PhonePageBarProvider } from './PhonePageBar.js';
2929
import { useLastApp } from '../context/LastAppProvider.js';
30+
import { rememberAppReturnPage } from '../utils/appReturnPage.js';
3031
import { useMetadata } from '../providers/MetadataProvider.js';
3132
import { appAddressSegment } from '../utils/appRoute.js';
3233
import { ShellPageActionsScope, ShellSidebarExpandFallback } from './ShellPageActions.js';
@@ -202,6 +203,16 @@ export function ConsoleLayout({
202203
useEffect(() => {
203204
if (activeAppName) rememberApp(activeAppName);
204205
}, [activeAppName, rememberApp]);
206+
// objectstack#36501 — and the app page in view, where Studio's 「‹ Back to
207+
// app」 returns: an app → Studio entry leaves from the page recorded last.
208+
useEffect(() => {
209+
if (!activeAppName) return;
210+
rememberAppReturnPage({
211+
path: `${location.pathname}${location.search}${location.hash}`,
212+
app: activeAppName,
213+
label: appLabel,
214+
});
215+
}, [activeAppName, appLabel, location.pathname, location.search, location.hash]);
205216
const { apps: metadataApps } = useMetadata();
206217
const appBasePath = `/apps/${appAddressSegment(metadataApps, activeApp) ?? activeAppName}`;
207218
// objectstack#36362 — the app's design mode, held here so it stays on from
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The app page the person last had open, for Studio's 「‹ Back to app」
5+
* (objectstack#36501).
6+
*
7+
* `ConsoleLayout` records it on every app route; Studio's top bar reads it.
8+
* An app → Studio entry is an in-app navigation, so the record names the page
9+
* the author came from, and the back link returns there.
10+
*
11+
* Held in module memory on purpose, never in browser storage: a Studio URL
12+
* opened directly (a new tab, a pasted link, a reload) starts with no record,
13+
* and the back link then lands on the package's own app instead of on a page
14+
* from some earlier visit.
15+
*/
16+
17+
/** One app page, as the app bar names it. */
18+
export interface AppReturnPage {
19+
/** The route, with its query and hash: where the back link navigates. */
20+
path: string;
21+
/** The app's name (its route key). */
22+
app: string;
23+
/** The app's display label, in the language it was shown in. */
24+
label: string;
25+
}
26+
27+
let lastAppPage: AppReturnPage | null = null;
28+
29+
/** Records `page` as the app page now open. */
30+
export function rememberAppReturnPage(page: AppReturnPage): void {
31+
if (!page.path || !page.app) return;
32+
lastAppPage = { ...page };
33+
}
34+
35+
/** The app page last open in this page load, or `null` when none was. */
36+
export function readAppReturnPage(): AppReturnPage | null {
37+
return lastAppPage;
38+
}
39+
40+
/** Tests only: forget the record, as a fresh page load starts. */
41+
export function resetAppReturnPageForTests(): void {
42+
lastAppPage = null;
43+
}

0 commit comments

Comments
 (0)