Skip to content

Commit 138faaa

Browse files
feat(app-shell): on a phone, sign-in lands in an app whose home is its whole menu, and the bottom bar is fixed to Home, Notifications, Approvals and search (#35912)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu7iKZbTviWuMAXjrAurGDA5)_ repo:objectstack#1 · os-sales · session_01L6bhgU7ah5dc72qr3aWHFu Fixes #35881 Fixes #35882 Clause-②: no Metadata-protocol: none Ruling-ref: 7045309332 (maintainer, 2026-11-20 16:50:40Z, 「上次用的优先」: on a phone the last-used app first, the declared default only when there is no record yet) · 7045325067 (maintainer, 2026-11-20 16:50:46Z, epic #35880 constraints: one console at narrow width, and a "Shared with desktop" section at acceptance) ## 维护者速读 - 手机上的用户登录后直接进上次用的应用;应用首页就是这个应用的全部菜单;底部栏固定为首页、通知、审批和一个搜索按钮。电脑和平板上看到的不变。 - 属于「手机端重做」专题的前两张卡:登录去向和应用首页,以及底部固定三格。 - 出问题时影响的是手机上的导航(进错应用、菜单或底部栏不对);不动数据,撤回这个 PR 就恢复原样。 - 无 ## What changes (phone width only, below 768 px) **Where sign-in lands (#35881).** `/` on a phone opens the app the person used last. The declared default (`isDefault`) is used only when there is no record yet. With one app it opens that app; with several and neither, it opens the app list. The order lives in one function, `resolvePhoneLandingPath` in `ui/apps/console/src/components/RootLandingRedirect.tsx`, with a test for each order. The last app is a per-person preference row (`ui.app.last`, `LastAppProvider`), recorded by `ConsoleLayout` whenever an app is open. It joins the console's one shared preference read (the budget test pins that it adds no request). `/` waits for that read for at most 2 s, then resolves without it. Desktop landing is unchanged: `resolveLandingPath` is not touched. **The app's home is its whole menu (#35881).** On a phone, `/apps/SEGMENT` renders `PhoneAppHome` instead of redirecting to the landing entry. The menu in it is the sidebar's own: `UnifiedSidebar` draws its navigation block (context selectors, area switcher, `NavigationRenderer` with the same member gates, labels, icons, groups and order) a second time, through a portal into the page's slot. So the page cannot list an entry the sidebar hides, or order them differently. 「‹」 on a deeper page goes back to it, and the scroll position is restored. An app that shows the member no entry still renders the no-access state. **App switcher (#35881).** On a phone, the app pill at the top left opens a bottom `Sheet`: 「Current app」 checked, 「Other apps」 with Setup last, and a search box at the bottom (`PhoneAppList`). A phone's `/home` is the same list as a page. The desktop dropdown is unchanged. **Bottom bar (#35882).** `PhoneAppNavBar` is rewritten in place. It has three fixed cells and a round search button: - **Home** opens the app's home. - **Notifications** opens `sys_inbox_message?view=mine`, the bell's 「View all」 target. - **Approvals** opens `system/approvals`, under the app the bell hosts them under (`resolveHostAppSegment`). - **Search** opens the command palette. The badges are the bell's two addends from `useInboxBell`: unread topics and pending approvals. The bar is mounted only on those three pages (`isPhoneTabRoute`). A list, a record, a form, a dashboard or a page has the screen to itself. The app bar there shows 「‹」 and the page title, and on the three tab pages it shows the app pill with the app's name. Removed with the old bar (#34594 and its follow-up #35020): - menu entries in the bar, the 「More」 cell and its highlight - the stars that pinned entries, and the drawer's phone search box and pin hint Pins already stored are no longer read. Nothing deletes them. The drawer still opens with the left-edge swipe. ## Shared with desktop | Phone part | Uses | Kept separate, and why | |---|---|---| | App home menu | The sidebar's own `NavigationRenderer` block in `UnifiedSidebar` (same gates, area switcher, labels, icons), portalled into the page | Only the container: a page instead of the drawer. Phone rows drop the desktop row action (pin/star) and the Favorites rows, as the drawer did. | | App switcher | `AppSwitcher` (same trigger, same `onAppChange`, same `appAddressSegment` address), `useLauncherApps` (same app set as the desktop dropdown and Home tiles), `AppMark`, `Sheet side="bottom"` from `@object-ui/components` | The list body `PhoneAppList` is new, because the desktop dropdown's menu items are not a touch list with search. It is shared between the sheet and the phone `/home`. The phone sheet holds the list alone. 「Back to home」 and 「All apps」 are dropped because they would open that same list (a phone's `/home` is it), 「Settings」 because Setup is a row in the list, and 「Edit / Open APP in Studio」 because Studio authoring stays a desktop entry. | | Bottom bar | The console's existing phone bar `PhoneAppNavBar` (#34594), rewritten in place; `useInboxBell` + `groupNotifications` (the bell's own counts); the bell's own inbox targets; `useCommandPalette` (the top bar's search) | `@object-ui/layout`'s `MobileBottomNav` (the `AppSchemaRenderer` host) is not used: it draws the app's first five menu entries, which is the app-following bar #35882 replaces. | | Landing | `resolveLandingPath` (desktop order) is the fallback inside `resolvePhoneLandingPath`; the last app rides the shared `sys_user_preference` read (`UserStateBridge`) | The last-app-first rule applies only on a phone, per ruling 7045309332. | | Width switch | `usePhoneViewport` / `useSidebar().isMobile` (the existing < 768 px switch) | none | ## Tests New: - `layout/__tests__/PhoneAppNavBar.fixedTabs-35882.test.tsx`: the three pages, the cells and their targets, the lit cell, another app, search, badges (9+ cap, topic count), with CONTROLs. - `layout/__tests__/AppSwitcher.phoneSheet-35881.test.tsx`: sheet order (current, others, Setup last), search, pick by address, name on tab pages, desktop CONTROL. - `console/__tests__/AppContent.phoneAppHome-35881.test.tsx`: the phone app root renders the home and stays at `/apps/crm`, no-access still shown, 1024 px CONTROL redirects. - `apps/console/.../RootLandingRedirect.test.ts`: `resolvePhoneLandingPath`, one test per order (last app wins, its address, no record → default, single app / `/home`, gone/hidden/off ignored, desktop CONTROL). - `apps/console/.../RootLandingRedirect.route.test.tsx`: the real `/` route on a phone: last app wins, default with no record, the bounded wait, desktop CONTROL. Migrated: - `UnifiedSidebar.phoneNavBar-34594.test.tsx` → `UnifiedSidebar.phoneAppHome-35881.test.tsx` (git mv, rewritten): the app home shows the sidebar's menu in order with groups and hrefs, no star/search/pin hint/Favorites, and CONTROLs at 1024 px and without the page. - `ConsoleLayout.phoneRecordOneBar-28483.test.tsx`: the bar describe now pins the three tab routes, Home's address, eight deeper routes with no bar, and the 768/1440 CONTROL. The inset padding is 3.5rem. - `AppHeader.sidebarTrigger-12429.test.tsx`: 「‹」 goes to the app's home on a deeper page; on the tab pages there is no 「‹」, the pill names the app, and there is no search or bell up top; 768 px CONTROL. - `consoleUserPreferenceBudget.test.tsx`: the `ui.app.last` key joins the one shared read; one more debounced write. - `HomePage.phoneTapTargets-29147.test.tsx`: at 375 px with apps, Home is the app list and asks for no checklist placement. The 1024 px checklist CONTROL is kept. - `ui/e2e/live/phone-nav-drawer-back-29131.spec.ts`: opens the drawer by the left-edge swipe, because 「More」 is gone. Voided (the behaviour is removed by #35882): - #34594: first four entries + More; pins first; a foreign or hidden pin takes no cell; the More sheet's search and stars; star pins through the pin store; record/form routes hide the bar (replaced by "only three pages draw it"); `phoneNavBarEntries` (3 unit tests); `hidesPhoneNavBar`. - #35020: "the bar lights More / its cell for the page in view" (2 tests). - #34596: "375 px: the checklist is drawn after the apps and before My work" (that part of a phone Home is gone). `docs/qa/platform-checklist`: no item names the old bar; none changed. ## Verification - `vitest` (from `ui/`): every test file under `ui/packages/app-shell/src` and `ui/apps/console/src` that imports a changed module (PhoneAppNavBar, PhoneAppHome, PhoneAppList, AppSwitcher, AppHeader, ConsoleLayout, UnifiedSidebar, AppContent, ConsoleShell, HomePage, LastAppProvider, UserStateAdapters, RootLandingRedirect): 222 files, 1814 passed, 0 failed. The whole `app-shell` package (2354 files) in one local run passed the container's one-hour limit and was stopped without a result, so the full package is left to CI's sharded Test UI. - `type-check` (`tsc --noEmit` and the test tsconfig) for `@object-ui/app-shell`, `@object-ui/console` and `@object-ui/i18n`: clean (turbo, 78 tasks, deps built). `eslint` on every changed file: 0 errors. - `node scripts/pm/dispatch-gates.mjs --commands`: 41 derived families, all run, all exit 0; `--ran` reconcile: 41 derived, 41 run, 0 NOT-MEASURED. `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys`: exit 0 (11 keys added and 2 removed in all 11 locales). `node scripts/pm/overlap-check.mjs`: VERDICT clean (merges with `main` and with #35909 and #35910, which share the locale files). Neither file the neighbouring list cards own (`objectViewPageHeader.tsx`, `ui/packages/plugin-list/**`) is touched. - Changed lines 2740 vs the 3000 threshold: under. - **Browser, before / after**: `examples/app-showcase` (`objectstack dev --seed-admin`) with the `ui/apps/console` Vite dev server over it, headless Chromium. Before = the changed `ui/` sources checked out from the merge base; after = this head. Screenshots are kept with the seat. - Phone 375×812 (touch), after: the first sign-in with no record (two apps, none default) lands on the app list (「Choose an app」, Showcase and Setup, search box). The app root `/apps/com.example.showcase` stays there and shows the menu with its groups (Workspace, Data Model…) and icons, Home lit, badges 1 and 3. The pill opens the bottom sheet (Current app ✓ Showcase, Other apps Setup, search). A list (`showcase_task`) has no bottom bar, with 「‹」 and the title at the top. Notifications and Approvals draw the bar with their cell lit. After visiting the app, `/` lands in it. - Phone, before: the app root redirected to the first entry (Capability Map) with the five-cell bar (four entries + More), and the list drew the bar too. - Desktop 1440×900 and tablet 820×1180, before vs after, pixel diff: the app root (redirects to the landing entry in both), the list and `/home` are identical apart from relative timestamps and one badge's antialiasing. - Not measured: Safari / WebKit (no WebKit build in the container); the edge-swipe e2e (`phone-nav-drawer-back-29131`, nightly) was edited but not run here. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the changed files: 0 errors) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. (two folded cards, one pull request, per the coordinator's pairing) - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. (the 维护者速读 block and the maintainer's quotes are Chinese by the maintainer's standing rule) - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgU7ah5dc72qr3aWHFu <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgU7ah5dc72qr3aWHFu --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2a0cd20 commit 138faaa

38 files changed

Lines changed: 1918 additions & 827 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
feat(app-shell): on a phone, sign-in lands in an app whose home is its whole menu, and the bottom bar is fixed to Home, Notifications, Approvals and search
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
Phone width only (below 768 px). Desktop and tablet widths do not change.
13+
14+
- **Where sign-in lands.** A phone opens the app the person used last. The app the product marks as default is used only when there is no record yet, for example on a first sign-in. With one app it opens that app; with several and neither, it opens the app list. The last app is kept per person with their other console preferences (the `ui.app.last` key), so it follows them across devices. It is read in the same request as those preferences, not in a new one. A desktop still lands on the declared default first, as before.
15+
- **The app's home is its whole menu.** On a phone, `/apps/SEGMENT` shows the app's menu with its groups, order and icons, one row per entry. It no longer redirects to the first entry. This is the sidebar's own menu drawn in a second place, so it cannot list an entry the sidebar hides. 「‹」 on a page one level down goes back to it, and the page comes back scrolled as it was left. An app that shows the member no entry still says so.
16+
- **App switcher.** The app pill at the top left opens a bottom sheet: 「Current app」 with a check, then 「Other apps」 with Setup last, and a search box at the bottom. On a phone, `/home` is that same list as a page.
17+
- **Bottom bar.** The bar has three fixed cells, Home, Notifications and Approvals, and a round search button. They do not change with the app and cannot be configured. Home opens the app's home. Notifications and Approvals open the pages the bell opens, with the bell's two counts as badges. Search opens the command palette. The bar shows only on those three pages; a list, a record, a form or any deeper page has the screen to itself. The bar no longer holds menu entries, a 「More」 cell or pinned entries (objectstack#34594). Pins already stored are ignored, and the drawer's menu search and pin hint are gone. The drawer still opens with a swipe in from the left edge.

‎ui/apps/console/src/components/RootLandingRedirect.route.test.tsx‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
*/
6565

6666
import { describe, expect, it, vi, beforeEach } from 'vitest';
67-
import { render, screen } from '@testing-library/react';
67+
import { act, render, screen } from '@testing-library/react';
6868
import { MemoryRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
6969
import type { ReactNode } from 'react';
7070

@@ -82,6 +82,11 @@ const metadata = vi.hoisted(() => ({
8282
},
8383
}));
8484

85+
/** objectstack#35881 — the width and the person's last app, varied by the phone cases. */
86+
const phone = vi.hoisted(() => ({
87+
value: { isPhone: false, lastApp: null as string | null, settled: true },
88+
}));
89+
8590
/** The auth verdict each case varies. */
8691
const auth = vi.hoisted(() => ({
8792
value: { isAuthenticated: false, isLoading: false, user: null as any },
@@ -107,6 +112,8 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
107112
<Navigate to={to} replace={replace} />
108113
</>
109114
),
115+
usePhoneViewport: () => phone.value.isPhone,
116+
useLastApp: () => ({ lastApp: phone.value.lastApp, settled: phone.value.settled, rememberApp: () => {} }),
110117
SETUP_APP_PACKAGE_ID: 'com.objectstack.setup',
111118
SETUP_APP_NAME: 'setup',
112119
useMetadata: () => ({
@@ -187,6 +194,7 @@ const OTHER_APP = { name: 'showcase_app' };
187194
beforeEach(() => {
188195
metadata.value = { apps: [], loading: false, status: 'ready', refresh: vi.fn(async () => {}) };
189196
auth.value = { isAuthenticated: false, isLoading: false, user: null };
197+
phone.value = { isPhone: false, lastApp: null, settled: true };
190198
});
191199

192200
// ── (b) The control QA used to isolate the defect ────────────────────────
@@ -390,3 +398,45 @@ describe('the landing carries the query and hash `/` arrived with', () => {
390398
expect(screen.getByTestId('location-hash').textContent).toBe('');
391399
});
392400
});
401+
402+
// ── objectstack#35881, ruling 7045309332 (「上次用的优先」) ────────────────────
403+
describe('a phone lands in the app the person used last (objectstack#35881)', () => {
404+
beforeEach(() => {
405+
auth.value.isAuthenticated = true;
406+
metadata.value.apps = [OTHER_APP, DEFAULT_APP];
407+
});
408+
409+
it('the last-used app wins over the declared default', () => {
410+
phone.value = { isPhone: true, lastApp: 'showcase_app', settled: true };
411+
renderAt('/');
412+
expect(location()).toBe('/apps/showcase_app');
413+
});
414+
415+
it('with no record yet it takes the declared default', () => {
416+
phone.value = { isPhone: true, lastApp: null, settled: true };
417+
renderAt('/');
418+
expect(location()).toBe('/apps/crm_app');
419+
});
420+
421+
it('waits while the record is still being read, then resolves without it after the wait', () => {
422+
vi.useFakeTimers();
423+
try {
424+
phone.value = { isPhone: true, lastApp: null, settled: false };
425+
renderAt('/');
426+
expect(location()).toBe('/');
427+
expect(screen.getByTestId('loading-fallback')).toBeInTheDocument();
428+
act(() => {
429+
vi.advanceTimersByTime(2000);
430+
});
431+
expect(location()).toBe('/apps/crm_app');
432+
} finally {
433+
vi.useRealTimers();
434+
}
435+
});
436+
437+
it('CONTROL — a desktop ignores the last app and keeps the declared default', () => {
438+
phone.value = { isPhone: false, lastApp: 'showcase_app', settled: true };
439+
renderAt('/');
440+
expect(location()).toBe('/apps/crm_app');
441+
});
442+
});

‎ui/apps/console/src/components/RootLandingRedirect.test.ts‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

33
import { describe, it, expect } from 'vitest';
4-
import { resolveLandingPath, isAppListConclusive } from './RootLandingRedirect';
4+
import { resolveLandingPath, resolvePhoneLandingPath, isAppListConclusive } from './RootLandingRedirect';
55

66
describe('resolveLandingPath', () => {
77
it('routes to the App marked isDefault (isDefault now ROUTES, not just badges)', () => {
@@ -185,3 +185,46 @@ describe('isAppListConclusive — is this list an answer, or an unknown?', () =>
185185
expect(isAppListConclusive(undefined)).toBe(true);
186186
});
187187
});
188+
189+
// objectstack#35881, ruling 7045309332 (「上次用的优先」): on a phone the app the
190+
// person used last wins; the declared default applies only when there is no
191+
// record yet. One function, one test per order.
192+
describe('resolvePhoneLandingPath — the last app first, then the desktop order', () => {
193+
const APPS = [
194+
{ name: 'crm', _packageId: 'com.acme.crm' },
195+
{ name: 'cloud_control', isDefault: true },
196+
{ name: 'service' },
197+
];
198+
199+
it('the last-used app beats the declared default', () => {
200+
expect(resolvePhoneLandingPath(APPS, 'service')).toBe('/apps/service');
201+
});
202+
203+
it('the last-used app lands at its address segment (its package id when it has one)', () => {
204+
expect(resolvePhoneLandingPath(APPS, 'crm')).toBe('/apps/com.acme.crm');
205+
});
206+
207+
it('no record yet: the declared default', () => {
208+
expect(resolvePhoneLandingPath(APPS, null)).toBe('/apps/cloud_control');
209+
expect(resolvePhoneLandingPath(APPS, undefined)).toBe('/apps/cloud_control');
210+
});
211+
212+
it('no record and no default: the single visible app, else /home', () => {
213+
expect(resolvePhoneLandingPath([{ name: 'only' }], null)).toBe('/apps/only');
214+
expect(resolvePhoneLandingPath([{ name: 'a' }, { name: 'b' }], null)).toBe('/home');
215+
});
216+
217+
it('a last app that is gone, hidden or switched off is ignored', () => {
218+
expect(resolvePhoneLandingPath(APPS, 'removed')).toBe('/apps/cloud_control');
219+
expect(
220+
resolvePhoneLandingPath([...APPS, { name: 'secret', hidden: true }], 'secret'),
221+
).toBe('/apps/cloud_control');
222+
expect(
223+
resolvePhoneLandingPath([...APPS, { name: 'off', active: false }], 'off'),
224+
).toBe('/apps/cloud_control');
225+
});
226+
227+
it('CONTROL — the desktop resolver does not read the last app', () => {
228+
expect(resolveLandingPath(APPS)).toBe('/apps/cloud_control');
229+
});
230+
});

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
* declaration is the source of truth.)
3434
*/
3535

36-
import { useEffect, useRef } from 'react';
36+
import { useEffect, useRef, useState } from 'react';
3737
import { useLocation } from 'react-router-dom';
3838
import {
3939
useMetadata,
4040
LoadingFallback,
4141
RedirectWithSplash,
4242
SETUP_APP_PACKAGE_ID,
4343
SETUP_APP_NAME,
44+
useLastApp,
45+
usePhoneViewport,
4446
} from '@object-ui/app-shell';
4547
import type { MetadataTypeStatus } from '@object-ui/app-shell';
4648

@@ -136,6 +138,39 @@ export function resolveLandingPath(apps: readonly LandingApp[] | null | undefine
136138
return '/home';
137139
}
138140

141+
/**
142+
* The path `/` redirects to on a phone (objectstack#35881): the app this
143+
* person last had open, when it is still an active, visible app; otherwise
144+
* the three rules of {@link resolveLandingPath} (the declared default, the one
145+
* app, the app list at `/home`).
146+
*
147+
* The order is the maintainer's ruling (record 7045309332 on #35881, Sales
148+
* 2026-11-20 16:50Z, 「上次用的优先」): the last app beats a declared default,
149+
* which decides only a first sign-in with no last app yet. From 768 px up `/`
150+
* resolves as before, through {@link resolveLandingPath} alone.
151+
*/
152+
export function resolvePhoneLandingPath(
153+
apps: readonly LandingApp[] | null | undefined,
154+
lastApp: string | null | undefined,
155+
): string {
156+
const list = apps ?? [];
157+
const last = lastApp
158+
? list.find(
159+
(a): a is LandingApp & { name: string } =>
160+
a?.name === lastApp && a.active !== false && a.hidden !== true,
161+
)
162+
: undefined;
163+
if (last) return `/apps/${landingSegment(list, last)}`;
164+
return resolveLandingPath(apps);
165+
}
166+
167+
/**
168+
* How long a phone's `/` waits for the person's last app to be read before it
169+
* resolves without it (objectstack#35881). The row rides the console's one
170+
* preference read, which is normally in by the time the app list is.
171+
*/
172+
const LAST_APP_WAIT_MS = 2000;
173+
139174
/**
140175
* Is the app list this resolver was handed an ANSWER, or an unknown standing
141176
* in for one? (objectui#4233)
@@ -183,6 +218,15 @@ const APP_LIST_RETRY_DELAY_MS = 1500;
183218
export function RootLandingRedirect() {
184219
const { apps, loading, getTypeStatus, refresh } = useMetadata();
185220
const location = useLocation();
221+
// objectstack#35881 — a phone lands in the person's last app.
222+
const phone = usePhoneViewport();
223+
const { lastApp, settled: lastAppSettled } = useLastApp();
224+
const [lastAppWaitOver, setLastAppWaitOver] = useState(false);
225+
useEffect(() => {
226+
if (!phone || lastAppSettled) return;
227+
const id = setTimeout(() => setLastAppWaitOver(true), LAST_APP_WAIT_MS);
228+
return () => clearTimeout(id);
229+
}, [phone, lastAppSettled]);
186230

187231
// "Not yet" (`loading`) and "asked and failed" (`status === 'error'`) are
188232
// both "no answer" — they differ only in whether waiting will help.
@@ -207,6 +251,7 @@ export function RootLandingRedirect() {
207251
}, [unresolved, refresh]);
208252

209253
if (loading || unresolved) return <LoadingFallback />;
254+
if (phone && !lastAppSettled && !lastAppWaitOver) return <LoadingFallback />;
210255
// `RedirectWithSplash`, not a bare `<Navigate>` (objectui#6378). This is the
211256
// widest measured instance of the boot blank: the line above holds the splash
212257
// while the app list loads, and handing off to a null-rendering redirect left
@@ -217,6 +262,8 @@ export function RootLandingRedirect() {
217262
// overlays (`?palette=1`, `?recordId=`) live in the query, and the landing is
218263
// a bare `/apps/<segment>` or `/home`, so there is nothing to merge with. The
219264
// app root it lands on carries them on to the app's own landing in turn.
220-
const landing = resolveLandingPath(apps as LandingApp[] | undefined);
265+
const landing = phone
266+
? resolvePhoneLandingPath(apps as LandingApp[] | undefined, lastApp)
267+
: resolveLandingPath(apps as LandingApp[] | undefined);
221268
return <RedirectWithSplash to={`${landing}${location.search}${location.hash}`} replace />;
222269
}

‎ui/e2e/live/phone-nav-drawer-back-29131.spec.ts‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import { test, expect, type Page } from '@playwright/test';
1212
* browser's own, the close is an outside tap, and the reload is a real one,
1313
* which keeps `history.state`.
1414
*
15-
* On a phone inside an app the drawer opens from the bottom menu bar's 「More」
16-
* cell (objectstack#34594): the app bar's left slot holds the Back-to-home
17-
* link there, not the sidebar trigger, which only the desktop control below
18-
* still taps. Both open the same drawer through `setOpenMobile(true)`, so the
19-
* history hook sees the same `openMobile` whichever control opened it.
15+
* On a phone inside an app the drawer opens by a swipe in from the left edge:
16+
* the bottom bar's 「More」 cell is gone (objectstack#35882, the app's menu is
17+
* the app's home page, objectstack#35881), and the app bar's left slot holds
18+
* 「‹」 back to that home, not the sidebar trigger, which only the desktop
19+
* control below still taps. Both open the same drawer through
20+
* `setOpenMobile(true)`, so the history hook sees the same `openMobile`
21+
* whichever opened it.
2022
*
2123
* In `test:e2e:live:nightly`, not the required `:ci` allowlist.
2224
*/
@@ -25,7 +27,8 @@ const APP = 'com.example.showcase';
2527
const LIST = `/apps/${APP}/showcase_task`;
2628
const DRAWER = '[data-sidebar="sidebar"][data-mobile="true"]';
2729
const TRIGGER = 'button[data-sidebar="trigger"]';
28-
const MORE = '[data-testid="phone-app-nav-more"]';
30+
/** On a phone list the app bar's 「‹」, there once the page is drawn. */
31+
const PHONE_BACK = '[data-testid="app-bar-phone-home"]';
2932
const FLAG = '__navDrawerOpen';
3033

3134
async function openList(page: Page, opener: string) {
@@ -36,8 +39,17 @@ async function openList(page: Page, opener: string) {
3639
await expect(page.locator(opener).first()).toBeVisible();
3740
}
3841

42+
/** A swipe in from the left edge, the phone's drawer gesture (`UnifiedSidebar`). */
43+
async function swipeFromEdge(page: Page) {
44+
await page.evaluate(() => {
45+
const touch = (x: number) => new Touch({ identifier: 1, target: document.body, clientX: x, clientY: 420 });
46+
document.dispatchEvent(new TouchEvent('touchstart', { touches: [touch(10)], changedTouches: [touch(10)] }));
47+
document.dispatchEvent(new TouchEvent('touchend', { touches: [], changedTouches: [touch(120)] }));
48+
});
49+
}
50+
3951
async function openDrawer(page: Page) {
40-
await page.locator(MORE).first().tap();
52+
await swipeFromEdge(page);
4153
await expect(page.locator(DRAWER)).toBeVisible();
4254
await expect.poll(() => drawerFlag(page)).toBe(true);
4355
}
@@ -58,7 +70,7 @@ for (const width of [375, 390]) {
5870
test.use({ viewport: { width, height: 844 }, isMobile: true, hasTouch: true });
5971

6072
test('Back with the drawer open closes it and stays on the list', async ({ page }) => {
61-
await openList(page, MORE);
73+
await openList(page, PHONE_BACK);
6274
const url = page.url();
6375
await openDrawer(page);
6476

@@ -70,7 +82,7 @@ for (const width of [375, 390]) {
7082
});
7183

7284
test('an outside tap closes the drawer and pops its entry: Back goes to the previous page', async ({ page }) => {
73-
await openList(page, MORE);
85+
await openList(page, PHONE_BACK);
7486
const before = await historyLength(page);
7587
await openDrawer(page);
7688

@@ -87,7 +99,7 @@ for (const width of [375, 390]) {
8799
});
88100

89101
test('choosing a nav entry replaces the drawer entry: Back returns to the list', async ({ page }) => {
90-
await openList(page, MORE);
102+
await openList(page, PHONE_BACK);
91103
const listUrl = page.url();
92104
await openDrawer(page);
93105

@@ -112,12 +124,12 @@ for (const width of [375, 390]) {
112124
});
113125

114126
test('a reload with the drawer open leaves it closed, with no flagged entry left', async ({ page }) => {
115-
await openList(page, MORE);
127+
await openList(page, PHONE_BACK);
116128
await openDrawer(page);
117129
const length = await historyLength(page);
118130

119131
await page.reload();
120-
await expect(page.locator(MORE).first()).toBeVisible();
132+
await expect(page.locator(PHONE_BACK).first()).toBeVisible();
121133

122134
await expect.poll(() => drawerFlag(page)).toBe(false);
123135
await expect(page.locator(DRAWER)).toBeHidden();

‎ui/packages/app-shell/src/console/AppContent.tsx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ import { readItemPreferLocal, useReadItemsByName } from '../hooks/useObjectPrese
3636
import { useLauncherApps } from '../hooks/useLauncherApps.js';
3737
import { resolveRecordFormTarget, resolveRecordFormModalLayout, resolveFormViewChrome, selectRecordFormView, resolveNavigateCreateUrl, resolveNavigateEditUrl, resolvePostCreateTarget, recordFormCreateValues, readRecordFormCreateValues, RECORD_FORM_CREATE_VALUES_STATE } from '../utils/recordFormNavigation.js';
3838
import { deriveRecordSurface, deriveRecordFlowSurface } from '@object-ui/plugin-view/core';
39-
import { isPhoneViewportNow } from '../hooks/usePhoneViewport.js';
39+
import { isPhoneViewportNow, usePhoneViewport } from '../hooks/usePhoneViewport.js';
40+
import { PhoneAppHome } from '../layout/PhoneAppHome.js';
4041
import { servedObjectLabel, servedObjectPluralLabel } from '../hooks/servedObjectLabel.js';
4142
import { RECORD_DRAWER_PARAM, RECORD_FORM_PARAM, RECORD_FORM_OBJECT_PARAM, RECORD_FORM_LINK_PARAM } from '../urlParams.js';
4243
import { appAddressSegment, appRouteSegment, canonicalAppPathname, matchAppBySegment } from '../utils/appRoute.js';
@@ -1968,6 +1969,11 @@ function AppRootLanding({
19681969
}) {
19691970
const gates = useNavMemberGates();
19701971
const location = useLocation();
1972+
// objectstack#35881 — on a phone the app's root is the app's home: its whole
1973+
// menu, drawn by the sidebar into this page (`PhoneAppHome`), rather than a
1974+
// redirect to its first entry. Read synchronously, so the first frame does
1975+
// not start a redirect a phone would then undo.
1976+
const phone = usePhoneViewport();
19711977
// objectstack#25338 — an app that names objects, none of which this member
19721978
// may read, has nothing for them: its dashboards and pages would answer a
19731979
// grid of "You don't have access" tiles. Say so once, before any landing is
@@ -2003,6 +2009,15 @@ function AppRootLanding({
20032009
gates.evaluateVisibility,
20042010
ctx,
20052011
);
2012+
// objectstack#35881 — a phone never redirects to an entry: the menu is the
2013+
// page. An app that shows this member no entry, now or once its pending
2014+
// reads answer, still says so.
2015+
if (phone) {
2016+
if (appServesNoNavigation(shownApp) && appServesNoNavigation(undecidedApp)) {
2017+
return <AppNoAccessEmptyState app={app} setupPath={setupPath} />;
2018+
}
2019+
return <PhoneAppHome basePath={location.pathname.replace(/\/+$/, '')} />;
2020+
}
20062021
if (
20072022
undecidedLanding !== landing ||
20082023
(!landing && appServesNoNavigation(shownApp) !== appServesNoNavigation(undecidedApp))
@@ -2027,6 +2042,7 @@ function AppRootLanding({
20272042
if (appServesNoNavigation(shownApp)) {
20282043
return <AppNoAccessEmptyState app={app} setupPath={setupPath} />;
20292044
}
2045+
20302046
// objectstack-ai/objectstack#29771 — a navigation with no in-app landing:
20312047
// every entry the member is shown, in `navigation` and in every area, is a
20322048
// `url` or `action` link (a working or `doc` entry anywhere would have

0 commit comments

Comments
 (0)