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(ui): live shell-command activity cards
rubenluetke10-beepfd4f007cf250
diff --git a/jarvis/plugins/tool/run_shell.py b/jarvis/plugins/tool/run_shell.pyindex 454ca3db37..b1d27c4d89 100644--- a/jarvis/plugins/tool/run_shell.py+++ b/jarvis/plugins/tool/run_shell.py@@ -34,7 +34,7 @@ from typing import Anyfrom jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGSfrom jarvis.core.protocols import ExecutionContext, ToolResult-from jarvis.plugins.tool.command_impact import DESTRUCTIVE, classify_command+from jarvis.safety.command_impact import DESTRUCTIVE, classify_commandif sys.platform == "win32":_SHELL_LABEL = "Windows PowerShell 5.1"diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsxindex cc273148ad..59f07bb67a 100644--- a/jarvis/ui/web/frontend/src/App.tsx+++ b/jarvis/ui/web/frontend/src/App.tsx@@ -19,6 +19,7 @@ import { InputIsolationBanner } from "@/components/layout/InputIsolationBanner";import { VoiceWarmingBanner } from "@/components/layout/VoiceWarmingBanner";import { MainView } from "@/components/layout/MainView";import { ToastLayer } from "@/components/ToastLayer";+import { CommandActivityLayer } from "@/components/CommandActivityLayer";import { EditContextMenu } from "@/components/EditContextMenu";import { JarvisDock } from "@/components/JarvisDock";import { CliConnectPoller } from "@/components/CliConnectPoller";@@ -210,6 +211,7 @@ export default function App() {</div></main><ToastLayer />+ <CommandActivityLayer /><EditContextMenu /></div>);@@ -264,6 +266,7 @@ export default function App() {</main><ToastLayer />+ <CommandActivityLayer />{/* Right-click Cut/Copy/Paste. The desktop WebView ships with its owncontext menu disabled, so without this there is no mouse-driven pasteanywhere in the app — including the IDE terminals. */}diff --git a/jarvis/ui/web/frontend/src/components/CommandActivityLayer.tsx b/jarvis/ui/web/frontend/src/components/CommandActivityLayer.tsxnew file mode 100644index 0000000000..102bba0fc6--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/CommandActivityLayer.tsx@@ -0,0 +1,242 @@+import { useEffect, useState } from "react";+import {+ CheckCircle2,+ Eye,+ FilePenLine,+ ShieldAlert,+ SquareTerminal,+ TriangleAlert,+ X,+ XCircle,+} from "lucide-react";+import { useCommandActivityStore } from "@/store/commandActivity";+import type {+ CommandActivityEntry,+ CommandImpactLevel,+} from "@/lib/commandActivity";+import { cn } from "@/lib/utils";+import { useT } from "@/i18n";++/**+ * Live shell-command activity — the first place the app SHOWS a command run.+ *+ * Every subprocess spawns windowless on purpose, so until now the only sign+ * that Jarvis touched the machine was the spoken result. These cards make+ * the act visible while it happens: what runs (mono, exactly as executed),+ * what it would do (impact badge from the safety classifier — reads /+ * changes / deletes), and how it ended (duration, error, or the safety+ * layer's block). Trust through visibility — the UI half of the shell+ * explain layer.+ *+ * Sits above the JarvisDock (bottom-right); toasts keep the top-right.+ */++const MAX_VISIBLE = 4;++const LEVEL_ICON: Record<CommandImpactLevel, typeof Eye> = {+ read: Eye,+ modify: FilePenLine,+ destructive: TriangleAlert,+ unknown: SquareTerminal,+};++/** Accent per impact level — calm for reads, warm for writes, hot for+ * deletes; the same temperature scale the toasts already speak. */+const LEVEL_STYLE: Record<+ CommandImpactLevel,+ { chip: string; text: string; bar: string }+> = {+ read: {+ chip: "border-sky-400/30 bg-sky-400/10 text-sky-400",+ text: "text-sky-400",+ bar: "text-sky-400",+ },+ modify: {+ chip: "border-amber-500/30 bg-amber-500/10 text-amber-500",+ text: "text-amber-500",+ bar: "text-amber-500",+ },+ destructive: {+ chip: "border-destructive/40 bg-destructive/10 text-destructive",+ text: "text-destructive",+ bar: "text-destructive",+ },+ unknown: {+ chip: "border-border bg-muted/40 text-muted-foreground",+ text: "text-muted-foreground",+ bar: "text-muted-foreground",+ },+};++function formatDuration(ms: number): string {+ if (ms < 1000) return `${Math.max(1, Math.round(ms))} ms`;+ return `${(ms / 1000).toFixed(ms < 10_000 ? 1 : 0)} s`;+}++export function CommandActivityLayer() {+ const entries = useCommandActivityStore((s) => s.entries);+ const prune = useCommandActivityStore((s) => s.prune);++ // One shared 1 s heartbeat: advances the live timers AND expires settled+ // cards. Only runs while there is something on screen.+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ if (entries.length === 0) return;+ const timer = window.setInterval(() => {+ const ts = Date.now();+ setNow(ts);+ prune(ts);+ }, 1000);+ return () => window.clearInterval(timer);+ }, [entries.length, prune]);++ if (entries.length === 0) return null;++ const visible = entries.slice(-MAX_VISIBLE);+ const overflow = entries.length - visible.length;++ return (+ <div+ aria-live="polite"+ className="pointer-events-none fixed bottom-16 right-4 z-50 flex w-[360px] flex-col items-end gap-2"+ >+ {overflow > 0 && (+ <span className="rounded-full border border-border bg-card/95 px-2 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground backdrop-blur">+ +{overflow}+ </span>+ )}+ {visible.map((entry) => (+ <CommandCard key={entry.id} entry={entry} now={now} />+ ))}+ </div>+ );+}++function CommandCard({+ entry,+ now,+}: {+ entry: CommandActivityEntry;+ now: number;+}) {+ const t = useT();+ const dismiss = useCommandActivityStore((s) => s.dismiss);+ const style = LEVEL_STYLE[entry.level];+ const LevelIcon = LEVEL_ICON[entry.level];+ const running = entry.status === "running";++ return (+ <div+ role="status"+ className={cn(+ "pointer-events-auto relative w-full overflow-hidden rounded-lg border bg-card/95 backdrop-blur",+ "animate-in slide-in-from-bottom-3 fade-in duration-300",+ entry.status === "failed" || entry.status === "blocked"+ ? "border-destructive/40"+ : "border-border",+ )}+ >+ <div className="flex items-start gap-2.5 px-3 py-2.5">+ <span+ className={cn(+ "mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border",+ style.chip,+ )}+ title={entry.words || undefined}+ >+ <LevelIcon className="h-3.5 w-3.5" />+ </span>++ <div className="min-w-0 flex-1">+ <div className="flex items-baseline justify-between gap-2">+ <span+ className={cn(+ "text-[11px] font-semibold tracking-wide",+ style.text,+ )}+ >+ {t(`command_activity.level_${entry.level}`)}+ </span>+ <StatusBadge entry={entry} now={now} />+ </div>++ {entry.command && (+ <div+ className="mt-1 flex items-center gap-1.5 font-mono text-[11px] leading-relaxed text-foreground/90"+ title={entry.command}+ >+ <span className={cn("shrink-0 font-bold", style.text)}>❯</span>+ <span className="truncate">{entry.command}</span>+ </div>+ )}++ {entry.detail && entry.status !== "done" && (+ <div className="mt-1 break-words text-[10px] leading-relaxed text-muted-foreground">+ {entry.detail}+ </div>+ )}+ </div>++ <button+ type="button"+ onClick={() => dismiss(entry.id)}+ className="shrink-0 text-muted-foreground/60 transition-colors hover:text-foreground"+ aria-label={t("command_activity.dismiss")}+ >+ <X className="h-3 w-3" />+ </button>+ </div>++ {/* Indeterminate sweep while running — 2 px of the impact color. */}+ {running && (+ <div+ className={cn(+ "command-activity-progress h-0.5 w-full opacity-80",+ style.bar,+ )}+ />+ )}+ </div>+ );+}++function StatusBadge({+ entry,+ now,+}: {+ entry: CommandActivityEntry;+ now: number;+}) {+ const t = useT();+ switch (entry.status) {+ case "running": {+ const elapsed = Math.max(0, Math.round((now - entry.startedTs) / 1000));+ return (+ <span className="shrink-0 text-[10px] tabular-nums text-muted-foreground">+ {elapsed > 0 ? `${elapsed} s` : t("command_activity.running")}+ </span>+ );+ }+ case "done":+ return (+ <span className="flex shrink-0 items-center gap-1 text-[10px] tabular-nums text-primary">+ <CheckCircle2 className="h-3 w-3" />+ {entry.durationMs ? formatDuration(entry.durationMs) : t("command_activity.done")}+ </span>+ );+ case "failed":+ return (+ <span className="flex shrink-0 items-center gap-1 text-[10px] text-destructive">+ <XCircle className="h-3 w-3" />+ {t("command_activity.failed")}+ </span>+ );+ case "blocked":+ return (+ <span className="flex shrink-0 items-center gap-1 text-[10px] text-destructive">+ <ShieldAlert className="h-3 w-3" />+ {t("command_activity.blocked")}+ </span>+ );+ }+}diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.tsindex 93ea89ea53..a504231a99 100644--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts@@ -17,6 +17,10 @@ import {type VoiceState,} from "@/store/events";import { useSubAgentStore, SUB_AGENT_EVENT_NAMES } from "@/store/jarvisAgents";+import {+ useCommandActivityStore,+ COMMAND_ACTIVITY_EVENTS,+} from "@/store/commandActivity";import { WSAudioLevel, WSEventEnvelope, WSWelcome } from "@/schema/ws";import { useI18nStore, hydrateUiLanguage, hydrateReplyLanguage, translate } from "@/i18n";import { hydrateUiTheme } from "@/hooks/useTheme";@@ -161,6 +165,20 @@ export function useWebSocket(): void {Math.floor(env.timestamp_ns / 1_000_000),);+ // Live shell-command activity: the ToolExecutor's run_shell events+ // become visible cards (CommandActivityLayer). Pre-filtered on the+ // three action event names; the store ignores every other tool.+ if (COMMAND_ACTIVITY_EVENTS.has(env.event_name)) {+ useCommandActivityStore+ .getState()+ .ingest(+ env.event_name,+ env.trace_id,+ env.payload,+ Math.floor(env.timestamp_ns / 1_000_000),+ );+ }+// Jarvis-Agents dashboard: build the live tree from the Phase-5.5 events.if (SUB_AGENT_EVENT_NAMES.has(env.event_name)) {useSubAgentStorediff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 4813b1c7b4..9b2ed00045 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -486,6 +486,17 @@"group_earlier": "Früher","resize_hint": "Zum Verändern ziehen · Doppelklick zum Zurücksetzen"},+ "command_activity": {+ "level_read": "Liest nur",+ "level_modify": "Verändert etwas",+ "level_destructive": "Löscht etwas",+ "level_unknown": "Shell-Befehl",+ "running": "läuft…",+ "done": "Fertig",+ "failed": "Fehlgeschlagen",+ "blocked": "Blockiert",+ "dismiss": "Ausblenden"+ },"thinking": {"label": "Denkt nach","thought_for": "Denkzeit",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 2ec810627c..cc000a794c 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -486,6 +486,17 @@"group_earlier": "Earlier","resize_hint": "Drag to resize · double-click to reset"},+ "command_activity": {+ "level_read": "Reads only",+ "level_modify": "Changes something",+ "level_destructive": "Deletes something",+ "level_unknown": "Shell command",+ "running": "running…",+ "done": "Done",+ "failed": "Failed",+ "blocked": "Blocked",+ "dismiss": "Dismiss"+ },"thinking": {"label": "Thinking","thought_for": "Thought for",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex c21faacb04..18a9071dfd 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -486,6 +486,17 @@"group_earlier": "Antes","resize_hint": "Arrastra para redimensionar · doble clic para restablecer"},+ "command_activity": {+ "level_read": "Solo lee",+ "level_modify": "Cambia algo",+ "level_destructive": "Borra algo",+ "level_unknown": "Comando de shell",+ "running": "en curso…",+ "done": "Listo",+ "failed": "Falló",+ "blocked": "Bloqueado",+ "dismiss": "Ocultar"+ },"thinking": {"label": "Pensando","thought_for": "Pensó durante",diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.cssindex 33b4962285..4889b68116 100644--- a/jarvis/ui/web/frontend/src/index.css+++ b/jarvis/ui/web/frontend/src/index.css@@ -1271,6 +1271,47 @@background-size: 48px 48px;}+ /*+ * Live command activity (CommandActivityLayer) — the indeterminate sweep+ * under a RUNNING shell command. `currentColor` inherits the impact accent+ * from the card (sky = reads, amber = modifies, red = deletes), so the bar+ * and the badge can never disagree. Transform-only, like every loop in+ * this file, and reduced-motion collapses it to a calm static strip.+ */+ .command-activity-progress {+ position: relative;+ background: currentColor;+ opacity: 0.14;+ }++ .command-activity-progress::after {+ content: "";+ position: absolute;+ inset: 0;+ background: linear-gradient(+ 90deg,+ transparent,+ currentColor 45%,+ currentColor 55%,+ transparent+ );+ transform: translateX(-100%);+ animation: command-activity-sweep 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;+ }++ @keyframes command-activity-sweep {+ to {+ transform: translateX(100%);+ }+ }++ @media (prefers-reduced-motion: reduce) {+ .command-activity-progress::after {+ animation: none;+ transform: none;+ }+ }+:root:not(.dark) .uw-stage {background-image:linear-gradient(rgb(var(--accent-rgb) / 0.07) 1px, transparent 1px),diff --git a/jarvis/ui/web/frontend/src/lib/commandActivity.test.ts b/jarvis/ui/web/frontend/src/lib/commandActivity.test.tsnew file mode 100644index 0000000000..099c5aea50--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/commandActivity.test.ts@@ -0,0 +1,185 @@+import { describe, expect, it } from "vitest";+import {+ FAILED_TTL_MS,+ MAX_COMMAND_ENTRIES,+ pruneCommandActivity,+ reduceCommandActivity,+ RUNNING_TTL_MS,+ SETTLED_TTL_MS,+ type CommandActivityEntry,+} from "./commandActivity";++const T0 = 1_000_000;++function proposed(+ command: string,+ impact?: { level?: string; commands?: string },+) {+ return {+ tool_name: "run_shell",+ args: { command },+ risk_tier: "monitor",+ ...(impact ? { impact } : {}),+ };+}++function feed(+ events: Array<[string, string, unknown, number?]>,+): CommandActivityEntry[] {+ let entries: CommandActivityEntry[] = [];+ for (const [name, traceId, payload, ts] of events) {+ entries =+ reduceCommandActivity(entries, name, traceId, payload, ts ?? T0) ??+ entries;+ }+ return entries;+}++describe("reduceCommandActivity", () => {+ it("surfaces a proposed run_shell call with its impact badge", () => {+ const entries = feed([+ [+ "ActionProposed",+ "t1",+ proposed("rm -rf build", {+ level: "destructive",+ commands: "rm",+ }),+ ],+ ]);+ expect(entries).toHaveLength(1);+ expect(entries[0]).toMatchObject({+ id: "t1",+ command: "rm -rf build",+ level: "destructive",+ words: "rm",+ status: "running",+ });+ });++ it("ignores every other tool", () => {+ const result = reduceCommandActivity(+ [],+ "ActionProposed",+ "t1",+ { tool_name: "open_app", args: { app: "notepad" } },+ T0,+ );+ expect(result).toBeNull();+ });++ it("pairs Executed with its Proposed via trace id", () => {+ const entries = feed([+ ["ActionProposed", "t1", proposed("ls", { level: "read" })],+ [+ "ActionExecuted",+ "t1",+ { tool_name: "run_shell", success: true, duration_ms: 42 },+ T0 + 500,+ ],+ ]);+ expect(entries[0]).toMatchObject({+ status: "done",+ durationMs: 42,+ settledTs: T0 + 500,+ });+ });++ it("marks a failed execution with its error detail", () => {+ const entries = feed([+ ["ActionProposed", "t1", proposed("definitely-missing")],+ [+ "ActionExecuted",+ "t1",+ { tool_name: "run_shell", success: false, error: "exit 127" },+ T0 + 300,+ ],+ ]);+ expect(entries[0]).toMatchObject({ status: "failed", detail: "exit 127" });+ });++ it("shows a blacklist denial even without a Proposed", () => {+ // A blacklist match raises BEFORE ActionProposed — the denial is the+ // only event of that run and must still become a visible card.+ const entries = feed([+ [+ "ActionDenied",+ "t9",+ { tool_name: "run_shell", reason: "blacklist: rm -rf /*" },+ ],+ ]);+ expect(entries[0]).toMatchObject({+ status: "blocked",+ detail: "blacklist: rm -rf /*",+ level: "destructive",+ });+ });++ it("missing impact classifies as unknown, never crashes", () => {+ const entries = feed([+ ["ActionProposed", "t1", proposed("some-binary --x")],+ ]);+ expect(entries[0].level).toBe("unknown");+ });++ it("dedupes a replayed Proposed for the same trace", () => {+ const p = proposed("ls", { level: "read" });+ const entries = feed([+ ["ActionProposed", "t1", p],+ ["ActionProposed", "t1", p],+ ]);+ expect(entries).toHaveLength(1);+ });++ it("caps the list and keeps running entries alive", () => {+ const events: Array<[string, string, unknown, number?]> = [];+ for (let i = 0; i < MAX_COMMAND_ENTRIES + 5; i++) {+ events.push(["ActionProposed", `t${i}`, proposed("ls")]);+ // Settle every entry except the very first one.+ if (i > 0) {+ events.push([+ "ActionExecuted",+ `t${i}`,+ { tool_name: "run_shell", success: true },+ ]);+ }+ }+ const entries = feed(events);+ expect(entries.length).toBeLessThanOrEqual(MAX_COMMAND_ENTRIES);+ expect(entries.some((e) => e.id === "t0")).toBe(true); // still running+ });+});++describe("pruneCommandActivity", () => {+ it("expires done entries after their TTL, failures later", () => {+ const entries = feed([+ ["ActionProposed", "ok", proposed("ls")],+ ["ActionExecuted", "ok", { tool_name: "run_shell", success: true }, T0],+ ["ActionProposed", "bad", proposed("rm x")],+ [+ "ActionExecuted",+ "bad",+ { tool_name: "run_shell", success: false, error: "exit 1" },+ T0,+ ],+ ]);+ const afterDoneTtl = pruneCommandActivity(entries, T0 + SETTLED_TTL_MS + 1);+ expect(afterDoneTtl?.map((e) => e.id)).toEqual(["bad"]);+ const afterFailTtl = pruneCommandActivity(+ afterDoneTtl ?? [],+ T0 + FAILED_TTL_MS + 1,+ );+ expect(afterFailTtl).toEqual([]);+ });++ it("expires a running entry whose Executed never arrived", () => {+ const entries = feed([["ActionProposed", "t1", proposed("ls")]]);+ expect(pruneCommandActivity(entries, T0 + RUNNING_TTL_MS - 1)).toBeNull();+ expect(pruneCommandActivity(entries, T0 + RUNNING_TTL_MS + 1)).toEqual([]);+ });++ it("returns null when nothing changed", () => {+ const entries = feed([["ActionProposed", "t1", proposed("ls")]]);+ expect(pruneCommandActivity(entries, T0 + 10)).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/commandActivity.ts b/jarvis/ui/web/frontend/src/lib/commandActivity.tsnew file mode 100644index 0000000000..cc9766236a--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/commandActivity.ts@@ -0,0 +1,209 @@+/**+ * Live command activity model — the pure event→entry mapping behind the+ * shell-visibility layer (CommandActivityLayer.tsx).+ *+ * Until now a running shell command was invisible: no window opens (all+ * subprocesses spawn with CREATE_NO_WINDOW), output goes to the brain, and+ * the only trace sat in data/sessions.db. This module turns the ToolExecutor+ * events the backend already broadcasts over the WS wildcard forwarder into+ * a small live list the activity cards render.+ *+ * The impact classification (read / modify / destructive) arrives ON the+ * ActionProposed payload — computed server-side by+ * `jarvis/safety/command_impact.py` at the WS boundary, so there is no+ * TypeScript twin of the classifier to drift out of sync.+ *+ * Pure module on purpose: no React, no zustand, no timers — fully covered by+ * commandActivity.test.ts (same pattern as thinkingSteps.ts).+ */++export type CommandImpactLevel = "read" | "modify" | "destructive" | "unknown";++export type CommandActivityStatus = "running" | "done" | "failed" | "blocked";++export interface CommandActivityEntry {+ /** trace_id of the ToolExecutor run — pairs Proposed with Executed/Denied. */+ id: string;+ /** The full command string (render-clipped, full text in the tooltip). */+ command: string;+ level: CommandImpactLevel;+ /** Classified leading words ("rm", "ls, grep") for the badge tooltip. */+ words: string;+ status: CommandActivityStatus;+ startedTs: number;+ durationMs?: number;+ /** Denial reason / execution error — raw runtime text, never translated. */+ detail?: string;+ /** Wall-clock ms when the entry left "running" (drives auto-expiry). */+ settledTs?: number;+}++/** Hard cap — a runaway turn must not grow the array unbounded. */+export const MAX_COMMAND_ENTRIES = 24;++/** How long a settled card lingers before the layer prunes it. */+export const SETTLED_TTL_MS = 6_000;+/** Failures and blocks stay longer — they are the ones worth reading. */+export const FAILED_TTL_MS = 12_000;+/** A "running" entry whose Executed event never arrived (dropped WS frame,+ * client reconnect) must not spin forever. */+export const RUNNING_TTL_MS = 5 * 60_000;++const LEVELS: readonly CommandImpactLevel[] = [+ "read",+ "modify",+ "destructive",+ "unknown",+];++function str(v: unknown): string {+ return typeof v === "string" ? v : "";+}++function num(v: unknown): number {+ return typeof v === "number" && Number.isFinite(v) ? v : 0;+}++function impactOf(payload: Record<string, unknown>): {+ level: CommandImpactLevel;+ words: string;+} {+ const impact = (payload.impact ?? {}) as Record<string, unknown>;+ const raw = str(impact.level);+ const level = (LEVELS as readonly string[]).includes(raw)+ ? (raw as CommandImpactLevel)+ : "unknown";+ return { level, words: str(impact.commands) };+}++function commandOf(payload: Record<string, unknown>): string {+ const args = (payload.args ?? {}) as Record<string, unknown>;+ return str(args.command).trim();+}++function push(+ entries: CommandActivityEntry[],+ entry: CommandActivityEntry,+): CommandActivityEntry[] {+ const next = [...entries, entry];+ if (next.length > MAX_COMMAND_ENTRIES) {+ // Drop the oldest *settled* entry first so running cards survive the cap.+ const idx = next.findIndex((e) => e.status !== "running");+ next.splice(idx === -1 ? 0 : idx, 1);+ }+ return next;+}++function settle(+ entries: CommandActivityEntry[],+ id: string,+ tsMs: number,+ patch: Pick<CommandActivityEntry, "status"> &+ Partial<Pick<CommandActivityEntry, "durationMs" | "detail">>,+): CommandActivityEntry[] | null {+ // Prefer the exact trace pair; fall back to the most recent running entry+ // (an Executed forwarded without its Proposed, e.g. after a reconnect).+ let idx = entries.findIndex((e) => e.id === id && e.status === "running");+ if (idx === -1) {+ for (let i = entries.length - 1; i >= 0; i--) {+ if (entries[i].status === "running") {+ idx = i;+ break;+ }+ }+ }+ if (idx === -1) return null;+ const next = [...entries];+ next[idx] = { ...next[idx], ...patch, settledTs: tsMs };+ return next;+}++/**+ * Apply one WS event. Returns the new list, or null when the event is+ * irrelevant (the common case — callers skip the store update entirely).+ */+export function reduceCommandActivity(+ entries: CommandActivityEntry[],+ eventName: string,+ traceId: string,+ payload: unknown,+ tsMs: number,+): CommandActivityEntry[] | null {+ const p = (payload ?? {}) as Record<string, unknown>;+ if (str(p.tool_name) !== "run_shell") return null;++ switch (eventName) {+ case "ActionProposed": {+ if (entries.some((e) => e.id === traceId)) return null;+ const { level, words } = impactOf(p);+ return push(entries, {+ id: traceId,+ command: commandOf(p),+ level,+ words,+ status: "running",+ startedTs: tsMs,+ });+ }++ case "ActionExecuted": {+ const failed = p.success === false;+ const settled = settle(entries, traceId, tsMs, {+ status: failed ? "failed" : "done",+ durationMs: num(p.duration_ms) || undefined,+ detail: failed ? str(p.error) || undefined : undefined,+ });+ if (settled) return settled;+ // Executed without a visible Proposed: still surface it, already done.+ return push(entries, {+ id: traceId,+ command: "",+ level: "unknown",+ words: "",+ status: failed ? "failed" : "done",+ startedTs: tsMs,+ durationMs: num(p.duration_ms) || undefined,+ detail: failed ? str(p.error) || undefined : undefined,+ settledTs: tsMs,+ });+ }++ case "ActionDenied": {+ const detail = str(p.reason) || undefined;+ const settled = settle(entries, traceId, tsMs, {+ status: "blocked",+ detail,+ });+ if (settled) return settled;+ // A blacklist match raises BEFORE ActionProposed — the denial is the+ // only event of that run. Showing it is the whole point: the user+ // SEES the safety layer step in.+ return push(entries, {+ id: traceId,+ command: "",+ level: "destructive",+ words: "",+ status: "blocked",+ startedTs: tsMs,+ detail,+ settledTs: tsMs,+ });+ }++ default:+ return null;+ }+}++/** Drop expired entries. Returns null when nothing changed (skip re-render). */+export function pruneCommandActivity(+ entries: CommandActivityEntry[],+ nowMs: number,+): CommandActivityEntry[] | null {+ const keep = entries.filter((e) => {+ if (e.status === "running") return nowMs - e.startedTs < RUNNING_TTL_MS;+ const ttl = e.status === "done" ? SETTLED_TTL_MS : FAILED_TTL_MS;+ return nowMs - (e.settledTs ?? e.startedTs) < ttl;+ });+ return keep.length === entries.length ? null : keep;+}diff --git a/jarvis/ui/web/frontend/src/store/commandActivity.ts b/jarvis/ui/web/frontend/src/store/commandActivity.tsnew file mode 100644index 0000000000..8cd38738ff--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/commandActivity.ts@@ -0,0 +1,61 @@+import { create } from "zustand";+import {+ pruneCommandActivity,+ reduceCommandActivity,+ type CommandActivityEntry,+} from "@/lib/commandActivity";++/**+ * Live shell-command activity, fed by the WS wildcard event stream+ * (useWebSocket.ts) and rendered by CommandActivityLayer.tsx.+ *+ * Deliberately its own store: the entries change at tool-call rhythm, and+ * keeping them out of the big event store means a running command re-renders+ * two activity cards, not the whole shell.+ */+interface CommandActivityState {+ entries: CommandActivityEntry[];+ ingest: (+ eventName: string,+ traceId: string,+ payload: unknown,+ tsMs: number,+ ) => void;+ /** Called by the layer's 1 s tick — expires settled/stuck cards. */+ prune: (nowMs: number) => void;+ dismiss: (id: string) => void;+}++export const useCommandActivityStore = create<CommandActivityState>()(+ (set, get) => ({+ entries: [],++ ingest: (eventName, traceId, payload, tsMs) => {+ const next = reduceCommandActivity(+ get().entries,+ eventName,+ traceId,+ payload,+ tsMs,+ );+ if (next) set({ entries: next });+ },++ prune: (nowMs) => {+ const next = pruneCommandActivity(get().entries, nowMs);+ if (next) set({ entries: next });+ },++ dismiss: (id) =>+ set((state) => ({+ entries: state.entries.filter((e) => e.id !== id),+ })),+ }),+);++/** The event names the WS hook needs to forward here (cheap pre-filter). */+export const COMMAND_ACTIVITY_EVENTS: ReadonlySet<string> = new Set([+ "ActionProposed",+ "ActionExecuted",+ "ActionDenied",+]);diff --git a/jarvis/ui/web/schema.py b/jarvis/ui/web/schema.pyindex 4718c99e49..8551450979 100644--- a/jarvis/ui/web/schema.py+++ b/jarvis/ui/web/schema.py@@ -16,7 +16,8 @@ from uuid import UUIDfrom pydantic import BaseModel, Field-from jarvis.core.events import Event+from jarvis.core.events import ActionProposed, Event+from jarvis.safety.command_impact import classify_command# ----------------------------------------------------------------------# Outgoing (Server → Client)@@ -126,6 +127,33 @@ def _jsonable(value: Any) -> Any:return str(value)+def _enrich_shell_impact(event: Event, payload: dict[str, Any]) -> None:+ """Attach the command-impact classification to run_shell ActionProposed.++ Display metadata for the live command activity UI: the frontend shows a+ plain-language badge (reads / modifies / deletes) next to the running+ command. Classified HERE, at the UI boundary, with the same+ ``jarvis.safety.command_impact`` module the risk-tier hook and the voice+ confirmation use — one source of truth, no TypeScript twin to drift+ (the five-layer-enum lesson). Best-effort: display metadata must never+ break the WS feed, and the event itself stays untouched (frozen).+ """+ if not isinstance(event, ActionProposed) or payload.get("tool_name") != "run_shell":+ return+ try:+ args = payload.get("args")+ command = args.get("command") if isinstance(args, dict) else None+ if not isinstance(command, str) or not command.strip():+ return+ impact = classify_command(command)+ payload["impact"] = {+ "level": impact.level,+ "commands": ", ".join(dict.fromkeys(impact.commands)),+ }+ except Exception: # noqa: BLE001 — cosmetic enrichment only+ return++def event_to_ws_envelope(event: Event) -> dict[str, Any]:"""Serializes a bus event into a JSON-able `WSEventEnvelope` dict.@@ -145,6 +173,8 @@ def event_to_ws_envelope(event: Event) -> dict[str, Any]:continuepayload[k] = _jsonable(v)+ _enrich_shell_impact(event, payload)+envelope = WSEventEnvelope(event_name=type(event).__name__,trace_id=str(event.trace_id),diff --git a/tests/unit/plugins/tool/test_command_impact.py b/tests/unit/plugins/tool/test_command_impact.pyindex b30614e00c..fa273961ae 100644--- a/tests/unit/plugins/tool/test_command_impact.py+++ b/tests/unit/plugins/tool/test_command_impact.py@@ -5,13 +5,13 @@ from __future__ import annotationsimport pytest-from jarvis.plugins.tool.command_impact import (+from jarvis.plugins.tool.run_shell import RunShellTool+from jarvis.safety.command_impact import (DESTRUCTIVE,MODIFY,READ,classify_command,)-from jarvis.plugins.tool.run_shell import RunShellTool@pytest.mark.parametrize(diff --git a/tests/unit/web/test_ws_envelope_shell_impact.py b/tests/unit/web/test_ws_envelope_shell_impact.pynew file mode 100644index 0000000000..50d5c257a2--- /dev/null+++ b/tests/unit/web/test_ws_envelope_shell_impact.py@@ -0,0 +1,58 @@+"""The WS envelope enriches run_shell ActionProposed with the command impact.++The live command activity UI shows a plain-language badge (reads / modifies /+deletes) next to a running command. The classification happens once, at the UI+boundary, with the SAME ``jarvis.safety.command_impact`` module the risk-tier+hook and the voice confirmation use — no TypeScript twin to drift.+"""+from __future__ import annotations++from uuid import uuid4++from jarvis.core.events import ActionExecuted, ActionProposed+from jarvis.ui.web.schema import event_to_ws_envelope+++def _proposed(tool_name: str, args: dict) -> ActionProposed:+ return ActionProposed(+ trace_id=uuid4(), tool_name=tool_name, args=args, risk_tier="monitor",+ )+++def test_run_shell_proposed_carries_the_impact() -> None:+ envelope = event_to_ws_envelope(+ _proposed("run_shell", {"command": "rm -rf build"})+ )+ assert envelope["payload"]["impact"] == {+ "level": "destructive",+ "commands": "rm",+ }+++def test_read_command_classifies_as_read() -> None:+ envelope = event_to_ws_envelope(+ _proposed("run_shell", {"command": "ls | grep foo"})+ )+ assert envelope["payload"]["impact"]["level"] == "read"+ assert "ls" in envelope["payload"]["impact"]["commands"]+++def test_other_tools_are_not_enriched() -> None:+ envelope = event_to_ws_envelope(+ _proposed("open_app", {"app": "notepad"})+ )+ assert "impact" not in envelope["payload"]+++def test_missing_command_is_not_enriched() -> None:+ envelope = event_to_ws_envelope(_proposed("run_shell", {}))+ assert "impact" not in envelope["payload"]+++def test_action_executed_is_untouched() -> None:+ envelope = event_to_ws_envelope(+ ActionExecuted(+ trace_id=uuid4(), tool_name="run_shell", success=True, duration_ms=12,+ )+ )+ assert "impact" not in envelope["payload"]