This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-06 19:41:37 -05:00
1 parent 97bb12095d
commit ef7ea5f828
14 files changed
+373 -30

No files matched your search

+9
View File
@@ -36,9 +36,18 @@ export interface ContextUsage {
source: 'estimated';
}
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
export interface ChatTask {
id: string;
content: string;
status: TaskStatus;
}
export interface ChatDetail {
chat: ChatInfo;
messages: ChatMessageRow[];
tasks?: ChatTask[];
context_usage?: ContextUsage | null;
}
@@ -86,6 +86,7 @@
{ id: 'memory', label: 'models.builtinTools.memory', desc: 'models.builtinTools.memoryDesc' },
{ id: 'chats', label: 'models.builtinTools.chats', desc: 'models.builtinTools.chatsDesc' },
{ id: 'skills', label: 'models.builtinTools.skills', desc: 'models.builtinTools.skillsDesc' },
{ id: 'tasks', label: 'models.builtinTools.tasks', desc: 'models.builtinTools.tasksDesc' },
{
id: 'automations',
label: 'models.builtinTools.automations',
@@ -11,8 +11,8 @@
let enabled = $state(false);
let backgroundEnabled = $state(false);
let maxConcurrent = $state(3);
let maxAsync = $state(3);
let maxConcurrent = $state(20);
let maxAsync = $state(20);
let maxIterations = $state(30);
let maxOutput = $state(30000);
let systemPrompt = $state('');
@@ -24,8 +24,8 @@
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;
maxConcurrent = Number(config['subagents.max_concurrent']) || 20;
maxAsync = Number(config['subagents.max_async']) || 20;
maxIterations = Number(config['subagents.max_iterations']) || 30;
maxOutput = Number(config['subagents.max_output']) || 30000;
systemPrompt = (config['subagents.system_prompt'] as string) || '';
@@ -87,7 +87,7 @@
type="number"
bind:value={maxConcurrent}
min="1"
max="10"
max="100"
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-[0.6875rem] text-gray-400 dark:text-gray-600"
@@ -124,7 +124,7 @@
type="number"
bind:value={maxAsync}
min="1"
max="10"
max="100"
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-[0.6875rem] text-gray-400 dark:text-gray-600"
@@ -5,6 +5,7 @@
import OutputEditView from './OutputEditView.svelte';
import ChatFilePreview from './ChatFilePreview.svelte';
import ConsecutiveActivityGroup from './ConsecutiveActivityGroup.svelte';
import MessageTimestamp from './MessageTimestamp.svelte';
import ReasoningCollapsible from './ReasoningCollapsible.svelte';
import ToolCallCollapsible from './ToolCallCollapsible.svelte';
import { currentWorkspace, openFileTab } from '$lib/stores';
@@ -21,6 +22,7 @@
usage: Record<string, number> | null;
chatId: string | null;
messageId: string;
createdAt?: number | null;
siblingIndex?: number;
siblingTotal?: number;
speaking?: boolean;
@@ -37,6 +39,7 @@
usage,
chatId,
messageId,
createdAt = null,
siblingIndex = 0,
siblingTotal = 1,
speaking = false,
@@ -593,7 +596,7 @@
<!-- Controls toolbar -->
{#if done || siblingTotal > 1}
<div class="flex items-center gap-1 mt-1 -ml-0.5">
<div class="group/timestamp-toolbar flex items-center gap-1 mt-1 -ml-0.5">
{#if siblingTotal > 1}
<button
class="p-0.5 rounded text-gray-400 dark:text-gray-600 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-default transition-colors duration-100"
@@ -784,6 +787,7 @@
>
</button>
{/if}
<MessageTimestamp {createdAt} />
</div>
{/if}
{/if}
@@ -20,12 +20,13 @@
import { searchFiles } from '$lib/apis/files';
import { getSkills } from '$lib/apis/skills';
import { uploadFile } from '$lib/apis/files';
import type { ContextUsage } from '$lib/apis/chat';
import type { ChatTask, ContextUsage } from '$lib/apis/chat';
import ModelSelector from '../common/ModelSelector.svelte';
import SendButton from './SendButton.svelte';
import PlusMenu from './PlusMenu.svelte';
import DictateButton from './DictateButton.svelte';
import QueuedMessageItem from './QueuedMessageItem.svelte';
import Tasks from './Tasks.svelte';
import Icon from '../Icon.svelte';
import { planMode } from '$lib/stores';
import {
@@ -69,6 +70,7 @@
workspace?: string;
placeholder?: string;
contextUsage?: ContextUsage | null;
tasks?: ChatTask[];
queuedMessages?: { id: string; content: string }[];
onsend: () => void;
oncompact?: () => void;
@@ -88,6 +90,7 @@
workspace = '',
placeholder = 'Message...',
contextUsage = null,
tasks = [],
queuedMessages = [],
onsend,
oncompact,
@@ -1003,6 +1006,12 @@
}}
role="presentation"
>
{#if tasks.length > 0}
<div class="mx-1">
<Tasks {tasks} />
</div>
{/if}
<!-- Queued messages (above input, matching open-webui layout) -->
{#if queuedMessages.length > 0}
<div
@@ -1031,7 +1040,10 @@
<button
type="button"
aria-label="Compact: shorten older messages so this chat can keep going."
use:tooltip={{ content: 'Shorten older messages so this chat can keep going.', placement: 'right' }}
use:tooltip={{
content: 'Shorten older messages so this chat can keep going.',
placement: 'right'
}}
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
{slashCommandIds[selectedSlashCommandIndex] === 'compact'
? 'app-interactive-active'
@@ -1164,9 +1176,7 @@
placement: 'right'
}}
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
{slashCommandIds[selectedSlashCommandIndex] === 'skills:list'
? 'app-interactive-active'
: ''}"
{slashCommandIds[selectedSlashCommandIndex] === 'skills:list' ? 'app-interactive-active' : ''}"
onmousedown={(e) => e.preventDefault()}
onclick={() => {
runSlashCommand('skills:list');
@@ -1191,14 +1201,13 @@
placement: 'right'
}}
class="slash-command-row flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs text-left transition-colors duration-75
{slashCommandIds[selectedSlashCommandIndex] === 'skills:create'
? 'app-interactive-active'
: ''}"
{slashCommandIds[selectedSlashCommandIndex] === 'skills:create' ? 'app-interactive-active' : ''}"
onmousedown={(e) => e.preventDefault()}
onclick={() => {
runSlashCommand('skills:create');
}}
onmouseenter={() => (selectedSlashCommandIndex = slashCommandIds.indexOf('skills:create'))}
onmouseenter={() =>
(selectedSlashCommandIndex = slashCommandIds.indexOf('skills:create'))}
>
<span class="app-icon-muted flex items-center justify-center w-4 shrink-0">
<Icon name="plus" size={14} />
@@ -15,7 +15,8 @@
type ChatMessageRow,
type ChatSendParams,
type ChatInfo,
type ContextUsage
type ContextUsage,
type ChatTask
} from '$lib/apis/chat';
import {
chatModels,
@@ -80,6 +81,7 @@
let allMessages = $state<ChatMessageRow[]>([]);
let currentMessageId = $state<string | null>(null);
let contextUsage = $state<ContextUsage | null>(null);
let chatTasks = $state<ChatTask[]>([]);
let showStatusModal = $state(false);
let showSkillsModal = $state(false);
let skillsModalList = $state<SkillInfo[]>([]);
@@ -107,6 +109,7 @@
let speakingMessageId = $state<string | null>(null);
let ttsStopRequested = false;
let commandSessionsChatId: string | null = null;
let taskClearTimer: ReturnType<typeof setTimeout> | null = null;
// This browser memory cache only helps while the current page is open, such as when
// someone taps the same speak button twice. The backend cache is the durable source
// for cross-session reuse and the workspace data flywheel.
@@ -315,6 +318,23 @@
.map((m) => ({ id: m.id, content: m.content }))
);
function setChatTasks(tasks: ChatTask[]) {
if (taskClearTimer) {
clearTimeout(taskClearTimer);
taskClearTimer = null;
}
chatTasks = tasks;
if (
tasks.length > 0 &&
!tasks.some((task) => task.status === 'pending' || task.status === 'in_progress')
) {
taskClearTimer = setTimeout(() => {
taskClearTimer = null;
chatTasks = [];
}, 4000);
}
}
$effect(() => {
if (chatId === commandSessionsChatId) return;
commandSessionsChatId = chatId;
@@ -345,6 +365,13 @@
allMessages = data.messages;
currentMessageId = data.chat.current_message_id;
contextUsage = data.context_usage ?? null;
setChatTasks(
(data.tasks ?? []).some(
(task) => task.status === 'pending' || task.status === 'in_progress'
)
? (data.tasks ?? [])
: []
);
// Update tab label with the real title from the DB
if (tabId && data.chat.title) {
chatTitle = data.chat.title;
@@ -418,10 +445,12 @@
let landingRefreshTimer: ReturnType<typeof setTimeout> | null = null;
function handleSocketEvent(data: {
type?: string;
chat_id: string;
message_id: string;
message_id?: string;
delta?: string;
output?: any;
tasks?: ChatTask[];
done?: boolean;
error?: string;
pending_inputs_processed?: boolean;
@@ -454,6 +483,11 @@
if (data.chat_id !== chatId) return;
if (data.type === 'chat:tasks') {
setChatTasks(data.tasks ?? []);
return;
}
// Title generated by backend — update tab label
if (data.title && tabId) {
updateTab(tabId, data.chat_id, data.title);
@@ -465,6 +499,7 @@
return;
}
if (!data.message_id) return;
const msg = allMessages.find((m) => m.id === data.message_id);
if (!msg) return;
@@ -535,6 +570,9 @@
// the DB reload returns. This avoids a transient blank message if the
// final `done` socket event beats the commit/read path.
msg.done = true;
if (chatTasks.some((task) => task.status === 'pending' || task.status === 'in_progress')) {
setChatTasks([]);
}
allMessages = [...allMessages];
loadChat(data.chat_id);
}
@@ -577,6 +615,7 @@
commandSessionsTimer = null;
window.removeEventListener('cptr:inspect-command-session', handleInspectCommandSession);
if (landingRefreshTimer) clearTimeout(landingRefreshTimer);
if (taskClearTimer) clearTimeout(taskClearTimer);
// Don't clear streamingChatTabs here -- the global listener in
// chat.ts handles cleanup when the "done" event arrives, so the
// spinner persists even when the chat tab is not active.
@@ -1481,6 +1520,7 @@
{sending}
{workspace}
placeholder={$t('chat.placeholder', { name: workspaceDisplayName })}
tasks={chatTasks}
onsend={send}
onstatus={handleStatusCommand}
{queuedMessages}
@@ -1524,6 +1564,7 @@
<UserMessage
content={msg.content}
meta={msg.meta}
createdAt={msg.created_at}
{siblingIndex}
siblingTotal={siblingIds.length}
onnavigate={(dir) => handleNavigate(msg.id, dir)}
@@ -1537,6 +1578,7 @@
usage={msg.usage}
{chatId}
messageId={msg.id}
createdAt={msg.created_at}
{siblingIndex}
siblingTotal={siblingIds.length}
speaking={speakingMessageId === msg.id}
@@ -1590,6 +1632,7 @@
{streaming}
{workspace}
{contextUsage}
tasks={chatTasks}
onsend={send}
oncompact={handleManualCompact}
onplan={handlePlanCommand}
@@ -0,0 +1,48 @@
<script lang="ts">
import { tooltip } from '$lib/tooltip';
interface Props {
createdAt?: number | null;
side?: 'left' | 'right';
}
let { createdAt = null, side = 'right' }: Props = $props();
function toDate(ts: number | null | undefined): Date | null {
if (!ts) return null;
const date = new Date(ts < 1_000_000_000_000 ? ts * 1000 : ts);
return Number.isNaN(date.getTime()) ? null : date;
}
const date = $derived(toDate(createdAt));
const label = $derived(
date?.toLocaleString(undefined, {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit'
}) ?? ''
);
const fullLabel = $derived(
date?.toLocaleString(undefined, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: '2-digit'
}) ?? ''
);
</script>
{#if date && label}
<time
datetime={date.toISOString()}
class="{side === 'left'
? 'mr-1'
: 'ml-1'} text-[0.6875rem] tabular-nums text-gray-400 dark:text-gray-600 select-none opacity-0 pointer-events-none transition-opacity duration-100 group-hover/timestamp-toolbar:opacity-100 group-hover/timestamp-toolbar:pointer-events-auto group-focus-within/timestamp-toolbar:opacity-100 group-focus-within/timestamp-toolbar:pointer-events-auto"
use:tooltip={fullLabel}
>
{label}
</time>
{/if}
@@ -0,0 +1,70 @@
<script lang="ts">
import Icon from '../Icon.svelte';
import { t } from '$lib/i18n';
import type { ChatTask } from '$lib/apis/chat';
interface Props {
tasks: ChatTask[];
}
let { tasks }: Props = $props();
let collapsed = $state(false);
const completedCount = $derived(tasks.filter((task) => task.status === 'completed').length);
const totalCount = $derived(tasks.length);
</script>
{#if tasks.length > 0}
<div class="app-subtle-surface my-1 overflow-hidden rounded-3xl border shadow-sm">
<div class="flex items-center justify-between px-3.5 pt-1.5 pb-1">
<div class="app-muted flex min-w-0 items-center gap-2 text-xs">
<Icon name="list" size={14} />
<span class="truncate">
{completedCount}
{$t('chat.tasksOutOf')}
{totalCount}
{$t('chat.tasksCompleted')}
</span>
</div>
<button
type="button"
class="app-muted flex size-6 items-center justify-center rounded-full bg-transparent transition-colors hover:text-gray-600 dark:hover:text-gray-300"
onclick={() => (collapsed = !collapsed)}
aria-label={collapsed ? $t('chat.tasksExpand') : $t('chat.tasksCollapse')}
>
<Icon name={collapsed ? 'chevron-down' : 'chevron-up'} size={12} />
</button>
</div>
{#if !collapsed}
<div class="space-y-1 px-2.5 pb-3">
{#each tasks as task, idx (task.id)}
<div class="flex items-start gap-2 rounded-2xl px-1 py-0.5 text-xs">
<span class="app-muted mt-0.5 flex size-3.5 shrink-0 items-center justify-center">
{#if task.status === 'completed'}
<Icon name="check" size={14} strokeWidth={2.5} />
{:else if task.status === 'in_progress'}
<span
class="size-3 rounded-full border-2 border-current border-t-transparent opacity-70 animate-spin"
></span>
{:else if task.status === 'cancelled'}
<span class="size-3 rounded-full border border-dashed border-current"></span>
{:else}
<span class="size-3 rounded-full border border-current"></span>
{/if}
</span>
<span
class="line-clamp-2 {task.status === 'completed'
? 'app-muted line-through'
: task.status === 'cancelled'
? 'app-muted line-through'
: 'text-gray-700 dark:text-gray-300'}"
>
{idx + 1}. {task.content}
</span>
</div>
{/each}
</div>
{/if}
</div>
{/if}
@@ -1,6 +1,7 @@
<script lang="ts">
import { tick } from 'svelte';
import Icon from '../Icon.svelte';
import MessageTimestamp from './MessageTimestamp.svelte';
import { fileIconName } from '$lib/utils/fileIcon';
import { openFileTab, setFileBrowserCwd, setActiveTab } from '$lib/stores';
import { t } from '$lib/i18n';
@@ -8,6 +9,7 @@
interface Props {
content: string;
meta?: Record<string, any> | null;
createdAt?: number | null;
siblingIndex?: number;
siblingTotal?: number;
onedit?: (content: string, submit: boolean) => void;
@@ -16,6 +18,7 @@
let {
content,
meta = null,
createdAt = null,
siblingIndex = 0,
siblingTotal = 1,
onedit,
@@ -240,7 +243,10 @@
</div>
</div>
{#if siblingTotal > 1 || onedit}
<div class="flex justify-end items-center gap-1 mt-0.5 invisible group-hover:visible">
<div
class="group/timestamp-toolbar flex w-full justify-end items-center gap-1 mt-1 invisible group-hover:visible"
>
<MessageTimestamp {createdAt} side="left" />
{#if siblingTotal > 1}
<button
class="p-0.5 rounded text-gray-400 dark:text-gray-600 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-default transition-colors duration-100"
@@ -577,6 +577,10 @@
"chat.tool.backgroundCommand": "Background: {{command}}",
"chat.tool.checkTask": "Check task {{id}}",
"chat.tool.killTask": "Kill task {{id}}",
"chat.tasksOutOf": "out of",
"chat.tasksCompleted": "tasks completed",
"chat.tasksExpand": "Expand tasks",
"chat.tasksCollapse": "Collapse tasks",
"chat.asyncSubagentComplete": "Background sub-agent finished",
"chat.tool.webSearch": "Search web: \"{{query}}\"",
"chat.tool.fetchUrl": "Fetch {{hostname}}",
@@ -923,6 +927,8 @@
"models.builtinTools.chatsDesc": "Search previous chats",
"models.builtinTools.skills": "Skills",
"models.builtinTools.skillsDesc": "View and manage Computer skills",
"models.builtinTools.tasks": "Tasks",
"models.builtinTools.tasksDesc": "Show visible task progress in chat",
"models.builtinTools.automations": "Automations",
"models.builtinTools.automationsDesc": "List and manage scheduled automations",
"models.builtinTools.images": "Images",