Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/release-notes/v2.4.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# V2.4.1 - Watcher

Ask Fate in chat: “Watch this PR’s CI and tell me when it finishes.” Fate finds the pull request and pins its commit. The turn ends normally, and Fate posts the result in the original chat even if you’ve switched away. GitHub pull request links, Actions run links, and events from enabled local MCP connectors are supported.

**Run → Monitor → Watches** now shows watch status and lets you stop a watch. No setup form, run ID, or commit SHA is required for PR checks.

See [MCP and CI watches](https://github.com/Master0fFate/fateUI/blob/v2.4.1/docs/mcp.md) for examples and requirements.
2 changes: 1 addition & 1 deletion PRODVER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0
2.4.1
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The cross-platform GitHub Actions package matrix runs for pull requests, pushes
- Native hosted runners build, install or mount, and smoke-test Windows x64, macOS Apple Silicon and Intel, and Linux x64 packages: Windows NSIS, macOS DMG and PKG, Linux AppImage and DEB.
- The version in `package.json` and `PRODVER` must match. The release tag is `v<version>`, and `node scripts/release-artifacts.mjs metadata --field display-version` combines that version with the optional `package.json.releaseName` for the display title.

The current source version is `2.4.0` (Watcher).
The current source version is `2.4.1` (Watcher).

1. Merge the version bump and `.github/release-notes/v<version>.md` into `main`.
2. Manually run **Cross-platform installers** on `main` with the promotion inputs empty. Confirm the run used the intended commit, all four native jobs passed, and `verified-release-installers` contains seven installers and `SHA256SUMS`. This artifact is retained for 14 days. This run does not publish anything.
Expand Down
10 changes: 7 additions & 3 deletions docs/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Context Mode's current Pi extension also includes its own MCP bridge. Install it

A Monitor watch uses a separate, one-shot connection to a named, enabled **local stdio** server from Settings → MCP. It does not list or call tools, and an ordinary MCP tool server will not work unless it explicitly implements the watch protocol. The connector runs with your OS rights. Fate asks for native confirmation before enabling a new, changed, or previously disabled local command. Imported local commands stay disabled until approved. HTTP MCP servers are not supported for watches.

### Run the example
### Connector example

1. Install the repository dependencies with `pnpm install` and have Node.js installed locally.
2. Add and enable a stdio server named `watch-demo` in **Settings → MCP**. Set the command to your Node.js executable (use its absolute path if needed), and set the arguments to a JSON array with the absolute path to [`examples/mcp-monitor-watch.mjs`](../examples/mcp-monitor-watch.mjs). On Windows, use forward slashes in the argument path or escape backslashes in JSON.
3. In a trusted saved desktop chat, open **Run → Monitor** and start an MCP watch for connector `watch-demo`, event ID `example-job`, revision `demo-1`. The example sends `success` about one second after subscription. By default the result stays in Monitor. To also get a saved assistant update, check **Automatically reply in this chat when the watch completes** and enter a follow-up instruction. Automatic replies require a saved chat that is already loaded. When it is idle, its configured physical model receives only the completion facts and that instruction, with no tools or chat history. A completion does not reopen a closed chat. The update appears in the original chat without changing your selection. Extension-only models and command-backed provider credentials or headers are not supported for automatic replies. If an OAuth token needs refreshing, use the provider in a regular chat before relying on an automatic reply. This server provides no tools, so try it in Monitor rather than using **Test saved server**.
3. In a trusted desktop chat, ask: “Watch event example-job revision demo-1 on MCP connector watch-demo and tell me when it finishes.” The example returns `success` roughly one second after subscribing. It provides no tools.

### Wire protocol (version 1)

Expand All @@ -42,4 +42,8 @@ A Monitor watch uses a separate, one-shot connection to a named, enabled **local
- Send a JSON-RPC notification (no `id`) with method `notifications/fate/watch` and params `{"eventId":"example-job","revision":"demo-1","result":"success"}`. The other terminal results are `failure`, `cancelled`, and `other`. Fate also requires the exact event ID and revision; unrelated notifications are ignored.
- Reserve stdout for newline-delimited MCP messages. The client ignores stderr, allows up to 10 seconds to initialize and subscribe, and accepts at most 64 KiB of stdout total. Fate closes the connection after one terminal result, on cancellation, or on failure. Stop connector work when stdin closes. Fate manages the connector process, not its descendants; do not use a launcher that leaves background processes behind.

GitHub Actions watches use a different adapter. They require an authenticated local `gh` CLI with access to the Actions run on `github.com`. Enter the literal `OWNER/REPO`, decimal run ID, and full commit SHA. Fate checks the returned repository, run ID and SHA before using a conclusion. Each lookup has a 10-second deadline and a 64 KiB output limit. No workflow is triggered, and enterprise hosts are not supported. Watches expire after one hour. Switching projects does not stop them, but explicitly closing the watched project or quitting Fate does. Watches do not resume on restart.
## Watch CI from chat

In a trusted desktop project, ask: “Watch this PR’s CI and tell me when it finishes.” Fate resolves the branch’s pull request and pins its current commit. You can also include a GitHub pull request or Actions run link in the request. An authenticated local `gh` CLI with access to the repository is required. No workflow is started or modified.

The turn ends normally. **Run → Monitor → Watches** shows the status and lets you stop the watch. When checks finish, Fate posts a text-only update in the original chat, without tools or chat history. Switching projects does not stop the watch. Watches expire after one hour and do not resume after quitting.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pi-fategui",
"version": "2.4.0",
"version": "2.4.1",
"releaseName": "Watcher",
"description": "A local-first desktop interface for the Pi coding agent",
"type": "module",
Expand Down
11 changes: 11 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { ComputerUseService } from './computer/ComputerUseService';
import { isElevated, relaunchElevated } from './computer/elevation';
import type { PiRuntimeService } from './pi/PiRuntimeService';
import { DesktopMonitorWatches } from './pi/DesktopMonitorWatches';
import { resolveGitHubWatch } from './pi/monitorSources';
import { McpConfigService } from './pi/McpConfigService';
import { ConnectionProfileStore } from './connections/ConnectionProfileStore';
import { ConnectionProfileEditor } from './connections/ConnectionProfileEditor';
Expand Down Expand Up @@ -521,6 +522,16 @@ app.whenReady().then(async () => {
},
});
monitorWatches = desktopWatches;
desktopRuntime.setChatWatchStarter(async (scope, { url, channel, followUp }, current, signal) => {
const stillCurrent = () => !hostStopping && connections?.isLocal === true && !signal?.aborted && current();
if (!stillCurrent()) throw new Error('This watch must be started in its original local chat.');
const source = channel ? { kind: 'mcp' as const, ...channel }
: await resolveGitHubWatch(scope.workspaceRoot, url ? { url } : {}, signal ?? new AbortController().signal);
if (!stillCurrent()) throw new Error('The chat changed before the watch could start.');
await desktopWatches.start({ ...scope, source, wake: true, followUp: followUp ?? 'Tell me how the watched work finished.' }, stillCurrent, true);
if (source.kind === 'mcp') return `${source.eventId} on ${source.connector}`;
return source.kind === 'github-pr' ? `${source.repo} PR #${source.prNumber}` : `${source.repo} run ${source.runId}`;
});
desktopRuntime.setMonitorWorkspacePins((root) => desktopWatches.hasActiveWork(root));
desktopRuntime.subscribeMonitorTargetInvalidation((root, sessionId) => desktopWatches.clear(root, sessionId));
const mainCommands = registerIpc({ runtime, ...(useCoreIpcAdapter ? { core } : { monitorCore: core }), connections, ...(connectionEditor ? { connectionEditor } : {}), projects, files, git, settings, learning: core.learning, ...(core.savedAgents ? { agents: core.savedAgents } : {}), google, terminal, logs, music, computerUse, speech, hotkey, updates, recovery, browser: browserHost, attestations: core.attestations, checkpoints: new CheckpointRestoreService(core.attestations, core.checkpoints), newWindow: () => windows.createWindow(), rendererPolicy, monitorWatches: desktopWatches });
Expand Down
26 changes: 19 additions & 7 deletions src/main/pi/DesktopMonitorWatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const POLL_MS = 20_000;
const MAX_WATCHES = 8;
const MAX_HISTORY = 24;
const MAX_COMPLETIONS = 256;
const FIRST_SAVE_GRACE_MS = 30_000;

type Connector = Extract<McpServerDefinition, { transport: 'stdio' }>;
export interface MonitorWakeInput {
Expand Down Expand Up @@ -45,6 +46,7 @@ interface Watch {
answer?: string;
connector?: Connector;
nextCheck: number;
saveDeadline?: number;
failures: number;
}

Expand Down Expand Up @@ -88,7 +90,7 @@ export class DesktopMonitorWatches {
return [...this.watches.values()].some(({ request }) => request.workspaceRoot === workspaceRoot);
}

async start(input: unknown, scopeIsCurrent?: () => boolean): Promise<void> {
async start(input: unknown, scopeIsCurrent?: () => boolean, waitForFirstSave = false): Promise<void> {
const request = monitorWatchRequestSchema.parse(input);
if (!this.deps.isLocal() || this.disposed) throw new Error('Monitor watches require the local desktop.');
if (this.watches.size + this.starting.size >= MAX_WATCHES || this.working.size + this.starting.size >= MAX_WATCHES) throw new Error('Stop a watch before adding another.');
Expand All @@ -100,20 +102,24 @@ export class DesktopMonitorWatches {
this.starting.add(admission);
try {
const { source } = request;
if (source.kind === 'github-actions') { source.repo = source.repo.toLowerCase(); source.sha = source.sha.toLowerCase(); }
if (source.kind !== 'mcp') { source.repo = source.repo.toLowerCase(); source.sha = source.sha.toLowerCase(); }
const connector = source.kind === 'mcp' ? (await this.connectors()).find(({ name }) => name === source.connector) : undefined;
if (source.kind === 'mcp' && !connector) throw new Error('Enable the local stdio connector in Settings > MCP before starting a watch.');
const roots = await this.deps.trustedRoots();
if (!roots.includes(request.workspaceRoot) || !await target.isSaved()) throw new Error('The original trusted saved chat is unavailable.');
if (!roots.includes(request.workspaceRoot)) throw new Error('The original trusted chat is unavailable.');
const saved = await target.isSaved();
if (!saved && !waitForFirstSave) throw new Error('The original trusted saved chat is unavailable.');
if (admission.cancelled || this.disposed || !this.deps.isLocal() || scopeIsCurrent?.() === false) {
throw new Error('Monitor scope changed before the watch could start.');
}
const key = JSON.stringify([request.workspaceRoot, request.sessionId, source.kind === 'mcp'
? [source.kind, source.connector, source.eventId, source.revision] : [source.kind, source.repo, source.runId, source.sha]]);
? [source.kind, source.connector, source.eventId, source.revision]
: [source.kind, source.repo, source.kind === 'github-pr' ? source.prNumber : source.runId, source.sha]]);
if (this.consumed.has(key) || [...this.watches.values()].some((watch) => watch.key === key)) throw new Error('This completion is already watched or was already recorded for this chat.');
const id = randomUUID();
const watch: Watch = { request, key, target, controller: new AbortController(), ...(connector ? { connector } : {}),
status: { id, source, state: 'waiting', wake: request.wake, expiresAt: Date.now() + TTL_MS }, nextCheck: 0, failures: 0 };
status: { id, source, state: 'waiting', wake: request.wake, expiresAt: Date.now() + TTL_MS },
nextCheck: 0, ...(!saved ? { saveDeadline: Date.now() + FIRST_SAVE_GRACE_MS } : {}), failures: 0 };
this.watches.set(id, watch);
this.schedule(0);
} finally { this.starting.delete(admission); }
Expand Down Expand Up @@ -187,7 +193,13 @@ export class DesktopMonitorWatches {
if (pinned && !configs.some((item) => sameConnector(pinned, item))) { this.finish(watch, 'stopped'); continue; }
const saved = await watch.target.isSaved();
if (!this.live(watch)) continue;
if (!saved) { this.clear(watch.request.workspaceRoot, watch.request.sessionId); continue; }
if (!saved) {
if (watch.saveDeadline !== undefined) {
if (Date.now() >= watch.saveDeadline) this.finish(watch, 'failed');
} else this.clear(watch.request.workspaceRoot, watch.request.sessionId);
continue;
}
delete watch.saveDeadline;
if (this.working.size >= MAX_WATCHES || this.working.has(watch) || Date.now() < watch.nextCheck) continue;
this.working.add(watch);
const operation = (watch.status.result === undefined ? this.step(watch) : this.wake(watch)).catch(() => {
Expand All @@ -204,7 +216,7 @@ export class DesktopMonitorWatches {
let result: MonitorWatchResult | undefined;
await this.revalidate(watch);
try {
if (source.kind === 'github-actions') result = await pollGitHub(source, signal);
if (source.kind !== 'mcp') result = await pollGitHub(source, signal, watch.request.workspaceRoot);
else {
const launch = (servers: readonly McpServerDefinition[]) => {
const approved = servers.find((server): server is Connector => server.transport === 'stdio' && server.enabled && sameConnector(server, watch.connector!));
Expand Down
10 changes: 10 additions & 0 deletions src/main/pi/MultiProjectPiRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { PiEvent, ProjectState, RuntimeState, SessionSummary } from '../../
import type { AgentWorkspacePolicy } from '../../shared/contracts/multiAgent';
import type { TaskEvent } from '../../shared/contracts/tasks';
import type { MonitorRunsSource } from './monitor/MonitorDashboard';
import type { ChatWatchStarter } from './monitor/ChatWatchTool';
import type { AgentRunStarter } from '../agents/AgentRunTool';
import type { GoogleAccount } from '../google/GoogleAccount';
import type { PiBrowserRuntimeIntegration } from './BrowserRuntimeBridge';
Expand Down Expand Up @@ -166,6 +167,7 @@ export class MultiProjectPiRuntime {
private readonly focusListeners = new Set<() => void>();
private readonly monitorTargetInvalidations = new Set<(projectPath: string, sessionId?: string) => void>();
private monitorPins: ((projectPath: string) => boolean) | undefined;
private chatWatchStarter: ChatWatchStarter | null = null;
private readonly servicePaths = new WeakMap<PiRuntimeService, string>();
private readonly checkoutOwnership: CheckoutOwnership | null;
private stopping = false;
Expand Down Expand Up @@ -393,6 +395,12 @@ export class MultiProjectPiRuntime {
return this.bootService.setProjectPreview(project, sessions);
}

setChatWatchStarter(starter: ChatWatchStarter | null): void {
this.chatWatchStarter = starter;
this.bootService.setChatWatchStarter(starter);
this.manager.forEach((_path, service) => service.setChatWatchStarter(starter));
}

setMonitorWorkspacePins(pins: (projectPath: string) => boolean): void {
this.monitorPins = pins;
}
Expand Down Expand Up @@ -602,6 +610,7 @@ export class MultiProjectPiRuntime {
});
if (this.deps.learning) service.setLearningService(this.deps.learning);
if (this.deps.monitorRuns) service.setMonitorRunsSource(this.deps.monitorRuns);
service.setChatWatchStarter(this.chatWatchStarter);
if (this.deps.computerUse) service.setComputerUse(this.deps.computerUse);
if (this.deps.agentRunStarter) service.setAgentRunStarter(this.deps.agentRunStarter);
if (this.deps.agentSessionGate) service.setAgentSessionGate(this.deps.agentSessionGate);
Expand Down Expand Up @@ -668,6 +677,7 @@ export class MultiProjectPiRuntime {
case 'setEventSink': return (sink: (events: PiEvent[]) => void) => self.setEventSink(sink);
case 'setGoalEventSink': return (sink: (event: GoalMaxEvent) => void) => self.setGoalEventSink(sink);
case 'setTaskEventSink': return (sink: (event: TaskEvent) => void) => self.setTaskEventSink(sink);
case 'setChatWatchStarter': return (starter: ChatWatchStarter | null) => self.setChatWatchStarter(starter);
case 'dispose': return () => self.dispose();
default: break;
}
Expand Down
Loading
Loading