From 67bddcf4b3f8d79d20b2983659b6f9a095df6a3c Mon Sep 17 00:00:00 2001 From: kris Date: Mon, 30 Mar 2026 21:02:35 +0800 Subject: [PATCH] fix: continue live-first workbench reads --- web/storyforge-web-v4/assets/app.js | 15 ++++----------- .../tests/workbench-pages.test.mjs | 4 ++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/web/storyforge-web-v4/assets/app.js b/web/storyforge-web-v4/assets/app.js index 51cf8ad..68264be 100644 --- a/web/storyforge-web-v4/assets/app.js +++ b/web/storyforge-web-v4/assets/app.js @@ -2406,14 +2406,10 @@ async function loadPlatformAccount(platform, accountId, requestToken = 0) { return true; } const videosPath = getWorkbenchRoute(normalizedPlatform, "videos", accountId); - const supportsAccountVideos = videosPath && backendSupports(`/v2/${normalizedPlatform}/accounts/{account_id}/videos`); - const supportsAccountSnapshots = normalizedPlatform === "douyin" && backendSupports("/v2/douyin/accounts/{account_id}/snapshots"); - const supportsCreatorFields = normalizedPlatform === "douyin" && backendSupports("/v2/douyin/accounts/{account_id}/creator-fields"); - const supportsAnalysisReports = normalizedPlatform === "douyin" && backendSupports("/v2/douyin/accounts/{account_id}/analysis-reports"); try { const [workspace, videos, snapshotsPayload, analysisReportsPayload] = await Promise.all([ storyforgeFetch(workspacePath), - supportsAccountVideos + videosPath ? storyforgeFetch(videosPath).catch(() => ({ items: [], meta: {}, @@ -2428,10 +2424,10 @@ async function loadPlatformAccount(platform, accountId, requestToken = 0) { latest_video_ids: [], high_score_threshold: 60 }), - supportsAccountSnapshots + normalizedPlatform === "douyin" ? storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/snapshots`).catch(() => []) : Promise.resolve([]), - supportsAnalysisReports + normalizedPlatform === "douyin" ? storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/analysis-reports`).catch(() => []) : Promise.resolve([]) ]); @@ -2442,7 +2438,7 @@ async function loadPlatformAccount(platform, accountId, requestToken = 0) { appState.selectedVideos = videos; if (normalizedPlatform === "douyin") { appState.snapshots = safeArray(snapshotsPayload?.items || snapshotsPayload); - appState.creatorFields = supportsCreatorFields && hasCreatorCenterSnapshot(appState.snapshots) + appState.creatorFields = hasCreatorCenterSnapshot(appState.snapshots) ? await storyforgeFetch(`/v2/douyin/accounts/${encodeURIComponent(accountId)}/creator-fields`).catch(() => null) : null; appState.analysisReports = safeArray(analysisReportsPayload?.items || analysisReportsPayload); @@ -9306,9 +9302,6 @@ async function openPlatformAgentDetailAction(platform) { const skills = safeArray(skillsPayload?.items || skillsPayload).slice(0, 6); const skillVersionEntries = await Promise.all( skills.map(async (item) => { - if (!backendSupports("/v2/platform-agents/{platform}/skills/{skill_id}/versions")) { - return [item.id, []]; - } const payload = await storyforgeFetch(`/v2/platform-agents/${encodeURIComponent(normalizedPlatform)}/skills/${encodeURIComponent(item.id)}/versions?project_id=${encodeURIComponent(project.id)}`).catch(() => ({ items: [] })); return [item.id, safeArray(payload?.items || payload).slice(0, 3)]; }) diff --git a/web/storyforge-web-v4/tests/workbench-pages.test.mjs b/web/storyforge-web-v4/tests/workbench-pages.test.mjs index 59d22ae..57c0dd4 100644 --- a/web/storyforge-web-v4/tests/workbench-pages.test.mjs +++ b/web/storyforge-web-v4/tests/workbench-pages.test.mjs @@ -292,11 +292,13 @@ test("quota and review screens foreground live next-step guidance", () => { test("tracking refresh and top-video analysis flows expose async feedback inside the workbench", () => { const tracking = extractBetween(APP, "function renderTrackingScreen()", "function renderAutomationScreen()"); const discovery = extractBetween(APP, "function renderDiscoveryOverviewSection(", "function renderDiscoveryRelationsSection("); + const accountWorkspaceLoad = extractBetween(APP, "async function loadPlatformAccount(", "async function bootstrap()"); const trackingActions = extractBetween(APP, "async function markTrackingDigestRead()", "function createEmptyTrackingDigest("); const oneLinerSession = extractBetween(APP, "async function ensureOneLinerSession()", "async function submitOneLinerMessage("); const oneLinerRun = extractBetween(APP, "async function createOneLinerRun(", "async function confirmOneLinerRun("); const oneLinerAction = extractBetween(APP, "async function executeOneLinerAction(", "function openCurrentOneLinerRunResultAction("); const skillReview = extractBetween(APP, "function openPlatformSkillReviewAction(", "function openPlatformSkillRollbackAction("); + const agentDetail = extractBetween(APP, "async function openPlatformAgentDetailAction(", "function openPlatformSkillReviewAction("); const topVideoAction = extractBetween(APP, "function openAnalyzeTopVideosAction()", "function openSimilaritySearchAction()"); assert.match(APP, /function summarizeTrackingRefreshPayload\(/); @@ -310,10 +312,12 @@ test("tracking refresh and top-video analysis flows expose async feedback inside assert.match(discovery, /最近高分拆解/); assert.match(discovery, /这批结果已经回流到当前账号页/); assert.doesNotMatch(trackingActions, /当前后端暂不支持.*跟踪已读游标|当前后端暂不支持.*批量跟踪同步|当前后端暂不支持.*单账号跟踪同步/s); + assert.doesNotMatch(accountWorkspaceLoad, /supportsAccountVideos|supportsAccountSnapshots|supportsCreatorFields|supportsAnalysisReports/); assert.doesNotMatch(oneLinerSession, /当前后端还没有接入 OneLiner 会话接口/); assert.doesNotMatch(oneLinerRun, /当前后端还没有接入主 Agent 运行层/); assert.doesNotMatch(oneLinerAction, /当前后端还没有接入 OneLiner 动作执行器/); assert.doesNotMatch(skillReview, /当前后端还没有接入平台技能验收接口/); + assert.ok(!agentDetail.includes('backendSupports("/v2/platform-agents/{platform}/skills/{skill_id}/versions")')); assert.doesNotMatch(topVideoAction, /当前后端暂不支持.*高分作品批量分析/s); assert.match(topVideoAction, /当前实例未提供/); });