synabun 2026.5.13-beta → 2026.5.14-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CHANGELOG.md +113 -96
  2. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,13 +1,27 @@
1
1
  # Project Changelog
2
2
 
3
- ## 2026-05-13
3
+ ## OpenCode Sidepanel V2
4
4
 
5
- ### Fixed — Sidepanel Pills Open Blank Session After Server Restart
6
- - **Pill click landed on "New chat" instead of resuming the underlying Claude session** — `loadConfig()` in `neural-interface/public/shared/ui-claude-panel.js` detected a server-bootId mismatch and `removeItem`'d `STOR.tabs` / `STOR.tabsLegacy` / `STOR.session` outright. Pills (rendered by `ui-sidepanel-tray.js`) read those same keys but render before the panel inits, so they survived the restart visually — but the first pill click triggered `toggleClaudePanel` → `loadConfig` → wipe → `restoreTabs` found nothing → fell through to `createTab(null, 'New chat')`.
7
- - Replaced the wipe with a new `_scrubStaleTabState(key)` helper added above `restoreTabs()`. On bootId mismatch it now **preserves** resumable identity (`id`, `sessionId`, `label`, `project`, `model`, `effort`) and **drops** runtime-only state that would lie post-restart (`running` / `_wasRunning`, `queue` / `queuePaused`, `planMode` / `planFilePath`, `sessionCost` — re-synced via `syncSessionCosts()`). Tabs with no `sessionId` and only a default label ("New chat", "New session", "Claude") are pruned; the legacy `STOR.session` single-sessionId key is left intact.
8
- - Codex and OpenCode panels never had a bootId wipe, so their pills already worked across restarts — Claude was the lone outlier.
5
+ ### Added — OpenCode Sidepanel V2 (Clean-Slate Rebuild)
6
+ - **Fresh SDK wrapper `lib/opencode-v2-client.js`** — New ~190-line wrapper around `@opencode-ai/sdk/v2`'s `createOpencodeClient`. Pass-through philosophy: NO `normalizeV2Event` translation, NO `buildSystemForPlanMode` injection, NO legacy shape massaging. `connect({ port })` runs an `event.subscribe()` loop with 1s→10s exponential-backoff auto-reconnect via `AbortController`, emitting `{ eventType, event }` envelopes verbatim through an internal `event.onEvent(listener)` registry. Surfaces `session.list/create/get/delete/abort/messages/prompt` and `permission.reply`; `unwrap()` translates hey-api `{ data, error, response }` to `{ status, data }` and throws on error; `clean()` strips `undefined` keys so the URL builder doesn't append `?foo=undefined`. Verbose log gated on `OCPV2_VERBOSE=1`.
7
+ - **New WS route `/ws/opencode-v2` + REST endpoints** — `neural-interface/server.js` adds `_ocpV2WsClients` Set, `broadcastToOpencodeV2Clients()`, `installOpencodeV2Listener()` (independent bridge from legacy `installOpencodeClientListener`), and `handleOpencodeV2Ws(ws)`. The handler implements `init / session:list / session:create / session:get / session:delete / session:messages / message:send / message:abort / permission:reply` over id-correlated JSON frames, with per-session `AbortController` map so a fresh send cancels the previous in-flight prompt cleanly. New REST: `GET /api/opencode-v2/status`, `POST /api/opencode-v2/serve/start`, `POST /api/opencode-v2/serve/stop`. Wired `opencodeV2Client.connect/disconnect` into both `ensureOpencodeServer` boot points and `stopOpencodeServer`, sharing the same `opencode serve` process on port 4096 as the legacy panel. `/ws/opencode-v2` added to the upgrade allowlist and connection router; legacy `/ws/opencode-skin` route remains registered (orphaned).
8
+ - **Browser modules under `public/shared/ocp-v2/`** — Six fresh modules totaling under 1500 lines:
9
+ - `ocp-v2-styles.js` — `.ocpv2-*` CSS injected once, slide-in panel, message bubbles, tool cards with status badges, reasoning collapsibles, permission cards, error banners, compose footer with autosizing textarea.
10
+ - `ocp-v2-state.js` — pub/sub state store: `serverStatus`, `sessionId`/`sessionInfo`, `messageOrder[]`, `messages: Map<id,{parts:Map}>`, `running`, `pendingPermission`, `errors[]`. Setters fire `notify()` to all `subscribe()` listeners.
11
+ - `ocp-v2-ws.js` — WebSocket client. `api.{init,sessionList,sessionCreate,sessionGet,sessionDelete,sessionMessages,send,abort,permissionReply}` returns id-correlated promises. `handleEvent()` dispatches `message.updated` / `message.removed` / `message.part.updated` / `session.idle` / `session.error` / `permission.asked` / `permission.replied` into state mutations; auto-reconnect after 1.5s on close.
12
+ - `ocp-v2-render.js` — full CLI parity renderers: text (minimal Markdown — paragraphs, fences, inline code, **bold**, *italic*, lists, links — no external deps), reasoning (collapsible `<details>`, open while streaming), tool (header with name + status badge, input JSON, output `<pre>`, error variant), file chip, step markers, permission card with `Allow once / Always / Reject` buttons that lock on click and call `api.permissionReply()`, error banner. Mounts on the messages container and re-renders on every state notification.
13
+ - `ocp-v2-send.js` — compose textarea + Send/Abort button. Enter sends, Shift+Enter newline, optimistic user message rendered before SDK echoes back, button toggles to Abort while `running`. `doAbort()` calls `api.abort(sessionId)` and force-clears `running`.
14
+ - `ocp-v2-panel.js` — slide-in panel container. Lazy boot on first toggle: `api.init()` → `setServerStatus` → `startFreshSession()` (auto-creates one fresh session per panel open, matches CLI single-session model). Header shows `OpenCode · {sid8}` + status pill (`ready` / `running` / `error`) + a `New` button to spawn a new session. Emits `opencode-panel:visibility` so the existing navbar binding still highlights the topright button.
15
+ - **Barrel + navbar swap** — New `public/shared/ui-opencode-panel-v2.js` re-exports `toggleOpencodePanel` / `isOpencodePanelOpen` / `openOpencodeWithPrompt` from `ocp-v2/ocp-v2-panel.js`. Single-line edit in `public/shared/ui-navbar.js` repoints the import from `./ui-opencode-panel.js` → `./ui-opencode-panel-v2.js`. Topright OpenCode button now opens the V2 panel; old `public/shared/ocp/**` (13 files, ~14000 lines), `public/shared/ui-opencode-panel.js`, and `lib/opencode-client.js` remain unmodified on disk as a rollback safety net.
9
16
 
10
- ## 2026-05-12
17
+ ### Added — Reasoning Effort Picker in OpenCode V2 Sidepanel
18
+ - **Variant picker in compose footer** — New `neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js` module renders a small dropdown beside the model picker that lets users pick a reasoning/thinking effort (`low` / `medium` / `high` / `max` / `xhigh` / `minimal` / `none`) for any OpenCode model that exposes a `variants` map. Auto-hides when the active model has no variants. Includes a "default" entry that clears the variant so the SDK falls back to its built-in default.
19
+ - Persists per-model selection in `localStorage` under `ocp-v2-model-variants` so each model remembers its preferred effort across sessions.
20
+ - Subscribes to `config:model` and restores the saved variant whenever the user switches models.
21
+ - Variants ordered by `PREFERRED_ORDER` (`none, minimal, low, medium, high, max, xhigh`); unknown variant names appended alphabetically; entries with `disabled: true` filtered out.
22
+ - **State plumbing** — Added `variant: null` field plus `setVariant()` setter to `neural-interface/public/shared/ocp-v2/ocp-v2-state.js` (emits `config:variant` event).
23
+ - **Send pipeline** — `neural-interface/public/shared/ocp-v2/ocp-v2-send.js` mounts the variant picker before the model picker in `.ocpv2-footer-right` and forwards `variant: s.variant || undefined` on every `api.send()` call. WS API in `neural-interface/public/shared/ocp-v2/ocp-v2-ws.js` carries the field through to the server, and `neural-interface/server.js` forwards it to `opencodeV2Client.session.prompt(...)` (the v2 client already passes through arbitrary fields via `...rest`).
24
+ - **Styles** — Added `#ocpv2-variant-dd` rules to `neural-interface/public/shared/ocp-v2/ocp-v2-styles.js`: brain icon, capitalised variant names, smaller right-anchored menu, reused `ocpv2-model-menu-in` animation.
11
25
 
12
26
  ### Fixed — OpenCode V2 Sidepanel Error Auto-Heal
13
27
  - **Stale header error pill recovery** — `ocp-v2-state.js` now has explicit `healing`, `clearErrors()`, and `setHealing()` state so transient OpenCode/WebSocket failures no longer leave the sidepanel header stuck on `error` after the connection recovers.
@@ -32,10 +46,6 @@
32
46
  - **`hasOpenCodeState` short-circuits on `sessionId`** — V2 plain entries have no `draft`/`plan`/`title` fields; predicate now treats any entry with a `sessionId` as meaningful so placeholder pills render correctly during the pre-boot window.
33
47
  - **`tabLabel` fallback for unbooted v2 placeholders** — Placeholder pills show `OpenCode · {sid8}` when no title is persisted yet (v2 plain payload doesn't store titles), instead of a generic "New session" label.
34
48
 
35
- ### Changed — Sidepanel Header & Tray Pill Polish
36
- - **`stopPropagation` on OCP header buttons** — `+` (new session), Minimize, Close, and Slide buttons in `ocp-v2-panel.js` now `event.stopPropagation()` so a click no longer bubbles into the session-menu open/close handler. Removes a race where a stray header click could toggle the session dropdown.
37
- - **`data-tooltip-pos` on every sidepanel pill close button** — Tray pill X buttons in `ui-claude-panel.js` (`.cp-session-pill`), `cdx/cdx-tabs.js` (`.cxp-session-pill`), `ocp-v2-panel.js` (`.ocpv2-session-pill`), and the placeholder pills in `ui-sidepanel-tray.js` all got `data-tooltip-pos="top"` so the "Close" tooltip stops clipping at the bottom edge of the tray. OCP header buttons got `data-tooltip-pos="bottom"` for symmetry.
38
-
39
49
  ### Fixed — OpenCode V2 Sub-Agent Sidepanel Reliability
40
50
  - **Sub-agent tray pill no longer disappears on spawn** — Sub-agent sessions (e.g. the `Task` / `Explore` tool) used to fire server-side without producing a tray pill, leaving the user to dig through the Resume header. Multiple detection gaps fixed in `ocp-v2-manager.js`: new `readParentID()` helper reads `parentID` / `parentId` / `parent_id` / `session.parentID` variants; `AGENT_TOOL_NAMES` expanded with `invoke` / `subagent` / `spawn` / `explore` / `plan` casing variants; new `scanForOrphanChildren()` calls `api.sessionList()` on `registerPrimaryPanel` and `bindPrimarySession` to find children whose `parentID` matches the active session; a new `session.updated` listener catches sub-agents whose `parentID` arrives after creation; the fallback tool-event path no longer requires strict parent-equality so a mid-spawn tab switch still attaches.
41
51
  - **Late `session.created` events buffered** — `ocp-v2-ws.js` now keeps a 32-entry / 60 s TTL ring of `session.created` events and replays them to every new `subscribeSessionCreated` subscriber. The panel manager registers only after `boot()` finishes, so child spawns that fired during boot used to be dropped silently — now they are seen.
@@ -52,44 +62,9 @@
52
62
  - **Header status shows the task, not "idle"** — `ocp-v2-childpanel.js` accepts a new `taskInfo` option and exposes `instance.setTaskInfo()`. New `currentTaskLabel(s)` builds the badge from (priority) the currently-running tool name → `${subagentType} · ${summary}` → summary alone → subagent type alone. `syncHeader()` displays the label both while running and while idle, with the same string as `data-tooltip`. `ocp-v2-manager.js` added `describeAgentTask(part, ev, toolName)` to extract `{subagentType, summary}` from the parent's tool input (`state.input.description` / `state.input.prompt` / `subagent_type` / `agent`) and `lookupParentTaskInfo(childSid)` which scans the parent store's recent tool parts when no replay part is available (session.created / session.updated / orphan-scan paths). Task info is threaded through `ensureChildSpawn` → `spawnChildPanel` → `createChildPanel`.
53
63
  - **Child pill tooltip pops left, not above** — `ocp-v2-childpanel.js` sets `data-tooltip-pos="left"` on both the child tray pill and its close button. The tray is right-anchored, so `above` tooltips were getting clipped at the screen edge; left placement uses `ui-tooltip.js`'s existing left path. The tray pill tooltip also appends ` — ${taskLabel}` so the minimized state still surfaces the agent's task.
54
64
 
55
- ## 2026-05-11
56
-
57
- ### Fixed — Long-Session Memory Leaks
58
- - **Bounded `_orphanedProcs` map** — Claude-skin orphan processes accumulated in `server.js` when a kill timer never fired (crash, kill -9, sleep) and an entry was never reattached. Added a 60-second sweep (`setInterval(...).unref()`) that deletes entries whose `proc` is null/killed/exited and clears the stale `killTimer`.
59
- - **Pruned `_ocpSessionOwners` / `_ocpSessionActivity`** — `_ocpStartSilenceWatchdog` in `server.js` now removes session entries with no live clients and `lastEventAt` older than 30 minutes. Watchdog scan no longer iterates dead sessions for the lifetime of the process.
60
- - **Idle screencast frame waste** — `onScreencastFrame` in `server.js` now bails out early (still ack'ing `Page.screencastFrameAck` to keep the CDP pipeline alive) when `session.clients` is empty, skipping JPEG buffer allocation and broadcast. Removed the per-frame `frameCount++` and conditional `console.log` that allocated even when not logging.
61
-
62
- ### Changed — Whiteboard Drag Hot Path
63
- - **rAF-batched `renderAll()`** — `ui-whiteboard.js` now schedules renders through `requestAnimationFrame` via `_renderRafId`. Multiple mousemove handlers used to call `renderAll()` synchronously per pointer event; renders are coalesced to one per frame. Added `renderAllImmediate()` for explicit flushes.
64
- - **`_elementMap` O(1) lookups** — Added `_findEl(id)` Map cache. Rebuilt lazily when `_elements.length` changes; `_invalidateElementMap()` is called from `undo()`/`redo()` to cover same-length object replacement. Replaced 8 `_elements.find(el2 => el2.id === ...)` calls inside `onMouseMove` (move-multi, shape-create, section-create, move, move-arrow, move-pen, rotate, resize).
65
- - **Cached root rect** — Added `_rootRectCached` + `_getRootRect()`/`_invalidateRootRect()`. `clientToCanvas()` and the pen-drawing path reuse the cached rect for the duration of a gesture; cache is cleared at mouseup and on window resize. Eliminates `_root.getBoundingClientRect()` layout flushes inside the 60 Hz mousemove loop.
66
-
67
- ### Changed — Sidepanel Markdown Rendering
68
- - **OCP v2 incremental render** — Rewrote `render()` in `ocp-v2-render.js` to use a key/sig reconciler (`_reconcile`, `_partSig`, `_msgSig`) instead of `_container.innerHTML = ''` followed by a full rebuild. User messages, assistant part bubbles, error banners, permission cards, question cards, and the post-plan card now have stable composite keys and content signatures so unchanged nodes are reused. Scroll position is far more stable across streaming deltas.
69
- - **LRU markdown memoization** — Added a 512-entry insertion-order LRU cache around `renderMarkdown()` in `ocp-v2-render.js`, `md()` in `cdx/cdx-render.js`, and `md()` in `ocp/ocp-render.js`. Identical text re-rendered during streaming/state-change passes now returns cached HTML instead of re-invoking `marked.parse()`.
70
-
71
- ### Changed — Storage Layer
72
- - **Deferred `JSON.parse` to flush time** — `storage.js` introduces `STR_SENTINEL`. `setItem()` no longer parses the caller-provided string on every call; `_dirty[key] = STR_SENTINEL` records "parse the current cache string at flush time". `_flushToServer()` and the `beforeunload` `sendBeacon` path resolve sentinels by parsing the cached string once when actually flushing. Big win for callers that store large snapshots (whiteboard, codex transcripts) where every keystroke previously triggered a redundant `JSON.parse`.
73
-
74
- ### Changed — Floating Terminal Drag Compositing
75
- - **Simplified `.term-float-tab.float-dragging` shadow** — In `styles.css`, replaced the multi-layer `box-shadow: var(--shadow-2xl), 0 0 0 1px rgba(0,0,0,0.4)` with a single `0 8px 24px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.4)`, dropped the `box-shadow` transition (kept `border-radius`), and added `will-change: transform, left, top` so the dragging window stays on its own composited layer. Removes per-frame GPU compositing thrash during drag.
76
-
77
- ## 2026-05-09
78
-
79
- ### Added — Reasoning Effort Picker in OpenCode V2 Sidepanel
80
-
81
- - **Variant picker in compose footer** — New `neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js` module renders a small dropdown beside the model picker that lets users pick a reasoning/thinking effort (`low` / `medium` / `high` / `max` / `xhigh` / `minimal` / `none`) for any OpenCode model that exposes a `variants` map. Auto-hides when the active model has no variants. Includes a "default" entry that clears the variant so the SDK falls back to its built-in default.
82
- - Persists per-model selection in `localStorage` under `ocp-v2-model-variants` so each model remembers its preferred effort across sessions.
83
- - Subscribes to `config:model` and restores the saved variant whenever the user switches models.
84
- - Variants ordered by `PREFERRED_ORDER` (`none, minimal, low, medium, high, max, xhigh`); unknown variant names appended alphabetically; entries with `disabled: true` filtered out.
85
- - **State plumbing** — Added `variant: null` field plus `setVariant()` setter to `neural-interface/public/shared/ocp-v2/ocp-v2-state.js` (emits `config:variant` event).
86
- - **Send pipeline** — `neural-interface/public/shared/ocp-v2/ocp-v2-send.js` mounts the variant picker before the model picker in `.ocpv2-footer-right` and forwards `variant: s.variant || undefined` on every `api.send()` call. WS API in `neural-interface/public/shared/ocp-v2/ocp-v2-ws.js` carries the field through to the server, and `neural-interface/server.js` forwards it to `opencodeV2Client.session.prompt(...)` (the v2 client already passes through arbitrary fields via `...rest`).
87
- - **Styles** — Added `#ocpv2-variant-dd` rules to `neural-interface/public/shared/ocp-v2/ocp-v2-styles.js`: brain icon, capitalised variant names, smaller right-anchored menu, reused `ocpv2-model-menu-in` animation.
65
+ ---
88
66
 
89
- ## 2026-05-07
90
-
91
- ### Changed — Empty-Plan Re-Prompt Button (Claude Panel)
92
- - **Replaced "Plan text was empty" status text with an interactive button** — When the user clicks `Edit plan` in the post-plan card but the plan extractor and `/api/latest-plan` disk fallback both fail to surface a plan file, `neural-interface/public/shared/ui-claude-panel.js` previously printed a static `appendStatus()` line ("Plan text was empty — ask Claude to re-output the plan, or click Continue with implementation to proceed."). The `noFile()` callback in the `'plan'` action handler now renders an inline `msg-status` row containing the short text "Plan text was empty." plus a primary `post-plan-action pp-primary` button labeled "Ask Claude to re-output the plan". Clicking the button populates `#cp-input` with a re-prompt instruction (`Please re-output the full plan you were preparing. Use ExitPlanMode with the complete plan text...`) and calls `send()`. Button disables on click, and falls back to a status if the WebSocket is closed. Scoped to the Claude panel only — `ocp-panel.js` retains the existing `renderErrorMessage` pattern.
67
+ ## OpenCode Sidepanel (Legacy)
93
68
 
94
69
  ### Added — OpenCode Sidepanel Trace System
95
70
  - **`ocp-trace.js` client trace bus** — New `neural-interface/public/shared/ocp/ocp-trace.js` exporting `trace()`, `traceTimer()`, `setTraceLevel()`, `setTraceContext()`, `onTrace()`, and `exportTraceLog()`. 5000-event ring buffer, level-gated routing (silent/errors/normal/verbose, persisted in `localStorage:ocp.traceLevel`), CSS-styled `[ocp-trace]` `console.debug` mirror, 250ms batched POST to `/api/ocp/trace/ingest`, `keepalive: true` flush on `pagehide`/`visibilitychange`.
@@ -101,37 +76,16 @@
101
76
  - **4th recovery button** — `renderProseQuestionRecoveryCard()` in `neural-interface/public/shared/ocp/ocp-render.js` now renders a "Force question tool now" button alongside the existing Reply directly / Re-ask / Dismiss buttons. Wired in `ocp-plan.js` to send a hard prompt with a literal `question({ questions: [...] })` one-shot example so models like Kimi K2.6 can pattern-match the tool-call shape.
102
77
  - **`question:list` polling fallback** — `startQuestionPolling()` / `stopQuestionPolling()` in `neural-interface/public/shared/ocp/ocp-questions.js`. While a plan turn is active and no question card is visible, polls `question.list()` every 2.5s and surfaces any pending question via `backfillPendingQuestions()`. Wired from `ocp-send.js` to start on plan-mode turn start and stop on resolve / abort / error.
103
78
 
104
- ### Fixed — OpenCode Question Reply "Fetch Failed" Frozen UI
105
- - **Non-terminal reply error path** — In `neural-interface/public/shared/ocp/ocp-questions.js renderOpencodeQuestion`, the `requestWs('question:reply')` catch handler no longer flips `tab.running=false` / `endTurn(tab)`. Instead it re-enables the question card (`locked=''`, buttons re-enabled) and shows "Click an answer again to retry." Previously a transient SDK fetch error caused the entire turn to be marked complete, freezing the UI behind a stale card.
106
- - **Composer unblocking on prose-recovery dismiss** — `onReplyDirectly` and `onDismiss` callbacks in `ocp-plan.js showProseQuestionRecoveryUI` now defensively clear `tab.showPostPlanActions = false` so the composer always re-enables when the user closes the prose-recovery card.
107
-
108
- ### Fixed — OpenCode Sidepanel Question Card Multi-Question Routing Trace
109
- - **`event:in` + `q:queued` diagnostics** — `neural-interface/public/shared/ocp/ocp-events.js` now traces every routed SDK event with `eventType`, `sid`, `partType`, `toolName`, plus `q:asked` (with question count) and `q:queued` (with `reason: no-container | active-question-busy`). Makes it possible to determine — from the trace alone — whether the model emitted `question.asked`, whether the router rendered or queued it, and why.
79
+ ### Fixed — OpenCode Plan Mode Forces `question` Tool + Prose-Question Recovery
80
+ - **Plan-mode prompt-prefix injection** — `neural-interface/server.js` previously sent `body.mode='plan'` and `body.tools={...}` without any prompt instruction, so models like Kimi K2.6 wrote clarification questions as prose ("Before I proceed, a couple of quick questions:") instead of calling the OpenCode `question` tool — the sidepanel only renders interactive cards for actual `question` tool calls, so prose questions stranded the user. New `OPENCODE_PLAN_MODE_INSTRUCTION` constant (mirroring the existing `CODEX_PLAN_MODE_PREFIXES` at ~line 2828) is now prepended to the first text part in every `body.mode === 'plan'` send: it explicitly states `You MUST call the \`question\` tool`, forbids prose questions, and reminds the model to call `ExitPlanMode` when ready. Idempotent via a `startsWith('[PLAN MODE]')` guard so the prefix isn't double-injected on multi-turn plan refinement.
81
+ - **Per-turn question-tool usage tracking** — `neural-interface/public/shared/ocp/ocp-tabs.js` adds a `tab._questionToolUsedThisTurn` flag set to `true` in all three question-detection sites (`message.part.updated` tool branch, `tool.start` handler, and the dedicated `question.asked` SSE event), reset to `false` at the start of `sendMessage()`, when entering plan mode in `setTabMode()`, and on tab clear.
82
+ - **Prose-question detector** — New `looksLikeProseQuestions(content)` helper scans the last 400 chars of captured plan text for trailing patterns: `quick/a couple of/two/before i proceed … questions:`, `Question N:` markers, or 2+ trailing `?` per line.
83
+ - **`maybeShowPostPlanUI` recovery reroute** — When `!force && !_exitPlanDetected && !_questionToolUsedThisTurn && looksLikeProseQuestions(planContent)`, the function now calls `showProseQuestionRecoveryUI(tab)` and returns `false` instead of stamping the misleading PLAN COMPLETE card. Fixes the long-standing "press STOP after prose questions → PLAN COMPLETE for half-finished plan" trap.
84
+ - **`MODEL ASKED QUESTIONS IN PROSE` recovery card** — New `renderProseQuestionRecoveryCard()` / `removeProseQuestionRecoveryCards()` exports in `neural-interface/public/shared/ocp/ocp-render.js`, plus a new `.ocp-prose-question-card` block in `neural-interface/public/shared/ocp/ocp-styles.js` (amber accent so it's visually distinct from the green-ish PLAN COMPLETE). Three actions: **Reply directly** focuses the OCP input field; **Re-ask using question tool** sends a follow-up prompt instructing the model to re-ask using the `question` tool; **Dismiss** removes the card. Cards are also cleared on next `sendMessage()` and on `setTabMode()` exit-plan.
110
85
 
111
86
  ### Changed — OpenCode Plan-Mode System Instruction
112
87
  - **One-shot `question` tool example** — `PLAN_MODE_INSTRUCTION` in `neural-interface/lib/opencode-client.js` and the duplicate `OPENCODE_PLAN_MODE_INSTRUCTION` in `neural-interface/server.js` now include a literal `question({ questions: [{ question, header, options: [{label, description}], multiSelect }] })` example block plus a "If you find yourself writing 'let me ask a few questions'… STOP and call the `question` tool" reinforcement. Kimi K2.6 ignored the abstract directive but pattern-matches the concrete example.
113
88
 
114
- ### Added — OpenCode Sidepanel V2 (Clean-Slate Rebuild)
115
- - **Fresh SDK wrapper `lib/opencode-v2-client.js`** — New ~190-line wrapper around `@opencode-ai/sdk/v2`'s `createOpencodeClient`. Pass-through philosophy: NO `normalizeV2Event` translation, NO `buildSystemForPlanMode` injection, NO legacy shape massaging. `connect({ port })` runs an `event.subscribe()` loop with 1s→10s exponential-backoff auto-reconnect via `AbortController`, emitting `{ eventType, event }` envelopes verbatim through an internal `event.onEvent(listener)` registry. Surfaces `session.list/create/get/delete/abort/messages/prompt` and `permission.reply`; `unwrap()` translates hey-api `{ data, error, response }` to `{ status, data }` and throws on error; `clean()` strips `undefined` keys so the URL builder doesn't append `?foo=undefined`. Verbose log gated on `OCPV2_VERBOSE=1`.
116
- - **New WS route `/ws/opencode-v2` + REST endpoints** — `neural-interface/server.js` adds `_ocpV2WsClients` Set, `broadcastToOpencodeV2Clients()`, `installOpencodeV2Listener()` (independent bridge from legacy `installOpencodeClientListener`), and `handleOpencodeV2Ws(ws)`. The handler implements `init / session:list / session:create / session:get / session:delete / session:messages / message:send / message:abort / permission:reply` over id-correlated JSON frames, with per-session `AbortController` map so a fresh send cancels the previous in-flight prompt cleanly. New REST: `GET /api/opencode-v2/status`, `POST /api/opencode-v2/serve/start`, `POST /api/opencode-v2/serve/stop`. Wired `opencodeV2Client.connect/disconnect` into both `ensureOpencodeServer` boot points and `stopOpencodeServer`, sharing the same `opencode serve` process on port 4096 as the legacy panel. `/ws/opencode-v2` added to the upgrade allowlist and connection router; legacy `/ws/opencode-skin` route remains registered (orphaned).
117
- - **Browser modules under `public/shared/ocp-v2/`** — Six fresh modules totaling under 1500 lines:
118
- - `ocp-v2-styles.js` — `.ocpv2-*` CSS injected once, slide-in panel, message bubbles, tool cards with status badges, reasoning collapsibles, permission cards, error banners, compose footer with autosizing textarea.
119
- - `ocp-v2-state.js` — pub/sub state store: `serverStatus`, `sessionId`/`sessionInfo`, `messageOrder[]`, `messages: Map<id,{parts:Map}>`, `running`, `pendingPermission`, `errors[]`. Setters fire `notify()` to all `subscribe()` listeners.
120
- - `ocp-v2-ws.js` — WebSocket client. `api.{init,sessionList,sessionCreate,sessionGet,sessionDelete,sessionMessages,send,abort,permissionReply}` returns id-correlated promises. `handleEvent()` dispatches `message.updated` / `message.removed` / `message.part.updated` / `session.idle` / `session.error` / `permission.asked` / `permission.replied` into state mutations; auto-reconnect after 1.5s on close.
121
- - `ocp-v2-render.js` — full CLI parity renderers: text (minimal Markdown — paragraphs, fences, inline code, **bold**, *italic*, lists, links — no external deps), reasoning (collapsible `<details>`, open while streaming), tool (header with name + status badge, input JSON, output `<pre>`, error variant), file chip, step markers, permission card with `Allow once / Always / Reject` buttons that lock on click and call `api.permissionReply()`, error banner. Mounts on the messages container and re-renders on every state notification.
122
- - `ocp-v2-send.js` — compose textarea + Send/Abort button. Enter sends, Shift+Enter newline, optimistic user message rendered before SDK echoes back, button toggles to Abort while `running`. `doAbort()` calls `api.abort(sessionId)` and force-clears `running`.
123
- - `ocp-v2-panel.js` — slide-in panel container. Lazy boot on first toggle: `api.init()` → `setServerStatus` → `startFreshSession()` (auto-creates one fresh session per panel open, matches CLI single-session model). Header shows `OpenCode · {sid8}` + status pill (`ready` / `running` / `error`) + a `New` button to spawn a new session. Emits `opencode-panel:visibility` so the existing navbar binding still highlights the topright button.
124
- - **Barrel + navbar swap** — New `public/shared/ui-opencode-panel-v2.js` re-exports `toggleOpencodePanel` / `isOpencodePanelOpen` / `openOpencodeWithPrompt` from `ocp-v2/ocp-v2-panel.js`. Single-line edit in `public/shared/ui-navbar.js` repoints the import from `./ui-opencode-panel.js` → `./ui-opencode-panel-v2.js`. Topright OpenCode button now opens the V2 panel; old `public/shared/ocp/**` (13 files, ~14000 lines), `public/shared/ui-opencode-panel.js`, and `lib/opencode-client.js` remain unmodified on disk as a rollback safety net.
125
-
126
- ## 2026-05-06
127
-
128
- ### Fixed — Terminal ESC Key Now Aborts CLI TUIs On First Press (Floating + Docked)
129
- - **Single ESC reaches the PTY instead of `\x1b\x1b`** — In `neural-interface/public/shared/ui-terminal.js`, the global window-capture ESC handler in `initTerminal()` sent `\x1b` over the WS without `e.preventDefault()` / `e.stopImmediatePropagation()`, so xterm.js's own keydown listener on `.xterm-helper-textarea` fired afterwards and re-emitted ESC via `term.onData(...)` (line 1915). The PTY received `\x1b\x1b`, which Bubbletea-based TUIs (OpenCode, Claude Code, Codex) interpret as a Meta-prefix and ignore — so the running task never aborted. Handler now sends one `\x1b`, calls `e.preventDefault()` + `e.stopImmediatePropagation()` to block the duplicate, and re-focuses via `requestAnimationFrame(() => session.term?.focus())` instead of the old `term?.blur()` / `ta.blur()` pair (focus loss had forced the user to click back into the terminal between keystrokes).
130
- - **Docked terminal now has ESC coverage** — Previous early return `if (!isXterm) return;` left the docked panel without any ESC fallback when focus drifted to a tab title or panel chrome. Handler now resolves the target session by DOM ancestry: xterm helper textarea → its viewport's `dataset.sessionId`, else `.term-float-tab` → that tab's session, else inside `_panel` (`#terminal-panel`) → `_sessions[_activeIdx]`. Skips non-terminal `input/textarea/select/[contenteditable]` so search/rename/path inputs still consume ESC normally.
131
- - **Removed redundant per-floating-window ESC branch** — `attachTab()`'s `win.addEventListener('keydown', ...)` had a duplicate ESC sender that was unreachable for the common case (skipped when target was a textarea). Stripped the ESC branch; the Ctrl+C copy-on-selection branch stays as the floating-window-only fallback.
132
-
133
- ## 2026-05-05
134
-
135
89
  ### Fixed — OpenCode Plan-Mode Stall Recovery Now Always Shows PLAN COMPLETE (Followup)
136
90
  - **PLAN COMPLETE always renders after a stall** — In `neural-interface/public/shared/ocp/ocp-tabs.js`, the `executePlanStallRecovery()` added in the prior fix took the wrong fallback when `tab.planContent` ended up shorter than 40 chars: it called `showProseQuestionRecoveryUI(tab)` (which renders a card titled `MODEL ASKED QUESTIONS IN PROSE`), instead of the user-expected `PLAN COMPLETE`. Reproduced on `opencode-go/kimi-k2.6` plan mode where the user reported "the agent asked a few questions … then automatically returned an error … but why isn't it presenting the plan complete normally?". Recovery now unconditionally calls `maybeShowPostPlanUI(tab, { source: \`stall:${reason}\`, force: true })` — `force: true` skips both the 40-char gate AND the prose-question guard. The prose-question recovery card is for a different bug class (model wrote questions as text instead of using the `question` tool) and should never be the stall fallback.
137
91
  - **Broader content extraction via `extractPlanTextLoose`** — The previous recovery called `capturePlanContent(tab)` which only adopts DOM text > 80 chars from the *last* `.ocp-msg-assistant` bubble, missing two key paths used by kimi-k2.6: (1) the live thinking block content (rendered into `.ocp-think-content-live` by the new inline `<think>` parser), and (2) `tab.planContent` not being populated by `message.part.delta` events (deltas update the DOM only — only `message.part.updated` updates `tab.planContent`). Recovery now calls `extractPlanTextLoose(tab)` which already covers all six extraction sources: existing `tab.planContent` → `ExitPlanMode` tool args → `todowrite`/`tasks` todos → final assistant text bubble (>40 chars) → standalone `.ocp-think-block .ocp-think-content` (matches both finalized AND live-streaming thinking blocks since the live block carries both classes) → subagent (Agent/task) tool result → last-resort any assistant bubble.
@@ -144,6 +98,18 @@
144
98
  - **Couples with finalization watchdog clearing** — `clearPlanFinalizationWatchdog(tab)` now also calls `clearPlanStallTimers(tab)`, so all 16 existing terminal/abort sites (message.completed, session.status:idle, session.idle, session.error, abortTab, sendMessage start/resolved/catch, setTabMode, etc.) clear stall timers without per-site edits.
145
99
  - **Soft-prompt card** — New `renderPlanStallSoftCard()` in `neural-interface/public/shared/ocp/ocp-render.js` mirrors the prose-question recovery card with a cool-blue accent (vs. amber) so users can visually distinguish "stuck" from "asked questions in prose". CSS in `neural-interface/public/shared/ocp/ocp-styles.js` (`.ocp-plan-stall-card` and friends).
146
100
 
101
+ ### Fixed — OpenCode Plan Mode Auto-Finalizes After ExitPlanMode
102
+ - **PLAN COMPLETE without manual STOP** — When a plan-mode model emitted `ExitPlanMode` but the OpenCode server never delivered a terminal `session.idle` / `message.completed`, the post-plan card stayed buried until the user pressed STOP (which triggered `message:abort` → server-emitted `session.idle` → post-plan funnel). The `schedulePlanFinalizationWatchdog()` in `neural-interface/public/shared/ocp/ocp-tabs.js` was previously armed only inside `recordAgentChildEvent` for the Deepseek subagent-idle case, never for parent-level `ExitPlanMode` without subagents (e.g., Anthropic plan mode). The watchdog is now armed (with a 5 s timeout) in BOTH ExitPlanMode detection sites — the legacy `tool.start` handler and the modern `message.part.updated` handler — replacing the lone `clearPlanFinalizationWatchdog(tab)` call with a clear-then-schedule pair.
103
+ - **Parameterized timeout** — `schedulePlanFinalizationWatchdog(tab, { timeoutMs = 8000 } = {})` accepts an optional `timeoutMs`; the subagent-idle case keeps the 8 s default while ExitPlanMode-detected uses 5 s (the tool already returned, terminal event should arrive in 1–3 s).
104
+ - **Relaxed min-length guard on watchdog fire** — When `_exitPlanDetected = true`, the 40-char `tab.planContent` minimum is bypassed so plans whose text only lives on `toolInput.plan` (no separate assistant prose) still render. The existing `maybeShowPostPlanUI(tab, { force: tab._exitPlanDetected })` already passes `force: true` for the tool-detected path.
105
+
106
+ ### Fixed — OpenCode Question Reply "Fetch Failed" Frozen UI
107
+ - **Non-terminal reply error path** — In `neural-interface/public/shared/ocp/ocp-questions.js renderOpencodeQuestion`, the `requestWs('question:reply')` catch handler no longer flips `tab.running=false` / `endTurn(tab)`. Instead it re-enables the question card (`locked=''`, buttons re-enabled) and shows "Click an answer again to retry." Previously a transient SDK fetch error caused the entire turn to be marked complete, freezing the UI behind a stale card.
108
+ - **Composer unblocking on prose-recovery dismiss** — `onReplyDirectly` and `onDismiss` callbacks in `ocp-plan.js showProseQuestionRecoveryUI` now defensively clear `tab.showPostPlanActions = false` so the composer always re-enables when the user closes the prose-recovery card.
109
+
110
+ ### Fixed — OpenCode Sidepanel Question Card Multi-Question Routing Trace
111
+ - **`event:in` + `q:queued` diagnostics** — `neural-interface/public/shared/ocp/ocp-events.js` now traces every routed SDK event with `eventType`, `sid`, `partType`, `toolName`, plus `q:asked` (with question count) and `q:queued` (with `reason: no-container | active-question-busy`). Makes it possible to determine — from the trace alone — whether the model emitted `question.asked`, whether the router rendered or queued it, and why.
112
+
147
113
  ### Fixed — OpenCode Sidepanel Live Thinking Stream for Inline `<think>` Tag Models
148
114
  - **CLI-style typing for Kimi K2 / DeepSeek R1 / Qwen QwQ via opencode-go** — In `neural-interface/public/shared/ocp/ocp-render.js`, models that emit reasoning as inline `<think>…</think>` tags (rather than as a structured `partType === 'reasoning'` part) previously had their reasoning render as raw `<think>` text in the live bubble, with `<think>` parsing only happening at `finalizeStreamingMessage()`. The user complaint: thinking should "type into" the sidepanel as it does in the OpenCode CLI. New stateful parser `_routeStreamingChunk(el, container, chunk)` walks each delta, splits at `<think>` / `</think>` boundaries, and routes inside-tag content to the live thinking block via `_appendThinkTextOnly` and outside-tag content to the live text node via `_appendRawTextOnly`.
149
115
  - **Element-level state** — `el._thinkInside` tracks whether subsequent deltas continue inside an unclosed `<think>` block. `el._thinkPendingTag` buffers a partial tag that lands at a chunk boundary (e.g., delta ending with `<thi` or `</thin`); `_matchTrailingTagPrefix(s, target)` finds the longest suffix of `s` that prefixes `target`, so the partial flushes correctly when the rest of the tag arrives in the next delta.
@@ -157,10 +123,19 @@
157
123
  - **Removed obsolete render path** — Deleted `renderStreamingElement()` and `scheduleStreamingRender()` (the 16 ms `innerHTML`-rebuild path) since the live append path replaces it.
158
124
  - **Live styling cues** — Added `.ocp-think-block-live` (slightly brighter border) and a pulsing `Thinking…` summary label via `@keyframes ocp-think-pulse` in `neural-interface/public/shared/ocp/ocp-styles.js`, plus `scroll-behavior: smooth` on `.ocp-think-content-live`.
159
125
 
160
- ### Fixed — OpenCode Plan Mode Auto-Finalizes After ExitPlanMode
161
- - **PLAN COMPLETE without manual STOP** — When a plan-mode model emitted `ExitPlanMode` but the OpenCode server never delivered a terminal `session.idle` / `message.completed`, the post-plan card stayed buried until the user pressed STOP (which triggered `message:abort` → server-emitted `session.idle` → post-plan funnel). The `schedulePlanFinalizationWatchdog()` in `neural-interface/public/shared/ocp/ocp-tabs.js` was previously armed only inside `recordAgentChildEvent` for the Deepseek subagent-idle case, never for parent-level `ExitPlanMode` without subagents (e.g., Anthropic plan mode). The watchdog is now armed (with a 5 s timeout) in BOTH ExitPlanMode detection sites — the legacy `tool.start` handler and the modern `message.part.updated` handler — replacing the lone `clearPlanFinalizationWatchdog(tab)` call with a clear-then-schedule pair.
162
- - **Parameterized timeout** — `schedulePlanFinalizationWatchdog(tab, { timeoutMs = 8000 } = {})` accepts an optional `timeoutMs`; the subagent-idle case keeps the 8 s default while ExitPlanMode-detected uses 5 s (the tool already returned, terminal event should arrive in 1–3 s).
163
- - **Relaxed min-length guard on watchdog fire** — When `_exitPlanDetected = true`, the 40-char `tab.planContent` minimum is bypassed so plans whose text only lives on `toolInput.plan` (no separate assistant prose) still render. The existing `maybeShowPostPlanUI(tab, { force: tab._exitPlanDetected })` already passes `force: true` for the tool-detected path.
126
+ ### Fixed — OpenCode Sidepanel Project Selector Lost the Project Path
127
+ - **Session created in the right directory** — The `session:create` WS handler in `neural-interface/server.js` now forwards the panel-supplied cwd to OpenCode as `POST /session?directory=<encoded path>`. OpenCode binds each session to the directory passed in this query parameter (`session.directory`); previously the call omitted it, so every OpenCode session inherited the serve cwd (`PACKAGE_ROOT` = SynaBun) and ALL agent tool calls (Read, Bash, Edit, Write) resolved relative to SynaBun even when the user had picked a different project in the footer. With the query param wired through, OpenCode's tools natively resolve at the project root the user selected.
128
+ - **Fresh-session cwd routing** — Switching the project via the OpenCode footer dropdown previously mutated only `tab.project` in `neural-interface/public/shared/ocp/ocp-panel.js`, leaving the existing OpenCode session bound to the cwd it was first created with. Added `setActiveProject()` in `neural-interface/public/shared/ocp/ocp-tabs.js` that updates `tab.project` + `STOR.project`, drops the bound `tab.sessionId` (along with title, token usage, plan/post-plan, watchdogs, tool activity, question/permission queues, and snapshot flush), refreshes the project chip label, and clears the messages container so the next `sendMessage()` creates a fresh OpenCode session at the new cwd. The projectbar dropdown click handler and the name-modal commit now both route through `setActiveProject()` instead of touching `tab.project` directly.
129
+ - **Greeting carries the absolute project path** — Updated `buildOpencodeGreetingUserPrompt()` in `neural-interface/server.js` to spell out the absolute project working directory (`Project working directory: \`/abs/path\``) and instruct the agent to use it for all file operations whenever the selected project differs from `PACKAGE_ROOT`. Belt-and-suspenders alongside the new `?directory=` query param, so the agent's first turn explicitly states the cwd it should be operating in.
130
+
131
+ ---
132
+
133
+ ## Claude Sidepanel
134
+
135
+ ### Fixed — Sidepanel Pills Open Blank Session After Server Restart
136
+ - **Pill click landed on "New chat" instead of resuming the underlying Claude session** — `loadConfig()` in `neural-interface/public/shared/ui-claude-panel.js` detected a server-bootId mismatch and `removeItem`'d `STOR.tabs` / `STOR.tabsLegacy` / `STOR.session` outright. Pills (rendered by `ui-sidepanel-tray.js`) read those same keys but render before the panel inits, so they survived the restart visually — but the first pill click triggered `toggleClaudePanel` → `loadConfig` → wipe → `restoreTabs` found nothing → fell through to `createTab(null, 'New chat')`.
137
+ - Replaced the wipe with a new `_scrubStaleTabState(key)` helper added above `restoreTabs()`. On bootId mismatch it now **preserves** resumable identity (`id`, `sessionId`, `label`, `project`, `model`, `effort`) and **drops** runtime-only state that would lie post-restart (`running` / `_wasRunning`, `queue` / `queuePaused`, `planMode` / `planFilePath`, `sessionCost` — re-synced via `syncSessionCosts()`). Tabs with no `sessionId` and only a default label ("New chat", "New session", "Claude") are pruned; the legacy `STOR.session` single-sessionId key is left intact.
138
+ - Codex and OpenCode panels never had a bootId wipe, so their pills already worked across restarts — Claude was the lone outlier.
164
139
 
165
140
  ### Fixed — Claude Sidepanel Plan-Mode "Plan Text Was Empty" Edit Flow
166
141
  - **Server-side plan file authoring before `killProc()`** — `neural-interface/server.js` ExitPlanMode hook (`handleClaudeSkinWebSocket`, ~line 6616) now calls `writePlanFile(inputPlan || planText, { cwd: workDir })` before the kill. Previously the kill (intentional, prevents `--print`-mode auto-implementation) ran before `PostToolUse` could fire, so `post-plan.mjs` never authored a plan file from `tool_input.plan`. Result: clicking "Edit Plan" hit `noFile()` with "Plan text was empty — ask Claude to re-output the plan…". Server now writes `data/plans/YYYY-MM-DD/<slug>.md` directly from `ExitPlanMode.input.plan` (or the preceding text block as fallback).
@@ -170,34 +145,76 @@
170
145
  - **Removed redundant `/api/create-plan` POST from 3 eager-capture sites** — `renderAssistant()` (ExitPlanMode-detection block, partial-message dedup branch, new-message branch) no longer POSTs the captured plan content. Capture still stashes `tab._planContent` from `exitBlock.input.plan` for the implementation-prompt flow, but file authoring is exclusively server-side.
171
146
  - **Removed `extractPlanText`/`materialize` DOM-scrape fallback from Edit Plan click handler** — `renderPostPlanActions()`'s `a.action === 'plan'` branch no longer scrapes `.msg-body` rendered prose and POSTs it to `/api/create-plan`. The DOM only ever held rendered prose narration, never authoritative plan markdown — that path was the source of the garbage-named plan files. Click flow simplified to: `tab.planFilePath` → `openPlan` immediately; else one `requestAnimationFrame` retry for in-flight `plan_file_written`; else `diskFallback` via `GET /api/latest-plan`; else `noFile()`.
172
147
 
173
- ### Fixed — OpenCode Plan Mode Forces `question` Tool + Prose-Question Recovery
174
- - **Plan-mode prompt-prefix injection** — `neural-interface/server.js` previously sent `body.mode='plan'` and `body.tools={...}` without any prompt instruction, so models like Kimi K2.6 wrote clarification questions as prose ("Before I proceed, a couple of quick questions:") instead of calling the OpenCode `question` tool — the sidepanel only renders interactive cards for actual `question` tool calls, so prose questions stranded the user. New `OPENCODE_PLAN_MODE_INSTRUCTION` constant (mirroring the existing `CODEX_PLAN_MODE_PREFIXES` at ~line 2828) is now prepended to the first text part in every `body.mode === 'plan'` send: it explicitly states `You MUST call the \`question\` tool`, forbids prose questions, and reminds the model to call `ExitPlanMode` when ready. Idempotent via a `startsWith('[PLAN MODE]')` guard so the prefix isn't double-injected on multi-turn plan refinement.
175
- - **Per-turn question-tool usage tracking** — `neural-interface/public/shared/ocp/ocp-tabs.js` adds a `tab._questionToolUsedThisTurn` flag set to `true` in all three question-detection sites (`message.part.updated` tool branch, `tool.start` handler, and the dedicated `question.asked` SSE event), reset to `false` at the start of `sendMessage()`, when entering plan mode in `setTabMode()`, and on tab clear.
176
- - **Prose-question detector** — New `looksLikeProseQuestions(content)` helper scans the last 400 chars of captured plan text for trailing patterns: `quick/a couple of/two/before i proceed … questions:`, `Question N:` markers, or 2+ trailing `?` per line.
177
- - **`maybeShowPostPlanUI` recovery reroute** — When `!force && !_exitPlanDetected && !_questionToolUsedThisTurn && looksLikeProseQuestions(planContent)`, the function now calls `showProseQuestionRecoveryUI(tab)` and returns `false` instead of stamping the misleading PLAN COMPLETE card. Fixes the long-standing "press STOP after prose questions → PLAN COMPLETE for half-finished plan" trap.
178
- - **`MODEL ASKED QUESTIONS IN PROSE` recovery card** — New `renderProseQuestionRecoveryCard()` / `removeProseQuestionRecoveryCards()` exports in `neural-interface/public/shared/ocp/ocp-render.js`, plus a new `.ocp-prose-question-card` block in `neural-interface/public/shared/ocp/ocp-styles.js` (amber accent so it's visually distinct from the green-ish PLAN COMPLETE). Three actions: **Reply directly** focuses the OCP input field; **Re-ask using question tool** sends a follow-up prompt instructing the model to re-ask using the `question` tool; **Dismiss** removes the card. Cards are also cleared on next `sendMessage()` and on `setTabMode()` exit-plan.
179
-
180
- ### Added — AskUserQuestion Manual QA Test Suite
181
- - **Test suite at `tests/ask-user-question/`** — Manual QA suite for the `AskUserQuestion` interactive question card across Claude, Codex, and OpenCode sidepanels. Each scenario is a directive copy-paste prompt that forces the panel CLI to invoke its `AskUserQuestion` equivalent (Claude `control_request`, Codex `request_user_input`, OpenCode `tool.start` / `question.asked`) with a specific shape, so visual and functional rendering can be verified across all three panels.
182
- - **`README.md`** — Master entry with the panel-to-render-function map (`renderAskUserQuestion()` in `neural-interface/public/shared/ui-claude-panel.js`, `renderUserInputRequest()` in `neural-interface/public/shared/cdx/cdx-requests.js`, `renderQuestionCard()` in `neural-interface/public/shared/ocp/ocp-render.js`), pre-flight steps, and recommended run order.
183
- - **`checklist.md`** — Per-panel verification checklist covering visual checks (header chip, options layout, `Submit (x/y)` progress, locked state, inter-block spacing) and functional checks (selection toggling, multi-select, "Other" / custom-input path, submit transmission, queue behavior). Includes a scenario × panel scoreboard.
184
- - **`master-prompt.md`** — Single 4-question stress prompt (mixed multi/single-select, long labels, descriptions) for end-to-end smoke testing after granular scenarios.
185
- - **`scenarios/01-12-*.md`** — 12 numbered scenarios covering single-select min/max, multi-select, batched 2/4-question cards with mixed types, `Other` / custom typed answer, sequential queue (`_questionQueue` / `processQuestionQueue`), plan-mode integration, long-content overflow, header-only cards, no-options free-text fallback, and cancel-mid-answer queue clearing.
148
+ ### Changed — Empty-Plan Re-Prompt Button (Claude Panel)
149
+ - **Replaced "Plan text was empty" status text with an interactive button** — When the user clicks `Edit plan` in the post-plan card but the plan extractor and `/api/latest-plan` disk fallback both fail to surface a plan file, `neural-interface/public/shared/ui-claude-panel.js` previously printed a static `appendStatus()` line ("Plan text was empty — ask Claude to re-output the plan, or click Continue with implementation to proceed."). The `noFile()` callback in the `'plan'` action handler now renders an inline `msg-status` row containing the short text "Plan text was empty." plus a primary `post-plan-action pp-primary` button labeled "Ask Claude to re-output the plan". Clicking the button populates `#cp-input` with a re-prompt instruction (`Please re-output the full plan you were preparing. Use ExitPlanMode with the complete plan text...`) and calls `send()`. Button disables on click, and falls back to a status if the WebSocket is closed. Scoped to the Claude panel only — `ocp-panel.js` retains the existing `renderErrorMessage` pattern.
186
150
 
187
- ## 2026-05-04
151
+ ---
188
152
 
189
- ### Fixed — OpenCode Sidepanel Project Selector Lost the Project Path
190
- - **Session created in the right directory** — The `session:create` WS handler in `neural-interface/server.js` now forwards the panel-supplied cwd to OpenCode as `POST /session?directory=<encoded path>`. OpenCode binds each session to the directory passed in this query parameter (`session.directory`); previously the call omitted it, so every OpenCode session inherited the serve cwd (`PACKAGE_ROOT` = SynaBun) and ALL agent tool calls (Read, Bash, Edit, Write) resolved relative to SynaBun even when the user had picked a different project in the footer. With the query param wired through, OpenCode's tools natively resolve at the project root the user selected.
191
- - **Fresh-session cwd routing** — Switching the project via the OpenCode footer dropdown previously mutated only `tab.project` in `neural-interface/public/shared/ocp/ocp-panel.js`, leaving the existing OpenCode session bound to the cwd it was first created with. Added `setActiveProject()` in `neural-interface/public/shared/ocp/ocp-tabs.js` that updates `tab.project` + `STOR.project`, drops the bound `tab.sessionId` (along with title, token usage, plan/post-plan, watchdogs, tool activity, question/permission queues, and snapshot flush), refreshes the project chip label, and clears the messages container so the next `sendMessage()` creates a fresh OpenCode session at the new cwd. The projectbar dropdown click handler and the name-modal commit now both route through `setActiveProject()` instead of touching `tab.project` directly.
192
- - **Greeting carries the absolute project path** — Updated `buildOpencodeGreetingUserPrompt()` in `neural-interface/server.js` to spell out the absolute project working directory (`Project working directory: \`/abs/path\``) and instruct the agent to use it for all file operations whenever the selected project differs from `PACKAGE_ROOT`. Belt-and-suspenders alongside the new `?directory=` query param, so the agent's first turn explicitly states the cwd it should be operating in.
153
+ ## Codex Sidepanel
193
154
 
194
155
  ### Fixed — Codex Sidepanel Project Switching
195
156
  - **Fresh-session cwd routing** — Fixed the Codex footer project selector so changing projects updates the bound `_project` state in `neural-interface/public/shared/cdx/cdx-tabs.js` instead of only mutating `tab.project` in `neural-interface/public/shared/cdx/cdx-panel.js`; the new `setActiveProject()` keeps `tab.project`, `STOR.project`, branch UI, and fresh thread reset state in sync before `dispatchPrompt()` sends `query.cwd`.
196
157
  - **Sandbox root refresh** — Sends `reset_thread` to the Codex websocket after a project change and clears `_threadId` when the server explicitly returns `threadId: null`, preventing stale app-server thread IDs from leaking into fresh sessions and causing workspace-write permissions to target the old folder.
197
158
 
159
+ ---
160
+
161
+ ## Sidepanel Header & Tray
162
+
163
+ ### Changed — Sidepanel Header & Tray Pill Polish
164
+ - **`stopPropagation` on OCP header buttons** — `+` (new session), Minimize, Close, and Slide buttons in `ocp-v2-panel.js` now `event.stopPropagation()` so a click no longer bubbles into the session-menu open/close handler. Removes a race where a stray header click could toggle the session dropdown.
165
+ - **`data-tooltip-pos` on every sidepanel pill close button** — Tray pill X buttons in `ui-claude-panel.js` (`.cp-session-pill`), `cdx/cdx-tabs.js` (`.cxp-session-pill`), `ocp-v2-panel.js` (`.ocpv2-session-pill`), and the placeholder pills in `ui-sidepanel-tray.js` all got `data-tooltip-pos="top"` so the "Close" tooltip stops clipping at the bottom edge of the tray. OCP header buttons got `data-tooltip-pos="bottom"` for symmetry.
166
+
167
+ ---
168
+
169
+ ## Terminal
170
+
171
+ ### Fixed — Terminal ESC Key Now Aborts CLI TUIs On First Press (Floating + Docked)
172
+ - **Single ESC reaches the PTY instead of `\x1b\x1b`** — In `neural-interface/public/shared/ui-terminal.js`, the global window-capture ESC handler in `initTerminal()` sent `\x1b` over the WS without `e.preventDefault()` / `e.stopImmediatePropagation()`, so xterm.js's own keydown listener on `.xterm-helper-textarea` fired afterwards and re-emitted ESC via `term.onData(...)` (line 1915). The PTY received `\x1b\x1b`, which Bubbletea-based TUIs (OpenCode, Claude Code, Codex) interpret as a Meta-prefix and ignore — so the running task never aborted. Handler now sends one `\x1b`, calls `e.preventDefault()` + `e.stopImmediatePropagation()` to block the duplicate, and re-focuses via `requestAnimationFrame(() => session.term?.focus())` instead of the old `term?.blur()` / `ta.blur()` pair (focus loss had forced the user to click back into the terminal between keystrokes).
173
+ - **Docked terminal now has ESC coverage** — Previous early return `if (!isXterm) return;` left the docked panel without any ESC fallback when focus drifted to a tab title or panel chrome. Handler now resolves the target session by DOM ancestry: xterm helper textarea → its viewport's `dataset.sessionId`, else `.term-float-tab` → that tab's session, else inside `_panel` (`#terminal-panel`) → `_sessions[_activeIdx]`. Skips non-terminal `input/textarea/select/[contenteditable]` so search/rename/path inputs still consume ESC normally.
174
+ - **Removed redundant per-floating-window ESC branch** — `attachTab()`'s `win.addEventListener('keydown', ...)` had a duplicate ESC sender that was unreachable for the common case (skipped when target was a textarea). Stripped the ESC branch; the Ctrl+C copy-on-selection branch stays as the floating-window-only fallback.
175
+
176
+ ### Changed — Floating Terminal Drag Compositing
177
+ - **Simplified `.term-float-tab.float-dragging` shadow** — In `styles.css`, replaced the multi-layer `box-shadow: var(--shadow-2xl), 0 0 0 1px rgba(0,0,0,0.4)` with a single `0 8px 24px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.4)`, dropped the `box-shadow` transition (kept `border-radius`), and added `will-change: transform, left, top` so the dragging window stays on its own composited layer. Removes per-frame GPU compositing thrash during drag.
178
+
179
+ ---
180
+
181
+ ## Performance & Stability
182
+
183
+ ### Fixed — Long-Session Memory Leaks
184
+ - **Bounded `_orphanedProcs` map** — Claude-skin orphan processes accumulated in `server.js` when a kill timer never fired (crash, kill -9, sleep) and an entry was never reattached. Added a 60-second sweep (`setInterval(...).unref()`) that deletes entries whose `proc` is null/killed/exited and clears the stale `killTimer`.
185
+ - **Pruned `_ocpSessionOwners` / `_ocpSessionActivity`** — `_ocpStartSilenceWatchdog` in `server.js` now removes session entries with no live clients and `lastEventAt` older than 30 minutes. Watchdog scan no longer iterates dead sessions for the lifetime of the process.
186
+ - **Idle screencast frame waste** — `onScreencastFrame` in `server.js` now bails out early (still ack'ing `Page.screencastFrameAck` to keep the CDP pipeline alive) when `session.clients` is empty, skipping JPEG buffer allocation and broadcast. Removed the per-frame `frameCount++` and conditional `console.log` that allocated even when not logging.
187
+
188
+ ### Changed — Whiteboard Drag Hot Path
189
+ - **rAF-batched `renderAll()`** — `ui-whiteboard.js` now schedules renders through `requestAnimationFrame` via `_renderRafId`. Multiple mousemove handlers used to call `renderAll()` synchronously per pointer event; renders are coalesced to one per frame. Added `renderAllImmediate()` for explicit flushes.
190
+ - **`_elementMap` O(1) lookups** — Added `_findEl(id)` Map cache. Rebuilt lazily when `_elements.length` changes; `_invalidateElementMap()` is called from `undo()`/`redo()` to cover same-length object replacement. Replaced 8 `_elements.find(el2 => el2.id === ...)` calls inside `onMouseMove` (move-multi, shape-create, section-create, move, move-arrow, move-pen, rotate, resize).
191
+ - **Cached root rect** — Added `_rootRectCached` + `_getRootRect()`/`_invalidateRootRect()`. `clientToCanvas()` and the pen-drawing path reuse the cached rect for the duration of a gesture; cache is cleared at mouseup and on window resize. Eliminates `_root.getBoundingClientRect()` layout flushes inside the 60 Hz mousemove loop.
192
+
193
+ ### Changed — Sidepanel Markdown Rendering
194
+ - **OCP v2 incremental render** — Rewrote `render()` in `ocp-v2-render.js` to use a key/sig reconciler (`_reconcile`, `_partSig`, `_msgSig`) instead of `_container.innerHTML = ''` followed by a full rebuild. User messages, assistant part bubbles, error banners, permission cards, question cards, and the post-plan card now have stable composite keys and content signatures so unchanged nodes are reused. Scroll position is far more stable across streaming deltas.
195
+ - **LRU markdown memoization** — Added a 512-entry insertion-order LRU cache around `renderMarkdown()` in `ocp-v2-render.js`, `md()` in `cdx/cdx-render.js`, and `md()` in `ocp/ocp-render.js`. Identical text re-rendered during streaming/state-change passes now returns cached HTML instead of re-invoking `marked.parse()`.
196
+
197
+ ### Changed — Storage Layer
198
+ - **Deferred `JSON.parse` to flush time** — `storage.js` introduces `STR_SENTINEL`. `setItem()` no longer parses the caller-provided string on every call; `_dirty[key] = STR_SENTINEL` records "parse the current cache string at flush time". `_flushToServer()` and the `beforeunload` `sendBeacon` path resolve sentinels by parsing the cached string once when actually flushing. Big win for callers that store large snapshots (whiteboard, codex transcripts) where every keystroke previously triggered a redundant `JSON.parse`.
199
+
200
+ ---
201
+
202
+ ## Notifications
203
+
198
204
  ### Added — Pending Remember Picker on Notifications Health Tab
199
205
  - **Inline provider/model picker** — New "Run Pending Remembers" button on the Notifications drawer Health tab in `neural-interface/public/shared/ui-sessions.js`. Clicking expands an inline picker with provider buttons (Claude Code / Codex / OpenCode), a per-provider model dropdown, and Cancel/Run actions, so each orphaned `pending-remember` flag can be summarized into a real memory by the user's chosen sidepanel CLI instead of an isolated background agent.
200
206
  - **Per-provider model loading** — Claude models pulled from `/api/claude/config`, OpenCode models flattened from `/api/opencode/providers/full` as `provider/model` ids, Codex falls back to a static list (`gpt-5-codex`, `gpt-5`, `o4`, `o4-mini`) since its model list is WebSocket-only.
201
207
  - **Sidepanel routing** — Run dispatches the prompt to the chosen sidepanel: Claude via `sendToPanel({ newTab: true, autoSubmit: true })`, OpenCode via `openOpencodeWithPrompt({ autoSend: true })`, Codex by toggling the panel and pre-filling `#cxp-input` (auto-send is unreliable from outside the Codex panel).
202
208
  - **Server endpoint** — New `GET /api/sessions/pending-remember-prompt` in `neural-interface/server.js` returns `{ ok, count, prompt }`; resolves each orphaned session id to its `~/.claude/projects/<projKey>/<sessionId>.jsonl` transcript and embeds those paths in the prompt so the executing CLI can read them.
203
209
  - **Picker styling** — Added `.sm-pr-picker` / `.sm-pr-row` / `.sm-pr-providers` / `.sm-pr-select` rules in `neural-interface/public/shared/styles.css`, including an `active` pill state for the selected provider.
210
+
211
+ ---
212
+
213
+ ## Testing
214
+
215
+ ### Added — AskUserQuestion Manual QA Test Suite
216
+ - **Test suite at `tests/ask-user-question/`** — Manual QA suite for the `AskUserQuestion` interactive question card across Claude, Codex, and OpenCode sidepanels. Each scenario is a directive copy-paste prompt that forces the panel CLI to invoke its `AskUserQuestion` equivalent (Claude `control_request`, Codex `request_user_input`, OpenCode `tool.start` / `question.asked`) with a specific shape, so visual and functional rendering can be verified across all three panels.
217
+ - **`README.md`** — Master entry with the panel-to-render-function map (`renderAskUserQuestion()` in `neural-interface/public/shared/ui-claude-panel.js`, `renderUserInputRequest()` in `neural-interface/public/shared/cdx/cdx-requests.js`, `renderQuestionCard()` in `neural-interface/public/shared/ocp/ocp-render.js`), pre-flight steps, and recommended run order.
218
+ - **`checklist.md`** — Per-panel verification checklist covering visual checks (header chip, options layout, `Submit (x/y)` progress, locked state, inter-block spacing) and functional checks (selection toggling, multi-select, "Other" / custom-input path, submit transmission, queue behavior). Includes a scenario × panel scoreboard.
219
+ - **`master-prompt.md`** — Single 4-question stress prompt (mixed multi/single-select, long labels, descriptions) for end-to-end smoke testing after granular scenarios.
220
+ - **`scenarios/01-12-*.md`** — 12 numbered scenarios covering single-select min/max, multi-select, batched 2/4-question cards with mixed types, `Other` / custom typed answer, sequential queue (`_questionQueue` / `processQuestionQueue`), plan-mode integration, long-content overflow, header-only cards, no-options free-text fallback, and cancel-mid-answer queue clearing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synabun",
3
- "version": "2026.5.13-beta",
3
+ "version": "2026.5.14-beta2",
4
4
  "description": "Persistent vector memory for AI assistants",
5
5
  "license": "Apache-2.0",
6
6
  "author": "The SynaBun Authors",