Show activity indicators for terminals and their workspaces (#1507)

* feat: show activity indicators for terminals and their workspaces

A terminal surfaces whether the agent running inside it is working, idle,
or waiting for input as a tab dot, and that state rolls up into the
owning workspace status — so an agent run inside a terminal reads the
same as a native agent. Finishing a turn raises a "Terminal finished"
notification that routes back to the workspace terminal tab.

Activity is reported by the agents, not parsed from terminal output:
Claude and Codex command hooks and an OpenCode plugin post coarse state
to a local daemon endpoint, and a source-agnostic per-terminal tracker
maps it to working/idle/attention. Hook installation is opt-in and off
by default because it edits your real agent config files; enable it under
a host's Terminal settings and Paseo installs the hooks globally, runs
them via `paseo hooks <agent> <event>`, and removes its own hooks when
you opt back out. Installation and reporting are idempotent and
fail-open, so a missing or failing hook never breaks the user's shell.

* Fix terminal activity routing and CI test

Test drift: anchor the provider-leak test to the repo root instead of process.cwd() so it passes under the server workspace CI runner.

Also restore auth-first JSON parsing outside the terminal-activity route and route subdirectory terminal activity to the deepest active workspace.

* Fix workspace resolver regression

Code drift: terminal activity routing needs parent-workspace prefix matching, but agent directory and historical fetches keep exact registered workspace semantics, including archived exact matches.

* Narrow terminal/draft workspace subscriptions to the fields they use

terminal-panel and the draft agent tab subscribed to the whole workspace
descriptor via useWorkspace but read only workspaceDirectory (plus projectKind
in TerminalPanel, plus id in the draft tab), so they re-rendered on any field
change of that workspace (status, diffStat, scripts). Switch them to the
existing useWorkspaceDirectory / useWorkspaceFields hooks so they re-render only
when the fields they actually read change. No behavior change.

* Make TerminalActivity.state forward-compatible

A strict z.enum rejects the whole payload when a newer daemon reports a
terminal activity state this client predates, breaking the protocol's
old-client-parses-new-daemon contract (the activity field has no .catch at
its embedding in messages.ts, so the failure bubbles up). Degrade unknown
states to "idle" (no indicator, no notification) via .catch, matching the
enum-with-catch pattern used elsewhere in the protocol. Add a forward-compat
regression test.
This commit is contained in:
Mohamed Boudra
2026-06-14 23:29:14 +08:00
committed by GitHub
parent 21deb08673
commit 0d76654ba0
76 changed files with 4873 additions and 127 deletions

View File

@@ -0,0 +1,15 @@
import { z } from "zod";
export const TERMINAL_ACTIVITY_STATES = ["idle", "working", "attention"] as const;
export type TerminalActivityState = (typeof TERMINAL_ACTIVITY_STATES)[number];
export const TerminalActivitySchema = z.object({
// Forward-compat: a newer daemon may send a state this client doesn't know.
// Degrade unknown states to "idle" (no indicator, no notification) so the
// message still parses, instead of a strict enum rejecting the whole payload.
state: z.enum(TERMINAL_ACTIVITY_STATES).catch("idle"),
changedAt: z.number(),
});
export type TerminalActivity = z.infer<typeof TerminalActivitySchema>;