feat(desktop): add monitor scheduler, Playwright CDP layer, and account health

Move monitor-task scheduling authority onto the client with a durable
file-backed queue that survives restart, drops stale cross-day tasks,
enforces per-platform serialism, and adapts global concurrency from
Electron process metrics. Publish tasks keep their existing FIFO.

Add a hidden Playwright CDP manager that attaches to Electron Chromium
on account session partitions, lets adapters opt into `executionMode:
"playwright"`, and leaves the existing hidden WebContentsView path in
place for current adapters.

Introduce an account-health subsystem with silent probes, projected
health/auth states, and IPC invalidation events so the renderer can
show accurate auth/probe status and verification timestamps.

Server-side, derive and forward title/business_date/scheduler_group_key/
question_text metadata on desktop task events so the local scheduler
can defer same-question fan-out before leasing.
This commit is contained in:
2026-04-20 17:16:15 +08:00
parent 07881a66d0
commit 55e1c2e74b
26 changed files with 3001 additions and 153 deletions
+49
View File
@@ -1,5 +1,54 @@
# Progress Log
## Session: 2026-04-20
### Phase 15: Desktop Scheduler Design & Integration
- **Status:** complete
- Actions taken:
- Re-read the planning files and recovered the current desktop AI monitoring scope from the existing repo changes.
- Audited the desktop runtime controller, process metrics sampler, runtime snapshot, session registry, and monitor adapter surface.
- Confirmed the current desktop task executor is global-serial, monitor-task staleness dropping is already implemented, and no durable local queue/cache exists yet.
- Confirmed `playwright-core` is installed but `connectOverCDP()` is not wired, while hidden Electron execution already exists via `BrowserWindow` and `WebContentsView`.
- Added `monitor-scheduler.ts` as a durable file-backed local scheduler for monitor tasks, including same-day persistence, stale cross-day pruning, per-platform mutual exclusion, question-level cooldowns, and lease-miss backoff.
- Refactored `runtime-controller.ts` so publish tasks keep a conservative explicit queue while monitor tasks are selected through the local scheduler with adaptive max concurrency from Electron process metrics.
- Extended runtime diagnostics to surface the monitor scheduler snapshot and made the lease manager track multiple active leases instead of a single global lease placeholder.
- Files created/modified:
- `task_plan.md` (updated)
- `findings.md` (updated)
- `progress.md` (updated)
- `apps/desktop-client/src/main/monitor-scheduler.ts` (created)
- `apps/desktop-client/src/main/runtime-controller.ts` (updated)
- `apps/desktop-client/src/main/lease-manager.ts` (updated)
- `apps/desktop-client/src/main/runtime-snapshot.ts` (updated)
### Phase 16: Hidden Playwright CDP Execution Layer
- **Status:** complete
- Actions taken:
- Added `playwright-cdp.ts` as a reusable hidden-browser manager that launches hidden Electron `BrowserWindow` instances on account-bound sessions and attaches Playwright via `chromium.connectOverCDP()`.
- Enabled Electron remote debugging in bootstrap so the app exposes a CDP endpoint for local Playwright attachment.
- Extended adapter context with an optional Playwright `{ browser, page }` handle and wired the runtime controller to acquire/release hidden Playwright pages when an adapter declares `executionMode: "playwright"`.
- Kept the existing hidden `WebContentsView` path intact so current adapters like Doubao continue to work unchanged.
- Files created/modified:
- `apps/desktop-client/src/main/playwright-cdp.ts` (created)
- `apps/desktop-client/src/main/bootstrap.ts` (updated)
- `apps/desktop-client/src/main/adapters/base.ts` (updated)
- `apps/desktop-client/src/main/runtime-controller.ts` (updated)
### Phase 17: Verification & Delivery
- **Status:** in_progress
- Actions taken:
- Added optional scheduler metadata to desktop task events in shared types and server publishers so the local scheduler can make safer fan-out decisions before leasing.
- Ran `gofmt` on the modified Go files after the event metadata changes.
- Verified `pnpm --filter @geo/desktop-client typecheck` passes.
- Verified `pnpm --filter @geo/desktop-client build` passes.
- Verified `pnpm --filter admin-web typecheck` still passes after the shared-type event additions.
- Verified `go test ./internal/tenant/app/...` passes from `server/`.
- Files created/modified:
- `packages/shared-types/src/index.ts` (updated)
- `server/internal/tenant/app/desktop_task_events.go` (updated)
- `server/internal/tenant/app/desktop_task_service.go` (updated)
- `server/internal/tenant/app/publish_job_service.go` (updated)
## Session: 2026-04-04
### Phase 13: Prompt Centralization