feat(desktop): implement workspace foundation + desktop-client skeleton
Plan 0 (workspaces): add workspaces + workspace_memberships schema, extend JWT/Actor/claims with primary_workspace_id, seed default workspace per tenant, thread workspace_id through tenant monitoring quota. Plan A (desktop skeleton): new Electron app (apps/desktop-client) with main/ preload/renderer, shared Vue component package (packages/ui-shared), and server surface — desktop client registration + token rotation + heartbeat, SSE task event stream, desktop accounts/tasks/content handlers, publish job endpoint, and supporting repositories, services, sqlc queries, and migrations. Hard cutover per plan: remove browser-extension monitoring callback endpoints, stub legacy media API in admin-web, and delete monitoring_callback_handler.go.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
interface SchedulerSnapshot {
|
||||
initializedAt: number;
|
||||
phase: "idle" | "running" | "paused";
|
||||
queueDepth: number;
|
||||
currentTaskId: string | null;
|
||||
lastSseEventAt: number | null;
|
||||
lastHeartbeatAt: number | null;
|
||||
lastPullAt: number | null;
|
||||
lastAccountsSyncAt: number | null;
|
||||
lastTaskStartedAt: number | null;
|
||||
lastTaskFinishedAt: number | null;
|
||||
nextHeartbeatAt: number | null;
|
||||
nextPullAt: number | null;
|
||||
lastError: string | null;
|
||||
}
|
||||
|
||||
const schedulerState: SchedulerSnapshot = {
|
||||
initializedAt: 0,
|
||||
phase: "idle",
|
||||
queueDepth: 0,
|
||||
currentTaskId: null,
|
||||
lastSseEventAt: null,
|
||||
lastHeartbeatAt: null,
|
||||
lastPullAt: null,
|
||||
lastAccountsSyncAt: null,
|
||||
lastTaskStartedAt: null,
|
||||
lastTaskFinishedAt: null,
|
||||
nextHeartbeatAt: null,
|
||||
nextPullAt: null,
|
||||
lastError: null,
|
||||
};
|
||||
|
||||
export function initScheduler(): void {
|
||||
schedulerState.initializedAt = schedulerState.initializedAt || Date.now();
|
||||
}
|
||||
|
||||
export function setSchedulerPhase(phase: SchedulerSnapshot["phase"]): void {
|
||||
schedulerState.phase = phase;
|
||||
}
|
||||
|
||||
export function setSchedulerQueueDepth(queueDepth: number): void {
|
||||
schedulerState.queueDepth = Math.max(0, queueDepth);
|
||||
}
|
||||
|
||||
export function setSchedulerCurrentTask(taskId: string | null): void {
|
||||
schedulerState.currentTaskId = taskId;
|
||||
if (taskId) {
|
||||
schedulerState.lastTaskStartedAt = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
export function noteSchedulerTaskFinished(): void {
|
||||
schedulerState.lastTaskFinishedAt = Date.now();
|
||||
}
|
||||
|
||||
export function noteSchedulerSseEvent(): void {
|
||||
schedulerState.lastSseEventAt = Date.now();
|
||||
}
|
||||
|
||||
export function noteSchedulerHeartbeat(): void {
|
||||
schedulerState.lastHeartbeatAt = Date.now();
|
||||
}
|
||||
|
||||
export function noteSchedulerPull(): void {
|
||||
schedulerState.lastPullAt = Date.now();
|
||||
}
|
||||
|
||||
export function noteSchedulerAccountsSync(): void {
|
||||
schedulerState.lastAccountsSyncAt = Date.now();
|
||||
}
|
||||
|
||||
export function setSchedulerNextHeartbeat(timestamp: number | null): void {
|
||||
schedulerState.nextHeartbeatAt = timestamp;
|
||||
}
|
||||
|
||||
export function setSchedulerNextPull(timestamp: number | null): void {
|
||||
schedulerState.nextPullAt = timestamp;
|
||||
}
|
||||
|
||||
export function setSchedulerError(message: string | null): void {
|
||||
schedulerState.lastError = message;
|
||||
}
|
||||
|
||||
export function getSchedulerState(): SchedulerSnapshot {
|
||||
return { ...schedulerState };
|
||||
}
|
||||
Reference in New Issue
Block a user