From 977f51ea1b1211ec940f7c785a1b119ec8bff8e9 Mon Sep 17 00:00:00 2001 From: JJ Lee Date: Wed, 19 Aug 2026 14:29:16 +0200 Subject: [PATCH] fix(bridge): align inspector messages to `kind` field convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The relay scripts in chat_panel.ts and deck/shell.ts filter on `d.kind.indexOf('run:') === 0`, but inspector_bridge.ts was emitting messages with `type` as the discriminator field. This mismatch caused all run/device messages to be silently dropped at the relay, never reaching the SolidJS app iframe. Rename `type` → `kind` in RunBridgeMessage, DeviceBridgeMessage, and InspectorReverse unions + all broadcast call sites. The relay scripts and test mocks (which call the function API) require no changes. Part of harmoniqs/opencode#214. --- packages/extension/src/inspector_bridge.ts | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/extension/src/inspector_bridge.ts b/packages/extension/src/inspector_bridge.ts index aa76564f..d1a2aef4 100644 --- a/packages/extension/src/inspector_bridge.ts +++ b/packages/extension/src/inspector_bridge.ts @@ -10,22 +10,22 @@ import * as vscode from "vscode"; // ============================================================================ export type RunBridgeMessage = - | { type: "run:iteration"; runId: string; iter: number; objective: number; inf_pr: number; inf_du: number } - | { type: "run:pulse-meta"; runId: string; drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string } - | { type: "run:pulse"; runId: string; iter: number; dt: number; values: number[][] } - | { type: "run:completion"; runId: string; fidelity: number; iterations: number; status: string } - | { type: "run:activate"; runId: string } - | { type: "run:timing"; runId: string; elapsed: number } - | { type: "run:label"; runId: string; label: string }; + | { kind: "run:iteration"; runId: string; iter: number; objective: number; inf_pr: number; inf_du: number } + | { kind: "run:pulse-meta"; runId: string; drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string } + | { kind: "run:pulse"; runId: string; iter: number; dt: number; values: number[][] } + | { kind: "run:completion"; runId: string; fidelity: number; iterations: number; status: string } + | { kind: "run:activate"; runId: string } + | { kind: "run:timing"; runId: string; elapsed: number } + | { kind: "run:label"; runId: string; label: string }; export type DeviceBridgeMessage = - | { type: "device:status"; device: string; status: unknown } - | { type: "device:actions"; device: string; actions: unknown[] } - | { type: "device:activate"; device: string }; + | { kind: "device:status"; device: string; status: unknown } + | { kind: "device:actions"; device: string; actions: unknown[] } + | { kind: "device:activate"; device: string }; export type InspectorBridgeMessage = RunBridgeMessage | DeviceBridgeMessage; export type InspectorReverse = - | { type: "device:refresh"; device: string }; + | { kind: "device:refresh"; device: string }; type Poster = (msg: unknown) => void; const posters = new Set(); @@ -50,48 +50,48 @@ function broadcast(msg: InspectorBridgeMessage): void { // -------- run surface (called by RunsManager) -------- export function postRunIteration(runId: string, iter: number, objective: number, inf_pr: number, inf_du: number): void { - broadcast({ type: "run:iteration", runId, iter, objective, inf_pr, inf_du }); + broadcast({ kind: "run:iteration", runId, iter, objective, inf_pr, inf_du }); } export function postRunPulseMeta( runId: string, meta: { drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string }, ): void { - broadcast({ type: "run:pulse-meta", runId, ...meta }); + broadcast({ kind: "run:pulse-meta", runId, ...meta }); } export function postRunPulse(runId: string, iter: number, dt: number, values: number[][]): void { - broadcast({ type: "run:pulse", runId, iter, dt, values }); + broadcast({ kind: "run:pulse", runId, iter, dt, values }); } export function postRunCompletion(runId: string, fidelity: number, iterations: number, status: string): void { - broadcast({ type: "run:completion", runId, fidelity, iterations, status }); + broadcast({ kind: "run:completion", runId, fidelity, iterations, status }); } export function postRunActivate(runId: string): void { - broadcast({ type: "run:activate", runId }); + broadcast({ kind: "run:activate", runId }); } export function postRunLabel(runId: string, label: string): void { - broadcast({ type: "run:label", runId, label }); + broadcast({ kind: "run:label", runId, label }); } export function postRunTiming(runId: string, elapsed: number): void { - broadcast({ type: "run:timing", runId, elapsed }); + broadcast({ kind: "run:timing", runId, elapsed }); } // -------- device surface (called by extension.ts poll) -------- export function postDeviceStatus(device: string, status: unknown): void { - broadcast({ type: "device:status", device, status }); + broadcast({ kind: "device:status", device, status }); } export function postDeviceActions(device: string, actions: unknown[]): void { - broadcast({ type: "device:actions", device, actions }); + broadcast({ kind: "device:actions", device, actions }); } export function postDeviceActivate(device: string): void { - broadcast({ type: "device:activate", device }); + broadcast({ kind: "device:activate", device }); } /** Test seam: how many posters are registered. */