Skip to content

feat(ui): staff-portal style for the inventory pages - #204

Merged
kevwilliams merged 6 commits into
feat/manual-inventory-recordsfrom
feat/inventory-staff-portal-style
Nov 27, 2026
Merged

kevwilliams merged 6 commits into
feat/manual-inventory-recordsfrom
feat/inventory-staff-portal-style

Conversation

@kevwilliams

Copy link
Copy Markdown
Contributor

Brings the inventory pages in line with staff-portal's list and detail style, rebuilt on the current feat/manual-inventory-records.

Changes

Session boundary (dcde392)

  • Only a change of signed-in user (including A→B→A) resets the inventory session. Host revalidation pauses reads and operations without showing anything, so the "Checking inventory access" and "Checking management access" flashes are gone.
  • Presentation-only URL changes (kind, record, tab, view, filters and so on) keep the loaded data.

List pages and Catalog (be46b9c)

  • A category switcher (popover of links grouped Equipment / Locations / Installation plans, with counts) replaces the long row of tabs.
  • New Catalog tab for Manufacturers and Device types, with a toggle between them. Each kind redirects to the page it belongs to.
  • One toolbar row: search, a Filter popover (facility and model/medium), an icon Refresh and Create.
  • The list is a datum-ui DataTable at compact density with sortable headers, a "rows per page · 1–N of M" footer, and row marks for conflicts and unavailable data.

Record pages (b9c6319)

  • Host-style entity header: a back link to the list (filters kept), the icon, name, a one-line summary and the actions.
  • Pill tabs.
  • Rack page: facility, height and issue badges move into the header summary; the face choice is a segmented pill; the device panel closes with an icon button.

Docs: docs/development/staff-inventory-ui.md describes the navigation and session boundary as implemented.

Testing

  • pnpm test in ui/provider: 1000 passed, including the native-controls guard.
  • Typecheck and pnpm build pass.
  • Checked by hand in staff-portal against the local remote.

Not in this PR

  • The facility detail page is unchanged from the base branch.

🤖 Generated with Claude Code

kevwilliams and others added 3 commits November 25, 2026 00:09
…oundary

The inventory masked itself behind "Checking inventory access…", re-ran host
loaders and re-read all collections whenever the tab was hidden or the host
revalidated (for example on a theme change), and cancelled in-flight saves.
No other staff-portal page does this, and per-request authorization already
covers what it protected. Match the host instead:

- Tab hide/show, pagehide/pageshow and focus leave inventory, cache, forms
  and in-flight saves alone.
- Navigation keeps the current view on screen until the host has loaded.
- A host revalidation for the same user pauses new reads and operations while
  it runs; nothing on screen changes.
- A change of signed-in user (including A→B→A) or of non-presentation URL
  parameters replaces the private cache, with one fresh read.

Tests for the removed hidden/pagehide/revalidation behaviour are removed; new
tests cover inventory, forms and saves surviving tab switches. The design doc
records the decision and the retained protections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g tab

List pages follow staff-portal's Customers list: one toolbar row on top of a
compact sortable datum-ui data table with a rows-per-page footer.

- A category switcher (datum-ui Popover of links grouped by Equipment,
  Locations and Installation plans) replaces the group and kind tab rows.
  Each category shows its count once access resolves; the count is a
  description, not part of the name.
- Manufacturers and Device types move to a Catalog tab with a two-option
  toggle. Links are absolute, and a kind requested on the other page is
  redirected there.
- The toolbar row: borderless search, one Filter popover (facility, model,
  Clear filters), icon Refresh, Create.
- The table keeps the directory rows' columns, attention edges and reasons,
  set on each row by InventoryListTable.
- Fix: the list toolbar and table shared a React key, which duplicated the
  toolbar on every list/record switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record pages open with the staff-portal entity header: a back link to the
list, the record's icon, name and one-line summary, and the actions. Record
tabs use the pill style.

The rack page moves facility, height and issue badges into the header
summary, uses pill tabs, shows the face choice as a segmented pill and closes
the device panel with an icon button. The screenshot script waits for the new
header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kevwilliams
kevwilliams requested a review from a team as a code owner November 25, 2026 18:51

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes.

The provider check is red at this head: in inventory-tab-navigation.test.tsx, "defaults to Devices and switches to every category without extra collection reads" fails at line 228. It expects the trigger "Inventory category: Racks" and gets "Facilities". This PR rewrote that test and the base has no switcher, so the failure is this PR's: either a stale trigger after chooseCategory or a race in the new helper.

  • User switches hold up. A to B remounts the keyed SessionQueries in the same render, and A to B to A is caught by the HostedInventory subscription, so B never sees A's data or a held operation.
  • With the pagehide, hidden and pageshow handling removed, nothing re-checks the signed-in user when a tab returns from hidden or from the back-forward cache. If another user signs in elsewhere meanwhile, the old user's data stays visible and writes go out under the new session. Show that the host revalidates on focus, or restore the check.
  • Deleted tests with no replacement: the denied-access test asserting exactly nine list GETs with no permission review or write, and generations staying masked until the newest loader finishes. Restore them or point to where they live now.

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The open review still applies at this head (b9c6319). The provider check is still red on inventory-tab-navigation.test.tsx ("defaults to Devices and switches to every category…": 1 failed, 962 passed). The session re-check on tab return and the deleted access and generation tests are also still open.

kevwilliams and others added 3 commits November 26, 2026 00:06
"defaults to Devices and switches to every category without extra collection
reads" failed in CI (trigger read "Facilities", expected "Racks") but passed
locally. The cause is the test, not the switcher: RouterProvider applies
router state to React inside startTransition, so router.state.location and
navigation.state reach the new category before the page commits, and the
"search box enabled" wait was satisfied by the previous category's search box.
Under CPU load the trigger was read before the transition committed (2 of 6
loaded runs failed locally).

Add switchCategory(), which waits for the new category's own search box (a
committed signal independent of the trigger), and use it in the loop; the
router-state checks become plain assertions after the commit. The trigger is
not stale: it and the page read the same rendered location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dcde392 removed the hidden/pagehide/pageshow handling to stop the "Checking
inventory access" flashes, and with it the only re-check of the signed-in
user after a tab was hidden or restored from the back-forward cache. The host
does not do this: the principal arrives only through the Milo layout loader
(requireStaffUser), which staff-portal re-runs on navigations and explicit
revalidation only; app/ has no focus, visibilitychange or pageshow handling
(staff-portal ba00ea6).

Restore the check without any visible state:

- Reads and operations gain a hold that pauses instead of cancelling
  (SessionHold). A read waits to start or deliver; a save waits in
  InventoryOperation.settle(), called right before every dispatch().
- Hiding the tab or pagehide holds the session. Showing it again, or any
  pageshow after a pagehide (always when persisted), calls router.revalidate().
  The same user releases the hold and held work continues; another user, no
  user, a host error or a rejected revalidate fails closed, so held writes
  are never sent and a new principal remounts the cache. A later successful
  check reopens the session for new work only.
- Host revalidation (e.g. a theme change) now holds and then releases
  same-user work instead of retiring it, so the return check does not refuse
  a save the user already made.

Tests cover a same-user return (no flash, only the host loader, held create
resumes, Refresh waits), a different user (old records gone, held create never
sent), bfcache pageshow, failed checks, and held create/label/placement saves
for both cases. The design doc records the host evidence and the new table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore, adapted to the switcher UI and the unmasked return check:

- Denied access: a denied Refresh reads exactly nine collections (all GET,
  nine distinct lists) with no write. It now also sends exactly one
  SelfSubjectAccessReview: Refresh re-checks management access by design
  (recheckInventoryPermission), issued with the reads before the denial is
  known; once Devices is denied the Create device permission query is
  disabled, so no further review follows. The base test saw zero because its
  denial arrived through a host revalidation that rebuilt the cache.
- Generations: overlapping return checks keep reads and operations held until
  the newest loader finishes; the earlier loader finishing releases nothing.
  The page itself is no longer masked, so the test asserts held work instead.
- A check answered after another pagehide keeps work held until the next
  return (was "must keep inventory concealed ...").
- Logout or host failure found on return, immediate and held, for hidden and
  pagehide, removes the private page and refuses held work; focus alone does
  not re-check (was "settled host restoration handles ...").
- A failed return check stays closed until a later check succeeds (was "keeps
  failed foreground restoration masked ...").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kevwilliams

Copy link
Copy Markdown
Contributor Author

@ecv @scotwells addressed in 64746f2, 83a2f58, 7693723.

  • Red check: this was a test race, not a stale trigger. RouterProvider commits in startTransition, so the wait passed before the page rendered. The helper now waits for the rendered category. It passes 20/20 under CPU load.
  • Tab return: staff-portal doesn't re-check the user on focus, visibility or pageshow. Its layout loader only runs on navigation or revalidate. So hiding the tab now holds reads and writes, and returning calls router.revalidate(). If it's the same user, the held work resumes. Otherwise it fails closed and no held write is sent. Tests are in inventory-return-check.test.tsx.
  • Deleted tests: both are restored. A denied Refresh now makes 9 GETs, 1 SSAR (Refresh re-checks access by design) and 0 writes.

992 tests pass.

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three holds are fixed at 7693723. The switcher test now waits for the new category's page to render, and CI is green. A returning tab re-checks the signed-in user, and no save goes out until the check confirms the same user. The deleted access and generation tests are back in their new form.

@kevwilliams
kevwilliams merged commit e3e1ec5 into feat/manual-inventory-records Nov 27, 2026
11 checks passed
@kevwilliams
kevwilliams deleted the feat/inventory-staff-portal-style branch November 27, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants