Skip to content

fix(frontend): highlight the portal item the content is showing - #2493

Merged
hello1101n merged 2 commits into
constructorfabric:mainfrom
hello1101n:fix/portal-nav-default-item-highlight
Aug 13, 2026
Merged

hello1101n merged 2 commits into
constructorfabric:mainfrom
hello1101n:fix/portal-nav-default-item-highlight

Conversation

@hello1101n

@hello1101n hello1101n commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The context pane matched ?item= against its own item ids, so the highlight and the content could disagree in two ways:

  1. No item in the URL/portal?zone=overview renders At a glance, but the menu marked nothing. The reader sees content with no idea which entry produced it.
  2. An item belonging to another zone — e.g. a People route still carrying item=trend. The view falls back to the roster, the pane matches nothing, and again no row is marked.

Overview, AI & Cost and People were all affected; each of those views already falls back to a default item internally, so the disagreement was structural rather than a one-off.

Fix

Resolve the effective item once, in the nav model:

resolveZoneItem(zoneId, item)  // the URL item if the zone lists it, else the zone's default

Both the context pane and the ZoneContent dispatcher read it, so the menu and the content can no longer name different things. ZONE_DEFAULT_ITEM is the single place a zone default is written; DEFAULT_OVERVIEW_ITEM now derives from it instead of restating the id.

Zones deliberately absent from the map:

  • Manage — with no item it renders a generic scaffold that is no menu row, so nothing should be highlighted.
  • Person — its default is a pseudo-item with no id, handled in PersonSectionsNav.

Behaviour change

?zone=overview&item=<unknown-id> now renders the default view instead of “x isn't an Overview view yet.” — unavoidable if the menu and the content must agree on one value.

Testing

  • nav-model.test.ts — defaults name a zone the rail has and an item the pane always renders (never a planned/unbuilt row); resolveZoneItem keeps a listed item, falls back for a foreign one, falls back when none is named, stays null for Manage.
  • context-pane.test.tsx — default highlighted for each of the three zones, highlight follows an explicit item, a foreign item is ignored, Manage still highlights nothing.
  • Full frontend suite (1121 tests), typecheck and lint clean.
  • Verified in a browser on a local compose stand: both cases before and after.

Summary by CodeRabbit

  • Bug Fixes

    • Improved portal navigation so the correct item is highlighted based on the selected zone and URL.
    • Added sensible default selections when no valid item is selected.
    • Prevented stale selections from another zone from appearing active.
    • Improved handling for zones without menu items, including Manage.
  • Tests

    • Added coverage for zone defaults, invalid selections, readiness filtering, and active-item highlighting.

Closes #2494

Screenshots

Local compose install, demo seed roster. Rail icon and pane row both mark the open view.

Surface Before After
?zone=overview nothing marked At a glance
?zone=aicost nothing marked Overview
/ic/<person>/team?item=trend nothing marked People (roster)

?zone=overview after the fix:

Overview with At a glance marked

/ic/<person>/team — roster marked:

People zone with the roster marked

?zone=overview&item=<unknown-id> — the behaviour change above, rendering the default view:

Overview falling back to At a glance for an unknown item

?zone=manage with no item — nothing marked, deliberately:

Manage zone with no entry marked

The context pane matched `?item=` against its item ids, so a URL naming no
item highlighted nothing while the content area rendered the zone's default
view, and an item left behind by another zone highlighted nothing while that
zone's view fell back to its own default.

Resolve the effective item once in nav-model (`resolveZoneItem`: the URL item
if the zone lists it, else the zone's default) and read it from both the pane
and the zone-content dispatcher, so the menu and the content can no longer
name different things.

Signed-off-by: hello1101n <hello1101n@users.noreply.github.com>
@hello1101n
hello1101n requested a review from a team as a code owner August 13, 2026 05:28
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 20549b29-8020-45e6-968c-a40a44573f0d

📥 Commits

Reviewing files that changed from the base of the PR and between 57ee3c4 and 62bcad9.

📒 Files selected for processing (6)
  • src/frontend/src/components/portal/context-pane.test.tsx
  • src/frontend/src/components/portal/context-pane.tsx
  • src/frontend/src/components/portal/zone-content.tsx
  • src/frontend/src/lib/portal/nav-model.test.ts
  • src/frontend/src/lib/portal/nav-model.ts
  • src/frontend/src/lib/portal/overview-configs.ts

📝 Walkthrough

Walkthrough

Changes

Portal navigation resolution

Layer / File(s) Summary
Navigation model resolution
src/frontend/src/lib/portal/nav-model.ts, src/frontend/src/lib/portal/overview-configs.ts, src/frontend/src/lib/portal/nav-model.test.ts
Defines zone defaults and available items. Validates URL-selected items and falls back to zone defaults or null.
Context pane active-item propagation
src/frontend/src/components/portal/context-pane.tsx, src/frontend/src/components/portal/context-pane.test.tsx
Resolves the active item in ContextPane and passes it to navigation components. Tests cover defaults, valid selections, stale selections, and Manage’s no-item view.
Zone content item normalization
src/frontend/src/components/portal/zone-content.tsx
Normalizes the selected item against the active zone before rendering zone views.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to 62bca

This change centralizes portal item selection so navigation highlighting and displayed content stay aligned, including default and invalid-item cases. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Portal
  participant ContextPane
  participant NavModel
  participant Navigation
  participant ZoneContent
  participant ZoneView
  Portal->>ContextPane: render active zone and portal item
  ContextPane->>NavModel: resolveZoneItem(activeZone, portalItem)
  NavModel-->>ContextPane: active item or null
  ContextPane->>Navigation: render navigation with active item
  Portal->>ZoneContent: render active zone and selected item
  ZoneContent->>NavModel: resolveZoneItem(activeZone, selectedItem)
  NavModel-->>ZoneContent: normalized item or null
  ZoneContent->>ZoneView: render normalized item
Loading

Possibly related PRs

Suggested reviewers: cyberantonz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing portal navigation highlighting to match the displayed content.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hello1101n
hello1101n added this pull request to the merge queue Aug 13, 2026
Merged via the queue into constructorfabric:main with commit 9f8d122 Aug 13, 2026
51 checks passed
@hello1101n
hello1101n deleted the fix/portal-nav-default-item-highlight branch August 13, 2026 06:20
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.

The portal side menu highlights nothing while a view is open

2 participants