feat(v2): add permission mode passthrough and fix agent stop-on-close

- Add permission_mode field to AgentQueryOptions (Rust, sidecar, bridge)
  flowing from controller through sidecar to SDK; defaults to
  bypassPermissions, supports default mode
- Fix AgentPane onDestroy bug: remove stopAgent() from onDestroy (fires
  on layout remounts), move stop-on-close to TilingGrid onClose handler
- Bundle SDK into sidecar via esbuild (remove --external flag)
This commit is contained in:
Hibryda 2026-03-06 23:33:51 +01:00
parent af0eb362e6
commit d5eb08ed42
7 changed files with 26 additions and 14 deletions

View file

@ -11,6 +11,7 @@ export interface AgentQueryOptions {
max_turns?: number;
max_budget_usd?: number;
resume_session_id?: string;
permission_mode?: string;
remote_machine_id?: string;
}

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { onMount } from 'svelte';
import { marked, Renderer } from 'marked';
import { queryAgent, stopAgent, isAgentReady, restartAgent } from '../../adapters/agent-bridge';
import {
@ -68,11 +68,8 @@
}
});
onDestroy(() => {
if (session?.status === 'running' || session?.status === 'starting') {
stopAgent(sessionId).catch(() => {});
}
});
// NOTE: Do NOT stop agents in onDestroy — it fires on layout changes/remounts,
// not just explicit close. Stop-on-close is handled by TilingGrid.
let followUpPrompt = $state('');

View file

@ -14,6 +14,8 @@
} from '../../stores/layout.svelte';
import { detachPane } from '../../utils/detach';
import { isDetachedMode } from '../../utils/detach';
import { stopAgent } from '../../adapters/agent-bridge';
import { getAgentSession } from '../../stores/agents.svelte';
let gridTemplate = $derived(getGridTemplate());
let panes = $derived(getPanes());
@ -162,7 +164,15 @@
<PaneContainer
title={pane.title}
status={pane.focused ? 'running' : 'idle'}
onClose={() => removePane(pane.id)}
onClose={() => {
if (pane.type === 'agent') {
const s = getAgentSession(pane.id);
if (s?.status === 'running' || s?.status === 'starting') {
stopAgent(pane.id).catch(() => {});
}
}
removePane(pane.id);
}}
onDetach={detached ? undefined : () => handleDetach(pane)}
>
{#if pane.type === 'terminal'}