Skip to content

fix(health-bar): multi-instance switcher with Popover+Command - #131

Merged
fedorovvvv merged 5 commits into
developfrom
fix/retry-button-timeline-icons
May 9, 2026
Merged

fedorovvvv merged 5 commits into
developfrom
fix/retry-button-timeline-icons

Conversation

@fedorovvvv

Copy link
Copy Markdown
Collaborator

Summary

  • Rewrites the instance switcher from Combobox to Popover.Root + Popover.Portal + Command.Root (shadcn-svelte pattern)
  • Fixes empty state not showing: Popover.Portal escapes the header's backdrop-filter stacking context, which was trapping the floating layer inside the header
  • Fixes off-screen positioning: previous Combobox anchored content to ComboboxInput (the FloatingLayer.Anchor), causing broken positioning when the input was hidden or absent
  • Ghost trigger button hover uses color-mix(in srgb, var(--fg) 10%, transparent) — adapts to light/dark/orch themes without border
  • Command.Empty auto-renders the empty state when no instances are listed (no manual {:else} needed)
  • Command.Item with keywords prop enables search by project name, host, and port
  • Fixes multi-instance registration: heartbeat now re-registers lost entries to survive concurrent write races
  • Adds ghost combobox variant with semi-transparent hover/open states

Why

Instances were spawning on different ports but the switcher showed nothing — the registry registrations were silently lost in concurrent-write races, and the dropdown positioned off-screen at Y=-253 due to the circular floating anchor dependency.

Test plan

  • Open forgeplan-web, click the project name in the header — empty state shows "Instance switcher / Only one instance is running..."
  • Start a second instance (npx @forgeplan/web start in another project) — switcher shows both with search input
  • Hover on trigger: semi-transparent bg in light, dark, orch themes; no border
  • Clicking an item navigates to that instance's URL

🤖 Generated with Claude Code

fedorovvvv and others added 5 commits May 9, 2026 17:55
…bobox variant

bin/commands/start.mjs: Replace heartbeat(id) with register({...entry,
heartbeatAt}) in the interval so a lost registry row (concurrent write race,
ADR-004 §5) is automatically re-added within 30 s instead of staying gone
forever. Extract instanceEntry once; heartbeat ticks spread it.

bin/lib/registry.mjs: Add TODO on heartbeat() silent-skip-if-missing gap;
fix stale "Heartbeat reconciles" comment in deregister().

template/src/shared/ui/combobox: Add ghost variant — transparent chrome that
blends into the header bar. Change icon from ChevronDown to ChevronsUpDown
(no rotation on open; bidirectional icon fits a select control better).
Add ghost-sm + ghost-md entries to playground showcase (rule 24).

template/src/entities/instance/api/store.ts: Reduce instance poll interval
3 s (was 5 s) for faster new-instance detection in the switcher combobox.

template/src/widgets/health-bar/ui/HealthBar.svelte: Use ghost variant for
the instance switcher so it blends into the monospace header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…isible instance switcher with empty state

Ghost variant hover/open now uses color-mix(in srgb, var(--fg) 10%, transparent)
instead of var(--bg-1), giving a theme-adaptive subtle overlay (works in both
dark and light themes) with no visible border.

HealthBar always renders the instance combobox; when only one instance is
running the dropdown shows an empty state explaining what the switcher does
and how to start a second instance.

Refs: PRD-027
…the dropdown

bits-ui Combobox requires ComboboxInput to be in the DOM to register with
the listbox context — without it clicking the Trigger does nothing. In the
no-other-instances branch we now always mount the input but collapse it
(visibility:hidden + height:0) so it takes no space and is not exposed to AT.

Refs: PRD-027
bits-ui Combobox anchors its floating Content to the ComboboxInput via
FloatingLayer.Anchor. When Input is inside the Content (our pattern),
the floating layer sees a circular reference and mis-positions the popup
(Y=-253, off-screen).

Fix: pass customAnchor={switcherEl} to ComboboxContent which forwards it
to ComboboxPrimitive.Content (via restProps → PopperLayer). This tells
bits-ui's floating-ui to use the .project-switcher div as the reference
element instead of the Input, giving correct below-trigger positioning.

With the anchor fixed, ComboboxInput is only rendered when hasOtherInstances
(needed for search); the empty state branch has no Input at all and shows
a plain explanation div instead.

Refs: PRD-027
Replaces bits-ui Combobox with Popover.Root+Portal+Command.Root so the
floating layer correctly escapes the header's backdrop-filter stacking
context. Previous implementation anchored to ComboboxInput (the
FloatingLayer.Anchor inside the portal), causing off-screen positioning
and rendering behind the graph toolbar.

Key changes:
- Popover.Portal ensures content renders at body level (z-index clean)
- Command.Empty auto-shows empty state when no instances listed
- Command.Item with keywords for search filtering
- Ghost trigger button styled via scoped .project-switcher :global()
  selectors — hover uses color-mix(in srgb, var(--fg) 10%, transparent)
  for adaptive semi-transparent overlay across all themes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fedorovvvv
fedorovvvv merged commit 4fe66c6 into develop May 9, 2026
3 checks passed
@fedorovvvv
fedorovvvv deleted the fix/retry-button-timeline-icons branch May 9, 2026 14:39
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.

1 participant