diff --git a/CHANGELOG.md b/CHANGELOG.md index f679473..a6889c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.1] - 2026-05-09 + +### Fixed + +- **Instance switcher rewritten with Popover+Command** (`health-bar`) — replaced + the bits-ui Combobox (anchor / open-in-empty-state issues) with a + Popover + Command combination that opens reliably, anchors correctly to its + trigger, and renders in both populated and empty states. +- **Combobox ghost variant** — semi-transparent background, no border, + consistent hover across themes; switcher is always visible even with + ≤ 1 live instance. +- **Registry heartbeat race** (`registry`) — heartbeat now re-registers an + entry evicted by a concurrent `init`, preventing silent loss of a running + instance. +- **Timeline toggle** (`template`) — restored Retry button and Lucide arrow + icons that regressed in 0.2.0. + ## [0.2.0] - 2026-05-09 ### Added (PRD-027 / RFC-023 / SPEC-003 / ADR-004 — multi-instance registry) diff --git a/bin/commands/start.mjs b/bin/commands/start.mjs index 8c2cb01..7a541c1 100644 --- a/bin/commands/start.mjs +++ b/bin/commands/start.mjs @@ -9,7 +9,6 @@ import { deregister, findFreePort, HEARTBEAT_INTERVAL_MS, - heartbeat, makeInstanceId, PORT_PROBE_MAX_OFFSET, register, @@ -216,23 +215,25 @@ export default defineCommand({ const webVersion = readPkgVersion() ?? "0.0.0"; const forgeplanCli = probeForgeplanCliVersion(); + // Build once; heartbeat ticks re-use this with a fresh heartbeatAt. + // child.pid is set synchronously after spawn returns; if missing (very + // rare, only when spawn failed) fall back to bin pid for a sweepable row. + const instanceEntry = { + id: instanceId, + host, + port, + pid: typeof child.pid === "number" ? child.pid : process.pid, + scope: scaffold.scope, + workspaceRoot: env.FORGEPLAN_CWD, + projectName, + startedAt, + heartbeatAt: startedAt, + webVersion, + forgeplanCli, + }; + try { - register({ - id: instanceId, - host, - port, - // child.pid is set synchronously after spawn returns; if it is missing - // (very rare, only when spawn failed) fall back to bin pid so we still - // have a sweepable row. - pid: typeof child.pid === "number" ? child.pid : process.pid, - scope: scaffold.scope, - workspaceRoot: env.FORGEPLAN_CWD, - projectName, - startedAt, - heartbeatAt: startedAt, - webVersion, - forgeplanCli, - }); + register(instanceEntry); registered = true; } catch (err) { // FIXME(registry-write-failed): non-fatal — instance still serves; UI @@ -243,7 +244,9 @@ export default defineCommand({ if (registered) { heartbeatTimer = setInterval(() => { try { - heartbeat(instanceId); + // Use register() instead of heartbeat() so the entry is re-added if + // it was lost due to a concurrent write race (ADR-004 §5 known gap). + register({ ...instanceEntry, heartbeatAt: new Date().toISOString() }); } catch { // FIXME(heartbeat-write-failed): swallow; sweep on next start fixes. } diff --git a/bin/lib/registry.mjs b/bin/lib/registry.mjs index afdb9a2..f3cfe30 100644 --- a/bin/lib/registry.mjs +++ b/bin/lib/registry.mjs @@ -124,7 +124,8 @@ export function register(entry) { export function deregister(id) { // RACE: read-modify-write window ~5ms. ADR-004 §5 acceptable for ≤10 - // instances; last-writer wins on rename. Heartbeat reconciles within 30s. + // instances; last-writer wins on rename. start.mjs re-registers on every + // heartbeat tick (30s) so any lost entry recovers automatically. const reg = readRegistry(); const next = { version: SCHEMA_VERSION, @@ -134,6 +135,11 @@ export function deregister(id) { return next; } +// TODO(registry-heartbeat-reconcile): this silently no-ops if the entry is +// missing (lost via concurrent register() race). Callers that need +// reconciliation should use register() with a fresh heartbeatAt instead. +// start.mjs was updated to do exactly that; this function is kept for +// external callers / backward-compat. export function heartbeat(id) { const reg = readRegistry(); const idx = reg.instances.findIndex((row) => row.id === id); diff --git a/package.json b/package.json index e1d6eb6..df10f86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@forgeplan/web", - "version": "0.2.0", + "version": "0.2.1", "description": "Interactive realtime web map for a Forgeplan workspace. Ships a pre-built SvelteKit app and a tiny init/start CLI — no npm install at user side.", "type": "module", "bin": { diff --git a/template/package.json b/template/package.json index 0d9ec98..278b29d 100644 --- a/template/package.json +++ b/template/package.json @@ -1,7 +1,7 @@ { "name": "forgeplan-web-app", "private": true, - "version": "0.2.0", + "version": "0.2.1", "type": "module", "scripts": { "dev": "vite dev --port 5174 --host 127.0.0.1", diff --git a/template/src/entities/instance/api/store.ts b/template/src/entities/instance/api/store.ts index f8417d1..d6becff 100644 --- a/template/src/entities/instance/api/store.ts +++ b/template/src/entities/instance/api/store.ts @@ -1,7 +1,7 @@ import { createPoller } from "@/shared/api"; import type { InstancesPayload } from "../model/types"; -const INSTANCE_POLL_INTERVAL_MS = 5_000; +const INSTANCE_POLL_INTERVAL_MS = 3_000; export const instancePoller = createPoller( "/api/instances", diff --git a/template/src/pages/home/ui/HomePage.svelte b/template/src/pages/home/ui/HomePage.svelte index 1a64997..e2c7589 100644 --- a/template/src/pages/home/ui/HomePage.svelte +++ b/template/src/pages/home/ui/HomePage.svelte @@ -25,6 +25,7 @@ import { Timeline, snapshotStore } from '@/widgets/timeline'; import { VersionFooter } from '@/widgets/version-footer'; import { Alert, Button } from '@/shared/ui'; + import RotateCcw from '@lucide/svelte/icons/rotate-ccw'; import type { ArtifactKind, ArtifactStatus } from '@/entities/artifact'; import { MosaicCanvas, @@ -291,10 +292,10 @@
{globalError} + >Retry
{/if} diff --git a/template/src/routes/playground/+page.svelte b/template/src/routes/playground/+page.svelte index 3375fa0..162eb8e 100644 --- a/template/src/routes/playground/+page.svelte +++ b/template/src/routes/playground/+page.svelte @@ -85,12 +85,16 @@ { variant: 'default', size: 'md' }, { variant: 'mono', size: 'sm' }, { variant: 'mono', size: 'md' }, + { variant: 'ghost', size: 'sm' }, + { variant: 'ghost', size: 'md' }, ]; let comboboxValues = $state>({ 'default-sm': '', 'default-md': '', 'mono-sm': '', 'mono-md': '', + 'ghost-sm': '', + 'ghost-md': '', }); diff --git a/template/src/shared/ui/combobox/Combobox.svelte b/template/src/shared/ui/combobox/Combobox.svelte index 4812134..8757b82 100644 --- a/template/src/shared/ui/combobox/Combobox.svelte +++ b/template/src/shared/ui/combobox/Combobox.svelte @@ -1,5 +1,5 @@ @@ -86,4 +86,8 @@ :global(.combobox-md) { font-size: 13px; } + :global(.combobox-ghost) { + font-family: var(--font-mono); + letter-spacing: 0.02em; + } diff --git a/template/src/shared/ui/combobox/ComboboxContent.svelte b/template/src/shared/ui/combobox/ComboboxContent.svelte index eb6720f..0242e65 100644 --- a/template/src/shared/ui/combobox/ComboboxContent.svelte +++ b/template/src/shared/ui/combobox/ComboboxContent.svelte @@ -10,6 +10,10 @@ align?: Align; sideOffset?: number; class?: string; + /** Override the floating anchor element. Pass the trigger ref so the + * dropdown positions relative to it instead of a ComboboxInput inside + * the portal. Required when the ComboboxInput is absent (e.g. empty state). */ + customAnchor?: string | HTMLElement | null; children?: Snippet; } @@ -18,6 +22,7 @@ align = 'start', sideOffset = 4, class: className, + customAnchor = null, children, }: Props = $props(); @@ -27,6 +32,7 @@ {side} {align} {sideOffset} + {customAnchor} class={`combobox-content ${className ?? ''}`} > diff --git a/template/src/shared/ui/combobox/ComboboxTrigger.svelte b/template/src/shared/ui/combobox/ComboboxTrigger.svelte index c0f7457..10013a7 100644 --- a/template/src/shared/ui/combobox/ComboboxTrigger.svelte +++ b/template/src/shared/ui/combobox/ComboboxTrigger.svelte @@ -1,7 +1,7 @@