Skip to content

Commit 03d9324

Browse files
committed
feat(app-shell): phone lands in an app whose home is its whole menu; bottom bar fixed to Home, Notifications, Approvals and search
On a phone (below 768 px): - `/` opens the app the person used last (a per-person `ui.app.last` preference on the shared read), else the declared default, else the single app, else the app list. - `/apps/SEGMENT` is the app's home: the sidebar's own menu drawn into the page through a portal, scroll restored on return. - The app pill opens a bottom sheet listing the apps with search; `/home` is the same list as a page. - The bottom bar is three fixed cells (Home, Notifications, Approvals) and a search button, shown only on those three pages; pinned menu entries, More and the stars are removed. Desktop and tablet widths are unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgU7ah5dc72qr3aWHFu
1 parent 8c18a36 commit 03d9324

38 files changed

Lines changed: 1913 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)