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
+31 -5
View File
@@ -1,10 +1,10 @@
# Task Plan: GEO admin-web backend completion and frontend foundation
## Goal
Finish the completed backend verification/implementation chain, then resume the interrupted work by establishing the missing frontend foundation for `admin-web` so it can authenticate against `tenant-api` and render the first dashboard slice.
Continue the desktop AI monitoring implementation by first adding a client-side local scheduler with durable queueing and adaptive execution policy, then adding a reusable hidden Playwright CDP execution layer that attaches to Electron Chromium and reuses existing account partitions.
## Current Phase
Phase 14
Phase 17
## Phases
### Phase 1: Progress Verification
@@ -94,10 +94,30 @@ Phase 14
- [x] Deliver the extraction result and any remaining gaps
- **Status:** complete
### Phase 15: Desktop Scheduler Design & Integration
- [x] Audit the current desktop runtime queue/task execution path and lock the scheduler constraints
- [x] Implement a durable local monitor-task queue/cache with stale-task cleanup
- [x] Implement platform-level mutual exclusion and adaptive global concurrency policy
- [x] Integrate the scheduler into runtime leasing/execution without regressing publish tasks
- **Status:** complete
### Phase 16: Hidden Playwright CDP Execution Layer
- [x] Add a reusable hidden-browser manager that attaches Playwright to Electron Chromium over CDP
- [x] Reuse desktop account partition/session state for hidden pages
- [x] Expose the hidden Playwright context/page lifecycle to future monitor adapters
- [x] Keep the current hidden-view path working for existing adapters during the transition
- **Status:** complete
### Phase 17: Verification & Delivery
- [x] Run targeted desktop type/build verification
- [ ] Inspect runtime snapshot output for new scheduler/CDP state
- [ ] Summarize what is production-ready versus still scaffolded
- **Status:** in_progress
## Key Questions
1. Which of the 9 steps are already implemented versus partially complete?
2. What is the earliest step whose acceptance criteria are not yet met?
3. What concrete code changes are required now to advance that step safely?
1. How should the desktop client defer and locally optimize monitor-task execution without violating one-task-per-platform serialism?
2. What is the smallest durable local cache that allows same-day resume while safely dropping stale next-day monitor tasks?
3. How can Playwright CDP attach cleanly to Electron Chromium while reusing existing account session partitions?
## Decisions Made
| Decision | Rationale |
@@ -115,6 +135,9 @@ Phase 14
| Reconstruct the screenshot layouts from visual position data, not OCR text alone | The user explicitly asked to follow image design including element placement |
| Move the quota card into the left sidebar footer and use page-level hero sections | This matches the reference screenshots more closely than the previous generic topbar layout |
| Centralize prompt text in a dedicated package instead of leaving it inside business logic functions | The user explicitly asked to extract hard-coded prompts for easier future optimization |
| Move scheduling authority fully into `desktop-client` | The user explicitly wants the server to dispatch tasks while the client decides when to execute them |
| Allow stale cross-day monitor tasks to be dropped on the client | The user explicitly allows漏采 and does not want next-day catch-up for unfinished tasks |
| Implement hidden browser infrastructure before expanding more adapters | Qwen and similar platforms cannot reliably use direct API calls and need browser-native execution |
## Errors Encountered
| Error | Attempt | Resolution |
@@ -125,9 +148,12 @@ Phase 14
| Gemini CLI `gemini-3.1-pro-preview` returned `429 MODEL_CAPACITY_EXHAUSTED` repeatedly | 1 | Stopped the Gemini path after the user requested not to use Gemini anymore |
| Playwright MCP navigation failed locally because it attempted to create `/.playwright-mcp` | 1 | Fell back to preview HTTP checks instead of blocking the turn on Playwright environment setup |
| Login button click did not trigger the sign-in flow in browser testing even though the backend endpoint worked | 1 | Bound the primary login button directly to `handleSubmit` and re-ran browser verification until the route change succeeded |
| Desktop monitor execution is currently global-serial and lacks durable local queueing | 1 | Replace the ad-hoc in-memory FIFO with a scheduler module that owns persistence, concurrency, and stale-task cleanup |
| `connectOverCDP()` is not wired yet even though `playwright-core` is installed | 1 | Add a dedicated hidden-browser manager instead of pushing CDP code directly into adapters or the runtime controller |
## Notes
- Re-check task_plan.md before major implementation decisions.
- Record concrete evidence for each claimed completed step.
- Frontend scope for this turn is limited to the tenant-facing `admin-web` shell, not the platform ops console.
- Visual references for this turn must be treated as layout guides, not just copy decks.
- Desktop AI monitoring scope for this turn is infrastructure-first: scheduler plus hidden browser layer, not all six adapters.