🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(workbench): add comment reads to the local report verify stub (#22784)
Rdmclin2740eb8e05546
diff --git a/apps/workbench/src/localReport/stubs/verifyStore.test.ts b/apps/workbench/src/localReport/stubs/verifyStore.test.tsnew file mode 100644index 00000000000..f3805f7ad2c--- /dev/null+++ b/apps/workbench/src/localReport/stubs/verifyStore.test.ts@@ -0,0 +1,82 @@+/**+ * @vitest-environment happy-dom+ *+ * The offline report reads the discussion through the same verify store hooks+ * and selectors as the hosted page, so the stub has to provide them.+ */+import { readFileSync } from 'node:fs';+import path from 'node:path';++import type { LocalAcceptanceSource } from '@lobechat/utils/verify/localAcceptance';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { collectStubUsage, parseStubSurface, stubUsageGaps } from '../../../app/stubs/surface';++const source: LocalAcceptanceSource = {+ acceptance: {+ createdAt: '2026-01-01T00:00:00.000Z',+ id: 'acc-1',+ requirement: 'Rename keeps the title',+ subjectKey: 'standalone-rename',+ },+ format: 1,+ generatedAt: '2026-01-01T00:00:00.000Z',+ reviews: [],+ rounds: [+ {+ dir: '20260101-000000-first',+ evidence: [],+ proposal: 'Rename now keeps the title after a reload.',+ report: null,+ results: [],+ run: {+ context: null,+ createdAt: '2026-01-01T00:00:00.000Z',+ goal: null,+ id: 'run-1',+ metadata: null,+ plan: null,+ roundIndex: 1,+ scenario: 'coding',+ title: 'Rename',+ },+ },+ ],+};++const openPage = async () => {+ document.body.innerHTML = `<script id="acceptance-local-data" type="application/json">${JSON.stringify(source)}</script>`;+ vi.resetModules();+ return import('./verifyStore');+};++describe('local verify store discussion', () => {+ afterEach(() => {+ document.body.innerHTML = '';+ });++ it('serves the page discussion as already confirmed', async () => {+ const { useVerifyStore, verifySelectors } = await openPage();+ const state = useVerifyStore.getState();++ const comments = verifySelectors.acceptanceComments('acc-1')(state);+ expect(comments?.canComment).toBe(false);+ expect(comments?.items).toHaveLength(1);+ expect(verifySelectors.isAcceptanceCommentsConfirmed('acc-1')(state)).toBe(true);+ expect(verifySelectors.acceptanceComments('other')(state)).toBeUndefined();+ expect(state.useFetchAcceptanceComments('acc-1').error).toBeUndefined();+ });++ it('covers every verify store API the comment list reads', () => {+ const root = path.resolve(import.meta.dirname, '../../../../..');+ const hook = readFileSync(+ path.join(root, 'src/features/Acceptance/Viewer/Comments/useAcceptanceCommentList.ts'),+ 'utf8',+ );+ const stub = readFileSync(path.join(import.meta.dirname, 'verifyStore.ts'), 'utf8');++ const usage = collectStubUsage(hook, '@/store/verify');+ expect(usage).not.toBeNull();+ expect(stubUsageGaps(parseStubSurface(stub), usage!)).toEqual([]);+ });+});diff --git a/apps/workbench/src/localReport/stubs/verifyStore.ts b/apps/workbench/src/localReport/stubs/verifyStore.tsindex 7c2eb31898b..630212934cf 100644--- a/apps/workbench/src/localReport/stubs/verifyStore.ts+++ b/apps/workbench/src/localReport/stubs/verifyStore.ts@@ -1,3 +1,4 @@+import type { AcceptanceCommentList } from '@lobechat/types';import { useSyncExternalStore } from 'react';import type { AcceptanceBundle } from '@/services/verify';@@ -20,6 +21,16 @@ const readBundleMap = (): Record<string, AcceptanceBundle> => {}};+/** The discussion holds each round's proposal, read from the page data. */+const readCommentMap = (): Record<string, AcceptanceCommentList> => {+ try {+ const report = getLocalReport();+ return { [report.acceptanceId]: report.comments() };+ } catch {+ return {};+ }+};+const sync = {error: undefined,isHydrated: true,@@ -38,6 +49,8 @@ const useFetchAcceptanceBundle = (_options?: { enabled?: boolean; refreshInterval?: number },) => sync;+const useFetchAcceptanceComments = (_acceptanceId?: string | null) => sync;+const refreshAcceptanceBundle = async (_acceptanceId: string) => {state = { ...state, acceptanceBundleMap: readBundleMap() };for (const listener of listeners) listener();@@ -45,21 +58,37 @@ const refreshAcceptanceBundle = async (_acceptanceId: string) => {const emptyState = {acceptanceBundleMap: readBundleMap(),+ acceptanceCommentMap: readCommentMap(),refreshAcceptanceBundle,useFetchAcceptanceBundle,+ useFetchAcceptanceComments,};+type VerifyState = typeof emptyState;+let state = emptyState;/*** `@/store/verify` for the offline report: the bundle map holds the one local* acceptance, recomputed whenever the reviewer records a decision.*/-export const useVerifyStore = <T>(selector: (current: typeof emptyState) => T): T =>+export const useVerifyStore = <T>(selector: (current: VerifyState) => T): T =>useSyncExternalStore(subscribe, () => selector(state));useVerifyStore.getState = () => state;+const acceptanceComments = (acceptanceId?: string | null) => (s: VerifyState) =>+ acceptanceId ? s.acceptanceCommentMap[acceptanceId] : undefined;++// The page data is the whole discussion, so what it holds is already confirmed.+const isAcceptanceCommentsConfirmed = (_acceptanceId?: string | null) => (_s: VerifyState) => true;++/** The selectors the offline viewer reads; each mirrors `@/store/verify`'s. */+export const verifySelectors = {+ acceptanceComments,+ isAcceptanceCommentsConfirmed,+};+try {getLocalReport().subscribe(() => void refreshAcceptanceBundle(getLocalReport().acceptanceId));} catch {