Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(automations): the section joins the app's design — schedules get a home, creating is never a hunt
rubenluetke10-beep089d30c696d2
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 5c02957699..537ebf1847 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -422,10 +422,10 @@},"prompt_mode": {"title": "Prompt-Modus",- "description": "Sag in deinen Worten und in jeder Sprache, was erledigt werden soll. Im Feld landet ein fertiger Prompt für einen KI-Coding-Agenten, auf Englisch: das Ziel, das du beschrieben hast, der Kontext und die Grenzen, die du genannt hast — und nichts Erfundenes.",- "sends_text": "Dein Transkript geht an das Modell, das auch die Briefings der Agentic IDE schreibt — ausgewählt unter API-Schlüssel → Agenten. Das ist meist ein Cloud-Modell und darf ein paar Sekunden nachdenken. Dein Rohtext bleibt immer in deinem Verlauf.",- "outranks": "Solange das an ist, treten das Aufräumen der Formulierung und die Übersetzung zurück: Ein Prompt ist immer Englisch und immer neu strukturiert. Antwortet kein Modell rechtzeitig, kommt dieses Diktat so an, als wäre der Prompt-Modus aus.",- "writer_hint": "Welches Modell schreibt: API-Schlüssel → Agenten → „Wer die Aufgaben-Briefings schreibt“."+ "description": "Sag in deinen Worten und in jeder Sprache, was erledigt werden soll. Im Feld landet ein fertiger Prompt für einen KI-Coding-Agenten, so formuliert, wie du es sagen würdest: das Ziel, das du beschrieben hast, der Kontext und die Grenzen, die du genannt hast, und jede Aufgabe, die du erwähnt hast — nichts erfunden, nichts weggelassen.",+ "sends_text": "Dein Transkript geht an dasselbe schnelle Modell wie das Aufräumen der Formulierung oben und kommt als Klartext in der Sprache zurück, in der du gesprochen hast — meist innerhalb weniger Sekunden. Dein Rohtext bleibt immer in deinem Verlauf.",+ "outranks": "Solange das an ist, treten das Aufräumen der Formulierung und die Übersetzung zurück: Der Prompt ist bereits neu strukturiert. Antwortet kein Modell rechtzeitig, kommt dieses Diktat so an, als wäre der Prompt-Modus aus.",+ "writer_hint": "Welches Modell schreibt: der Anbieter, der oben unter „Formulierung aufräumen“ gewählt ist."},"translate": {"title": "Immer in einer Sprache schreiben",@@ -605,6 +605,10 @@"build_hint": "Bau-Modus — der Agent darf Dateien ändern. Klick für Plan-Modus.","plan_hint": "Plan-Modus — der Agent liest und plant, ändert nichts. Klick für Bau-Modus.","folder": "Arbeitsordner",+ "attach_drop_hint": "Dateien hier ablegen, um sie anzuhängen",+ "attach_remove": "{name} entfernen",+ "attach_working": "Wird angehängt…",+ "attach_failed": "Diese Datei konnte nicht angehängt werden.","jarvis_tools": "Jarvis · {count} Tools","jarvis_tools_hint": "Dieser Chat steuert Jarvis: {count} Jarvis-Tools stehen ihm zur Verfügung — dieselben, die auch per Sprache laufen.","send": "Senden",@@ -861,14 +865,49 @@},"automations_view": {"title": "Automatisierungen",- "subtitle": "Wiederkehrende Agenten-Aufgaben — deine eigenen und ein Katalog fertiger Vorlagen.",+ "subtitle": "Alles, was Jarvis von selbst tut — wiederkehrende Automatisierungen, einmalige Zeitpläne und ein Katalog fertiger Vorlagen.","new_button": "Neue Automatisierung","refresh": "Aktualisieren","tab_automations": "Automatisierungen",+ "tab_schedules": "Zeitpläne","tab_runs": "Läufe",+ "tab_catalogue": "Katalog",+ "tabs_label": "Bereich",+ "browse_catalogue": "Katalog ansehen",+ "col_automation": "Automatisierung",+ "col_schedule": "Termin",+ "col_run": "Lauf",+ "col_when": "Wann",+ "col_in": "In",+ "col_duration": "Dauer",+ "col_actions": "Aktionen",+ "armed": "Aktiv",+ "stat_active": "Aktiv",+ "stat_active_hint": "laufen nach Zeitplan",+ "stat_active_paused": "{n} pausiert",+ "stat_next": "Nächster Lauf",+ "stat_next_hint": "nichts geplant",+ "stat_schedules": "Zeitpläne",+ "stat_schedules_hint": "einmalige Termine",+ "stat_problems": "Probleme",+ "stat_problems_hint": "alles sauber gelaufen",+ "yours_subtitle": "Läuft nach Zeitplan, bis du sie pausierst.",+ "schedules_heading": "Zeitpläne",+ "schedules_subtitle": "Einmalige Termine — laufen einmal und sind dann fertig.",+ "schedules_empty": "Keine Zeitpläne geplant.",+ "schedules_empty_hint": "Ein Zeitplan läuft genau einmal — zu einer festen Uhrzeit oder nach einer Wartezeit.",+ "new_schedule": "Neuer Zeitplan",+ "cancel_schedule": "Termin absagen",+ "runs_heading": "Läufe",+ "runs_subtitle": "Was gelaufen ist und was dabei herauskam.",+ "runs_filter_label": "Filter",+ "category_all": "Alle",+ "category_label": "Kategorie",+ "custom_title": "Eigene Automatisierung",+ "custom_description": "Beschreibe in eigenen Worten, was regelmäßig passieren soll.","yours_heading": "Deine Automatisierungen","yours_empty": "Noch keine Automatisierungen.",- "yours_empty_hint": "Füge eine aus dem Katalog unten hinzu oder erstelle deine eigene mit „Neue Automatisierung“.",+ "yours_empty_hint": "Nimm eine fertige aus dem Katalog oder beschreibe deine eigene.","catalogue_heading": "Katalog","catalogue_hint": "Fertige Automatisierungen — hinzufügen und den Zeitplan anpassen.","catalogue_loading": "Lade Katalog…",@@ -4597,18 +4636,19 @@"ide_chats": {"back_to_sections": "Bereiche","this_workspace": "Dieser Workspace",- "other_folders": "Andere Ordner",- "new_chat_here": "Neuer Chat in diesem Ordner",- "no_chats_here": "Noch keine Chats in diesem Ordner",+ "other_workspaces": "Andere Workspaces",+ "new_session": "Neue Session",+ "no_workspace": "Kein Workspace geöffnet.",+ "no_sessions_here": "Noch keine Coding-Sessions in diesem Workspace","show_more": "Mehr anzeigen"},"agentic_grid": {"view_switch": {- "hint": "Diesen Workspace als Chat oder als Terminal-Raster anzeigen",+ "hint": "Diesen Workspace als eine Unterhaltung oder als Terminal-Raster anzeigen","chat": "Chat","grid": "Raster",- "chat_hint": "Chat — sprich mit einem Agenten im Ordner dieses Workspaces.",- "grid_hint": "Terminal-Raster — alle Bereiche gleichzeitig auf dem Bildschirm."+ "chat_hint": "Chat — eine Coding-Session dieses Workspaces, als Unterhaltung gelesen.",+ "grid_hint": "Terminal-Raster — alle Sessions gleichzeitig auf dem Bildschirm."},"toolbar": {"more_controls": "Weitere Arbeitsbereich-Steuerelemente",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 38291cb479..60102f09cb 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -422,10 +422,10 @@},"prompt_mode": {"title": "Prompt Mode",- "description": "Say what you want done, in your own words and any language. What lands in the field is a finished prompt for an AI coding agent, in English: the goal you described, the context and limits you stated, and nothing made up.",- "sends_text": "Your transcript is sent to the model that writes the Agentic IDE's briefs — the one chosen under API Keys → Agents. That is usually a cloud model, and it may take a few seconds to think. Your raw text is always kept in your history.",- "outranks": "While this is on, the wording clean-up and the translation step back: a prompt is always English and always restructured. If no model answers in time, this dictation is delivered as it would be with Prompt Mode off.",- "writer_hint": "Which model writes it: API Keys → Agents → \"Who writes the task briefs\"."+ "description": "Say what you want done, in your own words and in any language. What lands in the field is a finished prompt for an AI coding agent, written the way you would say it: the goal you described, the context and limits you stated, and every task you mentioned — nothing made up, nothing dropped.",+ "sends_text": "Your transcript goes to the same fast model as the wording clean-up above and comes back as plain text in the language you spoke, usually within a few seconds. Your raw text is always kept in your history.",+ "outranks": "While this is on, the wording clean-up and the translation step back: the prompt is already restructured. If no model answers in time, this dictation is delivered as it would be with Prompt Mode off.",+ "writer_hint": "Which model writes it: the provider picked under \"Clean up my wording\" above."},"translate": {"title": "Always write in one language",@@ -605,6 +605,10 @@"build_hint": "Build mode — the agent may change files. Click for Plan mode.","plan_hint": "Plan mode — the agent reads and plans, changes nothing. Click for Build mode.","folder": "Working folder",+ "attach_drop_hint": "Drop the files here to attach them",+ "attach_remove": "Remove {name}",+ "attach_working": "Attaching…",+ "attach_failed": "That file could not be attached.","jarvis_tools": "Jarvis · {count} tools","jarvis_tools_hint": "This chat drives Jarvis: {count} Jarvis tools are available to it — the same ones the voice path uses.","send": "Send",@@ -861,14 +865,49 @@},"automations_view": {"title": "Automations",- "subtitle": "Recurring agent tasks — yours, and a catalogue of ready-made ones.",+ "subtitle": "Everything Jarvis does on its own — recurring automations, one-off schedules, and a catalogue of ready-made ones.","new_button": "New automation","refresh": "Refresh","tab_automations": "Automations",+ "tab_schedules": "Schedules","tab_runs": "Runs",+ "tab_catalogue": "Catalogue",+ "tabs_label": "Area",+ "browse_catalogue": "Browse catalogue",+ "col_automation": "Automation",+ "col_schedule": "Schedule",+ "col_run": "Run",+ "col_when": "When",+ "col_in": "In",+ "col_duration": "Duration",+ "col_actions": "Actions",+ "armed": "Armed",+ "stat_active": "Armed",+ "stat_active_hint": "running on schedule",+ "stat_active_paused": "{n} paused",+ "stat_next": "Next run",+ "stat_next_hint": "nothing scheduled",+ "stat_schedules": "Schedules",+ "stat_schedules_hint": "one-off moments",+ "stat_problems": "Problems",+ "stat_problems_hint": "everything ran clean",+ "yours_subtitle": "They run on their schedule until you pause them.",+ "schedules_heading": "Schedules",+ "schedules_subtitle": "One-off moments — they run once and are done.",+ "schedules_empty": "Nothing scheduled.",+ "schedules_empty_hint": "A schedule runs exactly once, at a time you pick or after a delay.",+ "new_schedule": "New schedule",+ "cancel_schedule": "Cancel schedule",+ "runs_heading": "Runs",+ "runs_subtitle": "What ran, and what came out of it.",+ "runs_filter_label": "Filter",+ "category_all": "All",+ "category_label": "Category",+ "custom_title": "Your own automation",+ "custom_description": "Describe in your own words what should happen regularly.","yours_heading": "Your automations","yours_empty": "No automations yet.",- "yours_empty_hint": "Add one from the catalogue below, or create your own with \"New automation\".",+ "yours_empty_hint": "Take a ready-made one from the catalogue, or describe your own.","catalogue_heading": "Catalogue","catalogue_hint": "Ready-made automations — add one and adjust its schedule.","catalogue_loading": "Loading catalogue…",@@ -4597,18 +4636,19 @@"ide_chats": {"back_to_sections": "Sections","this_workspace": "This workspace",- "other_folders": "Other folders",- "new_chat_here": "New chat in this folder",- "no_chats_here": "No chats in this folder yet",+ "other_workspaces": "Other workspaces",+ "new_session": "New session",+ "no_workspace": "No workspace is open.",+ "no_sessions_here": "No coding sessions in this workspace yet","show_more": "Show more"},"agentic_grid": {"view_switch": {- "hint": "Show this workspace as a chat or as the terminal grid",+ "hint": "Show this workspace as one conversation or as the terminal grid","chat": "Chat","grid": "Grid",- "chat_hint": "Chat — talk to an agent in this workspace's folder.",- "grid_hint": "Terminal grid — every pane on screen at once."+ "chat_hint": "Chat — one of this workspace's coding sessions, read as a conversation.",+ "grid_hint": "Terminal grid — every session on screen at once."},"toolbar": {"more_controls": "More workspace controls",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 0cf6aa0d1b..1b4168e05f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -422,10 +422,10 @@},"prompt_mode": {"title": "Modo prompt",- "description": "Di con tus palabras y en cualquier idioma qué quieres que se haga. En el campo aparece un prompt terminado para un agente de programación con IA, en inglés: el objetivo que describiste, el contexto y los límites que mencionaste, y nada inventado.",- "sends_text": "Tu transcripción se envía al modelo que escribe los briefings del Agentic IDE, el elegido en Claves API → Agentes. Suele ser un modelo en la nube y puede tardar unos segundos en pensar. Tu texto original siempre se guarda en tu historial.",- "outranks": "Mientras esté activo, la limpieza de redacción y la traducción pasan a segundo plano: un prompt siempre está en inglés y siempre se reestructura. Si ningún modelo responde a tiempo, este dictado llega como si el modo prompt estuviera apagado.",- "writer_hint": "Qué modelo lo escribe: Claves API → Agentes → «Quién escribe los briefings de tareas»."+ "description": "Di con tus palabras y en cualquier idioma qué quieres que se haga. En el campo aparece un prompt terminado para un agente de programación con IA, redactado como tú lo dirías: el objetivo que describiste, el contexto y los límites que mencionaste, y cada tarea que nombraste, sin nada inventado ni omitido.",+ "sends_text": "Tu transcripción va al mismo modelo rápido que la limpieza de redacción de arriba y vuelve como texto sin formato en el idioma en que hablaste, normalmente en pocos segundos. Tu texto original siempre se guarda en tu historial.",+ "outranks": "Mientras esté activo, la limpieza de redacción y la traducción pasan a segundo plano: el prompt ya viene reestructurado. Si ningún modelo responde a tiempo, este dictado llega como si el modo prompt estuviera apagado.",+ "writer_hint": "Qué modelo lo escribe: el proveedor elegido arriba en «Limpiar mi redacción»."},"translate": {"title": "Escribir siempre en un idioma",@@ -605,6 +605,10 @@"build_hint": "Modo construir: el agente puede cambiar archivos. Clic para el modo planificar.","plan_hint": "Modo planificar: el agente lee y planifica, no cambia nada. Clic para el modo construir.","folder": "Carpeta de trabajo",+ "attach_drop_hint": "Suelta aquí los archivos para adjuntarlos",+ "attach_remove": "Quitar {name}",+ "attach_working": "Adjuntando…",+ "attach_failed": "No se pudo adjuntar ese archivo.","send": "Enviar","stop": "Detener el turno","hint_connect": "{provider} aún no está conectado.",@@ -859,14 +863,49 @@},"automations_view": {"title": "Automatizaciones",- "subtitle": "Tareas recurrentes del agente: las tuyas y un catálogo de plantillas listas.",+ "subtitle": "Todo lo que Jarvis hace por su cuenta: automatizaciones recurrentes, programaciones únicas y un catálogo de plantillas listas.","new_button": "Nueva automatización","refresh": "Actualizar","tab_automations": "Automatizaciones",+ "tab_schedules": "Programaciones","tab_runs": "Ejecuciones",+ "tab_catalogue": "Catálogo",+ "tabs_label": "Área",+ "browse_catalogue": "Ver catálogo",+ "col_automation": "Automatización",+ "col_schedule": "Programación",+ "col_run": "Ejecución",+ "col_when": "Cuándo",+ "col_in": "En",+ "col_duration": "Duración",+ "col_actions": "Acciones",+ "armed": "Activa",+ "stat_active": "Activas",+ "stat_active_hint": "se ejecutan según su horario",+ "stat_active_paused": "{n} en pausa",+ "stat_next": "Próxima ejecución",+ "stat_next_hint": "nada programado",+ "stat_schedules": "Programaciones",+ "stat_schedules_hint": "momentos únicos",+ "stat_problems": "Problemas",+ "stat_problems_hint": "todo salió bien",+ "yours_subtitle": "Se ejecutan según su horario hasta que las pauses.",+ "schedules_heading": "Programaciones",+ "schedules_subtitle": "Momentos únicos: se ejecutan una vez y ya está.",+ "schedules_empty": "Nada programado.",+ "schedules_empty_hint": "Una programación se ejecuta una sola vez, a la hora que elijas o tras una espera.",+ "new_schedule": "Nueva programación",+ "cancel_schedule": "Cancelar programación",+ "runs_heading": "Ejecuciones",+ "runs_subtitle": "Qué se ejecutó y qué resultado dio.",+ "runs_filter_label": "Filtro",+ "category_all": "Todas",+ "category_label": "Categoría",+ "custom_title": "Tu propia automatización",+ "custom_description": "Describe con tus palabras lo que debe ocurrir de forma periódica.","yours_heading": "Tus automatizaciones","yours_empty": "Aún no hay automatizaciones.",- "yours_empty_hint": "Añade una del catálogo de abajo o crea la tuya con «Nueva automatización».",+ "yours_empty_hint": "Toma una lista del catálogo o describe la tuya.","catalogue_heading": "Catálogo","catalogue_hint": "Automatizaciones listas: añade una y ajusta su horario.","catalogue_loading": "Cargando catálogo…",@@ -4595,18 +4634,19 @@"ide_chats": {"back_to_sections": "Secciones","this_workspace": "Este espacio de trabajo",- "other_folders": "Otras carpetas",- "new_chat_here": "Nuevo chat en esta carpeta",- "no_chats_here": "Aún no hay chats en esta carpeta",+ "other_workspaces": "Otros espacios de trabajo",+ "new_session": "Nueva sesión",+ "no_workspace": "No hay ningún espacio de trabajo abierto.",+ "no_sessions_here": "Aún no hay sesiones de programación en este espacio de trabajo","show_more": "Mostrar más"},"agentic_grid": {"view_switch": {- "hint": "Mostrar este espacio de trabajo como chat o como cuadrícula de terminales",+ "hint": "Mostrar este espacio de trabajo como una conversación o como cuadrícula de terminales","chat": "Chat","grid": "Cuadrícula",- "chat_hint": "Chat: habla con un agente en la carpeta de este espacio de trabajo.",- "grid_hint": "Cuadrícula de terminales: todos los paneles a la vez en pantalla."+ "chat_hint": "Chat: una de las sesiones de programación de este espacio de trabajo, leída como conversación.",+ "grid_hint": "Cuadrícula de terminales: todas las sesiones a la vez en pantalla."},"toolbar": {"more_controls": "Más controles del espacio de trabajo",diff --git a/jarvis/ui/web/frontend/src/views/AutomationsView.test.tsx b/jarvis/ui/web/frontend/src/views/AutomationsView.test.tsxindex 8a5e03b1a9..43c2c71994 100644--- a/jarvis/ui/web/frontend/src/views/AutomationsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/AutomationsView.test.tsx@@ -8,6 +8,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";const TEMPLATED: Record<string, string> = {"automations_view.needs": "Needs {tools}","automations_view.added_notice": '"{title}" added.',+ "automations_view.stat_active_paused": "{n} paused",};vi.mock("@/i18n", () => ({@@ -27,9 +28,12 @@ vi.mock("@/views/ChatsView", () => ({),}));-// The create dialog has its own tests; here it only needs to be openable.+// The create dialog has its own tests; here it only needs to be openable, and+// the draft it opens with is what tells "New schedule" apart from "New".vi.mock("@/views/tasks/TaskCreateDialog", () => ({- TaskCreateDialog: () => <div>CREATE_DIALOG</div>,+ TaskCreateDialog: ({ initialDraft }: { initialDraft?: { scheduleMode?: string } }) => (+ <div>CREATE_DIALOG:{initialDraft?.scheduleMode ?? "default"}</div>+ ),}));import { AutomationsView } from "@/views/AutomationsView";@@ -97,6 +101,26 @@ const AUTOMATION = {last_result: "Three mails need a reply.",};+/** A one-off that has NOT fired yet — the whole point of the Schedules tab. */+const SCHEDULE = {+ id: "sched1",+ title: "Call the dentist",+ state: "scheduled",+ trigger_type: "at_time",+ due_at_ns: NOW_NS + 1800e9,+ created_at_ns: NOW_NS - 10e9,+ started_at_ns: null,+ finished_at_ns: null,+ attempts: 0,+ last_error: null,+ tags: [],+ created_by: "user",+ interval_seconds: null,+ next_due_at_ns: null,+ last_run_state: null,+ last_result: null,+};+const RUN = {id: "run1",title: "Weekly report",@@ -124,7 +148,7 @@ interface Call {function installFetch(opts: { templatesStatus?: number; tasks?: unknown[] } = {}) {const calls: Call[] = [];- const tasks = opts.tasks ?? [AUTOMATION, RUN];+ const tasks = opts.tasks ?? [AUTOMATION, SCHEDULE, RUN];const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {const url = String(input);const method = init?.method ?? "GET";@@ -145,6 +169,8 @@ function installFetch(opts: { templatesStatus?: number; tasks?: unknown[] } = {}if (url === "/api/tasks/auto1" && method === "PATCH") return json(200, { ok: true });if (url === "/api/tasks/auto1/cancel" && method === "POST") return json(200, { ok: true });if (url === "/api/tasks/auto1" && method === "DELETE") return json(200, { ok: true });+ if (url === "/api/tasks/sched1/cancel" && method === "POST") return json(200, { ok: true });+ if (url === "/api/tasks/sched1" && method === "DELETE") return json(200, { ok: true });if (url === "/api/tasks/run1") {return json(200, {...RUN,@@ -160,6 +186,7 @@ function installFetch(opts: { templatesStatus?: number; tasks?: unknown[] } = {}],});}+ if (url === "/api/tasks/sched1") return json(200, { ...SCHEDULE, spec: null, steps: [] });if (url === "/api/tasks/auto1") return json(200, { ...AUTOMATION, spec: null, steps: [] });throw new Error(`unexpected fetch ${method} ${url}`);});@@ -176,40 +203,117 @@ function renderView() {);}+/** Switch tabs by the chip rail's accessible name. */+function goToTab(key: string) {+ fireEvent.click(screen.getByRole("tab", { name: new RegExp(`automations_view.tab_${key}`) }));+}++/** Open a row's "⋯" menu and pick an entry by its label. */+function pickRowAction(rowLabel: string, action: string) {+ const row = screen.getByRole("row", { name: rowLabel });+ fireEvent.click(within(row).getByLabelText("automations_view.col_actions"));+ fireEvent.click(screen.getByRole("menuitem", { name: action }));+}+afterEach(() => {cleanup();vi.restoreAllMocks();});describe("AutomationsView", () => {- it("renders the user's automations and the catalogue grouped by category", async () => {+ it("opens on the user's automations, with the headline numbers above them", async () => {installFetch();renderView();- // The user's card (from the template tag it borrows the template's description).- const card = await screen.findByText("My inbox triage");- expect(card).toBeTruthy();- expect(screen.getByText("Three mails need a reply.")).toBeTruthy();- // Catalogue groups in order with localized headings.- expect(await screen.findByText("automations_view.category.news")).toBeTruthy();- expect(screen.getByText("automations_view.category.productivity")).toBeTruthy();- expect(screen.getByText("Morning briefing")).toBeTruthy();+ expect(await screen.findByText("My inbox triage")).toBeTruthy();+ // The row borrows the template's description via its `template:` tag.+ expect(screen.getByText("Sort the inbox.")).toBeTruthy();+ // One armed automation, one waiting schedule, nothing broken.+ const armed = screen.getByRole("group", { name: "automations_view.stat_active" });+ expect(within(armed).getByText("1")).toBeTruthy();+ const scheduled = screen.getByRole("group", { name: "automations_view.stat_schedules" });+ expect(within(scheduled).getByText("1")).toBeTruthy();+ const problems = screen.getByRole("group", { name: "automations_view.stat_problems" });+ expect(within(problems).getByText("automations_view.stat_problems_hint")).toBeTruthy();+ });++ it("the header button opens the create dialog", async () => {+ installFetch();+ renderView();+ await screen.findByText("My inbox triage");+ expect(screen.queryByText(/CREATE_DIALOG/)).toBeNull();+ fireEvent.click(screen.getByText("automations_view.new_button"));+ expect(screen.getByText("CREATE_DIALOG:default")).toBeTruthy();+ });++ it("a waiting one-shot lives on the Schedules tab, not in the run history", async () => {+ installFetch();+ renderView();+ await screen.findByText("My inbox triage");+ // Not a row on the automations tab (it IS named by the "next run" tile,+ // which is the point of that tile — so this asks about rows, not text).+ expect(screen.queryByRole("row", { name: "Call the dentist" })).toBeNull();++ goToTab("schedules");+ expect(await screen.findByRole("row", { name: "Call the dentist" })).toBeTruthy();++ goToTab("runs");+ expect(await screen.findByRole("row", { name: "Weekly report" })).toBeTruthy();+ expect(screen.queryByRole("row", { name: "Call the dentist" })).toBeNull();+ });++ it("the Schedules tab creates a one-off, not a recurring automation", async () => {+ installFetch();+ renderView();+ await screen.findByText("My inbox triage");+ goToTab("schedules");+ fireEvent.click(await screen.findByText("automations_view.new_schedule"));+ expect(screen.getByText("CREATE_DIALOG:once")).toBeTruthy();+ });++ it("the catalogue filters by category and offers a custom automation", async () => {+ installFetch();+ renderView();+ await screen.findByText("My inbox triage");+ goToTab("catalogue");++ expect(await screen.findByText("Morning briefing")).toBeTruthy();+ expect(screen.getByText("Inbox triage")).toBeTruthy();// The installed template says "Added"; the not-ready one names what it needs.const triage = screen.getByTestId("catalogue-inbox_triage");expect(within(triage).getByText("automations_view.added")).toBeTruthy();expect(within(triage).getByText("Needs Gmail")).toBeTruthy();++ // "Build your own" sits in the grid, so creating is never a hunt.+ fireEvent.click(screen.getByTestId("catalogue-custom"));+ expect(screen.getByText("CREATE_DIALOG:default")).toBeTruthy();+ });++ it("a category chip narrows the grid", async () => {+ installFetch();+ renderView();+ await screen.findByText("My inbox triage");+ goToTab("catalogue");+ await screen.findByText("Morning briefing");+ fireEvent.click(screen.getByRole("tab", { name: /automations_view.category.news/ }));+ expect(screen.getByText("Morning briefing")).toBeTruthy();+ expect(screen.queryByText("Inbox triage")).toBeNull();+ // The custom tile belongs to the unfiltered grid only.+ expect(screen.queryByTestId("catalogue-custom")).toBeNull();});it("shows an honest note when the catalogue route does not exist yet", async () => {installFetch({ templatesStatus: 404 });renderView();+ await screen.findByText("My inbox triage");+ goToTab("catalogue");expect(await screen.findByText("automations_view.catalogue_unavailable")).toBeTruthy();- // The user's automations still render.- expect(screen.getByText("My inbox triage")).toBeTruthy();});it("Add opens the dialog, validates required inputs and posts to the template route", async () => {const calls = installFetch();renderView();+ await screen.findByText("My inbox triage");+ goToTab("catalogue");const briefing = await screen.findByTestId("catalogue-morning_briefing");fireEvent.click(within(briefing).getByText("automations_view.add"));const dialog = await screen.findByRole("dialog");@@ -223,7 +327,12 @@ describe("AutomationsView", () => {await waitFor(() => {const add = calls.find((c) => c.url === "/api/tasks/templates/morning_briefing/add");expect(add?.method).toBe("POST");- const body = add?.body as { inputs: Record<string, string>; schedule: { kind: string; time: string }; title: string; locale: string };+ const body = add?.body as {+ inputs: Record<string, string>;+ schedule: { kind: string; time: string };+ title: string;+ locale: string;+ };expect(body.inputs).toEqual({ city: "Hamburg" });expect(body.schedule).toEqual({ kind: "daily", time: "07:30", weekday: 0 });expect(body.title).toBe("Morning briefing");@@ -243,7 +352,7 @@ describe("AutomationsView", () => {const patch = calls.find((c) => c.url === "/api/tasks/auto1" && c.method === "PATCH");expect(patch?.body).toEqual({ enabled: false });});- fireEvent.click(screen.getByText("automations_view.run_now"));+ pickRowAction("My inbox triage", "automations_view.run_now");await waitFor(() => {expect(calls.some((c) => c.url === "/api/tasks/auto1/run" && c.method === "POST")).toBe(true);});@@ -254,9 +363,9 @@ describe("AutomationsView", () => {const calls = installFetch();renderView();await screen.findByText("My inbox triage");- fireEvent.click(screen.getByLabelText("tasks_view.delete"));+ pickRowAction("My inbox triage", "tasks_view.delete");expect(screen.getByText("automations_view.delete_confirm")).toBeTruthy();- fireEvent.click(screen.getByText("tasks_view.delete"));+ fireEvent.click(screen.getByRole("button", { name: "tasks_view.delete" }));await waitFor(() => {const idx = (m: string, u: string) => calls.findIndex((c) => c.url === u && c.method === m);const cancel = idx("POST", "/api/tasks/auto1/cancel");@@ -266,21 +375,17 @@ describe("AutomationsView", () => {});});- it("the Runs tab lists finished runs and expands to the readable result text", async () => {+ it("a run row expands to the readable result text, and the chips filter", async () => {installFetch();renderView();await screen.findByText("My inbox triage");- fireEvent.click(screen.getByRole("tab", { name: /automations_view.tab_runs/ }));- expect(await screen.findByText("Weekly report")).toBeTruthy();- // The recurring automation is not a "run" row unless it is running/finished.- expect(screen.queryByText("My inbox triage")).toBeNull();- fireEvent.click(screen.getByLabelText("tasks_view.expand"));+ goToTab("runs");+ fireEvent.click(await screen.findByRole("row", { name: "Weekly report" }));const result = await screen.findByTestId("run-result");expect(result.textContent).toContain("The report is done.");expect(result.textContent).toContain("Two items are open.");expect(result.textContent).not.toContain("agent_result");- // Filter chips: "problems" hides the completed run.- fireEvent.click(screen.getByText("automations_view.runs_filter.problems"));+ fireEvent.click(screen.getByRole("tab", { name: "automations_view.runs_filter.problems" }));expect(screen.queryByText("Weekly report")).toBeNull();});});diff --git a/jarvis/ui/web/frontend/src/views/AutomationsView.tsx b/jarvis/ui/web/frontend/src/views/AutomationsView.tsxindex 3991e14790..db78cebda1 100644--- a/jarvis/ui/web/frontend/src/views/AutomationsView.tsx+++ b/jarvis/ui/web/frontend/src/views/AutomationsView.tsx@@ -1,17 +1,44 @@/**- * The Automations section: the user's recurring automations, the catalogue- * of ready-made ones (grouped by category), and a Runs tab with the history.+ * The Automations section — everything Jarvis does on its own, in one place.+ *+ * Four tabs over one content column: the user's recurring automations, the+ * one-off schedules waiting to fire, the run history, and the catalogue of+ * ready-made automations. The split is what the section was missing: a+ * waiting one-shot used to be filed under "Runs", so schedules had no home+ * and nobody found them, and the catalogue printed one sparse grid per+ * category down an unbounded-width page.+ *+ * The layout is the section design the rest of the app converged on: the+ * section header bar, a centred content column, a row of headline numbers,+ * a chip rail of tabs, and panels holding tables — the same shapes as Spend,+ * Local models and the extensions section.** Degrades honestly against an older backend: when the catalogue route does- * not exist yet (404 — it goes live with the next restart) the section says- * so inline, and a failed run/pause/delete call becomes a notice instead of- * a crash.+ * not exist yet (404 — it goes live with the next restart) the tab says so+ * inline, and a failed run/pause/delete call becomes a notice, not a crash.*/import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { History, Plus, RefreshCw, Workflow, X } from "lucide-react";+import {+ AlertTriangle,+ CalendarClock,+ LayoutGrid,+ Plus,+ RefreshCw,+ Timer,+ Workflow,+ X,+ Zap,+} from "lucide-react";import { ViewHeader } from "@/views/ChatsView";import { ScrollArea } from "@/components/ui/scroll-area";-import { Button } from "@/components/ui/button";+import {+ IconButton,+ Panel,+ PanelHeader,+ SegmentedFilter,+ SoftButton,+ StatTile,+} from "@/components/extensions/primitives";import { fill, useT } from "@/i18n";import { cn } from "@/lib/utils";import {@@ -23,33 +50,41 @@ import {useTemplates,} from "@/hooks/useAutomations";import { TaskCreateDialog } from "./tasks/TaskCreateDialog";-import { AutomationCard } from "./automations/AutomationCard";-import { CatalogueCard } from "./automations/CatalogueCard";+import type { TaskDraft } from "./tasks/taskSpec";+import { AutomationsPanel } from "./automations/AutomationsPanel";+import { CataloguePanel } from "./automations/CataloguePanel";+import { RunsPanel, RUN_FILTERS } from "./automations/RunsPanel";+import { SchedulesPanel } from "./automations/SchedulesPanel";import { TemplateAddDialog } from "./automations/TemplateAddDialog";import {- groupTemplates,+ automationStats,+ formatDelta,selectAutomations,selectRuns,+ selectSchedules,templateKeyOf,type AutomationTemplate,- type TaskSummary,+ type RunFilter,} from "./automations/automationsModel";-import { SectionLabel } from "./automations/shared";-import { RunsTab } from "./TasksView";+import { useTick } from "./automations/shared";-type Tab = "automations" | "runs";+type Tab = "automations" | "schedules" | "runs" | "catalogue";interface Notice {text: string;kind: "info" | "error";}+/** The create dialog opened as "a schedule" starts on the one-off branch. */+const SCHEDULE_DRAFT: Partial<TaskDraft> = { triggerMode: "schedule", scheduleMode: "once" };+export function AutomationsView() {const t = useT();const [tab, setTab] = useState<Tab>("automations");- const [showCreate, setShowCreate] = useState(false);+ const [createDraft, setCreateDraft] = useState<Partial<TaskDraft> | null>(null);const [adding, setAdding] = useState<AutomationTemplate | null>(null);const [highlightId, setHighlightId] = useState<string | null>(null);+ const [runFilter, setRunFilter] = useState<RunFilter>("all");const [notice, setNotice] = useState<Notice | null>(null);const noticeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);@@ -58,17 +93,25 @@ export function AutomationsView() {if (noticeTimer.current) clearTimeout(noticeTimer.current);noticeTimer.current = setTimeout(() => setNotice(null), kind === "error" ? 8000 : 4000);}, []);- useEffect(() => () => {- if (noticeTimer.current) clearTimeout(noticeTimer.current);- }, []);+ useEffect(+ () => () => {+ if (noticeTimer.current) clearTimeout(noticeTimer.current);+ },+ [],+ );const tasksQuery = useTasks();const templatesQuery = useTemplates();const tasks = useMemo(() => tasksQuery.data?.tasks ?? [], [tasksQuery.data]);const automations = useMemo(() => selectAutomations(tasks), [tasks]);+ const schedules = useMemo(() => selectSchedules(tasks), [tasks]);const runsCount = useMemo(() => selectRuns(tasks).length, [tasks]);+ const stats = useMemo(() => automationStats(tasks), [tasks]);- const templates = templatesQuery.data?.templates ?? [];+ const templates = useMemo(+ () => templatesQuery.data?.templates ?? [],+ [templatesQuery.data],+ );const templatesByKey = useMemo(() => new Map(templates.map((tpl) => [tpl.key, tpl])),[templates],@@ -82,7 +125,6 @@ export function AutomationsView() {}return map;}, [automations]);- const groups = useMemo(() => groupTemplates(templates), [templates]);const runNow = useRunNow();const setEnabled = useSetEnabled();@@ -134,9 +176,11 @@ export function AutomationsView() {const scrollToTask = useCallback((taskId: string) => {setTab("automations");setHighlightId(taskId);- // The card exists already (installed) — give React a frame to switch tabs.+ // The row exists already (installed) — give React a frame to switch tabs.requestAnimationFrame(() => {- document.getElementById(`automation-${taskId}`)?.scrollIntoView({ behavior: "smooth", block: "center" });+ document+ .getElementById(`automation-${taskId}`)+ ?.scrollIntoView({ behavior: "smooth", block: "center" });});setTimeout(() => setHighlightId((cur) => (cur === taskId ? null : cur)), 2500);}, []);@@ -152,6 +196,9 @@ export function AutomationsView() {);const catalogueUnavailable = templatesQuery.data?.unavailable === true;+ const openCreate = useCallback(() => setCreateDraft({}), []);+ const openScheduleCreate = useCallback(() => setCreateDraft(SCHEDULE_DRAFT), []);+ const openCatalogue = useCallback(() => setTab("catalogue"), []);return (<div className="flex h-full flex-col">@@ -161,163 +208,237 @@ export function AutomationsView() {subtitle={t("automations_view.subtitle")}right={<div className="flex items-center gap-1.5">- <Button- size="sm"- variant="ghost"+ <IconButton+ label={t("automations_view.refresh")}onClick={() => {tasksQuery.refetch();templatesQuery.refetch();}}disabled={tasksQuery.isRefetching}- aria-label={t("automations_view.refresh")}- title={t("automations_view.refresh")}><RefreshCw className={cn("h-4 w-4", tasksQuery.isRefetching && "animate-spin")} />- </Button>- <Button size="sm" onClick={() => setShowCreate(true)}>- <Plus className="mr-1 h-4 w-4" />+ </IconButton>+ <SoftButton primary onClick={openCreate}>+ <Plus className="h-3.5 w-3.5" />{t("automations_view.new_button")}- </Button>+ </SoftButton></div>}/>- {showCreate && <TaskCreateDialog onClose={() => setShowCreate(false)} />}+ {createDraft && (+ <TaskCreateDialog initialDraft={createDraft} onClose={() => setCreateDraft(null)} />+ )}{adding && (<TemplateAddDialog template={adding} onClose={() => setAdding(null)} onAdded={handleAdded} />)}- {/* Tabs */}- <div className="flex items-center gap-1 border-b border-border px-6">- <TabButton active={tab === "automations"} onClick={() => setTab("automations")} icon={Workflow}>- {t("automations_view.tab_automations")}- <Count n={automations.length} />- </TabButton>- <TabButton active={tab === "runs"} onClick={() => setTab("runs")} icon={History}>- {t("automations_view.tab_runs")}- <Count n={runsCount} />- </TabButton>- {notice && (- <div- role="status"- className={cn(- "ml-auto flex items-center gap-2 rounded-md border px-2.5 py-1 text-xs",- notice.kind === "error"- ? "border-destructive/50 text-destructive"- : "border-primary/40 text-primary",- )}- >- <span className="max-w-md truncate">{notice.text}</span>- <button type="button" onClick={() => setNotice(null)} aria-label={t("common.close")}>- <X className="h-3 w-3" />- </button>- </div>- )}- </div>-<ScrollArea className="flex-1">- <div className="p-6">- {tasksQuery.isLoading && (- <div className="text-sm text-muted-foreground">{t("tasks_view.loading")}</div>+ <div className="mx-auto flex max-w-[1180px] flex-col gap-4 px-6 py-6">+ {notice && (+ <div+ role="status"+ className={cn(+ "flex items-center gap-2 rounded-lg border px-3 py-2 text-sm",+ notice.kind === "error"+ ? "border-destructive/50 bg-destructive/5 text-destructive"+ : "border-primary/40 bg-primary/5 text-primary",+ )}+ >+ <span className="min-w-0 flex-1 truncate">{notice.text}</span>+ <button+ type="button"+ onClick={() => setNotice(null)}+ aria-label={t("common.close")}+ className="shrink-0 opacity-70 transition-opacity hover:opacity-100"+ >+ <X className="h-3.5 w-3.5" />+ </button>+ </div>)}+{tasksQuery.error && (- <div className="mb-4 rounded-lg border border-destructive/40 p-4 text-sm text-destructive">+ <div className="rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive">{t("tasks_view.load_error")}: {(tasksQuery.error as Error).message}</div>)}- {tab === "automations" ? (- <div className="space-y-8">- <section aria-labelledby="your-automations">- <div className="mb-3 flex items-baseline justify-between">- <h3 id="your-automations" className="text-sm font-semibold">- {t("automations_view.yours_heading")}- </h3>- <span className="text-[11px] text-muted-foreground">- {automations.length} {t("tasks_view.entries")}- </span>- </div>- {!tasksQuery.isLoading && automations.length === 0 ? (- <div className="flex flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-border/60 p-8 text-center">- <Workflow className="h-7 w-7 text-muted-foreground/50" />- <p className="text-sm text-muted-foreground">{t("automations_view.yours_empty")}</p>- <p className="max-w-xl text-[11px] leading-relaxed text-muted-foreground/70">- {t("automations_view.yours_empty_hint")}- </p>- </div>- ) : (- <div className="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3">- {automations.map((task: TaskSummary) => {- const key = templateKeyOf(task);- return (- <AutomationCard- key={task.id}- task={task}- template={key ? templatesByKey.get(key) : undefined}- highlighted={highlightId === task.id}- onRunNow={handleRunNow}- onSetEnabled={handleSetEnabled}- onDelete={handleDelete}- busy={{- run: runNow.isPending && runNow.variables === task.id,- toggle: setEnabled.isPending && setEnabled.variables?.id === task.id,- delete: deleteTask.isPending && deleteTask.variables?.id === task.id,- }}- />- );- })}- </div>- )}- </section>+ {/* Headline numbers — what is armed, what happens next, what broke. */}+ <div className="grid gap-3 sm:grid-cols-2 xl:grid-cols-4">+ <StatTile+ icon={<Zap className="h-4 w-4" />}+ label={t("automations_view.stat_active")}+ value={stats.active}+ hint={+ stats.paused > 0+ ? fill(t("automations_view.stat_active_paused"), { n: stats.paused })+ : t("automations_view.stat_active_hint")+ }+ tone="primary"+ loading={tasksQuery.isLoading}+ />+ <StatTile+ icon={<Timer className="h-4 w-4" />}+ label={t("automations_view.stat_next")}+ value={<NextRunValue dueNs={stats.nextDueNs} />}+ hint={stats.nextTitle || t("automations_view.stat_next_hint")}+ loading={tasksQuery.isLoading}+ />+ <StatTile+ icon={<CalendarClock className="h-4 w-4" />}+ label={t("automations_view.stat_schedules")}+ value={stats.schedules}+ hint={t("automations_view.stat_schedules_hint")}+ loading={tasksQuery.isLoading}+ />+ <StatTile+ icon={<AlertTriangle className="h-4 w-4" />}+ label={t("automations_view.stat_problems")}+ value={stats.problems}+ hint={stats.problemTitle || t("automations_view.stat_problems_hint")}+ tone={stats.problems > 0 ? "danger" : "success"}+ loading={tasksQuery.isLoading}+ />+ </div>++ <SegmentedFilter<Tab>+ label={t("automations_view.tabs_label")}+ value={tab}+ onChange={setTab}+ options={[+ { id: "automations", label: t("automations_view.tab_automations"), count: automations.length },+ { id: "schedules", label: t("automations_view.tab_schedules"), count: schedules.length },+ { id: "runs", label: t("automations_view.tab_runs"), count: runsCount },+ { id: "catalogue", label: t("automations_view.tab_catalogue"), count: templates.length },+ ]}+ />++ {tab === "automations" && (+ <Panel>+ <div className="px-4 pt-4">+ <PanelHeader+ title={t("automations_view.yours_heading")}+ subtitle={t("automations_view.yours_subtitle")}+ actions={+ <SoftButton onClick={openCatalogue}>+ <LayoutGrid className="h-3.5 w-3.5" />+ {t("automations_view.browse_catalogue")}+ </SoftButton>+ }+ />+ </div>+ <div className="mt-3">+ <AutomationsPanel+ automations={automations}+ templatesByKey={templatesByKey}+ highlightId={highlightId}+ onRunNow={handleRunNow}+ onSetEnabled={handleSetEnabled}+ onDelete={handleDelete}+ onCreate={openCreate}+ onBrowseCatalogue={openCatalogue}+ busy={{+ runId: runNow.isPending ? runNow.variables : undefined,+ toggleId: setEnabled.isPending ? setEnabled.variables?.id : undefined,+ deleteId: deleteTask.isPending ? deleteTask.variables?.id : undefined,+ }}+ loading={tasksQuery.isLoading}+ />+ </div>+ </Panel>+ )}++ {tab === "schedules" && (+ <Panel>+ <div className="px-4 pt-4">+ <PanelHeader+ title={t("automations_view.schedules_heading")}+ subtitle={t("automations_view.schedules_subtitle")}+ actions={+ <SoftButton primary onClick={openScheduleCreate}>+ <Plus className="h-3.5 w-3.5" />+ {t("automations_view.new_schedule")}+ </SoftButton>+ }+ />+ </div>+ <div className="mt-3">+ <SchedulesPanel+ schedules={schedules}+ onRunNow={handleRunNow}+ onDelete={handleDelete}+ onCreate={openScheduleCreate}+ busy={{+ runId: runNow.isPending ? runNow.variables : undefined,+ deleteId: deleteTask.isPending ? deleteTask.variables?.id : undefined,+ }}+ loading={tasksQuery.isLoading}+ />+ </div>+ </Panel>+ )}- <section aria-labelledby="catalogue">- <div className="mb-3 flex items-baseline justify-between">- <h3 id="catalogue" className="text-sm font-semibold">- {t("automations_view.catalogue_heading")}- </h3>- <span className="text-[11px] text-muted-foreground">- {t("automations_view.catalogue_hint")}- </span>- </div>- {catalogueUnavailable ? (- <div className="rounded-2xl border border-dashed border-border/60 p-6 text-center text-sm text-muted-foreground">- {t("automations_view.catalogue_unavailable")}- </div>- ) : templatesQuery.isLoading ? (- <div className="text-sm text-muted-foreground">{t("automations_view.catalogue_loading")}</div>- ) : templatesQuery.error ? (- <div className="rounded-lg border border-destructive/40 p-4 text-sm text-destructive">- {t("automations_view.catalogue_error")}: {(templatesQuery.error as Error).message}- </div>- ) : groups.length === 0 ? (- <div className="rounded-2xl border border-dashed border-border/60 p-6 text-center text-sm text-muted-foreground">- {t("automations_view.catalogue_empty")}- </div>- ) : (- <div className="space-y-6">- {groups.map((group) => (- <div key={group.category}>- <SectionLabel className="mb-2">- {t(`automations_view.category.${group.category}`)}- </SectionLabel>- <div className="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3">- {group.templates.map((tpl) => (- <CatalogueCard- key={tpl.key}- template={tpl}- installedTaskId={installedByKey.get(tpl.key)}- onAdd={setAdding}- onShowInstalled={scrollToTask}- />- ))}- </div>- </div>- ))}- </div>- )}- </section>+ {tab === "runs" && (+ <Panel>+ <div className="px-4 pt-4">+ <PanelHeader+ title={t("automations_view.runs_heading")}+ subtitle={t("automations_view.runs_subtitle")}+ actions={+ <SegmentedFilter<RunFilter>+ label={t("automations_view.runs_filter_label")}+ value={runFilter}+ onChange={setRunFilter}+ options={RUN_FILTERS.map((f) => ({+ id: f,+ label: t(`automations_view.runs_filter.${f}`),+ }))}+ />+ }+ />+ </div>+ <div className="mt-3">+ <RunsPanel tasks={tasks} filter={runFilter} onNotice={showNotice} />+ </div>+ </Panel>+ )}++ {tab === "catalogue" && (+ <div className="space-y-3">+ <PanelHeader+ title={t("automations_view.catalogue_heading")}+ subtitle={t("automations_view.catalogue_hint")}+ />+ {catalogueUnavailable ? (+ <Panel className="p-6 text-center text-sm text-muted-foreground">+ {t("automations_view.catalogue_unavailable")}+ </Panel>+ ) : templatesQuery.isLoading ? (+ <p className="text-sm text-muted-foreground">+ {t("automations_view.catalogue_loading")}+ </p>+ ) : templatesQuery.error ? (+ <Panel className="p-4 text-sm text-destructive">+ {t("automations_view.catalogue_error")}:{" "}+ {(templatesQuery.error as Error).message}+ </Panel>+ ) : templates.length === 0 ? (+ <Panel className="p-6 text-center text-sm text-muted-foreground">+ {t("automations_view.catalogue_empty")}+ </Panel>+ ) : (+ <CataloguePanel+ templates={templates}+ installedByKey={installedByKey}+ onAdd={setAdding}+ onShowInstalled={scrollToTask}+ onCreateCustom={openCreate}+ />+ )}</div>- ) : (- <RunsTab tasks={tasks} onNotice={showNotice} />+ )}++ {tasksQuery.isLoading && (+ <p className="text-sm text-muted-foreground">{t("tasks_view.loading")}</p>)}</div></ScrollArea>@@ -325,41 +446,12 @@ export function AutomationsView() {);}-function TabButton({- active,- onClick,- icon: Icon,- children,-}: {- active: boolean;- onClick: () => void;- icon: typeof Workflow;- children: React.ReactNode;-}) {- return (- <button- type="button"- role="tab"- aria-selected={active}- onClick={onClick}- className={cn(- "-mb-px inline-flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors",- active- ? "border-primary font-medium text-foreground"- : "border-transparent text-muted-foreground hover:text-foreground",- )}- >- <Icon className={cn("h-3.5 w-3.5", active ? "text-primary" : "text-muted-foreground")} />- {children}- </button>- );-}--function Count({ n }: { n: number }) {- if (!n) return null;- return (- <span className="rounded-full border border-border px-1.5 text-[10px] font-mono leading-4 text-muted-foreground">- {n}- </span>- );+/** The countdown as a tile value — "3h", "7min", "due now". Ticks each second. */+function NextRunValue({ dueNs }: { dueNs: number | null }) {+ const t = useT();+ useTick();+ if (dueNs == null) return <>—</>;+ const delta = dueNs - Date.now() * 1e6;+ if (delta <= 0) return <>{t("tasks_view.due_now")}</>;+ return <>{formatDelta(delta)}</>;}diff --git a/jarvis/ui/web/frontend/src/views/TasksView.tsx b/jarvis/ui/web/frontend/src/views/TasksView.tsxdeleted file mode 100644index 02daaf8836..0000000000--- a/jarvis/ui/web/frontend/src/views/TasksView.tsx+++ /dev/null@@ -1,219 +0,0 @@-/**- * The Runs tab of the Automations section — the run history.- *- * This file used to be the whole "Tasks" section. The section became- * Automations (`AutomationsView.tsx`) and the task list folded into its- * Runs tab; the file keeps its name so history and the route stay traceable.- *- * Every task that ran or is running (recurring and one-shot alike) plus the- * still-pending one-shots, newest activity first, with filter chips. A row- * expands to the readable result text and the step timeline.- */-import { useMemo, useState } from "react";-import { ChevronDown, ChevronRight, History, Trash2, X } from "lucide-react";-import { Button } from "@/components/ui/button";-import { useT } from "@/i18n";-import { cn } from "@/lib/utils";-import { useCancelTask, useDeleteTask, useTaskDetail } from "@/hooks/useAutomations";-import {- filterRuns,- formatDuration,- isActive,- isRecurringTrigger,- selectRuns,- type RunFilter,- type TaskSummary,-} from "./automations/automationsModel";-import {- ResultText,- SectionLabel,- StateDot,- StepTimeline,- formatWhen,- useStateLabels,-} from "./automations/shared";--const FILTERS: RunFilter[] = ["all", "running", "done", "problems"];--export interface RunsTabProps {- tasks: TaskSummary[];- onNotice: (text: string, kind?: "info" | "error") => void;-}--export function RunsTab({ tasks, onNotice }: RunsTabProps) {- const t = useT();- const [filter, setFilter] = useState<RunFilter>("all");- const [expanded, setExpanded] = useState<Record<string, boolean>>({});- const cancelMut = useCancelTask();- const deleteMut = useDeleteTask();-- const runs = useMemo(() => filterRuns(selectRuns(tasks), filter), [tasks, filter]);-- return (- <div className="space-y-3">- <div className="flex flex-wrap items-center gap-2">- {FILTERS.map((f) => (- <button- key={f}- type="button"- onClick={() => setFilter(f)}- aria-pressed={filter === f}- className={cn(- "rounded-md border px-2.5 py-1 text-xs transition-colors",- filter === f- ? "border-primary/60 bg-primary/10 text-primary"- : "border-border text-muted-foreground hover:border-primary/30 hover:text-foreground",- )}- >- {t(`automations_view.runs_filter.${f}`)}- </button>- ))}- <div className="ml-auto text-xs text-muted-foreground">- {runs.length} {t("tasks_view.entries")}- </div>- </div>-- {runs.length === 0 ? (- <div className="flex flex-col items-center justify-center gap-3 rounded-2xl border border-dashed border-border/60 p-10 text-center">- <History className="h-7 w-7 text-muted-foreground/50" />- <p className="text-sm text-muted-foreground">{t("automations_view.runs_empty")}</p>- </div>- ) : (- <ul className="space-y-2">- {runs.map((run) => (- <RunRow- key={run.id}- run={run}- expanded={!!expanded[run.id]}- onToggle={() => setExpanded((prev) => ({ ...prev, [run.id]: !prev[run.id] }))}- onCancel={() =>- cancelMut.mutate(run.id, {- onError: (err) => onNotice(`${t("common.error")}: ${(err as Error).message}`, "error"),- })- }- onDelete={() =>- deleteMut.mutate(- { id: run.id, active: isActive(run.state) },- { onError: (err) => onNotice(`${t("common.error")}: ${(err as Error).message}`, "error") },- )- }- busy={{- cancel: cancelMut.isPending && cancelMut.variables === run.id,- delete: deleteMut.isPending && deleteMut.variables?.id === run.id,- }}- />- ))}- </ul>- )}- </div>- );-}--function RunRow({- run,- expanded,- onToggle,- onCancel,- onDelete,- busy,-}: {- run: TaskSummary;- expanded: boolean;- onToggle: () => void;- onCancel: () => void;- onDelete: () => void;- busy: { cancel: boolean; delete: boolean };-}) {- const t = useT();- const labels = useStateLabels();- const when = formatWhen(run.finished_at_ns ?? run.started_at_ns ?? run.due_at_ns ?? run.created_at_ns);- const duration = formatDuration(run.started_at_ns, run.finished_at_ns);- const active = isActive(run.state);- // A recurring automation's row is its latest run; deleting it is the- // card's job on the Automations tab, so only one-shots offer Delete here.- const canDelete = !isRecurringTrigger(run.trigger_type) || !active;-- return (- <li className="card-outline">- <div className="flex items-center gap-3 px-4 py-3">- <button- type="button"- onClick={onToggle}- className="rounded-md p-1 text-muted-foreground transition-colors hover:text-foreground"- aria-label={expanded ? t("tasks_view.collapse") : t("tasks_view.expand")}- aria-expanded={expanded}- >- {expanded ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}- </button>- <StateDot state={run.state} />- <div className="min-w-0 flex-1">- <div className="flex items-center gap-2">- <span className="truncate text-sm font-medium">{run.title || t("tasks_view.untitled")}</span>- <span className="shrink-0 text-[11px] text-muted-foreground">{labels[run.state]}</span>- </div>- {(run.last_result || run.last_error) && (- <p- className={cn(- "mt-0.5 truncate text-xs",- run.last_error && !run.last_result ? "text-destructive/90" : "text-muted-foreground",- )}- >- {run.last_result || run.last_error}- </p>- )}- </div>- <div className="shrink-0 text-right text-[11px] text-muted-foreground">- <div>{when}</div>- {duration && <div className="font-mono">{duration}</div>}- </div>- <div className="flex shrink-0 items-center">- {active && (- <Button size="sm" variant="ghost" onClick={onCancel} disabled={busy.cancel} title={t("tasks_view.cancel")}>- <X className="h-4 w-4" />- </Button>- )}- {canDelete && (- <Button size="sm" variant="ghost" onClick={onDelete} disabled={busy.delete} title={t("tasks_view.delete")}>- <Trash2 className="h-4 w-4" />- </Button>- )}- </div>- </div>- {expanded && <RunDetail taskId={run.id} fallbackResult={run.last_result} />}- </li>- );-}--function RunDetail({ taskId, fallbackResult }: { taskId: string; fallbackResult?: string | null }) {- const t = useT();- const { data, isLoading, error } = useTaskDetail(taskId);- if (isLoading) {- return (- <div className="border-t border-border px-4 py-3 text-xs text-muted-foreground">- {t("tasks_view.loading_details")}- </div>- );- }- if (error) {- return (- <div className="border-t border-border px-4 py-3 text-xs text-destructive">- {t("common.error")}: {(error as Error).message}- </div>- );- }- const steps = data?.steps ?? [];- return (- <div className="space-y-3 border-t border-border px-4 py-3">- <div>- <SectionLabel className="mb-1.5">{t("automations_view.result")}</SectionLabel>- <ResultText steps={steps} fallback={fallbackResult} />- </div>- <div>- <SectionLabel className="mb-1.5">- {t("automations_view.timeline")} ({steps.length})- </SectionLabel>- <StepTimeline steps={steps} />- </div>- </div>- );-}diff --git a/jarvis/ui/web/frontend/src/views/automations/AutomationCard.tsx b/jarvis/ui/web/frontend/src/views/automations/AutomationCard.tsxdeleted file mode 100644index 3592b5def4..0000000000--- a/jarvis/ui/web/frontend/src/views/automations/AutomationCard.tsx+++ /dev/null@@ -1,232 +0,0 @@-/**- * One of the user's automations: icon, name, description, schedule line,- * next-run countdown, last-run dot + result preview, and the three actions- * (Run now, Pause/Resume, Delete). Expanding shows the latest run's result- * and the step timeline from the detail endpoint.- */-import { useState } from "react";-import { ChevronDown, ChevronRight, Loader2, Play, Trash2 } from "lucide-react";-import { Button } from "@/components/ui/button";-import { Switch } from "@/components/ui/switch";-import { useT } from "@/i18n";-import { cn } from "@/lib/utils";-import { useTaskDetail } from "@/hooks/useAutomations";-import { templateIcon } from "./automationIcons";-import {- firstLine,- isActive,- promptOfSpec,- scheduleLineForTask,- templateKeyOf,- type AutomationTemplate,- type TaskSummary,-} from "./automationsModel";-import {- Countdown,- ResultText,- SectionLabel,- StateDot,- StepTimeline,- formatWhen,- useScheduleWords,- useStateLabels,-} from "./shared";--export interface AutomationCardProps {- task: TaskSummary;- /** The template the task came from, when the catalogue knows it. */- template?: AutomationTemplate;- highlighted?: boolean;- onRunNow: (id: string) => void;- onSetEnabled: (id: string, enabled: boolean) => void;- onDelete: (id: string, active: boolean) => void;- busy?: { run?: boolean; toggle?: boolean; delete?: boolean };-}--export function AutomationCard({- task,- template,- highlighted,- onRunNow,- onSetEnabled,- onDelete,- busy,-}: AutomationCardProps) {- const t = useT();- const words = useScheduleWords();- const stateLabels = useStateLabels();- const [expanded, setExpanded] = useState(false);- const [confirmDelete, setConfirmDelete] = useState(false);-- const Icon = templateIcon(template?.icon);- const paused = task.state === "paused";- const running = task.state === "running";- const description = template?.description ?? "";- const schedule = scheduleLineForTask(task, words);- const lastState = task.last_run_state ?? null;-- return (- <article- id={`automation-${task.id}`}- data-template-key={templateKeyOf(task) ?? undefined}- className={cn(- "card-outline flex flex-col transition-shadow",- highlighted && "ring-2 ring-primary/60",- paused && "opacity-75",- )}- >- <div className="flex items-start gap-3 p-4">- <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/30 bg-primary/10">- <Icon className="h-4 w-4 text-primary" />- </div>- <div className="min-w-0 flex-1">- <h3 className="truncate text-sm font-semibold">{task.title || t("tasks_view.untitled")}</h3>- <CardDescription task={task} fallback={description} />- </div>- <Switch- checked={!paused}- disabled={busy?.toggle || running}- onCheckedChange={(on) => onSetEnabled(task.id, on)}- aria-label={paused ? t("automations_view.resume") : t("automations_view.pause")}- title={paused ? t("automations_view.resume") : t("automations_view.pause")}- />- </div>-- <dl className="grid grid-cols-2 gap-x-3 gap-y-1 border-t border-border/60 px-4 py-3 text-[11px]">- <dt className="text-muted-foreground">{t("automations_view.schedule_label")}</dt>- <dd className="truncate text-right text-foreground">{schedule}</dd>- <dt className="text-muted-foreground">{t("automations_view.next_run")}</dt>- <dd className="text-right text-foreground">- {running ? (- <span className="text-primary">{t("tasks_view.running_now")}</span>- ) : paused ? (- <span>{stateLabels.paused}</span>- ) : (- <Countdown dueNs={task.next_due_at_ns ?? task.due_at_ns} />- )}- </dd>- <dt className="text-muted-foreground">{t("automations_view.last_run")}</dt>- <dd className="flex items-center justify-end gap-1.5 text-right">- <StateDot state={lastState} />- <span className="truncate">- {lastState ? stateLabels[lastState] : t("automations_view.never_ran")}- {task.finished_at_ns ? ` · ${formatWhen(task.finished_at_ns)}` : ""}- </span>- </dd>- </dl>-- {(task.last_result || task.last_error) && (- <p- className={cn(- "line-clamp-2 border-t border-border/60 px-4 py-2.5 text-xs leading-relaxed",- task.last_error && !task.last_result ? "text-destructive/90" : "text-muted-foreground",- )}- >- {task.last_result || task.last_error}- </p>- )}-- <div className="mt-auto flex items-center gap-1 border-t border-border/60 px-2 py-1.5">- <Button- size="sm"- variant="ghost"- onClick={() => onRunNow(task.id)}- disabled={busy?.run || running}- title={t("automations_view.run_now")}- >- {busy?.run ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <Play className="h-3.5 w-3.5" />}- <span className="ml-1.5 text-xs">{t("automations_view.run_now")}</span>- </Button>- <button- type="button"- onClick={() => setExpanded((x) => !x)}- className="inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground"- aria-expanded={expanded}- >- {expanded ? <ChevronDown className="h-3.5 w-3.5" /> : <ChevronRight className="h-3.5 w-3.5" />}- {t("automations_view.details")}- </button>- <div className="ml-auto flex items-center gap-1">- {confirmDelete ? (- <>- <span className="text-[11px] text-muted-foreground">{t("automations_view.delete_confirm")}</span>- <Button- size="sm"- variant="destructive"- className="h-7 px-2 text-xs"- disabled={busy?.delete}- onClick={() => onDelete(task.id, isActive(task.state))}- >- {busy?.delete ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : t("tasks_view.delete")}- </Button>- <Button- size="sm"- variant="ghost"- className="h-7 px-2 text-xs"- onClick={() => setConfirmDelete(false)}- >- {t("automations_view.keep")}- </Button>- </>- ) : (- <Button- size="sm"- variant="ghost"- onClick={() => setConfirmDelete(true)}- title={t("tasks_view.delete")}- aria-label={t("tasks_view.delete")}- >- <Trash2 className="h-3.5 w-3.5" />- </Button>- )}- </div>- </div>-- {expanded && <AutomationDetail taskId={task.id} fallbackResult={task.last_result} />}- </article>- );-}--/** Template description, else the prompt's first line (fetched lazily from- * the detail spec only when there is no template to describe the task). */-function CardDescription({ task, fallback }: { task: TaskSummary; fallback: string }) {- const needsSpec = !fallback;- const { data } = useTaskDetail(task.id, needsSpec);- const text = fallback || firstLine(promptOfSpec(data?.spec));- if (!text) return null;- return <p className="mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground">{text}</p>;-}--function AutomationDetail({ taskId, fallbackResult }: { taskId: string; fallbackResult?: string | null }) {- const t = useT();- const { data, isLoading, error } = useTaskDetail(taskId);- if (isLoading) {- return (- <div className="border-t border-border px-4 py-3 text-xs text-muted-foreground">- {t("tasks_view.loading_details")}- </div>- );- }- if (error) {- return (- <div className="border-t border-border px-4 py-3 text-xs text-destructive">- {t("common.error")}: {(error as Error).message}- </div>- );- }- const steps = data?.steps ?? [];- return (- <div className="space-y-3 border-t border-border px-4 py-3">- <div>- <SectionLabel className="mb-1.5">{t("automations_view.latest_result")}</SectionLabel>- <ResultText steps={steps} fallback={fallbackResult} />- </div>- <div>- <SectionLabel className="mb-1.5">- {t("automations_view.timeline")} ({steps.length})- </SectionLabel>- <StepTimeline steps={steps} />- </div>- </div>- );-}diff --git a/jarvis/ui/web/frontend/src/views/automations/AutomationsPanel.tsx b/jarvis/ui/web/frontend/src/views/automations/AutomationsPanel.tsxnew file mode 100644index 0000000000..ef1447e985--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/automations/AutomationsPanel.tsx@@ -0,0 +1,355 @@+/**+ * The user's recurring automations, as one dense table.+ *+ * This used to be a grid of large cards. On a wide pane those cards stretched+ * to a third of a 4K screen each and a category with a single entry left two+ * thirds of the row empty — a lot of surface saying very little. The section+ * design's table says the same in one line per automation: what it is, when it+ * runs, when it ran last and how that went, with the arm switch and the action+ * menu on the right. A row opens to the latest result and the step timeline.+ */+import { Fragment, useState } from "react";+import { Loader2, MoreHorizontal, Play, Trash2 } from "lucide-react";+import { Switch } from "@/components/ui/switch";+import {+ ActionMenu,+ Cell,+ EmptyRow,+ IconButton,+ SoftButton,+ Table,+ TableHead,+ TableRow,+ type Column,+} from "@/components/extensions/primitives";+import { useT } from "@/i18n";+import { cn } from "@/lib/utils";+import { useTaskDetail } from "@/hooks/useAutomations";+import { templateIcon } from "./automationIcons";+import {+ firstLine,+ isActive,+ promptOfSpec,+ scheduleLineForTask,+ templateKeyOf,+ type AutomationTemplate,+ type TaskSummary,+} from "./automationsModel";+import {+ Countdown,+ ResultText,+ SectionLabel,+ StateDot,+ StepTimeline,+ formatWhen,+ useScheduleWords,+ useStateLabels,+} from "./shared";++export interface AutomationsPanelProps {+ automations: TaskSummary[];+ /** Template key → template, so a row can borrow its catalogue description. */+ templatesByKey: Map<string, AutomationTemplate>;+ highlightId: string | null;+ onRunNow: (id: string) => void;+ onSetEnabled: (id: string, enabled: boolean) => void;+ onDelete: (id: string, active: boolean) => void;+ onCreate: () => void;+ onBrowseCatalogue: () => void;+ busy: {+ runId?: string;+ toggleId?: string;+ deleteId?: string;+ };+ loading: boolean;+}++export function AutomationsPanel({+ automations,+ templatesByKey,+ highlightId,+ onRunNow,+ onSetEnabled,+ onDelete,+ onCreate,+ onBrowseCatalogue,+ busy,+ loading,+}: AutomationsPanelProps) {+ const t = useT();+ const [openId, setOpenId] = useState<string | null>(null);+ const [confirmId, setConfirmId] = useState<string | null>(null);++ const columns: Column[] = [+ { id: "name", label: t("automations_view.col_automation") },+ { id: "schedule", label: t("automations_view.schedule_label"), width: "minmax(0, 150px)" },+ { id: "next", label: t("automations_view.next_run"), width: "minmax(0, 120px)" },+ { id: "last", label: t("automations_view.last_run"), width: "minmax(0, 190px)" },+ { id: "toggle", label: t("automations_view.armed"), width: "48px", align: "center", srOnly: true },+ { id: "actions", label: t("automations_view.col_actions"), width: "36px", align: "right", srOnly: true },+ ];++ if (!loading && automations.length === 0) {+ return (+ <EmptyRow>+ <p>{t("automations_view.yours_empty")}</p>+ <p className="mx-auto mt-1 max-w-md text-xs text-muted-foreground/80">+ {t("automations_view.yours_empty_hint")}+ </p>+ <div className="mt-4 flex items-center justify-center gap-2">+ <SoftButton primary onClick={onCreate}>+ {t("automations_view.new_button")}+ </SoftButton>+ <SoftButton onClick={onBrowseCatalogue}>+ {t("automations_view.browse_catalogue")}+ </SoftButton>+ </div>+ </EmptyRow>+ );+ }++ return (+ <Table label={t("automations_view.tab_automations")}>+ <TableHead columns={columns} />+ {automations.map((task) => {+ const key = templateKeyOf(task);+ const template = key ? templatesByKey.get(key) : undefined;+ return (+ <Fragment key={task.id}>+ <AutomationRow+ columns={columns}+ task={task}+ template={template}+ highlighted={highlightId === task.id}+ open={openId === task.id}+ onToggleOpen={() => setOpenId((cur) => (cur === task.id ? null : task.id))}+ onRunNow={() => onRunNow(task.id)}+ onSetEnabled={(on) => onSetEnabled(task.id, on)}+ onAskDelete={() => setConfirmId(task.id)}+ busy={{+ run: busy.runId === task.id,+ toggle: busy.toggleId === task.id,+ }}+ />+ {confirmId === task.id && (+ <ConfirmDeleteRow+ busy={busy.deleteId === task.id}+ onConfirm={() => {+ onDelete(task.id, isActive(task.state));+ setConfirmId(null);+ }}+ onKeep={() => setConfirmId(null)}+ />+ )}+ {openId === task.id && (+ <AutomationDetail taskId={task.id} fallbackResult={task.last_result} />+ )}+ </Fragment>+ );+ })}+ </Table>+ );+}++function AutomationRow({+ columns,+ task,+ template,+ highlighted,+ open,+ onToggleOpen,+ onRunNow,+ onSetEnabled,+ onAskDelete,+ busy,+}: {+ columns: Column[];+ task: TaskSummary;+ template?: AutomationTemplate;+ highlighted: boolean;+ open: boolean;+ onToggleOpen: () => void;+ onRunNow: () => void;+ onSetEnabled: (on: boolean) => void;+ onAskDelete: () => void;+ busy: { run: boolean; toggle: boolean };+}) {+ const t = useT();+ const words = useScheduleWords();+ const stateLabels = useStateLabels();+ const Icon = templateIcon(template?.icon);+ const paused = task.state === "paused";+ const running = task.state === "running";+ const lastState = task.last_run_state ?? null;++ return (+ <TableRow+ columns={columns}+ id={`automation-${task.id}`}+ onClick={onToggleOpen}+ selected={open}+ ariaLabel={task.title || t("tasks_view.untitled")}+ className={cn(+ highlighted && "bg-primary/5 ring-1 ring-inset ring-primary/40",+ paused && "opacity-70",+ )}+ >+ <Cell>+ <div className="flex min-w-0 items-center gap-3">+ <span className="grid h-8 w-8 shrink-0 place-items-center rounded-lg border border-border bg-secondary/40">+ <Icon className="h-4 w-4 text-primary" />+ </span>+ <span className="min-w-0">+ <span className="block truncate font-medium text-foreground">+ {task.title || t("tasks_view.untitled")}+ </span>+ <AutomationSubline task={task} fallback={template?.description ?? ""} />+ </span>+ </div>+ </Cell>+ <Cell muted className="truncate">+ {scheduleLineForTask(task, words)}+ </Cell>+ <Cell muted>+ {running ? (+ <span className="text-primary">{t("tasks_view.running_now")}</span>+ ) : paused ? (+ <span>{stateLabels.paused}</span>+ ) : (+ <Countdown dueNs={task.next_due_at_ns ?? task.due_at_ns} />+ )}+ </Cell>+ <Cell muted>+ <span className="flex min-w-0 items-center gap-2">+ <StateDot state={lastState} />+ <span className="truncate">+ {lastState ? stateLabels[lastState] : t("automations_view.never_ran")}+ {task.finished_at_ns ? ` · ${formatWhen(task.finished_at_ns)}` : ""}+ </span>+ </span>+ </Cell>+ <Cell align="center" stop>+ <Switch+ checked={!paused}+ disabled={busy.toggle || running}+ onCheckedChange={onSetEnabled}+ aria-label={paused ? t("automations_view.resume") : t("automations_view.pause")}+ title={paused ? t("automations_view.resume") : t("automations_view.pause")}+ />+ </Cell>+ <Cell align="right" stop>+ <ActionMenu+ label={t("automations_view.col_actions")}+ actions={[+ {+ id: "run",+ label: t("automations_view.run_now"),+ icon: busy.run ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <Play className="h-3.5 w-3.5" />,+ disabled: busy.run || running,+ onSelect: onRunNow,+ },+ {+ id: "delete",+ label: t("tasks_view.delete"),+ icon: <Trash2 className="h-3.5 w-3.5" />,+ destructive: true,+ separatorAbove: true,+ onSelect: onAskDelete,+ },+ ]}+ trigger={({ open: menuOpen, toggle }) => (+ <IconButton+ label={t("automations_view.col_actions")}+ active={menuOpen}+ onClick={toggle}+ className="h-7 w-7"+ >+ <MoreHorizontal className="h-4 w-4" />+ </IconButton>+ )}+ />+ </Cell>+ </TableRow>+ );+}++/** Template description, else the prompt's first line (fetched lazily from+ * the detail spec only when there is no template to describe the task). */+function AutomationSubline({ task, fallback }: { task: TaskSummary; fallback: string }) {+ const needsSpec = !fallback;+ const { data } = useTaskDetail(task.id, needsSpec);+ const text = fallback || firstLine(promptOfSpec(data?.spec));+ if (!text) return null;+ return <span className="block truncate text-xs text-muted-foreground">{text}</span>;+}++/** The one-question delete confirmation, in place under its row. */+function ConfirmDeleteRow({+ busy,+ onConfirm,+ onKeep,+}: {+ busy: boolean;+ onConfirm: () => void;+ onKeep: () => void;+}) {+ const t = useT();+ return (+ <div+ role="presentation"+ className="flex items-center gap-2 border-b border-border/70 bg-destructive/5 px-3 py-2.5 text-sm last:border-b-0"+ >+ <span className="flex-1 text-muted-foreground">{t("automations_view.delete_confirm")}</span>+ <button+ type="button"+ disabled={busy}+ onClick={onConfirm}+ className="inline-flex h-7 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 disabled:opacity-50"+ >+ {busy && <Loader2 className="h-3.5 w-3.5 animate-spin" />}+ {t("tasks_view.delete")}+ </button>+ <SoftButton onClick={onKeep}>{t("automations_view.keep")}</SoftButton>+ </div>+ );+}++function AutomationDetail({+ taskId,+ fallbackResult,+}: {+ taskId: string;+ fallbackResult?: string | null;+}) {+ const t = useT();+ const { data, isLoading, error } = useTaskDetail(taskId);+ if (isLoading) {+ return (+ <div role="presentation" className="border-b border-border/70 bg-sheen/[0.03] px-4 py-3 text-xs text-muted-foreground last:border-b-0">+ {t("tasks_view.loading_details")}+ </div>+ );+ }+ if (error) {+ return (+ <div role="presentation" className="border-b border-border/70 bg-sheen/[0.03] px-4 py-3 text-xs text-destructive last:border-b-0">+ {t("common.error")}: {(error as Error).message}+ </div>+ );+ }+ const steps = data?.steps ?? [];+ return (+ <div role="presentation" className="space-y-3 border-b border-border/70 bg-sheen/[0.03] px-4 py-4 last:border-b-0">+ <div>+ <SectionLabel className="mb-1.5">{t("automations_view.latest_result")}</SectionLabel>+ <ResultText steps={steps} fallback={fallbackResult} />+ </div>+ <div>+ <SectionLabel className="mb-1.5">+ {t("automations_view.timeline")} ({steps.length})+ </SectionLabel>+ <StepTimeline steps={steps} />+ </div>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/views/automations/CatalogueCard.tsx b/jarvis/ui/web/frontend/src/views/automations/CatalogueCard.tsxindex 27be9d27e5..cb2e48f935 100644--- a/jarvis/ui/web/frontend/src/views/automations/CatalogueCard.tsx+++ b/jarvis/ui/web/frontend/src/views/automations/CatalogueCard.tsx@@ -1,11 +1,14 @@/**- * A catalogue entry: icon, name, description, default schedule and the Add- * button. When the template is already installed the card says so and links- * to the user's card; when a required plugin is missing it carries a quiet- * "needs Gmail" hint (Add still works — the dialog repeats the warning).+ * A catalogue entry: icon, name, description, default schedule and Add.+ *+ * The card carries a minimum height so a one-sentence template and a+ * three-sentence one line up in the same row instead of stair-stepping — the+ * ragged grid was most of what made the section look thrown together. When+ * the template is already installed the card says so and links to the user's+ * row; when a required plugin is missing it carries a quiet "needs Gmail"+ * line (Add still works — the dialog repeats the warning).*/-import { Check, Plus } from "lucide-react";-import { Button } from "@/components/ui/button";+import { Check, Clock, Plus } from "lucide-react";import { fill, useT } from "@/i18n";import { cn } from "@/lib/utils";import { templateIcon } from "./automationIcons";@@ -19,52 +22,70 @@ export interface CatalogueCardProps {onShowInstalled: (taskId: string) => void;}-export function CatalogueCard({ template, installedTaskId, onAdd, onShowInstalled }: CatalogueCardProps) {+export function CatalogueCard({+ template,+ installedTaskId,+ onAdd,+ onShowInstalled,+}: CatalogueCardProps) {const t = useT();const Icon = templateIcon(template.icon);const installed = Boolean(installedTaskId);+ const needsSomething = !template.ready && template.missing.length > 0;return (<articledata-testid={`catalogue-${template.key}`}- className={cn("card-outline flex flex-col", installed && "border-primary/30")}+ className={cn(+ "card-outline flex min-h-[148px] flex-col p-4",+ installed && "border-primary/40",+ )}>- <div className="flex items-start gap-3 p-4">- <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary/40">+ <div className="flex items-start gap-3">+ <span className="grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-border bg-secondary/40"><Icon className="h-4 w-4 text-primary" />- </div>+ </span><div className="min-w-0 flex-1">- <h3 className="truncate text-sm font-semibold">{template.name}</h3>- <p className="mt-0.5 line-clamp-3 text-xs leading-relaxed text-muted-foreground">+ <h3 className="truncate text-sm font-semibold text-foreground">{template.name}</h3>+ <p className="mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground">{template.description}</p></div></div>- <div className="mt-auto flex items-center gap-2 border-t border-border/60 px-4 py-2.5">- <div className="min-w-0 flex-1">- <div className="truncate text-[11px] text-muted-foreground">{template.schedule_label}</div>- {!template.ready && template.missing.length > 0 && (- <div className="truncate text-[11px] text-amber-600 dark:text-amber-400/90">- {fill(t("automations_view.needs"), { tools: humanizeMissing(template.missing) })}- </div>++ {needsSomething && (+ <p className="mt-2 truncate text-[11px] text-amber-600 dark:text-amber-400/90">+ {fill(t("automations_view.needs"), { tools: humanizeMissing(template.missing) })}+ </p>+ )}++ <div className="mt-auto flex items-center gap-2 pt-3">+ <span className="inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground">+ <Clock className="h-3 w-3 shrink-0" />+ <span className="truncate">{template.schedule_label}</span>+ </span>+ <span className="ml-auto shrink-0">+ {installed && installedTaskId ? (+ <button+ type="button"+ onClick={() => onShowInstalled(installedTaskId)}+ title={t("automations_view.show_installed")}+ className="inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/40 px-2.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10"+ >+ <Check className="h-3.5 w-3.5" />+ {t("automations_view.added")}+ </button>+ ) : (+ <button+ type="button"+ onClick={() => onAdd(template)}+ className="inline-flex h-7 items-center gap-1.5 rounded-md bg-sheen/[0.08] px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-sheen/[0.16]"+ >+ <Plus className="h-3.5 w-3.5" />+ {t("automations_view.add")}+ </button>)}- </div>- {installed && installedTaskId ? (- <button- type="button"- onClick={() => onShowInstalled(installedTaskId)}- className="inline-flex items-center gap-1 rounded-md border border-primary/40 px-2.5 py-1 text-xs text-primary transition-colors hover:bg-primary/10"- title={t("automations_view.show_installed")}- >- <Check className="h-3.5 w-3.5" />- {t("automations_view.added")}- </button>- ) : (- <Button size="sm" variant="outline" className="h-7 px-2.5 text-xs" onClick={() => onAdd(template)}>- <Plus className="mr-1 h-3.5 w-3.5" />- {t("automations_view.add")}- </Button>- )}+ </span></div></article>);diff --git a/jarvis/ui/web/frontend/src/views/automations/CataloguePanel.tsx b/jarvis/ui/web/frontend/src/views/automations/CataloguePanel.tsxnew file mode 100644index 0000000000..bc06fe1098--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/automations/CataloguePanel.tsx@@ -0,0 +1,116 @@+/**+ * The catalogue of ready-made automations.+ *+ * The old layout printed one grid per category down the page, so a category+ * holding a single template left two thirds of a row empty and the page read+ * as mostly whitespace. Categories are a filter now, not five separate grids:+ * one chip row, one grid, three columns inside the section's content width.+ *+ * The first tile is deliberately not a template — it is "build your own",+ * because the catalogue is where someone looks when they want an automation,+ * and the only way to make a custom one used to be a small button in the far+ * corner of the header.+ */+import { useMemo, useState } from "react";+import { Plus, Wand2 } from "lucide-react";+import { SegmentedFilter } from "@/components/extensions/primitives";+import { useT } from "@/i18n";+import { CatalogueCard } from "./CatalogueCard";+import {+ TEMPLATE_CATEGORIES,+ type AutomationTemplate,+ type TemplateCategory,+} from "./automationsModel";++type CategoryFilter = TemplateCategory | "all";++export interface CataloguePanelProps {+ templates: AutomationTemplate[];+ /** Template key → the user's task created from it, when installed. */+ installedByKey: Map<string, string>;+ onAdd: (template: AutomationTemplate) => void;+ onShowInstalled: (taskId: string) => void;+ onCreateCustom: () => void;+}++export function CataloguePanel({+ templates,+ installedByKey,+ onAdd,+ onShowInstalled,+ onCreateCustom,+}: CataloguePanelProps) {+ const t = useT();+ const [category, setCategory] = useState<CategoryFilter>("all");++ // Only categories that actually hold something become chips — an empty+ // "Finance" chip that filters to nothing is a dead end, not a feature.+ const options = useMemo(() => {+ const present = TEMPLATE_CATEGORIES.filter((c) =>+ templates.some((tpl) => tpl.category === c),+ );+ return [+ { id: "all" as CategoryFilter, label: t("automations_view.category_all"), count: templates.length },+ ...present.map((c) => ({+ id: c as CategoryFilter,+ label: t(`automations_view.category.${c}`),+ count: templates.filter((tpl) => tpl.category === c).length,+ })),+ ];+ }, [templates, t]);++ const shown = useMemo(+ () => (category === "all" ? templates : templates.filter((tpl) => tpl.category === category)),+ [templates, category],+ );++ return (+ <div className="space-y-3">+ <SegmentedFilter<CategoryFilter>+ label={t("automations_view.category_label")}+ value={category}+ onChange={setCategory}+ options={options}+ />+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3">+ {category === "all" && <CustomTile onClick={onCreateCustom} />}+ {shown.map((tpl) => (+ <CatalogueCard+ key={tpl.key}+ template={tpl}+ installedTaskId={installedByKey.get(tpl.key)}+ onAdd={onAdd}+ onShowInstalled={onShowInstalled}+ />+ ))}+ </div>+ </div>+ );+}++/** "Build your own" — the same size as a template card, drawn as an offer. */+function CustomTile({ onClick }: { onClick: () => void }) {+ const t = useT();+ return (+ <button+ type="button"+ onClick={onClick}+ data-testid="catalogue-custom"+ className="flex min-h-[148px] flex-col items-start gap-2 rounded-2xl border border-dashed border-border p-4 text-left transition-colors hover:border-primary/50 hover:bg-sheen/[0.04]"+ >+ <span className="grid h-9 w-9 place-items-center rounded-lg border border-primary/30 bg-primary/10">+ <Wand2 className="h-4 w-4 text-primary" />+ </span>+ <span className="text-sm font-semibold text-foreground">+ {t("automations_view.custom_title")}+ </span>+ <span className="text-xs leading-relaxed text-muted-foreground">+ {t("automations_view.custom_description")}+ </span>+ <span className="mt-auto inline-flex items-center gap-1 text-xs font-medium text-primary">+ <Plus className="h-3.5 w-3.5" />+ {t("automations_view.new_button")}+ </span>+ </button>+ );+}diff --git a/jarvis/ui/web/frontend/src/views/automations/RunsPanel.tsx b/jarvis/ui/web/frontend/src/views/automations/RunsPanel.tsxnew file mode 100644index 0000000000..8adc8f16aa--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/automations/RunsPanel.tsx@@ -0,0 +1,223 @@+/**+ * The run history — every task that ran or is running, newest first.+ *+ * Was a stack of full-width cards in `TasksView.tsx`; it is a table now, like+ * the two tabs beside it, so a long history stays scannable. A row opens to+ * the readable result text and the step timeline. Still-waiting one-shots are+ * NOT here any more — they belong to the Schedules tab, which is the whole+ * point of that tab existing.+ */+import { Fragment, useMemo, useState } from "react";+import { Loader2, MoreHorizontal, Trash2, X } from "lucide-react";+import {+ ActionMenu,+ Cell,+ EmptyRow,+ IconButton,+ Table,+ TableHead,+ TableRow,+ type Column,+} from "@/components/extensions/primitives";+import { useT } from "@/i18n";+import { cn } from "@/lib/utils";+import { useCancelTask, useDeleteTask, useTaskDetail } from "@/hooks/useAutomations";+import {+ filterRuns,+ formatDuration,+ isActive,+ isRecurringTrigger,+ selectRuns,+ type RunFilter,+ type TaskSummary,+} from "./automationsModel";+import {+ ResultText,+ SectionLabel,+ StateDot,+ StepTimeline,+ formatWhen,+ useStateLabels,+} from "./shared";++export const RUN_FILTERS: RunFilter[] = ["all", "running", "done", "problems"];++export interface RunsPanelProps {+ tasks: TaskSummary[];+ filter: RunFilter;+ onNotice: (text: string, kind?: "info" | "error") => void;+}++export function RunsPanel({ tasks, filter, onNotice }: RunsPanelProps) {+ const t = useT();+ const stateLabels = useStateLabels();+ const [openId, setOpenId] = useState<string | null>(null);+ const cancelMut = useCancelTask();+ const deleteMut = useDeleteTask();++ const runs = useMemo(() => filterRuns(selectRuns(tasks), filter), [tasks, filter]);++ const columns: Column[] = [+ { id: "name", label: t("automations_view.col_run") },+ { id: "result", label: t("automations_view.result"), width: "minmax(0, 1.1fr)" },+ { id: "when", label: t("automations_view.col_when"), width: "minmax(0, 130px)" },+ { id: "duration", label: t("automations_view.col_duration"), width: "minmax(0, 90px)", align: "right" },+ { id: "actions", label: t("automations_view.col_actions"), width: "36px", align: "right", srOnly: true },+ ];++ if (runs.length === 0) {+ return <EmptyRow>{t("automations_view.runs_empty")}</EmptyRow>;+ }++ return (+ <Table label={t("automations_view.tab_runs")}>+ <TableHead columns={columns} />+ {runs.map((run) => {+ const active = isActive(run.state);+ // A recurring automation's row is its latest run; deleting it is the+ // Automations tab's job, so only one-shots offer Delete here.+ const canDelete = !isRecurringTrigger(run.trigger_type) || !active;+ const duration = formatDuration(run.started_at_ns, run.finished_at_ns);+ const open = openId === run.id;+ return (+ <Fragment key={run.id}>+ <TableRow+ columns={columns}+ onClick={() => setOpenId((cur) => (cur === run.id ? null : run.id))}+ selected={open}+ ariaLabel={run.title || t("tasks_view.untitled")}+ >+ <Cell>+ <span className="flex min-w-0 items-center gap-2.5">+ <StateDot state={run.state} />+ <span className="min-w-0">+ <span className="block truncate font-medium text-foreground">+ {run.title || t("tasks_view.untitled")}+ </span>+ <span className="block truncate text-xs text-muted-foreground">+ {stateLabels[run.state]}+ </span>+ </span>+ </span>+ </Cell>+ <Cell muted>+ <span+ className={cn(+ "block truncate",+ run.last_error && !run.last_result && "text-destructive/90",+ )}+ >+ {run.last_result || run.last_error || "—"}+ </span>+ </Cell>+ <Cell muted className="truncate">+ {formatWhen(+ run.finished_at_ns ?? run.started_at_ns ?? run.due_at_ns ?? run.created_at_ns,+ )}+ </Cell>+ <Cell muted align="right" className="font-mono">+ {duration ?? "—"}+ </Cell>+ <Cell align="right" stop>+ <ActionMenu+ label={t("automations_view.col_actions")}+ actions={[+ ...(active+ ? [+ {+ id: "cancel",+ label: t("tasks_view.cancel"),+ icon:+ cancelMut.isPending && cancelMut.variables === run.id ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <X className="h-3.5 w-3.5" />+ ),+ onSelect: () =>+ cancelMut.mutate(run.id, {+ onError: (err) =>+ onNotice(+ `${t("common.error")}: ${(err as Error).message}`,+ "error",+ ),+ }),+ },+ ]+ : []),+ ...(canDelete+ ? [+ {+ id: "delete",+ label: t("tasks_view.delete"),+ icon: <Trash2 className="h-3.5 w-3.5" />,+ destructive: true,+ separatorAbove: active,+ onSelect: () =>+ deleteMut.mutate(+ { id: run.id, active: isActive(run.state) },+ {+ onError: (err) =>+ onNotice(+ `${t("common.error")}: ${(err as Error).message}`,+ "error",+ ),+ },+ ),+ },+ ]+ : []),+ ]}+ trigger={({ open: menuOpen, toggle }) => (+ <IconButton+ label={t("automations_view.col_actions")}+ active={menuOpen}+ onClick={toggle}+ className="h-7 w-7"+ >+ <MoreHorizontal className="h-4 w-4" />+ </IconButton>+ )}+ />+ </Cell>+ </TableRow>+ {open && <RunDetail taskId={run.id} fallbackResult={run.last_result} />}+ </Fragment>+ );+ })}+ </Table>+ );+}++function RunDetail({ taskId, fallbackResult }: { taskId: string; fallbackResult?: string | null }) {+ const t = useT();+ const { data, isLoading, error } = useTaskDetail(taskId);+ if (isLoading) {+ return (+ <div role="presentation" className="border-b border-border/70 bg-sheen/[0.03] px-4 py-3 text-xs text-muted-foreground last:border-b-0">+ {t("tasks_view.loading_details")}+ </div>+ );+ }+ if (error) {+ return (+ <div role="presentation" className="border-b border-border/70 bg-sheen/[0.03] px-4 py-3 text-xs text-destructive last:border-b-0">+ {t("common.error")}: {(error as Error).message}+ </div>+ );+ }+ const steps = data?.steps ?? [];+ return (+ <div role="presentation" className="space-y-3 border-b border-border/70 bg-sheen/[0.03] px-4 py-4 last:border-b-0">+ <div>+ <SectionLabel className="mb-1.5">{t("automations_view.result")}</SectionLabel>+ <ResultText steps={steps} fallback={fallbackResult} />+ </div>+ <div>+ <SectionLabel className="mb-1.5">+ {t("automations_view.timeline")} ({steps.length})+ </SectionLabel>+ <StepTimeline steps={steps} />+ </div>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/views/automations/SchedulesPanel.tsx b/jarvis/ui/web/frontend/src/views/automations/SchedulesPanel.tsxnew file mode 100644index 0000000000..7da9959200--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/automations/SchedulesPanel.tsx@@ -0,0 +1,143 @@+/**+ * Schedules — the one-off timed tasks ("remind me at 18:00", "run this in an+ * hour"). They were always creatable, but they had nowhere to live: a waiting+ * one-shot was mixed into the run history, which reads as a list of things+ * that already happened, so nobody found them. They get their own tab here,+ * sorted forwards, with the moment written out and a countdown beside it.+ */+import { Loader2, MoreHorizontal, Play, Trash2 } from "lucide-react";+import {+ ActionMenu,+ Cell,+ EmptyRow,+ IconButton,+ SoftButton,+ Table,+ TableHead,+ TableRow,+ type Column,+} from "@/components/extensions/primitives";+import { useT, useUiLanguage } from "@/i18n";+import { isActive, type TaskSummary } from "./automationsModel";+import { Countdown, StateDot, formatDueAt, useStateLabels } from "./shared";++export interface SchedulesPanelProps {+ schedules: TaskSummary[];+ onRunNow: (id: string) => void;+ onDelete: (id: string, active: boolean) => void;+ onCreate: () => void;+ busy: { runId?: string; deleteId?: string };+ loading: boolean;+}++export function SchedulesPanel({+ schedules,+ onRunNow,+ onDelete,+ onCreate,+ busy,+ loading,+}: SchedulesPanelProps) {+ const t = useT();+ const locale = useUiLanguage();+ const stateLabels = useStateLabels();++ const columns: Column[] = [+ { id: "name", label: t("automations_view.col_schedule") },+ { id: "due", label: t("automations_view.col_when"), width: "minmax(0, 200px)" },+ { id: "in", label: t("automations_view.col_in"), width: "minmax(0, 110px)" },+ { id: "state", label: t("common.status"), width: "minmax(0, 130px)" },+ { id: "actions", label: t("automations_view.col_actions"), width: "36px", align: "right", srOnly: true },+ ];++ if (!loading && schedules.length === 0) {+ return (+ <EmptyRow>+ <p>{t("automations_view.schedules_empty")}</p>+ <p className="mx-auto mt-1 max-w-md text-xs text-muted-foreground/80">+ {t("automations_view.schedules_empty_hint")}+ </p>+ <div className="mt-4 flex justify-center">+ <SoftButton primary onClick={onCreate}>+ {t("automations_view.new_schedule")}+ </SoftButton>+ </div>+ </EmptyRow>+ );+ }++ return (+ <Table label={t("automations_view.tab_schedules")}>+ <TableHead columns={columns} />+ {schedules.map((task) => (+ <TableRow+ key={task.id}+ columns={columns}+ id={`schedule-${task.id}`}+ ariaLabel={task.title || t("tasks_view.untitled")}+ >+ <Cell>+ <span className="block truncate font-medium text-foreground">+ {task.title || t("tasks_view.untitled")}+ </span>+ </Cell>+ <Cell muted className="truncate">+ {formatDueAt(task.due_at_ns, locale)}+ </Cell>+ <Cell muted>+ <Countdown dueNs={task.due_at_ns} />+ </Cell>+ <Cell muted>+ <span className="flex min-w-0 items-center gap-2">+ <StateDot state={task.state} />+ <span className="truncate">{stateLabels[task.state]}</span>+ </span>+ </Cell>+ <Cell align="right" stop>+ <ActionMenu+ label={t("automations_view.col_actions")}+ actions={[+ {+ id: "run",+ label: t("automations_view.run_now"),+ icon:+ busy.runId === task.id ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <Play className="h-3.5 w-3.5" />+ ),+ disabled: busy.runId === task.id,+ onSelect: () => onRunNow(task.id),+ },+ {+ id: "delete",+ label: t("automations_view.cancel_schedule"),+ icon:+ busy.deleteId === task.id ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <Trash2 className="h-3.5 w-3.5" />+ ),+ destructive: true,+ separatorAbove: true,+ disabled: busy.deleteId === task.id,+ onSelect: () => onDelete(task.id, isActive(task.state)),+ },+ ]}+ trigger={({ open, toggle }) => (+ <IconButton+ label={t("automations_view.col_actions")}+ active={open}+ onClick={toggle}+ className="h-7 w-7"+ >+ <MoreHorizontal className="h-4 w-4" />+ </IconButton>+ )}+ />+ </Cell>+ </TableRow>+ ))}+ </Table>+ );+}diff --git a/jarvis/ui/web/frontend/src/views/automations/automationsModel.test.ts b/jarvis/ui/web/frontend/src/views/automations/automationsModel.test.tsindex 2f9b6f1643..cf8d88b6a4 100644--- a/jarvis/ui/web/frontend/src/views/automations/automationsModel.test.ts+++ b/jarvis/ui/web/frontend/src/views/automations/automationsModel.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from "vitest";import {+ automationStats,extractAgentResult,filterRuns,firstLine,@@ -9,6 +10,7 @@ import {scheduleLineForTask,selectAutomations,selectRuns,+ selectSchedules,templateKeyOf,type AutomationTemplate,type ScheduleWords,@@ -93,15 +95,62 @@ describe("selection", () => {expect(selectAutomations(all).map((t) => t.id)).toEqual(["b", "a", "f"]);});- it("runs = ran/running + pending one-shots, newest activity first", () => {- expect(selectRuns(all).map((t) => t.id)).toEqual(["e", "f", "c", "d"]);+ it("schedules = waiting one-shots, soonest first", () => {+ const later = task({ id: "g", trigger_type: "after_delay", state: "pending", due_at_ns: 9 });+ expect(selectSchedules([...all, later]).map((t) => t.id)).toEqual(["d", "g"]);+ });++ it("runs = ran/running only — a waiting one-shot is a schedule, not a run", () => {+ expect(selectRuns(all).map((t) => t.id)).toEqual(["e", "f", "c"]);+ });++ it("a waiting one-shot lives on exactly one tab", () => {+ // The bug this split fixes: a schedule that had not fired yet was listed+ // under Runs, so it read as history and its own tab looked empty. A+ // RECURRING automation that is running right now is a different story —+ // it is legitimately both something you own and something happening, so+ // only the one-shot is pinned down here.+ const onTabs = (id: string) =>+ [selectAutomations(all), selectSchedules(all), selectRuns(all)].filter((list) =>+ list.some((t) => t.id === id),+ ).length;+ expect(onTabs("d")).toBe(1);+ expect(onTabs("e")).toBe(1);});it("filters runs by chip", () => {const runs = selectRuns(all);expect(filterRuns(runs, "done").map((t) => t.id)).toEqual(["e"]);expect(filterRuns(runs, "problems").map((t) => t.id)).toEqual(["c"]);- expect(filterRuns(runs, "running").map((t) => t.id)).toEqual(["f", "d"]);+ expect(filterRuns(runs, "running").map((t) => t.id)).toEqual(["f"]);+ });+});++describe("headline numbers", () => {+ const now = Date.now() * 1e6;++ it("counts what is armed, finds the soonest moment and names what broke", () => {+ const stats = automationStats([+ task({ id: "a", title: "Digest", state: "scheduled", next_due_at_ns: now + 7200e9 }),+ task({ id: "b", title: "Triage", state: "paused", next_due_at_ns: now + 60e9 }),+ task({ id: "c", title: "Pulse", state: "scheduled", next_due_at_ns: now + 600e9, last_run_state: "failed" }),+ task({ id: "d", title: "Ping", trigger_type: "at_time", state: "pending", due_at_ns: now + 300e9 }),+ task({ id: "e", title: "Old", state: "completed", trigger_type: "after_delay" }),+ ]);+ expect(stats.active).toBe(2);+ expect(stats.paused).toBe(1);+ expect(stats.schedules).toBe(1);+ // The paused one is due soonest but is not armed, so it must not win.+ expect(stats.nextTitle).toBe("Ping");+ expect(stats.problems).toBe(1);+ expect(stats.problemTitle).toBe("Pulse");+ });++ it("says nothing rather than zero when there is nothing to say", () => {+ const stats = automationStats([]);+ expect(stats.nextDueNs).toBeNull();+ expect(stats.nextTitle).toBe("");+ expect(stats.problemTitle).toBe("");});});diff --git a/jarvis/ui/web/frontend/src/views/automations/automationsModel.ts b/jarvis/ui/web/frontend/src/views/automations/automationsModel.tsindex 44f3d88228..82ceb0751f 100644--- a/jarvis/ui/web/frontend/src/views/automations/automationsModel.ts+++ b/jarvis/ui/web/frontend/src/views/automations/automationsModel.ts@@ -133,6 +133,11 @@ export function isRecurringTrigger(trigger: TriggerType): boolean {return trigger === "every" || trigger === "on_event";}+/** A one-off timed task (a "schedule") — the `after_delay` / `at_time` triggers. */+export function isOneShotTrigger(trigger: TriggerType): boolean {+ return trigger === "after_delay" || trigger === "at_time";+}+/** The template key a task was created from (`template:<key>` tag), if any. */export function templateKeyOf(task: Pick<TaskSummary, "tags">): string | null {for (const tag of task.tags ?? []) {@@ -152,18 +157,32 @@ export function selectAutomations(tasks: TaskSummary[]): TaskSummary[] {}/**- * The run history: everything that ran or is running (any trigger), plus the- * still-pending one-shots (after_delay / at_time) so they have a home too.- * Newest activity first.+ * The user's schedules: one-off timed tasks that are still waiting for their+ * moment. Soonest first — a schedule is read as "what happens next", not as+ * "what happened last", so this list is the only one sorted forwards.+ *+ * A one-shot that is already running belongs to the run history instead; the+ * three selections here are deliberately disjoint so no task shows up on two+ * tabs and gets deleted twice.*/-export function selectRuns(tasks: TaskSummary[]): TaskSummary[] {+export function selectSchedules(tasks: TaskSummary[]): TaskSummary[] {return tasks.filter((t) =>- isTerminal(t.state) ||- t.state === "running" ||- (!isRecurringTrigger(t.trigger_type) && isActive(t.state)),+ isOneShotTrigger(t.trigger_type) &&+ (t.state === "pending" || t.state === "scheduled" || t.state === "paused"),)+ .sort((a, b) => (a.due_at_ns ?? Number.MAX_SAFE_INTEGER) - (b.due_at_ns ?? Number.MAX_SAFE_INTEGER));+}++/**+ * The run history: everything that ran or is running, newest activity first.+ * A still-waiting one-shot is NOT a run — it lives on the Schedules tab until+ * it fires.+ */+export function selectRuns(tasks: TaskSummary[]): TaskSummary[] {+ return tasks+ .filter((t) => isTerminal(t.state) || t.state === "running").sort((a, b) => activityNs(b) - activityNs(a));}@@ -171,6 +190,61 @@ function activityNs(t: TaskSummary): number {return t.finished_at_ns ?? t.started_at_ns ?? t.due_at_ns ?? t.created_at_ns ?? 0;}+/** The four headline numbers above the tabs. */+export interface AutomationStats {+ /** Automations that are armed (everything except a paused one). */+ active: number;+ paused: number;+ /** The soonest upcoming moment across armed automations and schedules. */+ nextDueNs: number | null;+ /** Title of the task that owns `nextDueNs` ("" when nothing is due). */+ nextTitle: string;+ /** One-off schedules still waiting to fire. */+ schedules: number;+ /** Automations whose last run failed or was interrupted. */+ problems: number;+ /** Title of one such automation, for the tile's second line. */+ problemTitle: string;+}++/**+ * Derives the headline numbers from the task list.+ *+ * Deliberately NOT "runs in the last 7 days": a recurring task carries only+ * its latest run, so a per-week count would silently undercount and read as a+ * broken number. Every figure here is one the list can actually answer.+ */+export function automationStats(tasks: TaskSummary[]): AutomationStats {+ const automations = selectAutomations(tasks);+ const schedules = selectSchedules(tasks);++ let nextDueNs: number | null = null;+ let nextTitle = "";+ for (const task of [...automations, ...schedules]) {+ if (task.state === "paused") continue;+ const due = task.next_due_at_ns ?? task.due_at_ns ?? null;+ if (due == null) continue;+ if (nextDueNs == null || due < nextDueNs) {+ nextDueNs = due;+ nextTitle = task.title;+ }+ }++ const broken = automations.filter(+ (t) => t.last_run_state === "failed" || t.last_run_state === "interrupted",+ );++ return {+ active: automations.filter((t) => t.state !== "paused").length,+ paused: automations.filter((t) => t.state === "paused").length,+ nextDueNs,+ nextTitle,+ schedules: schedules.length,+ problems: broken.length,+ problemTitle: broken[0]?.title ?? "",+ };+}+export type RunFilter = "all" | "running" | "done" | "problems";export function filterRuns(runs: TaskSummary[], filter: RunFilter): TaskSummary[] {diff --git a/jarvis/ui/web/frontend/src/views/automations/shared.tsx b/jarvis/ui/web/frontend/src/views/automations/shared.tsxindex 9cb2e86948..54c05be587 100644--- a/jarvis/ui/web/frontend/src/views/automations/shared.tsx+++ b/jarvis/ui/web/frontend/src/views/automations/shared.tsx@@ -132,6 +132,29 @@ export function formatWhen(ns: number | null | undefined, locale?: string): stri}}+/**+ * A schedule's moment, written out: "Wed, 27.08., 07:00".+ *+ * `formatWhen` above answers "when did this happen" and drops the weekday for+ * anything today; a schedule is read forwards, and the weekday is the part a+ * person checks first ("is that before or after the weekend?").+ */+export function formatDueAt(ns: number | null | undefined, locale?: string): string {+ if (!ns) return "—";+ try {+ const d = new Date(ns / 1e6);+ return d.toLocaleString(locale, {+ weekday: "short",+ day: "2-digit",+ month: "2-digit",+ hour: "2-digit",+ minute: "2-digit",+ });+ } catch {+ return "—";+ }+}+/** The run's result as readable text (the `agent_result` step), never raw JSON. */export function ResultText({ steps, fallback }: { steps: TaskStep[] | undefined; fallback?: string | null }) {const t = useT();