Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 21 additions & 18 deletions bin/commands/start.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
deregister,
findFreePort,
HEARTBEAT_INTERVAL_MS,
heartbeat,
makeInstanceId,
PORT_PROBE_MAX_OFFSET,
register,
Expand Down Expand Up @@ -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
Expand All @@ -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.
}
Expand Down
8 changes: 7 additions & 1 deletion bin/lib/registry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion template/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion template/src/entities/instance/api/store.ts
Original file line number Diff line number Diff line change
@@ -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<InstancesPayload>(
"/api/instances",
Expand Down
5 changes: 3 additions & 2 deletions template/src/pages/home/ui/HomePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -291,10 +292,10 @@
<div class="error-row">
<code class="error-msg">{globalError}</code>
<Button
variant="ghost"
variant="secondary"
size="sm"
onclick={() => { listPoller.refresh(); graphPoller.refresh(); }}
>retry</Button>
><RotateCcw size={12} />Retry</Button>
</div>
</Alert>
{/if}
Expand Down
4 changes: 4 additions & 0 deletions template/src/routes/playground/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, string>>({
'default-sm': '',
'default-md': '',
'mono-sm': '',
'mono-md': '',
'ghost-sm': '',
'ghost-md': '',
});
</script>

Expand Down
6 changes: 5 additions & 1 deletion template/src/shared/ui/combobox/Combobox.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" module>
export type ComboboxVariant = 'default' | 'mono';
export type ComboboxVariant = 'default' | 'mono' | 'ghost';
export type ComboboxSize = 'sm' | 'md';
</script>

Expand Down Expand Up @@ -86,4 +86,8 @@
:global(.combobox-md) {
font-size: 13px;
}
:global(.combobox-ghost) {
font-family: var(--font-mono);
letter-spacing: 0.02em;
}
</style>
6 changes: 6 additions & 0 deletions template/src/shared/ui/combobox/ComboboxContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -18,6 +22,7 @@
align = 'start',
sideOffset = 4,
class: className,
customAnchor = null,
children,
}: Props = $props();
</script>
Expand All @@ -27,6 +32,7 @@
{side}
{align}
{sideOffset}
{customAnchor}
class={`combobox-content ${className ?? ''}`}
>
<ComboboxPrimitive.Viewport class="combobox-viewport">
Expand Down
29 changes: 26 additions & 3 deletions template/src/shared/ui/combobox/ComboboxTrigger.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import { Combobox as ComboboxPrimitive } from 'bits-ui';
import ChevronDown from '@lucide/svelte/icons/chevron-down';
import ChevronsUpDown from '@lucide/svelte/icons/chevrons-up-down';

interface Props {
class?: string;
Expand Down Expand Up @@ -29,7 +29,7 @@
<span class="combobox-trigger-content">
{@render children?.()}
</span>
<ChevronDown size={14} class="combobox-chevron" />
<ChevronsUpDown size={14} class="combobox-chevron" />
</ComboboxPrimitive.Trigger>

<style>
Expand Down Expand Up @@ -94,7 +94,30 @@
transition: transform 140ms ease;
}
:global(.combobox-trigger[data-state='open'] .combobox-chevron) {
transform: rotate(180deg);
color: var(--accent);
}
/* ghost variant — transparent chrome, blends into surrounding header text */
:global(.combobox-ghost .combobox-trigger) {
background: transparent;
border-color: transparent;
padding-left: 2px;
padding-right: 2px;
}
:global(.combobox-ghost .combobox-trigger:hover:not([data-disabled])) {
background: color-mix(in srgb, var(--fg) 10%, transparent);
border-color: transparent;
color: var(--fg);
}
:global(.combobox-ghost .combobox-trigger[data-state='open']) {
background: color-mix(in srgb, var(--fg) 10%, transparent);
border-color: transparent;
color: var(--fg);
}
:global(.combobox-ghost .combobox-chevron) {
opacity: 0.5;
}
:global(.combobox-ghost .combobox-trigger:hover .combobox-chevron,
.combobox-ghost .combobox-trigger[data-state='open'] .combobox-chevron) {
opacity: 1;
}
</style>
Loading
Loading