Skip to content

Commit a2dc858

Browse files
feat(ui): every menu row is a tile: objects in their colour, everything else on a light grey tile (#36164)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuFFKDUEw658BkLsJjATrqG7)_ Part of #36141 repo:objectstack#1 · os-sales · session_01L6bhgWopgUHAVkDYdjqW8g Clause-②: yes (widening) Metadata-protocol: none The widening: `@object-ui/components` exports `NeutralIconTile`, its props type `NeutralIconTileProps` and `NEUTRAL_ICON_TILE_CLASS`; `@object-ui/layout` exports `NAV_KIND_ICON` and `resolveNavKindIcon`. Nothing is removed or renamed, and no `packages/spec` path is touched. `Part of`, not `Fixes`: the card's item 4 (an automatic colour for an object with none) is on the maintainer's decision card and is not in this branch. This PR delivers items 1–3 and 5–7. ## What changes The rule, from the card: colour only says which object a row is, never which kind of menu entry it is, and every row draws the same tile. 1. **Non-object menu entries are tiles.** In the sidebar (`NavigationRenderer`) and the `nav:menu` page block, a `dashboard`, `report`, `page`, `url`, `component`, `doc` or `action` entry draws `NeutralIconTile`: the object tile's size, corners and glyph size, a light grey square with a dark grey glyph (`gray-200` / `gray-700`, swapped in the dark theme). The glyph is the entry's own `icon`, else its kind's (`NAV_KIND_ICON`: `layout-dashboard`, `chart-column`, `file`, `external-link`, `layout-grid`, `book-open`, `zap`). No kind has a colour of its own. 2. **Object entries** keep their object's tile (white glyph on the object's palette colour), unchanged. 3. **An object entry that opens a view** (`viewName`, e.g. "My Deals") is its object's tile; pinned. 5. Group headings and separators draw no tile; pinned. 6. **Recent, Favorites and Starred** in the sidebar, and Home's **Recently accessed**: a row about an object (the object, one of its views, one of its records) draws that object's tile in its icon and colour; a dashboard, page, report or Studio item draws the neutral tile with its kind's icon. The emoji those rows drew (📊 📈 📄 📋) are gone. `ContentItemTile` (app-shell, not exported) holds the rule for the sidebar; Home's row reads the same object metadata it already read for records. 7. **Phone app home menu** is the same `NavigationRenderer` (`renderAppMenu('home')`), so it follows with no code of its own; see the phone shots under Verification. ## Why The sidebar mixed solid colour squares (objects) with bare outline icons (everything else) in one column, which read as two weights. The maintainer asked what the non-object entries are and what colour they should take; the answer agreed was one light grey tile for all of them (card body, 「同意,立卡」). ## Verification - Unit: `components` `object-icon-tile-35985.test.tsx` (neutral tile: one value per theme, glyph contrast ≥ 4.5:1 both themes, lighter than every palette square, same shape as the object tile at all four sizes); `layout` `NavigationRenderer.objectTile-35985.test.tsx` (every non-object kind, an action and a row inside a group on the neutral tile; a view on its object's colour; group heading and separator draw none; kind glyphs); app-shell `UnifiedSidebar.favoritesMenu-12427.test.tsx` (object and record favourites are object tiles, a dashboard favourite neutral, no emoji; a Recent record object tile, a Recent metadata item neutral). Flipped pins: the 30126 controls (a dashboard with no icon now draws its kind's glyph, still never the object's), the 12604 Home rows (view and object rows now draw the object's tile), and four sidebar label lists that read the emoji as text. - Local, against `f5553525`: those files plus every app-shell / console test that mounts the sidebar, Home or `nav:menu` (119 files, 1,168 tests) pass; `type-check` for `@object-ui/components`, `@object-ui/layout`, `@object-ui/app-shell` clean; `eslint` on the changed files 0 errors. - Browser: HotCRM (hotcrm main `1468877`, `objectstack dev`), console `vite` from this branch, Sales app, 1440 and 375, light and dark, before and after, in the project thread's evidence folder (`build-seat1/36141/`): `*-sidebar-*`, `*-sidebar-recent-*`, `*-home-recent-*`, `*-phone-app-home-*`. After: every Sales sidebar row is a 20px rounded tile (24px on the phone); Home, Sales Home, Sales Performance, Product Catalog, Inbox, Sales Activity and CRM Overview sit on the light grey tile; the object rows are unchanged. HotCRM declares no object colour, so its object tiles are all the neutral `gray` palette square; that is item 4's question, not this PR's. - Review delta `5c70f68e` (L2 S1, N1, N2, N6 on `eb36a397`): the sidebar's Recent, Favorites and Starred rows ask the objects they name in ONE batched presence read (`readRecentObjects`, moved out of `HomePage.tsx` into `console/home/readRecentObjects.ts` and re-exported there); a name not answered served draws the object tile in its neutral colour and is never read by name. Pinned in `UnifiedSidebar.favoritesMenu-12427.test.tsx` ("never asks a missing one by name"), which fails with the gate removed (4 by-name calls name the missing object). `CONTENT_KIND_ICON` spreads `NAV_KIND_ICON`; `NavIconTarget`'s comment names the kind icon; the neutral-tile pin compares it with every palette square. Local: 180 affected files / 2,021 tests pass, app-shell type-check clean, eslint 0 errors. ## Follow-ups (not in this PR) - Item 4 (automatic colour) waits on the maintainer's decision card. If it is chosen it lands as its own commit on this branch with its own spec, changeset and L2 face. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [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. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgWopgUHAVkDYdjqW8g <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgWopgUHAVkDYdjqW8g --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1f11c33 commit a2dc858

19 files changed

Lines changed: 521 additions & 132 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/layout': patch
4+
'@object-ui/app-shell': patch
5+
---
6+
7+
feat(ui): every menu row is a tile: objects and their views in the object's colour, everything else on a light grey tile
8+
9+
Clause-②: yes (widening) — `@object-ui/components` adds `NeutralIconTile`, `NeutralIconTileProps` and `NEUTRAL_ICON_TILE_CLASS`; `@object-ui/layout` adds `NAV_KIND_ICON` and `resolveNavKindIcon`; nothing removed or renamed
10+
Metadata-protocol: none
11+
12+
The sidebar drew an object entry as its object's colour tile and every other entry as a bare line icon, so one column mixed solid squares and outlines. Now every row is a tile of the same size and corners, and colour still says only which object a row opens:
13+
14+
- **Object entries, and object entries that open one of its views** (a `viewName`, such as "My deals"): the object's tile, as before.
15+
- **Every other entry** (`dashboard`, `report`, `page`, `url`, `component`, `doc`, `action`): a light grey tile with a dark grey glyph, the entry's own `icon`, else its kind's (`NAV_KIND_ICON`: a dashboard, a column chart, a page, an outward arrow, a grid, a book, a bolt). No kind gets a colour of its own.
16+
- **Recent, Favorites and Starred in the sidebar, and Home's "Recently accessed"**: an object, one of its views or one of its records is that object's tile; a dashboard, page or report is the neutral tile. The emoji these rows drew are gone.
17+
- Group headings and separators are unchanged. The phone's app home lists the same menu, so it follows.

‎content/docs/frontend/layout.mdx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ the app document's `navigation` items (`{ "type": "app", "navigation": [...] }`,
437437
`objectui validate` accepts), drawn by the shell — the console's sidebar, or
438438
`AppSchemaRenderer` (the whole shell from metadata, above). Both hand the items to the
439439
`NavigationRenderer` component, and its items are JSON-shaped: `icon` really is a string
440-
name there, resolved by `resolveIcon`. There is no page node for navigation:
440+
name there, resolved by `resolveIcon`. Every row draws its icon on a tile of one size: an
441+
`object` entry (with or without a `viewName`) on its object's colour tile (`ObjectIconTile`),
442+
every other entry on the light grey `NeutralIconTile`, with the entry's own `icon` else its
443+
kind's (`NAV_KIND_ICON`). There is no page node for navigation:
441444
`navigation-renderer` was retired (objectui#11441), so a node written with that type
442445
renders the same "Unknown component type" panel.
443446

‎ui/packages/app-shell/src/console/home/HomePage.tsx‎

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import { useMetadata } from '../../providers/MetadataProvider.js';
2727
import { useRecentItems, type RecentItem } from '../../hooks/useRecentItems.js';
2828
import { useRecentItemLabel } from '../../hooks/useRecentItemLabel.js';
2929
import { useNavTargetLabel, type NavTargetLabelOptions } from '../../hooks/useNavTargetLabel.js';
30-
import { objectPresence, readObjectsByName } from '../../hooks/useObjectPresence.js';
31-
import { readObjectPresence } from '../appObjectScope.js';
30+
import { readObjectsByName } from '../../hooks/useObjectPresence.js';
31+
import { readRecentObjects, type RecentObjectReading } from './readRecentObjects.js';
3232
import { useFavorites } from '../../hooks/useFavorites.js';
3333
import { useObjectTranslation } from '@object-ui/i18n';
3434
import { useObjectLabel } from '@object-ui/i18n';
@@ -376,50 +376,7 @@ export interface HomePageProps {
376376
/** Home's labels read each object they name by name (objectstack#29121). */
377377
const BY_NAME: NavTargetLabelOptions = { byName: true };
378378

379-
/**
380-
* What Home may do with the object a "Recently accessed" row names
381-
* (objectstack#34692): `read` it (its label, its icon), leave it `unread`
382-
* while nobody has said whether this environment registers it, or drop the
383-
* row, because the environment does not (`absent`).
384-
*/
385-
export type RecentObjectReading = 'read' | 'unread' | 'absent';
386-
387-
/**
388-
* objectstack#34692 — the rule objectstack#26988 applies to a record page's
389-
* lists, `DashboardView` to its widgets and the navigation to its
390-
* `requiresObject` entries, applied to Home's recent rows: a row whose object
391-
* the registered object list does not hold (its package disabled after the
392-
* row was stored) is neither drawn nor asked about by name.
393-
*
394-
* While nothing has loaded the whole registry, `names` are asked in the ONE
395-
* `GET /meta/object?names=` presence read (`readObjectPresence`), which leaves
396-
* an unregistered name out instead of answering it 404. A name it answered
397-
* served is read by name, as before (objectstack#29121); a name it left out is
398-
* `absent`; a name not answered yet, or whose read failed, is `unread`: its
399-
* row is drawn, as every #26988 surface draws an entry its list has not
400-
* answered, and nothing is asked by name for it (`servedByName`'s rule).
401-
*
402-
* Once the whole registry is loaded, or on its way, or on a context with no
403-
* scope reads, `objectPresence` answers from that list: `absent` only from a
404-
* list that answered and holds other objects; an empty or unanswered list
405-
* reads every name as `read`, where no by-name request is made anyway.
406-
*/
407-
export function readRecentObjects(
408-
metadata: Pick<ReturnType<typeof useMetadata>, 'objects' | 'readObjectScope' | 'getTypeStatus'>,
409-
names: readonly string[],
410-
): (name: string) => RecentObjectReading {
411-
const { readObjectScope, getTypeStatus } = metadata;
412-
if (readObjectScope && getTypeStatus?.('object') === 'idle') {
413-
if (names.length === 0) return () => 'read';
414-
const { presence } = readObjectPresence(readObjectScope, undefined, names);
415-
const served = new Set(presence.objects.map((o) => (o as { name?: unknown } | null | undefined)?.name));
416-
const missing = new Set(presence.missing);
417-
return (name) => (served.has(name) ? 'read' : missing.has(name) ? 'absent' : 'unread');
418-
}
419-
const status = getTypeStatus?.('object');
420-
const objects = metadata.objects ?? [];
421-
return (name) => (objectPresence(name, status, objects) === 'absent' ? 'absent' : 'read');
422-
}
379+
export { readRecentObjects, type RecentObjectReading };
423380

424381
export function HomePage({ checklist }: HomePageProps = {}) {
425382
const navigate = useNavigate();
@@ -615,8 +572,10 @@ export function HomePage({ checklist }: HomePageProps = {}) {
615572
icon: undefined,
616573
};
617574
}
575+
// objectstack#36141 — an object, view or record row draws its object's
576+
// tile, so all three read the object's icon and colour.
618577
const objectDef =
619-
item.type === 'record' && objectName
578+
objectName
620579
? (readObjectsByName(metadata, [objectName]) as Array<{ name?: unknown; icon?: unknown; color?: unknown } | null | undefined>).find(
621580
(o) => o?.name === objectName,
622581
)
@@ -630,6 +589,7 @@ export function HomePage({ checklist }: HomePageProps = {}) {
630589
app: app ? appLabel(app) : undefined,
631590
icon: typeof objectIcon === 'string' && objectIcon !== '' ? objectIcon : undefined,
632591
color: typeof objectDef?.color === 'string' ? objectDef.color : undefined,
592+
object: !!objectDef,
633593
};
634594
};
635595

‎ui/packages/app-shell/src/console/home/HomeRail.tsx‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
FileText, Database, LayoutDashboard, File, List, CircleAlert, Rocket, Lock,
1919
} from 'lucide-react';
2020
import { useDisplayLocale } from '@object-ui/i18n';
21-
import { Button, cn, ObjectIconTile } from '@object-ui/components';
21+
import { Button, cn, NeutralIconTile, ObjectIconTile } from '@object-ui/components';
2222
import type { ActivityFeedReading } from '../../hooks/sharedUserFeeds.js';
2323
import type { HomeInboxStatus, HomeNotification, PendingApprovalRequest } from '../../hooks/useHomeInbox.js';
2424
import type { RecentItem } from '../../hooks/useRecentItems.js';
@@ -482,13 +482,19 @@ export interface RecentItemContext {
482482
context: string;
483483
/** The label of the app the entry was opened in, or `undefined` when no app on Home is it. */
484484
app?: string;
485-
/** A record's object icon (a Lucide name), or `undefined` to draw the kind's icon. */
485+
/** The row's object's icon (a Lucide name), or `undefined` to draw the kind's icon. */
486486
icon?: string;
487487
/**
488-
* A record's object palette colour (`ObjectSchema.color`): with `icon`, the
489-
* row draws the object's tile in that colour (objectstack#35985).
488+
* The row's object's palette colour (`ObjectSchema.color`), drawn as the
489+
* object's tile (objectstack#35985).
490490
*/
491491
color?: string;
492+
/**
493+
* The row is about an object (the object, one of its views or records) whose
494+
* metadata was read: it draws that object's tile; otherwise the neutral tile
495+
* with the kind's icon (objectstack#36141).
496+
*/
497+
object?: boolean;
492498
}
493499

494500
/**
@@ -529,7 +535,7 @@ export function HomeContinue({
529535
) : (
530536
<ul className="overflow-hidden rounded-lg border border-border bg-card">
531537
{items.map((it) => {
532-
const { context, app, icon, color } = describe(it);
538+
const { context, app, icon, color, object } = describe(it);
533539
const Icon = icon ? getIcon(icon) : RECENT_ICON[it.type] || FileText;
534540
const trail = [context, app, timeAgo(it.visitedAt, displayLocale)].filter(Boolean).join(' · ');
535541
return (
@@ -541,19 +547,15 @@ export function HomeContinue({
541547
data-recent-type={it.type}
542548
className="flex h-10 w-full items-center gap-2.5 px-3 text-left text-[13px] transition-colors hover:bg-muted/60 max-sm:h-11"
543549
>
544-
{icon ? (
545-
<span className="inline-flex shrink-0" data-testid="home-recent-icon" data-icon={icon}>
550+
{/* objectstack#36141 — the menu's rule: an object row is its
551+
object's tile, every other row the neutral tile. */}
552+
<span className="inline-flex shrink-0" data-testid="home-recent-icon" data-icon={icon ?? it.type}>
553+
{object || icon ? (
546554
<ObjectIconTile glyph={Icon} color={color} size="md" />
547-
</span>
548-
) : (
549-
<span
550-
className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground"
551-
data-testid="home-recent-icon"
552-
data-icon={it.type}
553-
>
554-
<Icon className="h-[13px] w-[13px]" />
555-
</span>
556-
)}
555+
) : (
556+
<NeutralIconTile glyph={Icon} size="md" />
557+
)}
558+
</span>
557559
<span className="min-w-0 flex-1 truncate">{labelOf(it)}</span>
558560
<span className="shrink-0 text-xs text-muted-foreground" data-testid="home-recent-trail">
559561
{trail}

‎ui/packages/app-shell/src/console/home/__tests__/HomePage.recentlyAccessed-12604.test.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ describe('Home "Recently accessed" (objectui#12604)', () => {
239239
expect(rows().map((row) => row.getAttribute('data-recent-type'))).toEqual(['record', 'view', 'dashboard', 'object']);
240240
});
241241

242-
it('a record row draws its object’s icon; every other row its kind’s', () => {
242+
it('a record, view or object row draws its object’s icon; every other row its kind’s (objectstack#36141)', () => {
243243
renderPage();
244244
const icons = rows().map((row) => within(row).getByTestId('home-recent-icon').getAttribute('data-icon'));
245-
expect(icons).toEqual(['building', 'view', 'dashboard', 'object']);
245+
expect(icons).toEqual(['building', 'building', 'dashboard', 'building']);
246246
});
247247

248248
it('each trail reads context · app · visit time, the time in the display locale', () => {
@@ -280,11 +280,13 @@ describe('Home "Recently accessed" (objectui#12604)', () => {
280280
});
281281
});
282282

283-
describe('a record row draws its object\'s tile (objectstack#35985)', () => {
284-
it('in the object\'s palette colour; the other kinds keep their muted kind icon', () => {
283+
describe('a row about an object draws its object\'s tile (objectstack#35985, objectstack#36141)', () => {
284+
it('a record, a view and an object row in the object\'s palette colour; a dashboard row on the neutral tile', () => {
285285
renderPage();
286286
const tiles = rows().map((row) => row.querySelector('[data-object-icon-tile]')?.getAttribute('data-object-icon-tile') ?? null);
287-
expect(tiles).toEqual(['orange', null, null, null]);
287+
expect(tiles).toEqual(['orange', 'orange', null, 'orange']);
288+
const neutral = rows().map((row) => row.querySelector('[data-neutral-icon-tile]') !== null);
289+
expect(neutral).toEqual([false, false, true, false]);
288290
});
289291
});
290292

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
import type { useMetadata } from '../../providers/MetadataProvider.js';
10+
import { objectPresence } from '../../hooks/useObjectPresence.js';
11+
import { readObjectPresence } from '../appObjectScope.js';
12+
13+
/**
14+
* What Home may do with the object a "Recently accessed" row names
15+
* (objectstack#34692): `read` it (its label, its icon), leave it `unread`
16+
* while nobody has said whether this environment registers it, or drop the
17+
* row, because the environment does not (`absent`).
18+
*/
19+
export type RecentObjectReading = 'read' | 'unread' | 'absent';
20+
21+
/**
22+
* objectstack#34692 — the rule objectstack#26988 applies to a record page's
23+
* lists, `DashboardView` to its widgets and the navigation to its
24+
* `requiresObject` entries, applied to Home's recent rows: a row whose object
25+
* the registered object list does not hold (its package disabled after the
26+
* row was stored) is neither drawn nor asked about by name.
27+
*
28+
* While nothing has loaded the whole registry, `names` are asked in the ONE
29+
* `GET /meta/object?names=` presence read (`readObjectPresence`), which leaves
30+
* an unregistered name out instead of answering it 404. A name it answered
31+
* served is read by name, as before (objectstack#29121); a name it left out is
32+
* `absent`; a name not answered yet, or whose read failed, is `unread`: its
33+
* row is drawn, as every #26988 surface draws an entry its list has not
34+
* answered, and nothing is asked by name for it (`servedByName`'s rule).
35+
*
36+
* Once the whole registry is loaded, or on its way, or on a context with no
37+
* scope reads, `objectPresence` answers from that list: `absent` only from a
38+
* list that answered and holds other objects; an empty or unanswered list
39+
* reads every name as `read`, where no by-name request is made anyway.
40+
*/
41+
export function readRecentObjects(
42+
metadata: Pick<ReturnType<typeof useMetadata>, 'objects' | 'readObjectScope' | 'getTypeStatus'>,
43+
names: readonly string[],
44+
): (name: string) => RecentObjectReading {
45+
const { readObjectScope, getTypeStatus } = metadata;
46+
if (readObjectScope && getTypeStatus?.('object') === 'idle') {
47+
if (names.length === 0) return () => 'read';
48+
const { presence } = readObjectPresence(readObjectScope, undefined, names);
49+
const served = new Set(presence.objects.map((o) => (o as { name?: unknown } | null | undefined)?.name));
50+
const missing = new Set(presence.missing);
51+
return (name) => (served.has(name) ? 'read' : missing.has(name) ? 'absent' : 'unread');
52+
}
53+
const status = getTypeStatus?.('object');
54+
const objects = metadata.objects ?? [];
55+
return (name) => (objectPresence(name, status, objects) === 'absent' ? 'absent' : 'read');
56+
}

0 commit comments

Comments
 (0)