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:
@@ -0,0 +1,34 @@
|
||||
type RuntimeInvalidationReason = "account-health";
|
||||
|
||||
type RuntimeInvalidationListener = (event: {
|
||||
reason: RuntimeInvalidationReason;
|
||||
at: number;
|
||||
}) => void;
|
||||
|
||||
const listeners = new Set<RuntimeInvalidationListener>();
|
||||
|
||||
export function emitRuntimeInvalidated(reason: RuntimeInvalidationReason): void {
|
||||
const event = {
|
||||
reason,
|
||||
at: Date.now(),
|
||||
} as const;
|
||||
|
||||
for (const listener of listeners) {
|
||||
try {
|
||||
listener(event);
|
||||
} catch (error) {
|
||||
console.warn("[desktop-runtime] invalidation listener failed", {
|
||||
reason,
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function onRuntimeInvalidated(listener: RuntimeInvalidationListener): () => void {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user