feat: deep link digital sync failures
This commit is contained in:
@@ -1701,8 +1701,14 @@
|
||||
.de-event-modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.de-event-modal-actions .de-btn-sm {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.de-event-history-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -73,6 +73,7 @@ interface QimingclawSyncFailure {
|
||||
lastAttemptAt: string | null;
|
||||
nextRetryAt?: string | null;
|
||||
dueForRetry?: boolean;
|
||||
managementRecordUrl?: string | null;
|
||||
error: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
@@ -73,6 +73,7 @@ interface ManagementSyncFailure {
|
||||
lastAttemptAt: string | null;
|
||||
nextRetryAt?: string | null;
|
||||
dueForRetry?: boolean;
|
||||
managementRecordUrl?: string | null;
|
||||
error: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -1837,12 +1838,36 @@ export default function CommandDeck({ onNavigate }: { onNavigate: (target: Digit
|
||||
<p>{selectedSyncFailure.error || '暂无错误详情。'}</p>
|
||||
</div>
|
||||
<div className="de-event-modal-actions">
|
||||
<button type="button" className="de-btn-secondary de-btn-sm" onClick={() => setSelectedSyncFailure(null)}>关闭</button>
|
||||
<button
|
||||
type="button"
|
||||
className="de-btn-secondary de-btn-sm"
|
||||
onClick={() => setSelectedSyncFailure(null)}
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
{selectedSyncFailure.managementRecordUrl && (
|
||||
<button
|
||||
type="button"
|
||||
className="de-btn-secondary de-btn-sm"
|
||||
onClick={() =>
|
||||
window.open(
|
||||
selectedSyncFailure.managementRecordUrl || '',
|
||||
'_blank',
|
||||
'noopener,noreferrer',
|
||||
)
|
||||
}
|
||||
>
|
||||
<Eye size={14} />
|
||||
查看管理端记录
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="de-btn-primary de-btn-sm"
|
||||
disabled={actionBusy === 'flush_management_sync'}
|
||||
onClick={() => { void flushManagementSync().then(() => setSelectedSyncFailure(null)); }}
|
||||
onClick={() => {
|
||||
void flushManagementSync().then(() => setSelectedSyncFailure(null));
|
||||
}}
|
||||
>
|
||||
{actionBusy === 'flush_management_sync' ? '同步中...' : '立即重试'}
|
||||
</button>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -13,8 +13,8 @@
|
||||
console.warn("[qimingclaw] digital employee auth bootstrap skipped", error);
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="./assets/index-DHy6Ywa5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-YI8Pgcr5.css">
|
||||
<script type="module" crossorigin src="./assets/index-BmpavZF5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-DDOlQz2O.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -4,6 +4,8 @@ import { getDomainTokenKey } from "@shared/utils/domain";
|
||||
import { getDb, readSetting } from "../../db";
|
||||
|
||||
const DEFAULT_SYNC_PATH = "/api/digital-employee/sync/outbox";
|
||||
const MANAGEMENT_SYNC_RECORD_PATH =
|
||||
"/system/content/content-digital-employee-sync";
|
||||
const DEFAULT_INTERVAL_MS = 30_000;
|
||||
const DEFAULT_BATCH_SIZE = 50;
|
||||
const REQUEST_TIMEOUT_MS = 15_000;
|
||||
@@ -42,6 +44,7 @@ export interface DigitalEmployeeSyncFailure {
|
||||
lastAttemptAt: string | null;
|
||||
nextRetryAt: string | null;
|
||||
dueForRetry: boolean;
|
||||
managementRecordUrl: string | null;
|
||||
error: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -109,7 +112,7 @@ export function getDigitalEmployeeSyncStatus(): DigitalEmployeeSyncStatus {
|
||||
failed: countOutbox("failed"),
|
||||
lastSyncAt,
|
||||
lastSyncError,
|
||||
recentFailures: readRecentFailures(),
|
||||
recentFailures: readRecentFailures(config),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -385,7 +388,10 @@ function countOutbox(status: string): number {
|
||||
return row?.count ?? 0;
|
||||
}
|
||||
|
||||
function readRecentFailures(limit = 3): DigitalEmployeeSyncFailure[] {
|
||||
function readRecentFailures(
|
||||
config: DigitalEmployeeSyncConfig,
|
||||
limit = 3,
|
||||
): DigitalEmployeeSyncFailure[] {
|
||||
const db = getDb();
|
||||
if (!db) return [];
|
||||
const rows = db
|
||||
@@ -422,6 +428,7 @@ function readRecentFailures(limit = 3): DigitalEmployeeSyncFailure[] {
|
||||
lastAttemptAt: row.last_attempt_at,
|
||||
nextRetryAt,
|
||||
dueForRetry: !nextRetryAt || Date.now() >= Date.parse(nextRetryAt),
|
||||
managementRecordUrl: buildManagementRecordUrl(config, row),
|
||||
error: row.error,
|
||||
createdAt: row.created_at,
|
||||
updatedAt: row.updated_at,
|
||||
@@ -429,6 +436,28 @@ function readRecentFailures(limit = 3): DigitalEmployeeSyncFailure[] {
|
||||
});
|
||||
}
|
||||
|
||||
function buildManagementRecordUrl(
|
||||
config: DigitalEmployeeSyncConfig,
|
||||
row: {
|
||||
id: string;
|
||||
entity_type: string;
|
||||
entity_id: string;
|
||||
},
|
||||
): string | null {
|
||||
if (!config.endpoint) return null;
|
||||
try {
|
||||
const endpoint = new URL(config.endpoint);
|
||||
const url = new URL(MANAGEMENT_SYNC_RECORD_PATH, endpoint.origin);
|
||||
if (config.clientKey) url.searchParams.set("client_key", config.clientKey);
|
||||
url.searchParams.set("entity_type", row.entity_type);
|
||||
url.searchParams.set("entity_id", row.entity_id);
|
||||
url.searchParams.set("outbox_id", row.id);
|
||||
return url.toString();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function nextRetryAtForFailure(
|
||||
lastAttemptAt: string | null,
|
||||
attempts: number,
|
||||
|
||||
@@ -446,7 +446,7 @@ crates/agent-electron-client/src/preload/webviewPerfBridge.ts
|
||||
- 数字员工任务设置工具栏已增加“同步管理端”按钮,可通过 bridge 立即触发 `flushSync` 并刷新页面投影。
|
||||
- 数字员工首页已增加管理端同步状态条,展示待同步数量、失败数量、最近同步时间和最近失败原因摘要。
|
||||
- 同步状态通过 bridge 返回最近失败 outbox 明细,首页可直接看到实体类型、outbox ID、操作类型、重试次数、失败时间和下次自动重试时间。
|
||||
- 点击失败 outbox 可打开详情弹窗,查看完整错误、实体 ID、退避状态,并可触发手动 `flushSync` 立即重试。
|
||||
- 点击失败 outbox 可打开详情弹窗,查看完整错误、实体 ID、退避状态,并可触发手动 `flushSync` 立即重试;若已配置管理端同步地址,详情弹窗可直接打开对应的管理端同步记录深链。
|
||||
|
||||
新增 IPC / Bridge:
|
||||
|
||||
@@ -479,15 +479,15 @@ qiming-backend/app-platform-modules/app-platform-agent/app-platform-agent-core-a
|
||||
GET /api/digital-employee/sync/records
|
||||
```
|
||||
|
||||
- 支持 `client_key`、`entity_type`、`entity_id`、`page_no`、`page_size` 查询参数。
|
||||
- 支持 `client_key`、`entity_type`、`entity_id`、`outbox_id`、`page_no`、`page_size` 查询参数。
|
||||
- 按当前登录上下文租户隔离,默认每页 20 条,最大每页 100 条。
|
||||
- 当前返回通用同步记录和原始 payload,用于管理端页面或联调工具先查看同步结果;后续再拆分为更丰富的 Plan / Task / Run / Event 查询模型。
|
||||
- 管理端已增加“数字员工同步记录”菜单、权限资源和列表页,可按客户端 Key、实体类型、实体 ID 查询并查看 payload。
|
||||
- 管理端已增加“数字员工同步记录”菜单、权限资源和列表页,可按客户端 Key、实体类型、实体 ID、Outbox ID 查询并查看 payload,且支持 URL 查询参数预填筛选条件。
|
||||
|
||||
下一步:
|
||||
|
||||
- 后续再拆分管理端 Plan / Task / Run / Event 查询模型,让同步记录从通用 payload 观察面升级为业务视图。
|
||||
- 数字员工页面继续补充更完整的同步重试历史和管理端记录深链。
|
||||
- 数字员工页面继续补充更完整的同步重试历史。
|
||||
|
||||
## 管理端联动原则
|
||||
|
||||
|
||||
Reference in New Issue
Block a user