This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-19 23:14:20 +02:00
1 parent 82acf9f107
commit fbed1b49fd
10 files changed
+799 -156

No files matched your search

@@ -10,7 +10,9 @@
let saving = $state(false);
let enabled = $state(false);
let backgroundEnabled = $state(false);
let maxConcurrent = $state(3);
let maxAsync = $state(3);
let maxIterations = $state(30);
let maxOutput = $state(30000);
let systemPrompt = $state('');
@@ -19,7 +21,9 @@
try {
const config = await getAdminConfig();
enabled = config['subagents.enabled'] === true || config['subagents.enabled'] === 'true';
backgroundEnabled = config['subagents.background_enabled'] === true || config['subagents.background_enabled'] === 'true';
maxConcurrent = Number(config['subagents.max_concurrent']) || 3;
maxAsync = Number(config['subagents.max_async']) || 3;
maxIterations = Number(config['subagents.max_iterations']) || 30;
maxOutput = Number(config['subagents.max_output']) || 30000;
systemPrompt = (config['subagents.system_prompt'] as string) || '';
@@ -34,7 +38,9 @@
try {
await updateConfig({
'subagents.enabled': enabled,
'subagents.background_enabled': backgroundEnabled,
'subagents.max_concurrent': maxConcurrent,
'subagents.max_async': maxAsync,
'subagents.max_iterations': maxIterations,
'subagents.max_output': maxOutput,
'subagents.system_prompt': systemPrompt
@@ -73,6 +79,27 @@
</div>
</div>
<div>
<label class="flex items-center justify-between cursor-pointer">
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.subagentsBackgroundEnabled')}</span>
<ToggleSwitch value={backgroundEnabled} onchange={(v) => { backgroundEnabled = v; }} />
</label>
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
{$t('admin.subagentsBackgroundHint')}
</p>
</div>
{#if backgroundEnabled}
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-async">{$t('admin.subagentsMaxAsync')}</label>
<div class="flex items-center gap-1.5 mt-1">
<input id="sa-async" type="number" bind:value={maxAsync} min="1" max="10"
class="w-16 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors" />
<span class="text-[11px] text-gray-400 dark:text-gray-600">{$t('admin.subagentsMaxAsyncHint')}</span>
</div>
</div>
{/if}
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-iterations">{$t('admin.subagentsMaxIterations')}</label>
<div class="flex items-center gap-1.5 mt-1">
@@ -188,7 +188,8 @@
}
case 'delegate_task': {
const t = args.task || '?';
return `Sub-agent: "${t.length > 60 ? t.slice(0, 60) + '…' : t}"`;
const label = args.background ? 'Background sub-agent' : 'Sub-agent';
return `${label}: "${t.length > 60 ? t.slice(0, 60) + '…' : t}"`;
}
default: {
// External tool: {server_id}_{tool_name} → "tool_name (server_id)"
@@ -161,8 +161,10 @@
const activePath = $derived.by((): PathEntry[] => {
if (!allMessages.length) return [];
// Exclude queued messages from the display path — they only appear in the queue UI
const displayMessages = allMessages.filter((m) => !m.meta?.queued);
// Exclude pending internal inputs until the parent has processed them.
const displayMessages = allMessages.filter(
(m) => !m.meta?.queued && !m.meta?.async_subagent_pending
);
if (!displayMessages.length) return [];
const msgMap = new Map(displayMessages.map((m) => [m.id, m]));
@@ -259,7 +261,7 @@
const isLanding = $derived(allMessages.length === 0 && !chatId);
const workspaceName = $derived(workspace.split('/').pop() || 'workspace');
// Queued messages: user messages with meta.queued flag (server-side queue)
// Queued messages: user-authored messages waiting behind an active response.
const queuedMessages = $derived(
allMessages
.filter((m) => m.role === 'user' && m.meta?.queued)
@@ -368,7 +370,8 @@
output?: any;
done?: boolean;
error?: string;
queue_processed?: boolean;
pending_inputs_processed?: boolean;
async_subagent_pending?: boolean;
title?: string;
}) {
// On the landing page, update the chat list in place from socket events
@@ -402,8 +405,8 @@
updateTab(tabId, data.chat_id, data.title);
}
// Queue was processed server-side: reload to see combined message + new generation
if (data.queue_processed) {
// Follow-up state changed server-side: reload to see new transcript/generation state.
if (data.pending_inputs_processed || data.async_subagent_pending) {
loadChat(data.chat_id);
return;
}
@@ -42,6 +42,21 @@
let editedContent = $state('');
let copied = $state(false);
let textareaEl: HTMLTextAreaElement;
let asyncExpanded = $state(false);
const isAsyncSubagentResult = $derived(meta?.async_subagent_result === true);
const delegationId = $derived(meta?.delegation_id || '');
const delegationIds = $derived(Array.isArray(meta?.delegation_ids) ? meta.delegation_ids : []);
const delegationLabel = $derived(
delegationId || (delegationIds.length > 1 ? `${delegationIds.length} tasks` : '')
);
const asyncSummary = $derived.by(() => {
const line = content
.split('\n')
.map((s) => s.trim())
.find((s) => s && !s.startsWith('['));
if (!line) return delegationLabel || '';
return line.length > 96 ? `${line.slice(0, 96)}...` : line;
});
async function startEdit() {
edit = true;
@@ -95,7 +110,37 @@
</script>
<div class="group">
{#if edit}
{#if isAsyncSubagentResult}
<div class="w-full min-w-0">
<button
type="button"
class="w-full min-w-0 flex items-center gap-2 text-left text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors"
aria-expanded={asyncExpanded}
onclick={() => (asyncExpanded = !asyncExpanded)}
>
<span class="w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600 shrink-0"></span>
<span class="text-[12px] font-medium shrink-0">{$t('chat.asyncSubagentComplete')}</span>
{#if asyncSummary}
<span class="text-[12px] truncate min-w-0 flex-1">{asyncSummary}</span>
{/if}
{#if delegationLabel}
<span class="hidden sm:inline text-[11px] font-mono text-gray-400 dark:text-gray-600 shrink-0">{delegationLabel}</span>
{/if}
<Icon
name="chevron-down"
size={12}
class="text-gray-400 dark:text-gray-600 shrink-0 transition-transform duration-150 {asyncExpanded ? 'rotate-180' : ''}"
/>
</button>
{#if asyncExpanded}
<div
class="mt-2 ml-3 border-l border-gray-100 dark:border-white/8 pl-3 text-[12.5px] leading-relaxed text-gray-600 dark:text-gray-400 whitespace-pre-wrap break-words"
>
{content}
</div>
{/if}
</div>
{:else if edit}
<!-- Edit mode: full width -->
<div class="w-full">
<div
@@ -541,6 +541,7 @@
"chat.tool.backgroundCommand": "Background: {{command}}",
"chat.tool.checkTask": "Check task {{id}}",
"chat.tool.killTask": "Kill task {{id}}",
"chat.asyncSubagentComplete": "Background sub-agent finished",
"chat.tool.webSearch": "Search web: \"{{query}}\"",
"chat.tool.fetchUrl": "Fetch {{hostname}}",
"chat.tool.fetchUrlFallback": "Fetch URL",
@@ -807,6 +808,10 @@
"admin.subagentsHint": "Allow the AI to delegate tasks to sub-agents. Each sub-agent creates a real chat with full tool access. Uses additional LLM calls.",
"admin.subagentsMaxConcurrent": "Max concurrent",
"admin.subagentsMaxConcurrentHint": "simultaneous sub-agents",
"admin.subagentsBackgroundEnabled": "Enable background sub-agents",
"admin.subagentsBackgroundHint": "Allow delegated sub-agents to keep running while the parent chat continues.",
"admin.subagentsMaxAsync": "Max background",
"admin.subagentsMaxAsyncHint": "background sub-agents",
"admin.subagentsMaxIterations": "Max iterations",
"admin.subagentsMaxIterationsHint": "tool loops per sub-agent",
"admin.subagentsMaxOutput": "Max output",