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:
2026-04-19 14:18:20 +08:00
parent 98f9e95875
commit b16e9f0bd1
141 changed files with 21533 additions and 357 deletions
+203
View File
@@ -28,6 +28,7 @@ export interface UserInfo {
name: string;
avatar_url: string | null;
tenant_id: number;
primary_workspace_id: number;
tenant_role: string;
permissions: string[];
membership: MembershipInfo | null;
@@ -62,6 +63,208 @@ export interface RefreshResponse {
expires_at: number;
}
export interface DesktopClientInfo {
id: string;
tenant_id: number;
workspace_id: number;
user_id: number;
device_name: string | null;
os: string | null;
cpu_arch: string | null;
client_version: string | null;
channel: string | null;
created_at: string;
last_seen_at: string | null;
last_rotated_at: string | null;
revoked_at: string | null;
}
export interface DesktopClientRegisterRequest {
device_name: string;
os: string;
cpu_arch?: string;
client_version: string;
channel?: string;
}
export interface DesktopClientRegisterResponse {
client_id: string;
client_token: string;
expires_at: number;
client: DesktopClientInfo;
}
export interface DesktopClientHeartbeatRequest {
device_name?: string;
os?: string;
cpu_arch?: string;
client_version?: string;
channel?: string;
}
export interface DesktopClientHeartbeatResponse {
client: DesktopClientInfo;
server_time: string;
}
export interface DesktopClientRotateResponse {
client_token: string;
expires_at: number;
client: DesktopClientInfo;
}
export interface DesktopAccountInfo {
id: string;
platform: string;
platform_uid: string;
display_name: string;
health: "live" | "expired" | "captcha" | "risk";
client_id: string | null;
account_fingerprint: string | null;
verified_at: string | null;
tags: string[];
sync_version: number;
deleted_at: string | null;
delete_requested_at: string | null;
}
export interface UpsertDesktopAccountRequest {
platform: string;
platform_uid: string;
account_fingerprint?: string | null;
display_name: string;
health: "live" | "expired" | "captcha" | "risk";
verified_at?: string | null;
tags?: string[];
if_sync_version?: number | null;
}
export interface PatchDesktopAccountRequest {
display_name?: string;
health?: "live" | "expired" | "captcha" | "risk";
verified_at?: string | null;
tags?: string[];
if_sync_version: number;
}
export interface DesktopTaskInfo {
id: string;
job_id: string;
tenant_id: number;
workspace_id: number;
target_account_id: string;
target_client_id: string;
platform: string;
kind: "publish" | "monitor";
payload: Record<string, JsonValue> | null;
status: "queued" | "in_progress" | "waiting_user" | "succeeded" | "failed" | "unknown" | "aborted";
dedup_key: string | null;
active_attempt_id: string | null;
lease_expires_at: string | null;
attempts: number;
parked_reason: string | null;
result: Record<string, JsonValue> | null;
error: Record<string, JsonValue> | null;
created_at: string;
updated_at: string;
}
export interface LeaseDesktopTaskRequest {
task_id?: string;
kind?: "publish" | "monitor";
}
export interface LeaseDesktopTaskResponse {
task: DesktopTaskInfo | null;
attempt_id?: string;
lease_token?: string;
lease_expires_at?: string | null;
}
export interface ExtendDesktopTaskRequest {
lease_token: string;
}
export interface ParkDesktopTaskRequest {
lease_token: string;
reason: "waiting_user" | "captcha";
}
export interface CompleteDesktopTaskRequest {
lease_token: string;
status: "succeeded" | "failed" | "unknown";
payload?: Record<string, JsonValue>;
error?: Record<string, JsonValue>;
}
export interface CancelDesktopTaskRequest {
lease_token?: string | null;
reason?: string | null;
}
export interface ReconcileDesktopTaskRequest {
status: "succeeded" | "failed" | "aborted" | "retry";
result?: Record<string, JsonValue>;
error?: Record<string, JsonValue>;
}
export interface DesktopTaskEventMessage {
type:
| "task_available"
| "task_leased"
| "task_extended"
| "task_parked"
| "task_completed"
| "task_canceled"
| "task_reconciled";
task_id: string;
job_id: string;
workspace_id: number;
target_client_id: string;
status:
| "queued"
| "in_progress"
| "waiting_user"
| "succeeded"
| "failed"
| "unknown"
| "aborted";
kind: "publish" | "monitor";
updated_at: string;
}
export interface DesktopArticleContent {
article_id: number;
title: string;
html_content: string | null;
markdown_content: string | null;
cover_asset_url: string | null;
}
export interface DesktopRuntimeSessionSyncRequest {
api_base_url: string;
mode: "authenticated" | "preview";
client_token: string | null;
desktop_client: DesktopClientInfo | null;
}
export interface CreatePublishJobAccountRequest {
account_id: string;
mode: "auto" | "manual";
}
export interface CreatePublishJobRequest {
title: string;
content_ref: Record<string, JsonValue>;
accounts: CreatePublishJobAccountRequest[];
scheduled_at?: string | null;
}
export interface CreatePublishJobResponse {
job_id: string;
task_ids: string[];
}
export interface WorkspaceOverview {
article_count: number;
published_count: number;
+17
View File
@@ -0,0 +1,17 @@
{
"name": "@geo/ui-shared",
"version": "0.1.0",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts",
"./tokens": "./src/tokens/index.ts",
"./tokens.css": "./src/tokens/index.css",
"./composables": "./src/composables/index.ts",
"./components": "./src/components/index.ts"
},
"peerDependencies": {
"ant-design-vue": "^4.2.6",
"vue": "^3.5.31"
}
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1 @@
export {};
+3
View File
@@ -0,0 +1,3 @@
export * from "./tokens/index";
export * from "./composables/index";
export * from "./components/index";
+98
View File
@@ -0,0 +1,98 @@
:root {
--geo-font-sans: "IBM Plex Sans", "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
--geo-font-mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", "Consolas", monospace;
--geo-color-bg-primary: #eef3f8;
--geo-color-bg-secondary: #e4ebf3;
--geo-color-bg-tertiary: #d6e1ec;
--geo-color-bg-elevated: rgba(255, 255, 255, 0.78);
--geo-color-bg-panel: rgba(247, 250, 253, 0.86);
--geo-color-text-primary: #111827;
--geo-color-text-secondary: #4b5563;
--geo-color-text-tertiary: #7b8794;
--geo-color-border: rgba(15, 23, 42, 0.08);
--geo-color-border-strong: rgba(15, 23, 42, 0.14);
--geo-color-brand: #0f766e;
--geo-color-brand-strong: #115e59;
--geo-color-brand-soft: rgba(15, 118, 110, 0.12);
--geo-color-success: #15803d;
--geo-color-success-soft: rgba(21, 128, 61, 0.12);
--geo-color-warn: #b45309;
--geo-color-warn-soft: rgba(180, 83, 9, 0.12);
--geo-color-danger: #b91c1c;
--geo-color-danger-soft: rgba(185, 28, 28, 0.12);
--geo-color-info: #2563eb;
--geo-color-info-soft: rgba(37, 99, 235, 0.12);
--geo-radius-sm: 12px;
--geo-radius-md: 20px;
--geo-radius-lg: 32px;
--geo-shadow-soft: 0 28px 60px rgba(15, 23, 42, 0.12);
--geo-shadow-card: 0 18px 36px rgba(15, 23, 42, 0.08);
--geo-shadow-edge: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
html[data-theme="dark"] {
--geo-color-bg-primary: #0a1015;
--geo-color-bg-secondary: #101820;
--geo-color-bg-tertiary: #16212c;
--geo-color-bg-elevated: rgba(16, 24, 32, 0.82);
--geo-color-bg-panel: rgba(10, 16, 21, 0.76);
--geo-color-text-primary: #ecf3fb;
--geo-color-text-secondary: #aebac7;
--geo-color-text-tertiary: #708090;
--geo-color-border: rgba(226, 232, 240, 0.08);
--geo-color-border-strong: rgba(226, 232, 240, 0.16);
--geo-color-brand: #46b7ab;
--geo-color-brand-strong: #63d0c4;
--geo-color-brand-soft: rgba(70, 183, 171, 0.14);
--geo-color-success: #5dd39e;
--geo-color-success-soft: rgba(93, 211, 158, 0.12);
--geo-color-warn: #f2a65a;
--geo-color-warn-soft: rgba(242, 166, 90, 0.14);
--geo-color-danger: #f36b7f;
--geo-color-danger-soft: rgba(243, 107, 127, 0.14);
--geo-color-info: #7aa2ff;
--geo-color-info-soft: rgba(122, 162, 255, 0.14);
--geo-shadow-soft: 0 32px 72px rgba(0, 0, 0, 0.42);
--geo-shadow-card: 0 18px 42px rgba(0, 0, 0, 0.28);
--geo-shadow-edge: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
html,
body,
#app {
min-height: 100%;
}
html {
color-scheme: light;
}
html[data-theme="dark"] {
color-scheme: dark;
}
body {
margin: 0;
font-family: var(--geo-font-sans);
background:
radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 32%),
radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 26%),
linear-gradient(180deg, var(--geo-color-bg-primary), var(--geo-color-bg-secondary));
color: var(--geo-color-text-primary);
}
* {
box-sizing: border-box;
}
button,
input,
textarea,
select {
font: inherit;
}
code,
pre {
font-family: var(--geo-font-mono);
}
+13
View File
@@ -0,0 +1,13 @@
export const themeTokens = {
colorBgPrimary: "var(--geo-color-bg-primary)",
colorBgSecondary: "var(--geo-color-bg-secondary)",
colorTextPrimary: "var(--geo-color-text-primary)",
colorTextSecondary: "var(--geo-color-text-secondary)",
colorBorder: "var(--geo-color-border)",
colorBrand: "var(--geo-color-brand)",
colorSuccess: "var(--geo-color-success)",
colorWarn: "var(--geo-color-warn)",
colorDanger: "var(--geo-color-danger)",
} as const;
export type ThemeTokenKey = keyof typeof themeTokens;