Skip to content

Commit 6037a9c

Browse files
committed
feat(record-page): one top bar above the record header on every face
The page, the split pane, the drawer and the maximized pane draw one 40 px bar of frame controls: the breadcrumb on the left (object › record, or the path one level down), and on the right the counter with ↓ ↑, the right column's switch, ⤢ / ⤡ and ✕, each only where it applies. The crumb row above the page header goes; a page the list row's ↗ opened steps that list's rows. The enlarged related list draws a toolbar over its table, and the Activity tab names its count on a link that opens another tab. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVP3twvBvDTwoLPU6J
1 parent 5da3a8c commit 6037a9c

25 files changed

Lines changed: 1227 additions & 272 deletions

‎ui/packages/app-shell/src/urlParams.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ export const RECORD_DETAIL_TAB_PARAM = 'tab';
104104
*/
105105
export const RECORD_RELATED_ENLARGE_PARAM = 'related';
106106

107+
/**
108+
* History-state flag beside {@link RECORD_RELATED_ENLARGE_PARAM}: the record
109+
* view pushed the `?related=` entry, so closing the tab pops it. Not a URL
110+
* parameter; a navigation that replaces the entry drops it.
111+
*/
112+
export const RECORD_RELATED_ENLARGE_PUSHED_STATE = '__relatedEnlargePushed';
113+
107114
/** Command palette overlay (ADR-0054 Phase 1; alias `cmdk`). */
108115
export const COMMAND_PALETTE_PARAM = 'palette';
109116

‎ui/packages/app-shell/src/views/ObjectView.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
745745
// an object that declares `page` (or `new_window` / `none`) keeps its
746746
// declaration. objectstack#27545 — the pane beside the list is the default.
747747
const [recordOpenPreference, setRecordOpenPreference] = useRecordOpenPreference();
748-
const { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowAsPage, drawerRoot, drawerRestore, handleListRowsChange, handleRootStep } = useObjectViewRecordNavigation({
748+
const { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowAsPage, drawerRoot, drawerRestore, handleListRowsChange, handleRootStep, listLabel } = useObjectViewRecordNavigation({
749749
activeView,
750750
objectDef,
751751
objects,
@@ -1166,6 +1166,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
11661166
drawerRoot={drawerRoot}
11671167
drawerRestore={drawerRestore}
11681168
handleRootStep={handleRootStep}
1169+
stepScope={listLabel}
11691170
dataSource={dataSource}
11701171
objects={objects}
11711172
onEdit={onEdit}

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 166 additions & 48 deletions
Large diffs are not rendered by default.

‎ui/packages/app-shell/src/views/objectViewRecordNavigation.ts‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ export function useObjectViewRecordNavigation({
127127
// (objectstack#27545) — and the location changes with it.
128128
const locationRef = useRef(location);
129129
locationRef.current = location;
130+
// The list's name — its view's tab label: what the page's way back says,
131+
// and the set the pane's counter names (objectstack#27524, Target 7).
132+
const listLabel = useMemo(
133+
() => viewTabLabel({ id: activeView?.id, name: activeView?.name, label: activeView?.label }, objectDef.name, servedViews, viewLabel, unlabelledViewText, language),
134+
[activeView?.id, activeView?.name, activeView?.label, objectDef.name, servedViews, viewLabel, unlabelledViewText, language],
135+
);
130136
// Memoize onNavigate to prevent stale closure in useNavigationOverlay's handleClick
131137
const handleNavOverlayNavigate = useCallback(
132138
(recordId: string | number, action?: string, extraState?: Record<string, unknown>) => {
@@ -156,7 +162,7 @@ export function useObjectViewRecordNavigation({
156162
...extraState,
157163
from: {
158164
pathname: pathname + (search || ''),
159-
label: viewTabLabel({ id: activeView?.id, name: activeView?.name, label: activeView?.label }, objectDef.name, servedViews, viewLabel, unlabelledViewText, language),
165+
label: listLabel,
160166
},
161167
};
162168
if (viewId) {
@@ -165,7 +171,7 @@ export function useObjectViewRecordNavigation({
165171
navigate(`record/${encodeURIComponent(String(recordId))}`, { state: originState });
166172
}
167173
},
168-
[navigate, viewId, objectDef, activeView?.id, activeView?.name, activeView?.label, viewLabel, unlabelledViewText, servedViews, language]
174+
[navigate, viewId, listLabel]
169175
);
170176
/**
171177
* The list surface's half of the record-link mechanism (objectui#4490):
@@ -274,15 +280,23 @@ export function useObjectViewRecordNavigation({
274280
* The row's `↗` (objectstack#26681): the record's page, handed the way back
275281
* to this list with that record open — the page's 「Collapse to drawer」
276282
* (`recordDrawerReturnState`), drawn only for a reader who arrived this
277-
* way (objectstack#27545).
283+
* way (objectstack#27545) — and the rows the list shows, which that page's
284+
* top bar steps through with its counter and ↓ ↑ (objectstack#27524,
285+
* Target 7). Read at click time: the handler never changes with the rows.
278286
*/
287+
const listRowIdsRef = useRef<readonly string[]>([]);
279288
const handleOpenRowAsPage = useCallback((recordId: string | number) => {
280289
const { pathname, search, state } = locationRef.current;
281290
const back = new URLSearchParams(search);
282291
back.set(RECORD_DRAWER_PARAM, String(recordId));
292+
const siblings = listRowIdsRef.current;
283293
const returnState = recordDrawerReturnState(
284294
{ pathname, search: `?${back.toString()}`, state },
285-
[{ objectName: objectDef.name, recordId: String(recordId) }],
295+
[{
296+
objectName: objectDef.name,
297+
recordId: String(recordId),
298+
...(siblings.includes(String(recordId)) ? { siblings } : {}),
299+
}],
286300
);
287301
handleNavOverlayNavigate(recordId, undefined, returnState);
288302
}, [objectDef.name, handleNavOverlayNavigate]);
@@ -293,6 +307,7 @@ export function useObjectViewRecordNavigation({
293307
* changes nothing.
294308
*/
295309
const [listRowIds, setListRowIds] = useState<{ key: string; ids: readonly string[] }>({ key: '', ids: [] });
310+
listRowIdsRef.current = listRowIds.ids;
296311
const handleListRowsChange = useCallback((rows: ReadonlyArray<Record<string, unknown>>) => {
297312
const ids = rows
298313
.map((row) => (row?.id ?? row?._id) as string | number | undefined)
@@ -331,5 +346,5 @@ export function useObjectViewRecordNavigation({
331346
navOverlay.close();
332347
}
333348
}, [drawerRecordId]);
334-
return { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowAsPage, drawerRoot, drawerRestore, handleListRowsChange, handleRootStep };
349+
return { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowAsPage, drawerRoot, drawerRestore, handleListRowsChange, handleRootStep, listLabel };
335350
}

‎ui/packages/app-shell/src/views/objectViewRecordOverlay.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
*
1414
* Since objectstack#26679 the pane is the in-place stack of
1515
* `./recordDrawerStack.tsx`: its root is the list row `?recordId=` names, a
16-
* related row or a lookup inside it opens one level down, and its bar names
17-
* no object (maintainer ruling 2 on that card).
16+
* related row or a lookup inside it opens one level down. Its top bar
17+
* (objectstack#27524, Target 7) names the object and the record at the root,
18+
* and its counter names the list's view (`stepScope`).
1819
*/
1920

2021
import type { ReactNode } from 'react';
@@ -37,6 +38,7 @@ export function ObjectViewRecordOverlay({
3738
drawerRoot,
3839
drawerRestore,
3940
handleRootStep,
41+
stepScope,
4042
dataSource,
4143
objects,
4244
onEdit,
@@ -55,6 +57,8 @@ export function ObjectViewRecordOverlay({
5557
drawerRoot: RecordNavigation['drawerRoot'];
5658
drawerRestore: RecordNavigation['drawerRestore'];
5759
handleRootStep: RecordNavigation['handleRootStep'];
60+
/** The list's name (its view), which the pane's counter says. */
61+
stepScope?: string;
5862
dataSource: ConsoleObjectViewProps['dataSource'];
5963
objects: ConsoleObjectViewProps['objects'];
6064
onEdit: ConsoleObjectViewProps['onEdit'];
@@ -70,6 +74,7 @@ export function ObjectViewRecordOverlay({
7074
mainContent={list}
7175
onClose={handleDrawerClose}
7276
onOpenAsPage={handleOpenAsPage}
77+
stepScope={stepScope}
7378
storageKey={`drawer-width:${objectDef.name}`}
7479
objects={objects}
7580
renderRecord={(level) => (

‎ui/packages/app-shell/src/views/recordDrawerContext.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ export function useRecordPane(): RecordPaneApi | null {
5555
return useContext(RecordPaneContext);
5656
}
5757

58+
/**
59+
* The pane's top bar, as the record drawn in it reaches it (objectstack#27524,
60+
* Target 7): the bar's slot for the record's panel switches — the right
61+
* column's ⊟, which only the record knows applies — and where the record says
62+
* its title for the bar's breadcrumb 「对象 › 记录名」. `null` outside a pane.
63+
*/
64+
export interface RecordPaneBarApi {
65+
/** The bar's element the record portals its panel switches into; `null` until it mounts. */
66+
toggleSlot: HTMLElement | null;
67+
/** The title of the record `recordId` names, once its row has loaded. */
68+
reportTitle(recordId: string, title: string | undefined): void;
69+
}
70+
71+
export const RecordPaneBarContext = createContext<RecordPaneBarApi | null>(null);
72+
73+
/** The top bar of the pane the record is drawn in, or `null` on its own page. */
74+
export function useRecordPaneBar(): RecordPaneBarApi | null {
75+
return useContext(RecordPaneBarContext);
76+
}
77+
5878
/**
5979
* Whether a record of this object opens in the drawer: its object's own way
6080
* of opening, the drawer unless it declares another (objectstack#26677 — the

0 commit comments

Comments
 (0)