diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 28452af..9108e27 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -4,7 +4,7 @@ - v1 is a single-file Python app (`bterminal.py`). Changes are localized. - v2 docs are in `docs/`. Architecture decisions are in `docs/task_plan.md`. -- Phase 3 (Agent SDK Integration) is in progress. Core implementation done, needs testing and polish. +- Phase 3 (Agent SDK Integration) core is complete. Needs testing and polish (markdown rendering, sidecar crash detection, auto-scroll lock). - Consult Memora (tag: `bterminal`) before making architectural changes. ## Documentation References @@ -29,6 +29,7 @@ - Node.js sidecar (`sidecar/agent-runner.ts`) spawns claude subprocesses, communicates with Rust via stdio NDJSON. - Agent dispatcher (`src/lib/agent-dispatcher.ts`) is a singleton that routes sidecar events to the agent store. - Maximum 4 active xterm.js instances to avoid WebKit2GTK memory issues. +- Store files using Svelte 5 runes (`$state`, `$derived`) MUST have `.svelte.ts` extension (not `.ts`). Import with `.svelte` suffix. Plain `.ts` compiles but fails at runtime with "rune_outside_svelte". ## Memora Tags diff --git a/CHANGELOG.md b/CHANGELOG.md index a6be2a6..0708f89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Svelte 5 rune stores (layout, agents, sessions) renamed from `.ts` to `.svelte.ts` — runes only work in `.svelte` and `.svelte.ts` files, plain `.ts` caused "rune_outside_svelte" runtime error (blank screen) +- Updated all import paths to use `.svelte` suffix for store modules + ### Added - Agent pane with prompt input, structured message rendering, stop button, and cost display (Phase 3) - Node.js sidecar manager (Rust) for spawning and communicating with agent-runner via stdio NDJSON (Phase 3) diff --git a/docs/phases.md b/docs/phases.md index 315d370..5ff7723 100644 --- a/docs/phases.md +++ b/docs/phases.md @@ -43,9 +43,9 @@ bterminal-v2/ Sidebar/ SessionList.svelte # Session browser stores/ - sessions.ts # Session state ($state runes) - agents.ts # Active agent tracking - layout.ts # Pane layout state + sessions.svelte.ts # Session state ($state runes) + agents.svelte.ts # Active agent tracking + layout.svelte.ts # Pane layout state adapters/ sdk-messages.ts # SDK message abstraction layer pty-bridge.ts # PTY IPC wrapper diff --git a/docs/progress.md b/docs/progress.md index 5fb5ab1..0ac1bae 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -68,12 +68,18 @@ - [x] SDK message adapter: full stream-json parser with 9 typed message types (sdk-messages.ts, 234 lines) - [x] Agent bridge: Tauri IPC adapter for sidecar communication (agent-bridge.ts, 53 lines) - [x] Agent dispatcher: routes sidecar events to agent store (agent-dispatcher.ts, 87 lines) -- [x] Agent store: session state with messages, cost tracking (agents.ts, 91 lines) +- [x] Agent store: session state with messages, cost tracking (agents.svelte.ts, 91 lines) - [x] AgentPane component: prompt input, message rendering, stop button, cost display (AgentPane.svelte, 420 lines) - [x] UI integration: Ctrl+Shift+N for new agent, sidebar agent button, TilingGrid routing Architecture decision: Uses `claude` CLI with `--output-format stream-json` instead of Agent SDK `query()` API. Avoids SDK npm dependency and version churn while getting identical structured output. +### Bug Fix: Svelte 5 Rune File Extensions (2026-03-06) +- [x] Diagnosed blank screen / "rune_outside_svelte" runtime error +- [x] Root cause: store files used `.ts` extension but contain Svelte 5 `$state`/`$derived` runes, which only work in `.svelte` and `.svelte.ts` files +- [x] Renamed: `layout.ts` -> `layout.svelte.ts`, `agents.ts` -> `agents.svelte.ts`, `sessions.ts` -> `sessions.svelte.ts` +- [x] Updated all import paths in 5 files to use `.svelte` suffix (e.g., `from './stores/layout.svelte'`) + ### Next Steps - [ ] Markdown rendering in agent text messages - [ ] Sidecar crash detection and restart UI diff --git a/docs/task_plan.md b/docs/task_plan.md index a9d4b73..aa2e6f3 100644 --- a/docs/task_plan.md +++ b/docs/task_plan.md @@ -124,6 +124,7 @@ See [phases.md](phases.md) for the full phased implementation plan (Phases 1-6). | MVP = Phases 1-4 | Ship usable tool before tackling tree viz, packaging, polish | 2026-03-05 | | Canvas addon (not WebGL) | WebKit2GTK has no WebGL. Explicit Canvas addon avoids silent fallback | 2026-03-05 | | claude CLI over Agent SDK query() | Use `claude -p --output-format stream-json` instead of SDK npm package. Avoids dependency + version churn, identical structured output | 2026-03-06 | +| `.svelte.ts` for rune stores | Svelte 5 `$state`/`$derived` runes require `.svelte.ts` extension (not `.ts`). Compiler silently passes `.ts` but runes fail at runtime. All store files must use `.svelte.ts`. | 2026-03-06 | ## Open Questions @@ -156,4 +157,6 @@ See [phases.md](phases.md) for the full phased implementation plan (Phases 1-6). ## Errors Encountered -(none yet) +| Error | Cause | Fix | Date | +|---|---|---|---| +| Blank screen, "rune_outside_svelte" runtime error | Store files used `.ts` extension but contain Svelte 5 `$state`/`$derived` runes. Runes only work in `.svelte` and `.svelte.ts` files. Compiler silently passes but fails at runtime. | Renamed stores to `.svelte.ts`, updated all import paths to use `.svelte` suffix | 2026-03-06 |