mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-19 19:02:29 +08:00
feat: $B watch — passive observation mode
Claude enters read-only mode and captures periodic snapshots (every 5s) while the user browses. Mutation commands (click, fill, etc.) are blocked during watch. $B watch stop exits and returns a summary with the last snapshot. Requires headed mode ($B connect). This is the inverse of the scout pattern — the workspace agent watches through the browser instead of the sidebar relaying to it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,12 +61,44 @@ export class BrowserManager {
|
||||
private isHeaded: boolean = false;
|
||||
private consecutiveFailures: number = 0;
|
||||
|
||||
// ─── Watch Mode ─────────────────────────────────────────
|
||||
private watching = false;
|
||||
public watchInterval: ReturnType<typeof setInterval> | null = null;
|
||||
private watchSnapshots: string[] = [];
|
||||
private watchStartTime: number = 0;
|
||||
|
||||
// ─── Headed State ────────────────────────────────────────
|
||||
private connectionMode: 'launched' | 'headed' = 'launched';
|
||||
private intentionalDisconnect = false;
|
||||
|
||||
getConnectionMode(): 'launched' | 'headed' { return this.connectionMode; }
|
||||
|
||||
// ─── Watch Mode Methods ─────────────────────────────────
|
||||
isWatching(): boolean { return this.watching; }
|
||||
|
||||
startWatch(): void {
|
||||
this.watching = true;
|
||||
this.watchSnapshots = [];
|
||||
this.watchStartTime = Date.now();
|
||||
}
|
||||
|
||||
stopWatch(): { snapshots: string[]; duration: number } {
|
||||
this.watching = false;
|
||||
if (this.watchInterval) {
|
||||
clearInterval(this.watchInterval);
|
||||
this.watchInterval = null;
|
||||
}
|
||||
const snapshots = this.watchSnapshots;
|
||||
const duration = Date.now() - this.watchStartTime;
|
||||
this.watchSnapshots = [];
|
||||
this.watchStartTime = 0;
|
||||
return { snapshots, duration };
|
||||
}
|
||||
|
||||
addWatchSnapshot(snapshot: string): void {
|
||||
this.watchSnapshots.push(snapshot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the gstack Chrome extension directory.
|
||||
* Checks: repo root /extension, global install, dev install.
|
||||
|
||||
Reference in New Issue
Block a user