From e7c957d650381650b634ce26d02767fca9bf5688 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Fri, 6 Mar 2026 23:34:00 +0100 Subject: [PATCH] docs: update docs for permission mode, agent stop-on-close fix, SDK bundling --- docs/progress.md | 27 ++++++++++++++++++++++----- docs/task_plan.md | 6 +++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/progress.md b/docs/progress.md index a8f8c62..c970a75 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -365,16 +365,33 @@ Design: No separate sidecar process per subagent. Parent's sidecar handles all; - [x] Session stop now uses AbortController.abort() instead of process.kill() - [x] CLAUDE* env var stripping preserved via SDK's `env` option in query() options - [x] Updated sidecar.rs Deno permissions: added --allow-write and --allow-net (required by SDK) -- [x] Added build:sidecar script to package.json (esbuild bundle with @anthropic-ai/claude-agent-sdk as external) -- [x] SDK options: permissionMode: 'bypassPermissions', allowDangerouslySkipPermissions: true, 10 allowedTools +- [x] Added build:sidecar script to package.json (esbuild bundle, SDK included) +- [x] SDK options: permissionMode configurable (default 'bypassPermissions'), allowDangerouslySkipPermissions conditional, 10 allowedTools - [x] Tested standalone: SDK sidecar successfully produced agent output - [x] All 114 vitest tests pass, Rust compiles clean -#### Bug Found (not yet fixed) -- [ ] AgentPane.svelte onDestroy calls stopAgent() on component unmount — kills running sessions when panes are switched/collapsed, not just when explicitly closed +#### Bug Found and Fixed +- [x] AgentPane.svelte onDestroy calls stopAgent() on component unmount — kills running sessions when panes are switched/collapsed, not just when explicitly closed (FIXED: see below) + +### Session: 2026-03-06 (continued) — Permission Mode, AgentPane Bug Fix, SDK Bundling + +#### Permission Mode Passthrough +- [x] Added `permission_mode` field to AgentQueryOptions in bterminal-core/src/sidecar.rs +- [x] Added `permissionMode` to QueryMessage interface in both sidecar runners (agent-runner.ts, agent-runner-deno.ts) +- [x] SDK options now use dynamic permissionMode: defaults to 'bypassPermissions', supports 'default' mode +- [x] allowDangerouslySkipPermissions conditionally set based on permissionMode value +- [x] Added `permission_mode` to AgentQueryOptions in agent-bridge.ts frontend adapter + +#### AgentPane onDestroy Bug Fix +- [x] Removed onDestroy stopAgent() from AgentPane.svelte — it was killing running agents on layout remounts +- [x] Moved stop-on-close logic to TilingGrid.svelte onClose handler: checks pane type is 'agent' and session status is running/starting before stopping +- [x] Added comment in AgentPane explaining why onDestroy must NOT stop agents + +#### SDK Bundling Fix +- [x] Removed `--external:@anthropic-ai/claude-agent-sdk` from esbuild build:sidecar script in package.json +- [x] SDK is now bundled into sidecar/dist/agent-runner.mjs (no external dependency at runtime) ### Next Steps -- [ ] Fix AgentPane onDestroy session killing bug - [ ] Real-world relay testing (2 machines) - [ ] TLS/certificate pinning for relay connections - [ ] E2E testing with Playwright/WebDriver (when display server available) diff --git a/docs/task_plan.md b/docs/task_plan.md index f2b7648..31e4575 100644 --- a/docs/task_plan.md +++ b/docs/task_plan.md @@ -79,7 +79,7 @@ The Agent SDK cannot run in Rust or the webview. Solution: - Node.js/Deno process uses `@anthropic-ai/claude-agent-sdk` query() function which handles claude subprocess management internally - SDK messages forwarded as-is via NDJSON — same format as CLI stream-json - If sidecar crashes: detect via process exit, show error in UI, offer restart -- **Packaging:** Bundle the sidecar JS as a single file (esbuild bundle). Require Node.js 20+ as system dependency. Document in install.sh. +- **Packaging:** Bundle the sidecar JS + SDK as a single file (esbuild bundle, SDK included). Require Node.js 20+ as system dependency. Document in install.sh. - **Deno-first:** SidecarCommand struct abstracts runtime. Deno preferred (runs TS directly, no build step). Falls back to Node.js if Deno not in PATH. ### SDK Abstraction Layer @@ -149,6 +149,9 @@ See [phases.md](phases.md) for the full phased implementation plan. | bterminal-relay as standalone binary | Rust binary with WebSocket server for remote machine management. Token auth + rate limiting. Per-connection isolated managers. | 2026-03-06 | | RemoteManager WebSocket client | Controller-side WebSocket client in remote.rs. Manages connections to multiple relays with heartbeat ping. 12 new Tauri commands for remote operations. | 2026-03-06 | | Frontend remote routing via remoteMachineId | Pane.remoteMachineId field determines local vs remote. Bridge adapters route to appropriate Tauri commands transparently. | 2026-03-06 | +| Permission mode passthrough | AgentQueryOptions.permission_mode flows Rust -> sidecar -> SDK. Defaults to 'bypassPermissions', supports 'default'. Enables non-bypass agent sessions. | 2026-03-06 | +| Stop-on-close in TilingGrid, not AgentPane | Removed onDestroy stopAgent() from AgentPane (fired on layout remounts). Stop logic moved to TilingGrid onClose handler — only fires on explicit user close. | 2026-03-06 | +| Bundle SDK into sidecar | Removed --external flag from esbuild build:sidecar. SDK bundled into agent-runner.mjs — no runtime dependency on node_modules. | 2026-03-06 | ## Open Questions @@ -185,3 +188,4 @@ See [phases.md](phases.md) for the full phased implementation plan. |---|---|---|---| | 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 | | Agent sessions produce no output (silent hang) | Claude CLI v2.1.69 hangs when spawned via child_process.spawn() with piped stdio. Known bug: github.com/anthropics/claude-code/issues/6775 | Migrated sidecar from raw CLI spawning to `@anthropic-ai/claude-agent-sdk` query() function. SDK handles subprocess management internally. | 2026-03-06 | +| Running agents killed on pane remount | AgentPane.svelte onDestroy called stopAgent() on component unmount, including layout changes and remounts — not just explicit close. | Removed onDestroy from AgentPane. Moved stop-on-close to TilingGrid onClose handler which only fires on explicit user action. | 2026-03-06 |