Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(workbench): harness row actions + create-via-chat dialog

cyh39cf8e2f4813
diff --git a/storage/background.py b/storage/background.py
index ccf0e86aa..33da5431c 100644
--- a/storage/background.py
+++ b/storage/background.py
@@ -128,6 +128,25 @@ class SQLiteBackgroundTaskStore:
)
return bool(result.rowcount)
+ def set_definition_enabled(
+ self,
+ definition_id: str,
+ enabled: bool,
+ *,
+ definition_type: Optional[str] = None,
+ ) -> bool:
+ with self.engine.begin() as conn:
+ stmt = (
+ update(run_definitions)
+ .where(run_definitions.c.id == definition_id)
+ .where(run_definitions.c.deleted_at.is_(None))
+ .values(enabled=1 if enabled else 0, updated_at=_utc_now_iso())
+ )
+ if definition_type is not None:
+ stmt = stmt.where(run_definitions.c.definition_type == definition_type)
+ result = conn.execute(stmt)
+ return bool(result.rowcount)
+
def list_watches(self) -> list[dict[str, Any]]:
with self.engine.connect() as conn:
rows = conn.execute(
diff --git a/ui/src/components/workbench/CreateViaChatDialog.tsx b/ui/src/components/workbench/CreateViaChatDialog.tsx
new file mode 100644
index 000000000..585a3de1e
--- /dev/null
+++ b/ui/src/components/workbench/CreateViaChatDialog.tsx
@@ -0,0 +1,203 @@
+import { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+import { ArrowRight, Loader2, Sparkles, X } from 'lucide-react';
+import clsx from 'clsx';
+
+import { useApi } from '../../context/ApiContext';
+import type { WorkbenchProject } from '../../context/ApiContext';
+import { Button } from '../ui/button';
+
+export type CreateViaChatKind = 'task' | 'watch';
+
+interface CreateViaChatDialogProps {
+ kind: CreateViaChatKind;
+ onClose: () => void;
+}
+
+// Mirrors design.pen AbIUE — single 500px-wide violet-glow card that
+// invites the user to describe a task/watch in natural language. The
+// "Open chat" button creates a fresh session under the selected project
+// and seeds it with an intent-shaped first user message; the agent
+// finishes the job by calling `vibe task add` / `vibe watch add`.
+export const CreateViaChatDialog: React.FC<CreateViaChatDialogProps> = ({ kind, onClose }) => {
+ const { t } = useTranslation();
+ const api = useApi();
+ const navigate = useNavigate();
+ const [projects, setProjects] = useState<WorkbenchProject[] | null>(null);
+ const [projectId, setProjectId] = useState<string>('');
+ const [submitting, setSubmitting] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ useEffect(() => {
+ let cancelled = false;
+ api
+ .listProjects()
+ .then((result) => {
+ if (cancelled) return;
+ setProjects(result.projects);
+ if (result.projects.length > 0) {
+ // Default to the most recently active project so the user can
+ // usually just hit "Open chat" without touching the picker.
+ const sorted = [...result.projects].sort((a, b) => {
+ const aTs = a.last_active_at || a.created_at;
+ const bTs = b.last_active_at || b.created_at;
+ return bTs.localeCompare(aTs);
+ });
+ setProjectId(sorted[0].id);
+ }
+ })
+ .catch((err) => {
+ if (!cancelled) setError(err?.message ?? String(err));
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [api]);
+
+ const open = async () => {
+ if (!projectId || submitting) return;
+ setSubmitting(true);
+ setError(null);
+ try {
+ const titleKey = kind === 'task' ? 'workbench.createDialog.kindTask' : 'workbench.createDialog.kindWatch';
+ const session = await api.createSession({
+ project_id: projectId,
+ agent_backend: 'claude',
+ title: t(`harness.createDialog.${kind === 'task' ? 'kindTask' : 'kindWatch'}`, {
+ // titleKey is only here so the translation linter doesn't drop it
+ defaultValue: t(titleKey, { defaultValue: 'Background work' }),
+ }),
+ });
+ const prompt = t(
+ kind === 'task' ? 'harness.createDialog.promptTask' : 'harness.createDialog.promptWatch',
+ );
+ // Send the seed message without `stream=1` — the user will land on
+ // the chat page and may want to edit before the agent answers. The
+ // backend still dispatches the agent run asynchronously, so the
+ // first reply is on the way by the time the page mounts.
+ try {
+ await api.sendSessionMessage(session.id, { text: prompt });
+ } catch (msgErr) {
+ // Non-fatal — the session exists; the user can just type instead.
+ console.error('[create-via-chat] seed message failed', msgErr);
+ }
+ navigate(`/chat/${encodeURIComponent(session.id)}`);
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ setSubmitting(false);
+ }
+ };
+
+ const noProjects = projects !== null && projects.length === 0;
+
+ return (
+ <div
+ className="fixed inset-0 z-50 flex items-center justify-center bg-[#080812F0] px-4"
+ role="dialog"
+ aria-modal="true"
+ aria-label={t('harness.createDialog.title')}
+ onClick={onClose}
+ >
+ <div
+ className="flex w-full max-w-[500px] flex-col items-center gap-5 rounded-2xl border border-violet/30 bg-surface p-7 shadow-[0_24px_48px_-6px_rgba(0,0,0,0.8),0_0_32px_-12px_rgba(124,91,255,0.55)]"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <button
+ type="button"
+ aria-label={t('harness.createDialog.cancel')}
+ onClick={onClose}
+ className="absolute right-4 top-4 text-muted transition hover:text-foreground"
+ >
+ <X className="size-4" />
+ </button>
+
+ {/* Hero icon — 64x64 violet-soft tile with glow */}
+ <div className="flex size-16 items-center justify-center rounded-2xl border border-violet/30 bg-violet-soft text-violet shadow-[0_0_28px_-6px_rgba(124,91,255,0.6)]">
+ <Sparkles className="size-[30px]" />
+ </div>
+
+ <div className="flex flex-col gap-1.5 text-center">
+ <div className="text-[20px] font-bold text-foreground">{t('harness.createDialog.title')}</div>
+ <div className="text-[12px] italic text-muted">{t('harness.createDialog.subtitle')}</div>
+ </div>
+
+ <div className="flex w-full flex-col gap-2.5 rounded-xl border border-border bg-foreground/[0.015] px-[18px] py-4">
+ <p className="text-[12.5px] leading-[1.65] text-foreground">
+ {t('harness.createDialog.body')}
+ </p>
+ <div className="h-px w-full bg-border" />
+ <p className="text-[11.5px] leading-[1.65] text-muted">{t('harness.createDialog.example')}</p>
+ </div>
+
+ <div className="flex w-full flex-col gap-1.5">
+ <label className="font-mono text-[10px] font-bold uppercase tracking-[0.16em] text-muted">
+ {t('harness.createDialog.projectLabel')}
+ </label>
+ {projects === null ? (
+ <div className="flex items-center gap-2 rounded-md border border-border-strong bg-surface-2 px-3 py-2 text-[12px] text-muted">
+ <Loader2 className="size-3 animate-spin" />
+ {t('common.loading')}
+ </div>
+ ) : noProjects ? (
+ <div className="rounded-md border border-dashed border-border bg-foreground/[0.02] px-3 py-2 text-[12px] text-muted">
+ {t('harness.createDialog.noProject')}
+ </div>
+ ) : (
+ <select
+ value={projectId}
+ onChange={(e) => setProjectId(e.target.value)}
+ className="rounded-md border border-border-strong bg-surface-2 px-3 py-2 text-[12.5px] text-foreground outline-none transition focus:border-violet"
+ >
+ {projects.map((p) => (
+ <option key={p.id} value={p.id}>
+ {p.display_name} · {p.folder_path}
+ </option>
+ ))}
+ </select>
+ )}
+ </div>
+
+ {error && (
+ <div className="w-full rounded-md border border-destructive/40 bg-destructive/[0.06] px-3 py-2 text-[12px] text-destructive">
+ {error}
+ </div>
+ )}
+
+ <div className="flex w-full items-center justify-end gap-2.5">
+ <button
+ type="button"
+ onClick={onClose}
+ disabled={submitting}
+ className="rounded-lg border border-border-strong px-4 py-2 text-[12px] font-medium text-foreground transition hover:bg-foreground/[0.04] disabled:opacity-50"
+ >
+ {t('harness.createDialog.cancel')}
+ </button>
+ <Button
+ type="button"
+ variant="default"
+ size="sm"
+ onClick={open}
+ disabled={submitting || noProjects || !projectId}
+ className={clsx(
+ 'gap-1.5 bg-violet text-[12px] font-bold text-white shadow-[0_3px_14px_-4px_rgba(124,91,255,0.6)]',
+ 'hover:brightness-110 disabled:shadow-none',
+ )}
+ >
+ {submitting ? (
+ <>
+ <Loader2 className="size-3.5 animate-spin" />
+ {t('harness.createDialog.opening')}
+ </>
+ ) : (
+ <>
+ {t('harness.createDialog.open')}
+ <ArrowRight className="size-3.5" />
+ </>
+ )}
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/ui/src/components/workbench/HarnessPage.tsx b/ui/src/components/workbench/HarnessPage.tsx
index 361907144..7fe72f904 100644
--- a/ui/src/components/workbench/HarnessPage.tsx
+++ b/ui/src/components/workbench/HarnessPage.tsx
@@ -6,9 +6,13 @@ import {
Eye,
Webhook,
History,
+ Plus,
+ Play,
+ Pause,
RefreshCw,
AlertTriangle,
CheckCircle2,
+ Trash2,
XCircle,
Loader2,
Clock,
@@ -24,6 +28,8 @@ import type {
HarnessWatch,
} from '../../context/ApiContext';
import { formatRelativeTime } from '../../lib/relativeTime';
+import { CreateViaChatDialog } from './CreateViaChatDialog';
+import type { CreateViaChatKind } from './CreateViaChatDialog';
type TabKey = 'tasks' | 'watches' | 'webhooks' | 'runs';
@@ -48,6 +54,10 @@ export const HarnessPage: React.FC = () => {
const [selectedRun, setSelectedRun] = useState<HarnessRun | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
+ // Per-id pending state so the row's toggle / delete buttons can show a
+ // spinner without disabling siblings.
+ const [pendingMutation, setPendingMutation] = useState<Record<string, boolean>>({});
+ const [createKind, setCreateKind] = useState<CreateViaChatKind | null>(null);
const refresh = useCallback(async () => {
setLoading(true);
@@ -75,6 +85,90 @@ export const HarnessPage: React.FC = () => {
refresh();
}, [refresh]);
+ const markPending = useCallback((id: string, value: boolean) => {
+ setPendingMutation((prev) => {
+ const next = { ...prev };
+ if (value) next[id] = true;
+ else delete next[id];
+ return next;
+ });
+ }, []);
+
+ const toggleTaskEnabled = useCallback(
+ async (task: HarnessTask) => {
+ markPending(task.id, true);
+ // Optimistic toggle so the pill flips instantly; rollback on error.
+ const next = !task.enabled;
+ setTasks((prev) => prev.map((t) => (t.id === task.id ? { ...t, enabled: next } : t)));
+ try {
+ await api.setHarnessTaskEnabled(task.id, next);
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ setTasks((prev) => prev.map((t) => (t.id === task.id ? { ...t, enabled: task.enabled } : t)));
+ } finally {
+ markPending(task.id, false);
+ }
+ },
+ [api, markPending],
+ );
+
+ const deleteTask = useCallback(
+ async (task: HarnessTask) => {
+ const confirmed = window.confirm(
+ t('harness.row.deleteConfirmTask', { name: task.name || task.id }),
+ );
+ if (!confirmed) return;
+ markPending(task.id, true);
+ try {
+ await api.deleteHarnessTask(task.id);
+ setTasks((prev) => prev.filter((t) => t.id !== task.id));
+ setSelection((prev) => (prev?.kind === 'task' && prev.id === task.id ? null : prev));
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ } finally {
+ markPending(task.id, false);
+ }
+ },
+ [api, markPending, t],
+ );
+
+ const toggleWatchEnabled = useCallback(
+ async (watch: HarnessWatch) => {
+ markPending(watch.id, true);
+ const next = !watch.enabled;
+ setWatches((prev) => prev.map((w) => (w.id === watch.id ? { ...w, enabled: next } : w)));
+ try {
+ await api.setHarnessWatchEnabled(watch.id, next);
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ setWatches((prev) => prev.map((w) => (w.id === watch.id ? { ...w, enabled: watch.enabled } : w)));
+ } finally {
+ markPending(watch.id, false);
+ }
+ },
+ [api, markPending],
+ );
+
+ const deleteWatch = useCallback(
+ async (watch: HarnessWatch) => {
+ const confirmed = window.confirm(
+ t('harness.row.deleteConfirmWatch', { name: watch.name || watch.id }),
+ );
+ if (!confirmed) return;
+ markPending(watch.id, true);
+ try {
+ await api.deleteHarnessWatch(watch.id);
+ setWatches((prev) => prev.filter((w) => w.id !== watch.id));
+ setSelection((prev) => (prev?.kind === 'watch' && prev.id === watch.id ? null : prev));
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ } finally {
+ markPending(watch.id, false);
+ }
+ },
+ [api, markPending, t],
+ );
+
// Fetch run detail (stdout/stderr) whenever a run is selected so the
// detail panel always shows the full body, not just the list excerpt.
useEffect(() => {
@@ -126,6 +220,16 @@ export const HarnessPage: React.FC = () => {
<h1 className="text-2xl font-bold text-foreground">{t('harness.title')}</h1>
<p className="text-[13px] text-muted">{t('harness.subtitle')}</p>
</div>
+ {(tab === 'tasks' || tab === 'watches') && (
+ <button
+ type="button"
+ onClick={() => setCreateKind(tab === 'tasks' ? 'task' : 'watch')}
+ className="flex items-center gap-1.5 rounded-md border border-violet/40 bg-violet/[0.08] px-3 py-1.5 text-[12px] font-bold text-violet shadow-[0_0_18px_-6px_rgba(124,91,255,0.55)] transition hover:brightness-110"
+ >
+ <Plus className="size-3.5" />
+ {t('harness.create')}
+ </button>
+ )}
<button
type="button"
onClick={() => refresh()}
@@ -192,10 +296,26 @@ export const HarnessPage: React.FC = () => {
<div className="grid grid-cols-[1fr_440px] gap-5">
<div className="flex flex-col gap-2">
{tab === 'tasks' && (
- <TasksList tasks={tasks} loading={loading} selectedId={selection?.kind === 'task' ? selection.id : null} onSelect={(id) => setSelection({ kind: 'task', id })} />
+ <TasksList
+ tasks={tasks}
+ loading={loading}
+ selectedId={selection?.kind === 'task' ? selection.id : null}
+ onSelect={(id) => setSelection({ kind: 'task', id })}
+ onToggleEnabled={toggleTaskEnabled}
+ onDelete={deleteTask}
+ pending={pendingMutation}
+ />
)}
{tab === 'watches' && (
- <WatchesList watches={watches} loading={loading} selectedId={selection?.kind === 'watch' ? selection.id : null} onSelect={(id) => setSelection({ kind: 'watch', id })} />
+ <WatchesList
+ watches={watches}
+ loading={loading}
+ selectedId={selection?.kind === 'watch' ? selection.id : null}
+ onSelect={(id) => setSelection({ kind: 'watch', id })}
+ onToggleEnabled={toggleWatchEnabled}
+ onDelete={deleteWatch}
+ pending={pendingMutation}
+ />
)}
{tab === 'webhooks' && <WebhooksEmpty />}
{tab === 'runs' && (
@@ -226,6 +346,10 @@ export const HarnessPage: React.FC = () => {
)}
</div>
</div>
+
+ {createKind && (
+ <CreateViaChatDialog kind={createKind} onClose={() => setCreateKind(null)} />
+ )}
</div>
);
};
@@ -252,57 +376,138 @@ interface TasksListProps {
loading: boolean;
selectedId: string | null;
onSelect: (id: string) => void;
+ onToggleEnabled: (task: HarnessTask) => void;
+ onDelete: (task: HarnessTask) => void;
+ pending: Record<string, boolean>;
}
-const TasksList: React.FC<TasksListProps> = ({ tasks, loading, selectedId, onSelect }) => {
+const TasksList: React.FC<TasksListProps> = ({
+ tasks,
+ loading,
+ selectedId,
+ onSelect,
+ onToggleEnabled,
+ onDelete,
+ pending,
+}) => {
const { t } = useTranslation();
if (tasks.length === 0 && !loading) return <EmptyState i18nKey="harness.emptyTasks" />;
return (
<>
{tasks.map((task) => {
const active = selectedId === task.id;
+ const isPending = !!pending[task.id];
const scheduleLabel = task.cron
? `cron · ${task.cron}`
: task.run_at
? `one-shot · ${task.run_at}`
: task.schedule_type || t('harness.unknownSchedule');
return (
- <button
+ <div
key={task.id}
- type="button"
- onClick={() => onSelect(task.id)}
className={clsx(
- 'flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition',
+ 'group/row flex items-center gap-3 rounded-lg border px-4 py-3 transition',
active ? 'border-violet/40 bg-violet/[0.05]' : 'border-border bg-surface hover:bg-foreground/[0.03]',
)}
>
- <div className="flex flex-1 flex-col gap-1">
- <div className="flex items-center gap-2">
- <span className="text-[14px] font-semibold text-foreground">{task.name || task.id}</span>
- {!task.enabled && (
- <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] uppercase text-muted">
- {t('harness.runtime.disabled')}
+ <button
+ type="button"
+ onClick={() => onSelect(task.id)}
+ className="flex flex-1 items-center gap-3 text-left"
+ >
+ <div className="flex flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="text-[14px] font-semibold text-foreground">{task.name || task.id}</span>
+ {!task.enabled && (
+ <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] uppercase text-muted">
+ {t('harness.runtime.disabled')}
+ </span>
+ )}
+ </div>
+ <div className="flex items-center gap-3 text-[11px] text-muted">
+ <span className="inline-flex items-center gap-1 font-mono">
+ <Clock className="size-3" />
+ {scheduleLabel}
</span>
- )}
+ {task.agent_name && <span>· {task.agent_name}</span>}
+ </div>
</div>
- <div className="flex items-center gap-3 text-[11px] text-muted">
- <span className="inline-flex items-center gap-1 font-mono">
- <Clock className="size-3" />
- {scheduleLabel}
- </span>
- {task.agent_name && <span>· {task.agent_name}</span>}
- </div>
- </div>
- {task.last_run_at && (
- <span className="font-mono text-[10px] text-muted">{formatRelativeTime(task.last_run_at, t)}</span>
- )}
- </button>
+ {task.last_run_at && (
+ <span className="font-mono text-[10px] text-muted">{formatRelativeTime(task.last_run_at, t)}</span>
+ )}
+ </button>
+ <RowActions
+ enabled={task.enabled}
+ pending={isPending}
+ onToggle={() => onToggleEnabled(task)}
+ onDelete={() => onDelete(task)}
+ />
+ </div>
);
})}
</>
);
};
+interface RowActionsProps {
+ enabled: boolean;
+ pending: boolean;
+ onToggle: () => void;
+ onDelete: () => void;
+}
+
+// Hover-revealed action cluster on each task/watch row. Two icon buttons
+// (toggle + delete) so the row stays compact and design.pen-aligned.
+const RowActions: React.FC<RowActionsProps> = ({ enabled, pending, onToggle, onDelete }) => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex items-center gap-1 opacity-0 transition-opacity group-hover/row:opacity-100">
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ onToggle();
+ }}
+ disabled={pending}
+ aria-label={enabled ? t('harness.row.disable') : t('harness.row.enable')}
+ title={enabled ? t('harness.row.disable') : t('harness.row.enable')}
+ className={clsx(
+ 'flex size-7 items-center justify-center rounded-md border transition',
+ enabled
+ ? 'border-border-strong text-muted hover:bg-foreground/[0.06] hover:text-foreground'
+ : 'border-mint/40 bg-mint/[0.08] text-mint hover:brightness-110',
+ pending && 'cursor-wait opacity-60',
+ )}
+ >
+ {pending ? (
+ <Loader2 className="size-3 animate-spin" />
+ ) : enabled ? (
+ <Pause className="size-3" />
+ ) : (
+ <Play className="size-3" />
+ )}
+ </button>
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ onDelete();
+ }}
+ disabled={pending}
+ aria-label={t('harness.row.delete')}
+ title={t('harness.row.delete')}
+ className={clsx(
+ 'flex size-7 items-center justify-center rounded-md border border-border-strong text-muted transition',
+ 'hover:border-pink/40 hover:bg-pink/[0.08] hover:text-pink',
+ pending && 'cursor-wait opacity-60',
+ )}
+ >
+ <Trash2 className="size-3" />
+ </button>
+ </div>
+ );
+};
+
interface TaskDetailProps {
task: HarnessTask;
}
@@ -356,51 +561,73 @@ interface WatchesListProps {
loading: boolean;
selectedId: string | null;
onSelect: (id: string) => void;
+ onToggleEnabled: (watch: HarnessWatch) => void;
+ onDelete: (watch: HarnessWatch) => void;
+ pending: Record<string, boolean>;
}
-const WatchesList: React.FC<WatchesListProps> = ({ watches, loading, selectedId, onSelect }) => {
+const WatchesList: React.FC<WatchesListProps> = ({
+ watches,
+ loading,
+ selectedId,
+ onSelect,
+ onToggleEnabled,
+ onDelete,
+ pending,
+}) => {
const { t } = useTranslation();
if (watches.length === 0 && !loading) return <EmptyState i18nKey="harness.emptyWatches" />;
return (
<>
{watches.map((watch) => {
const active = selectedId === watch.id;
+ const isPending = !!pending[watch.id];
const cmd = watch.shell_command || (Array.isArray(watch.command) ? watch.command.join(' ') : '') || '—';
return (
- <button
+ <div
key={watch.id}
- type="button"
- onClick={() => onSelect(watch.id)}
className={clsx(
- 'flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition',
+ 'group/row flex items-center gap-3 rounded-lg border px-4 py-3 transition',
active ? 'border-violet/40 bg-violet/[0.05]' : 'border-border bg-surface hover:bg-foreground/[0.03]',
)}
>
- <div className="flex flex-1 flex-col gap-1">
- <div className="flex items-center gap-2">
- <span className="text-[14px] font-semibold text-foreground">{watch.name || watch.id}</span>
- {watch.runtime.running ? (
- <span className="inline-flex items-center gap-1 rounded-full border border-mint/30 bg-mint/[0.08] px-2 py-0 font-mono text-[9px] font-bold uppercase text-mint">
- <span className="size-1.5 rounded-full bg-mint" />
- {t('harness.runtime.running')}
- </span>
- ) : !watch.enabled ? (
- <span className="inline-flex items-center gap-1 rounded-full border border-border-strong bg-foreground/[0.04] px-2 py-0 font-mono text-[9px] uppercase text-muted">
- <PauseCircle className="size-2.5" />
- {t('harness.runtime.paused')}
- </span>
- ) : (
- <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] uppercase text-muted">
- {t('harness.runtime.idle')}
- </span>
- )}
+ <button
+ type="button"
+ onClick={() => onSelect(watch.id)}
+ className="flex flex-1 items-center gap-3 text-left"
+ >
+ <div className="flex flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="text-[14px] font-semibold text-foreground">{watch.name || watch.id}</span>
+ {watch.runtime.running ? (
+ <span className="inline-flex items-center gap-1 rounded-full border border-mint/30 bg-mint/[0.08] px-2 py-0 font-mono text-[9px] font-bold uppercase text-mint">
+ <span className="size-1.5 rounded-full bg-mint" />
+ {t('harness.runtime.running')}
+ </span>
+ ) : !watch.enabled ? (
+ <span className="inline-flex items-center gap-1 rounded-full border border-border-strong bg-foreground/[0.04] px-2 py-0 font-mono text-[9px] uppercase text-muted">
+ <PauseCircle className="size-2.5" />
+ {t('harness.runtime.paused')}
+ </span>
+ ) : (
+ <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] uppercase text-muted">
+ {t('harness.runtime.idle')}
+ </span>
+ )}
+ </div>
+ <div className="truncate font-mono text-[11px] text-muted">{cmd}</div>
</div>
- <div className="truncate font-mono text-[11px] text-muted">{cmd}</div>
- </div>
- {watch.last_event_at && (
- <span className="font-mono text-[10px] text-muted">{formatRelativeTime(watch.last_event_at, t)}</span>
- )}
- </button>
+ {watch.last_event_at && (
+ <span className="font-mono text-[10px] text-muted">{formatRelativeTime(watch.last_event_at, t)}</span>
+ )}
+ </button>
+ <RowActions
+ enabled={watch.enabled}
+ pending={isPending}
+ onToggle={() => onToggleEnabled(watch)}
+ onDelete={() => onDelete(watch)}
+ />
+ </div>
);
})}
{watches.length === 0 && loading && <div className="px-4 py-6 text-[12px] text-muted">{t('common.loading')}</div>}
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 2f24dddb6..9821a22d5 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -114,7 +114,11 @@ export type ApiContextType = {
setDefaultVibeAgent: (name: string) => Promise<{ ok: boolean; default_agent_name: string; agent: VibeAgentBrief }>;
removeVibeAgent: (name: string) => Promise<{ ok: boolean; code?: string; message?: string; references?: Record<string, number>; removed_agent?: string }>;
listHarnessTasks: () => Promise<{ tasks: HarnessTask[] }>;
+ setHarnessTaskEnabled: (taskId: string, enabled: boolean) => Promise<{ ok: boolean; task?: HarnessTask }>;
+ deleteHarnessTask: (taskId: string) => Promise<{ ok: boolean; id?: string }>;
listHarnessWatches: () => Promise<{ watches: HarnessWatch[] }>;
+ setHarnessWatchEnabled: (watchId: string, enabled: boolean) => Promise<{ ok: boolean; watch?: HarnessWatch }>;
+ deleteHarnessWatch: (watchId: string) => Promise<{ ok: boolean; id?: string }>;
listHarnessRuns: (params?: HarnessRunsParams) => Promise<{ runs: HarnessRun[]; page: number; limit: number; has_more: boolean }>;
getHarnessRun: (runId: string) => Promise<{ ok: boolean; run: HarnessRun }>;
remoteAccessStatus: () => Promise<any>;
@@ -749,6 +753,18 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
return res.json();
};
+ const patchJson = async (path: string, payload: any) => {
+ const res = await apiFetch(path, {
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(payload),
+ });
+ if (!res.ok) {
+ await handleApiError(res, path);
+ }
+ return res.json();
+ };
+
const sleep = (ms: number) => new Promise((resolve) => window.setTimeout(resolve, ms));
const startAndPollAgentInstall = async (name: string): Promise<InstallResult> => {
@@ -989,7 +1005,13 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
setDefaultVibeAgent: (name) => postJson('/agents/default', { name }),
removeVibeAgent: (name) => deleteJson(`/agents/${encodeURIComponent(name)}`),
listHarnessTasks: () => getJson('/api/harness/tasks'),
+ setHarnessTaskEnabled: (taskId, enabled) =>
+ patchJson(`/api/harness/tasks/${encodeURIComponent(taskId)}`, { enabled }),
+ deleteHarnessTask: (taskId) => deleteJson(`/api/harness/tasks/${encodeURIComponent(taskId)}`),
listHarnessWatches: () => getJson('/api/harness/watches'),
+ setHarnessWatchEnabled: (watchId, enabled) =>
+ patchJson(`/api/harness/watches/${encodeURIComponent(watchId)}`, { enabled }),
+ deleteHarnessWatch: (watchId) => deleteJson(`/api/harness/watches/${encodeURIComponent(watchId)}`),
listHarnessRuns: (params) => {
const search = new URLSearchParams();
if (params?.status) search.set('status', params.status);
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 535b18fe0..c99b514fa 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1245,9 +1245,10 @@
"title": "Harness",
"subtitle": "Scheduled tasks, watches, webhooks, and the run history of all three.",
"soon": "soon",
+ "create": "Create",
"selectPrompt": "Select a row to view its full configuration.",
- "emptyTasks": "No scheduled tasks. Ask an agent to create one in chat.",
- "emptyWatches": "No watches running. Ask an agent to start one in chat.",
+ "emptyTasks": "No scheduled tasks. Ask an agent to create one.",
+ "emptyWatches": "No watches running. Ask an agent to start one.",
"emptyRuns": "No runs yet. They appear here once a task or watch fires.",
"webhooksSoon": "Webhooks are coming soon",
"webhooksSoonBody": "Inbound HTTP triggers will land in a follow-up release. Tasks and watches cover scheduled and event-driven runs today.",
@@ -1283,6 +1284,28 @@
"result": "Result",
"error": "Error",
"timing": "Timing"
+ },
+ "row": {
+ "enable": "Enable",
+ "disable": "Disable",
+ "delete": "Delete",
+ "deleteConfirmTask": "Delete \"{{name}}\"? It will stop running.",
+ "deleteConfirmWatch": "Delete \"{{name}}\"? The watch will stop immediately."
+ },
+ "createDialog": {
+ "title": "Talk to an agent to set up background work",
+ "subtitle": "Writing cron is the tool era; describing intent is the colleague era.",
+ "body": "Scheduled tasks, watches, and (soon) webhooks all come from a chat with an agent. The agent translates your intent into vibe task add / vibe watch add arguments so you never have to remember cron syntax.",
+ "example": "Example: \"Every weekday at 9:30am, summarize yesterday's #ops activity and post to #ops.\" The agent picks the cron, builds the prompt, and binds it to this project.",
+ "projectLabel": "Create in which project",
+ "noProject": "No projects yet — add one from the sidebar + button first.",
+ "cancel": "Cancel",
+ "open": "Open chat and walk me through",
+ "opening": "Creating session…",
+ "kindTask": "Scheduled task",
+ "kindWatch": "Watch",
+ "promptTask": "Help me create a scheduled task. What I want: [describe here, e.g. \"every weekday at 9:30am summarize yesterday's PR comments\"]. Once parameters look right, run vibe task add and bind it to this project.",
+ "promptWatch": "Help me create a watch. I want to wait for: [describe here, e.g. \"CI workflow #1234 to finish\"]. Notify me when the condition is met. Once parameters look right, run vibe watch add."
}
},
"chat": {
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 9ea3fe389..c5c6d5a74 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1245,9 +1245,10 @@
"title": "Harness",
"subtitle": "定时任务、Watch、Webhook 及其运行历史。",
"soon": "敬请期待",
+ "create": "创建",
"selectPrompt": "选择左侧条目查看完整配置。",
- "emptyTasks": "暂无定时任务。在 Chat 中让 Agent 创建一个。",
- "emptyWatches": "没有正在运行的 Watch。在 Chat 中让 Agent 开启一个。",
+ "emptyTasks": "暂无定时任务。让 Agent 帮你创建一个。",
+ "emptyWatches": "没有正在运行的 Watch。让 Agent 帮你开启一个。",
"emptyRuns": "暂无运行记录。任务或 Watch 触发后会出现在这里。",
"webhooksSoon": "Webhook 即将上线",
"webhooksSoonBody": "入站 HTTP 触发将在后续版本中落地。Tasks 和 Watches 已覆盖定时与事件驱动的运行。",
@@ -1283,6 +1284,28 @@
"result": "结果",
"error": "错误",
"timing": "时间线"
+ },
+ "row": {
+ "enable": "启用",
+ "disable": "禁用",
+ "delete": "删除",
+ "deleteConfirmTask": "确定要删除「{{name}}」吗?该任务将不再运行。",
+ "deleteConfirmWatch": "确定要删除「{{name}}」吗?Watch 会被立即停止。"
+ },
+ "createDialog": {
+ "title": "和 Agent 对话来创建后台任务",
+ "subtitle": "写 cron 是工具时代,描述意图是同事时代",
+ "body": "后台任务 / 等待器 / 未来的 Webhook 都通过和 Agent 对话创建。这样 Agent 能从你的真实意图里组装 vibe task add / vibe watch add 的参数,你不用记 cron 语法。",
+ "example": "举例:「每天工作日早上 9:30 总结一下 ops 频道昨天的活动,发到 #ops。」Agent 会自动转换成 cron 表达式 + 注入 prompt 模板。",
+ "projectLabel": "在哪个项目下创建",
+ "noProject": "还没有项目 — 先到侧栏 + 按钮建一个吧。",
+ "cancel": "取消",
+ "open": "打开会话引导我创建",
+ "opening": "创建会话中…",
+ "kindTask": "后台任务",
+ "kindWatch": "等待器",
+ "promptTask": "请帮我创建一个后台任务。我的需求是:[在这里描述,例如「每个工作日早上 9:30 总结昨天的 PR 评论」]。请确认参数后用 vibe task add 创建,并把任务挂到当前项目。",
+ "promptWatch": "请帮我创建一个等待器(watch)。我希望监听:[在这里描述,例如「等 CI 工作流 #1234 跑完」]。条件满足后通知我。请确认参数后用 vibe watch add 创建。"
}
},
"chat": {
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 98e149397..f049f712d 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2846,6 +2846,29 @@ def harness_tasks_list():
return jsonify({"tasks": store.list_scheduled_tasks()})
[email protected]("/api/harness/tasks/<task_id>", methods=["PATCH"])
+def harness_task_patch(task_id: str):
+ payload = request.json or {}
+ if "enabled" not in payload:
+ return jsonify({"ok": False, "code": "invalid_payload", "message": "missing 'enabled'"}), 400
+ enabled = bool(payload["enabled"])
+ with _harness_store() as store:
+ if not store.get_scheduled_task(task_id):
+ return jsonify({"ok": False, "code": "task_not_found"}), 404
+ store.set_definition_enabled(task_id, enabled, definition_type="scheduled")
+ task = store.get_scheduled_task(task_id)
+ return jsonify({"ok": True, "task": task})
+
+
[email protected]("/api/harness/tasks/<task_id>", methods=["DELETE"])
+def harness_task_delete(task_id: str):
+ with _harness_store() as store:
+ if not store.get_scheduled_task(task_id):
+ return jsonify({"ok": False, "code": "task_not_found"}), 404
+ store.remove_task(task_id)
+ return jsonify({"ok": True, "id": task_id})
+
+
@app.route("/api/harness/watches", methods=["GET"])
def harness_watches_list():
with _harness_store() as store:
@@ -2856,6 +2879,32 @@ def harness_watches_list():
return jsonify({"watches": watches})
[email protected]("/api/harness/watches/<watch_id>", methods=["PATCH"])
+def harness_watch_patch(watch_id: str):
+ payload = request.json or {}
+ if "enabled" not in payload:
+ return jsonify({"ok": False, "code": "invalid_payload", "message": "missing 'enabled'"}), 400
+ enabled = bool(payload["enabled"])
+ with _harness_store() as store:
+ if not store.get_watch(watch_id):
+ return jsonify({"ok": False, "code": "watch_not_found"}), 404
+ store.set_definition_enabled(watch_id, enabled, definition_type="watch")
+ watch = store.get_watch(watch_id)
+ runtime = store.load_watch_runtime().get("watches") or {}
+ if watch:
+ watch["runtime"] = runtime.get(watch_id) or {"running": False}
+ return jsonify({"ok": True, "watch": watch})
+
+
[email protected]("/api/harness/watches/<watch_id>", methods=["DELETE"])
+def harness_watch_delete(watch_id: str):
+ with _harness_store() as store:
+ if not store.get_watch(watch_id):
+ return jsonify({"ok": False, "code": "watch_not_found"}), 404
+ store.remove_task(watch_id)
+ return jsonify({"ok": True, "id": watch_id})
+
+
@app.route("/api/harness/runs", methods=["GET"])
def harness_runs_list():
from storage.pagination import make_page_request