🤯 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
✨ feat(acceptance): add read-only report embeds (#19885)
AmAzing-d9dca163d1ab
diff --git a/apps/workbench/app/root.tsx b/apps/workbench/app/root.tsxindex 6be78dc7709..306f489020f 100644--- a/apps/workbench/app/root.tsx+++ b/apps/workbench/app/root.tsx@@ -15,20 +15,22 @@ import { href as antdStaticCssHref } from 'virtual:lobehub/antd-static-css';import { href as themeVarsCssHref } from 'virtual:lobehub/theme-vars-css';import ErrorCapture, { type ErrorType } from '@/components/Error';-import NextThemeProvider from '@/layout/GlobalProvider/NextThemeProvider';import { resolveRequestLocale } from '@/locales/requestLocale';import { isChunkLoadError, notifyChunkError } from '@/utils/chunkError';-import WorkbenchShell from '../src/shell';+import { parseAcceptanceEmbedConfig } from '../src/shell/acceptanceEmbed';+import AcceptanceEmbedShell from '../src/shell/AcceptanceEmbedShell';import { loadWorkbenchResources } from '../src/shell/createWorkbenchI18n';import { buildPageMeta, workbenchMetaDescription } from './lib/seo';export const loader = async ({ request }: LoaderFunctionArgs) => {const locale = resolveRequestLocale(request);const resources = await loadWorkbenchResources(locale);+ const embedConfig = parseAcceptanceEmbedConfig(request.url);return {dir: isRtlLang(locale) ? 'rtl' : 'ltr',+ embedConfig,locale,resources,};@@ -50,7 +52,12 @@ export const Layout = ({ children }: PropsWithChildren) => {const data = useRouteLoaderData<typeof loader>('root');return (- <html suppressHydrationWarning dir={data?.dir ?? 'ltr'} lang={data?.locale ?? 'en-US'}>+ <html+ suppressHydrationWarning+ data-theme={data?.embedConfig.theme}+ dir={data?.dir ?? 'ltr'}+ lang={data?.locale ?? 'en-US'}+ ><head><meta charSet="utf-8" /><meta content="width=device-width, initial-scale=1" name="viewport" />@@ -73,11 +80,14 @@ export default function Root() {const data = useRouteLoaderData<typeof loader>('root');return (- <NextThemeProvider>- <WorkbenchShell locale={data?.locale} resources={data?.resources}>- <Outlet />- </WorkbenchShell>- </NextThemeProvider>+ <AcceptanceEmbedShell+ embed={data?.embedConfig.embed ?? false}+ initialLocale={data?.locale}+ initialTheme={data?.embedConfig.theme}+ resources={data?.resources}+ >+ <Outlet />+ </AcceptanceEmbedShell>);}@@ -93,10 +103,8 @@ export const ErrorBoundary = () => {// The boundary replaces Root, so it must rebuild the provider shell itself// (theme + i18n) for the shared error page to render properly.return (- <NextThemeProvider>- <WorkbenchShell locale={data?.locale} resources={data?.resources}>- <ErrorCapture error={error} />- </WorkbenchShell>- </NextThemeProvider>+ <AcceptanceEmbedShell embed={false} initialLocale={data?.locale} resources={data?.resources}>+ <ErrorCapture error={error} />+ </AcceptanceEmbedShell>);};diff --git a/apps/workbench/app/routes/acceptanceDetail.tsx b/apps/workbench/app/routes/acceptanceDetail.tsxindex ecb266dbc1b..c84cf0b3e5c 100644--- a/apps/workbench/app/routes/acceptanceDetail.tsx+++ b/apps/workbench/app/routes/acceptanceDetail.tsx@@ -1,14 +1,20 @@import { BRANDING_NAME } from '@lobechat/business-const';+import { lazy, Suspense } from 'react';import type { LoaderFunctionArgs, MetaFunction } from 'react-router';-import { useLoaderData } from 'react-router';+import { useLoaderData, useRouteLoaderData } from 'react-router';import { SWRConfig, unstable_serialize } from 'swr';import { verifyKeys } from '@/libs/swr/keys';-import AcceptanceDetail from '../../src/features/acceptance/AcceptanceDetail';+import WorkbenchLoading from '../../src/shell/WorkbenchLoading';import { cloudflareContext } from '../lib/cloudflareContext';import { buildPageMeta, truncateDescription, workbenchMetaDescription } from '../lib/seo';import { createServerLambdaClient } from '../lib/serverTrpc';+import type { loader as rootLoader } from '../root';++// The embed never loads the normal host's review and sharing capabilities.+const AcceptanceDetail = lazy(() => import('../../src/features/acceptance/AcceptanceDetail'));+const AcceptanceEmbed = lazy(() => import('../../src/features/acceptance/AcceptanceEmbed'));export const loader = async ({ context, params, request }: LoaderFunctionArgs) => {const acceptanceId = params.acceptanceId!;@@ -40,6 +46,7 @@ export const meta: MetaFunction<typeof loader> = ({ loaderData }) => {export default function AcceptanceDetailRoute() {const { acceptanceId, bundle } = useLoaderData<typeof loader>();+ const root = useRouteLoaderData<typeof rootLoader>('root');return (<SWRConfig@@ -49,7 +56,9 @@ export default function AcceptanceDetailRoute() {: {},}}>- <AcceptanceDetail />+ <Suspense fallback={<WorkbenchLoading />}>+ {root?.embedConfig.embed ? <AcceptanceEmbed /> : <AcceptanceDetail />}+ </Suspense></SWRConfig>);}diff --git a/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx b/apps/workbench/src/features/acceptance/AcceptanceDetail.tsxindex da2a359d84c..a4ddc8c2721 100644--- a/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx+++ b/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx@@ -13,6 +13,7 @@ import {import AcceptanceCheckInventory from '@/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory';import AcceptanceGoal from '@/features/Acceptance/Viewer/Header/AcceptanceGoal';import AcceptanceIdentity from '@/features/Acceptance/Viewer/Header/AcceptanceIdentity';+import AcceptanceShare from '@/features/Acceptance/Viewer/Header/AcceptanceShare';import { useAcceptanceBundle } from '@/features/Acceptance/Viewer/useAcceptanceBundle';import { WorkbenchHeader } from '../../shell/WorkbenchHeader';@@ -78,7 +79,12 @@ const WorkbenchAcceptanceDetail = () => {<div className={styles.body}><AcceptanceBundleGate height={'100%'}><Flexbox className={styles.report} gap={16}>- <AcceptanceIdentity />+ <Flexbox horizontal align={'flex-start'} gap={16} justify={'space-between'}>+ <Flexbox flex={1} style={{ minWidth: 0 }}>+ <AcceptanceIdentity />+ </Flexbox>+ <AcceptanceShare />+ </Flexbox><AcceptanceGoal /><AcceptanceCheckInventory /></Flexbox>diff --git a/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsxnew file mode 100644index 00000000000..43d750a920e--- /dev/null+++ b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx@@ -0,0 +1,105 @@+import { Flexbox } from '@lobehub/ui';+import { createStaticStyles, cssVar } from 'antd-style';+import { useState } from 'react';+import { useParams } from 'react-router';++import { extractUuid } from '@/features/Acceptance/utils';+import {+ AcceptanceBundleGate,+ AcceptanceScope,+ useAcceptanceScope,+} from '@/features/Acceptance/Viewer/AcceptanceScope';+import { messageThreads } from '@/features/Acceptance/Viewer/Comments/discussionTimeline';+import { groupCommentThreads } from '@/features/Acceptance/Viewer/Comments/threads';+import { useAcceptanceCommentList } from '@/features/Acceptance/Viewer/Comments/useAcceptanceCommentList';+import AcceptanceResources from '@/features/Acceptance/Viewer/Evidence/AcceptanceResources';+import AcceptanceGoal from '@/features/Acceptance/Viewer/Header/AcceptanceGoal';+import AcceptanceIdentity from '@/features/Acceptance/Viewer/Header/AcceptanceIdentity';+import AcceptanceTabs, {+ type AcceptanceTabKey,+} from '@/features/Acceptance/Viewer/Header/AcceptanceTabs';+import ReadChecks from '@/features/Acceptance/Viewer/ReadOnly/Checks';+import ReadDiscussion from '@/features/Acceptance/Viewer/ReadOnly/Discussion';+import { useAcceptanceBundle } from '@/features/Acceptance/Viewer/useAcceptanceBundle';++const styles = createStaticStyles(({ css }) => ({+ page: css`+ overflow: auto;+ width: 100%;+ height: 100dvh;+ background: ${cssVar.colorBgContainer};+ `,+ content: css`+ width: 100%;+ max-width: 1040px;+ margin-inline: auto;+ padding: 24px;++ h1 {+ overflow: visible;+ overflow-wrap: anywhere;+ white-space: normal;+ }++ @media (width <= 767px) {+ padding: 16px;+ }+ `,+}));++const EmbedContent = () => {+ const { acceptanceId } = useAcceptanceScope();+ const { data } = useAcceptanceBundle(acceptanceId);+ const { data: discussion } = useAcceptanceCommentList(acceptanceId);+ const [tab, setTab] = useState<AcceptanceTabKey>('checks');+ const resources = new Set(+ data?.checks.flatMap((check) =>+ check.evidence+ .filter((item) => item.fileUrl || item.documentId)+ .map((item) => item.fileId ?? item.documentId ?? item.id),+ ),+ );++ return (+ <Flexbox className={styles.content} gap={24}>+ <AcceptanceIdentity />+ <AcceptanceGoal />+ <AcceptanceTabs+ active={tab}+ checkCount={data?.checks.length ?? 0}+ discussionCount={messageThreads(groupCommentThreads(discussion?.items ?? [])).length}+ resourceCount={resources.size}+ onChange={setTab}+ />+ {/* Keep read capabilities mounted so tab and appearance changes preserve disclosure state. */}+ <div hidden={tab !== 'checks'}>+ <ReadChecks />+ </div>+ <div hidden={tab !== 'discussion'}>+ <ReadDiscussion />+ </div>+ <div hidden={tab !== 'resources'}>+ <AcceptanceResources />+ </div>+ </Flexbox>+ );+};++/** The public embed imports only reading capabilities, even when its viewer is the owner. */+const AcceptanceEmbed = () => {+ const { acceptanceId: param } = useParams<{ acceptanceId: string }>();+ const acceptanceId = extractUuid(param);+ if (!acceptanceId) return null;++ return (+ <AcceptanceScope embedded acceptanceId={acceptanceId} key={acceptanceId}>+ <div data-acceptance-embed className={styles.page}>+ <AcceptanceBundleGate>+ <EmbedContent />+ </AcceptanceBundleGate>+ </div>+ </AcceptanceScope>+ );+};++export default AcceptanceEmbed;diff --git a/apps/workbench/src/shell/AcceptanceEmbedShell.tsx b/apps/workbench/src/shell/AcceptanceEmbedShell.tsxnew file mode 100644index 00000000000..b223707ffea--- /dev/null+++ b/apps/workbench/src/shell/AcceptanceEmbedShell.tsx@@ -0,0 +1,66 @@+'use client';++import { type PropsWithChildren, useEffect, useState } from 'react';++import NextThemeProvider from '@/layout/GlobalProvider/NextThemeProvider';++import {+ type AcceptanceEmbedTheme,+ applyAcceptanceConfiguration,+ getReferrerOrigin,+ parseAcceptanceConfigureMessage,+} from './acceptanceEmbed';+import WorkbenchShell from './WorkbenchShell';++interface AcceptanceEmbedShellProps extends PropsWithChildren {+ embed: boolean;+ initialLocale?: string;+ initialTheme?: AcceptanceEmbedTheme;+ resources?: Record<string, unknown>;+}++const AcceptanceEmbedShell = ({+ children,+ embed,+ initialLocale = 'en-US',+ initialTheme,+ resources,+}: AcceptanceEmbedShellProps) => {+ const [locale, setLocale] = useState(initialLocale);+ const [theme, setTheme] = useState(initialTheme);++ useEffect(() => setLocale(initialLocale), [initialLocale]);+ useEffect(() => setTheme(initialTheme), [initialTheme]);++ useEffect(() => {+ if (!embed || window.parent === window) return;++ const trustedOrigin = getReferrerOrigin(document.referrer);+ if (!trustedOrigin) return;++ const handleMessage = (event: MessageEvent) => {+ const config = parseAcceptanceConfigureMessage(event, window.parent, trustedOrigin);+ if (!config) return;++ applyAcceptanceConfiguration(config, document.documentElement, (nextConfig) => {+ setLocale(nextConfig.locale);+ setTheme(nextConfig.theme);+ });+ };++ window.addEventListener('message', handleMessage);+ window.parent.postMessage({ type: 'lobehub:acceptance:ready' }, trustedOrigin);++ return () => window.removeEventListener('message', handleMessage);+ }, [embed]);++ return (+ <NextThemeProvider forcedTheme={embed ? theme : undefined}>+ <WorkbenchShell locale={locale} resources={resources}>+ {children}+ </WorkbenchShell>+ </NextThemeProvider>+ );+};++export default AcceptanceEmbedShell;diff --git a/apps/workbench/src/shell/WorkbenchLocale.tsx b/apps/workbench/src/shell/WorkbenchLocale.tsxindex 8d23ce4a7e9..c4a96ae02ca 100644--- a/apps/workbench/src/shell/WorkbenchLocale.tsx+++ b/apps/workbench/src/shell/WorkbenchLocale.tsx@@ -3,6 +3,7 @@import { ConfigProvider } from 'antd';import dayjs from 'dayjs';import { memo, type PropsWithChildren, useEffect, useState } from 'react';+import { I18nextProvider } from 'react-i18next';import { isRtlLang } from 'rtl-detect';import type { DayjsLocaleGlobEntry } from '@/utils/dayjsLocale';@@ -32,12 +33,12 @@ const dayjsLocaleLoaders: Record<string, DayjsLocaleGlobEntry> = {'zh-tw': () => import('dayjs/locale/zh-tw'),};-const updateDayjs = async (lang: string) => {+const loadDayjsLocale = async (lang: string) => {const locale = normalizeDayjsLocale(lang);const loader = dayjsLocaleLoaders[locale] ?? dayjsLocaleLoaders.en;const mod = await loadDayjsLocaleModule(loader!);- dayjs.locale(mod.default);+ return mod.default;};interface WorkbenchLocaleProps extends PropsWithChildren {@@ -53,9 +54,21 @@ const WorkbenchLocale = memo<WorkbenchLocaleProps>(({ children, defaultLang, resif (!i18n.instance.isInitialized) void i18n.init({ initAsync: !resources });useEffect(() => {+ if (defaultLang) void i18n.changeLanguage(defaultLang);+ }, [defaultLang, i18n]);++ useEffect(() => {+ let localeRequest = 0;const applyLocale = async (nextLang: string) => {+ const request = ++localeRequest;+ const [nextAntdLocale, nextDayjsLocale] = await Promise.all([+ getAntdLocale(nextLang),+ loadDayjsLocale(nextLang),+ ]);+ if (request !== localeRequest) return;++ dayjs.locale(nextDayjsLocale);setLang(nextLang);- const [nextAntdLocale] = await Promise.all([getAntdLocale(nextLang), updateDayjs(nextLang)]);setAntdLocale(nextAntdLocale);};@@ -63,14 +76,17 @@ const WorkbenchLocale = memo<WorkbenchLocaleProps>(({ children, defaultLang, resi18n.instance.on('languageChanged', applyLocale);return () => {+ localeRequest++;i18n.instance.off('languageChanged', applyLocale);};}, [defaultLang, i18n]);return (- <ConfigProvider direction={isRtlLang(lang) ? 'rtl' : 'ltr'} locale={antdLocale}>- {children}- </ConfigProvider>+ <I18nextProvider i18n={i18n.instance}>+ <ConfigProvider direction={isRtlLang(lang) ? 'rtl' : 'ltr'} locale={antdLocale}>+ {children}+ </ConfigProvider>+ </I18nextProvider>);});diff --git a/apps/workbench/src/shell/acceptanceEmbed.test.ts b/apps/workbench/src/shell/acceptanceEmbed.test.tsnew file mode 100644index 00000000000..8359ef2ac40--- /dev/null+++ b/apps/workbench/src/shell/acceptanceEmbed.test.ts@@ -0,0 +1,120 @@+import { describe, expect, it, vi } from 'vitest';++import {+ applyAcceptanceConfiguration,+ getReferrerOrigin,+ parseAcceptanceConfigureMessage,+ parseAcceptanceEmbedConfig,+} from './acceptanceEmbed';++describe('acceptance embed URL contract', () => {+ it('only enables embed and forced theme on an acceptance detail URL', () => {+ expect(+ parseAcceptanceEmbedConfig(+ 'https://workbench.example/acceptance/report-id?embed=1&theme=dark&hl=de-DE',+ ),+ ).toEqual({ embed: true, theme: 'dark' });+ expect(+ parseAcceptanceEmbedConfig('https://workbench.example/acceptance?embed=1&theme=dark'),+ ).toEqual({ embed: false, theme: undefined });+ expect(+ parseAcceptanceEmbedConfig('https://workbench.example/verify/run-id?embed=1&theme=dark'),+ ).toEqual({ embed: false, theme: undefined });+ });++ it.each(['/acceptance/report-id/check/check-id', '/acceptance/report-id/check/check-id/'])(+ 'keeps the check detail route %s outside embed mode',+ (path) => {+ expect(+ parseAcceptanceEmbedConfig(`https://workbench.example${path}?embed=1&theme=dark`),+ ).toEqual({ embed: false, theme: undefined });+ },+ );++ it('ignores invalid embed and theme values', () => {+ expect(+ parseAcceptanceEmbedConfig(+ 'https://workbench.example/acceptance/report-id?embed=true&theme=dark',+ ),+ ).toEqual({ embed: false, theme: undefined });+ expect(+ parseAcceptanceEmbedConfig(+ 'https://workbench.example/acceptance/report-id?embed=1&theme=system',+ ),+ ).toEqual({ embed: true, theme: undefined });+ });+});++describe('acceptance embed message validation', () => {+ const parentWindow = {} as Window;+ const validMessage = {+ data: { locale: 'de-DE', theme: 'dark', type: 'lobehub:acceptance:configure' },+ origin: 'https://parent.example',+ source: parentWindow,+ } as Pick<MessageEvent, 'data' | 'origin' | 'source'>;++ it('accepts a complete configuration from the exact trusted parent', () => {+ expect(+ parseAcceptanceConfigureMessage(validMessage, parentWindow, 'https://parent.example'),+ ).toEqual({ locale: 'de-DE', theme: 'dark', type: 'lobehub:acceptance:configure' });+ });++ it('rejects untrusted origins, sources, and invalid values', () => {+ expect(parseAcceptanceConfigureMessage(validMessage, parentWindow)).toBeUndefined();+ expect(+ parseAcceptanceConfigureMessage(+ { ...validMessage, origin: 'https://attacker.example' },+ parentWindow,+ 'https://parent.example',+ ),+ ).toBeUndefined();+ expect(+ parseAcceptanceConfigureMessage(+ { ...validMessage, source: {} as Window },+ parentWindow,+ 'https://parent.example',+ ),+ ).toBeUndefined();+ expect(+ parseAcceptanceConfigureMessage(+ { ...validMessage, data: { ...validMessage.data, locale: 'xx-YY' } },+ parentWindow,+ 'https://parent.example',+ ),+ ).toBeUndefined();+ expect(+ parseAcceptanceConfigureMessage(+ { ...validMessage, data: { ...validMessage.data, theme: 'system' } },+ parentWindow,+ 'https://parent.example',+ ),+ ).toBeUndefined();+ });++ it('derives an exact target origin only from a valid referrer', () => {+ expect(getReferrerOrigin('https://parent.example/path?q=1')).toBe('https://parent.example');+ expect(getReferrerOrigin('')).toBeUndefined();+ expect(getReferrerOrigin('not a URL')).toBeUndefined();+ expect(getReferrerOrigin('data:text/html,hello')).toBeUndefined();+ expect(getReferrerOrigin('file:///private/page.html')).toBeUndefined();+ });++ it('updates language, direction, and forced appearance without changing preferences', () => {+ localStorage.setItem('theme', 'light');+ const update = vi.fn();++ applyAcceptanceConfiguration(+ { locale: 'ar', theme: 'dark', type: 'lobehub:acceptance:configure' },+ document.documentElement,+ update,+ );++ expect(document.documentElement).toMatchObject({ dir: 'rtl', lang: 'ar' });+ expect(update).toHaveBeenCalledWith({+ locale: 'ar',+ theme: 'dark',+ type: 'lobehub:acceptance:configure',+ });+ expect(localStorage.getItem('theme')).toBe('light');+ });+});diff --git a/apps/workbench/src/shell/acceptanceEmbed.ts b/apps/workbench/src/shell/acceptanceEmbed.tsnew file mode 100644index 00000000000..13ae9539894--- /dev/null+++ b/apps/workbench/src/shell/acceptanceEmbed.ts@@ -0,0 +1,77 @@+import { isRtlLang } from 'rtl-detect';++import { type Locales, locales } from '../../../../packages/locales/src/resources';++export type AcceptanceEmbedTheme = 'dark' | 'light';++export interface AcceptanceEmbedConfig {+ embed: boolean;+ theme?: AcceptanceEmbedTheme;+}++export interface AcceptanceConfigureMessage {+ locale: Locales;+ theme: AcceptanceEmbedTheme;+ type: 'lobehub:acceptance:configure';+}++const acceptanceDetailPattern = /^\/acceptance\/[^/]+\/?$/;++export const parseAcceptanceEmbedConfig = (url: string | URL): AcceptanceEmbedConfig => {+ const parsed = typeof url === 'string' ? new URL(url) : url;+ const embed =+ acceptanceDetailPattern.test(parsed.pathname) && parsed.searchParams.get('embed') === '1';+ const theme = parsed.searchParams.get('theme');++ return {+ embed,+ theme: embed && (theme === 'dark' || theme === 'light') ? theme : undefined,+ };+};++export const getReferrerOrigin = (referrer: string): string | undefined => {+ if (!referrer) return undefined;++ try {+ const url = new URL(referrer);+ return url.protocol === 'https:' || url.protocol === 'http:' ? url.origin : undefined;+ } catch {+ return undefined;+ }+};++export const parseAcceptanceConfigureMessage = (+ event: Pick<MessageEvent, 'data' | 'origin' | 'source'>,+ parentWindow: Window,+ trustedOrigin?: string,+): AcceptanceConfigureMessage | undefined => {+ if (!trustedOrigin || event.source !== parentWindow || event.origin !== trustedOrigin) return;+ if (!event.data || typeof event.data !== 'object' || Array.isArray(event.data)) return;++ const { locale, theme, type } = event.data as Record<string, unknown>;+ if (+ type !== 'lobehub:acceptance:configure' ||+ (theme !== 'dark' && theme !== 'light') ||+ typeof locale !== 'string'+ )+ return;++ const supportedLocale = locales.find(+ (supported) =>+ supported.toLowerCase() === locale.toLowerCase() ||+ supported.toLowerCase().startsWith(`${locale.toLowerCase()}-`),+ );+ if (!supportedLocale) return;++ return { locale: supportedLocale, theme, type };+};++export const applyAcceptanceConfiguration = (+ config: AcceptanceConfigureMessage,+ element: Pick<HTMLElement, 'dir' | 'lang'>,+ update: (config: Pick<AcceptanceConfigureMessage, 'locale' | 'theme'>) => void,+) => {+ element.lang = config.locale;+ element.dir = isRtlLang(config.locale) ? 'rtl' : 'ltr';+ update(config);+};diff --git a/apps/workbench/src/shell/createWorkbenchI18n.test.ts b/apps/workbench/src/shell/createWorkbenchI18n.test.tsnew file mode 100644index 00000000000..50378ed5c0d--- /dev/null+++ b/apps/workbench/src/shell/createWorkbenchI18n.test.ts@@ -0,0 +1,78 @@+import { describe, expect, it, vi } from 'vitest';++import { createWorkbenchI18n } from './createWorkbenchI18n';++vi.mock('@/utils/i18n/loadI18nNamespaceModule', () => ({+ loadI18nNamespaceModule: async ({ lng }: { lng: string }) => ({+ default: {+ 'acceptance.tabs.checks':+ lng === 'zh-CN' ? '检查清单' : lng === 'ja-JP' ? 'チェックリスト' : 'Checklist',+ },+ }),+}));++const delayFirstNamespaceLoad = (i18n: ReturnType<typeof createWorkbenchI18n>) => {+ let release!: () => void;+ const gate = new Promise<void>((resolve) => {+ release = resolve;+ });+ const loadNamespaces = i18n.instance.loadNamespaces.bind(i18n.instance);+ let loadCount = 0;+ vi.spyOn(i18n.instance, 'loadNamespaces').mockImplementation(async (...args) => {+ if (loadCount++ === 0) await gate;++ return loadNamespaces(...args);+ });++ return release;+};++describe('workbench live locale changes', () => {+ it('loads translated report labels when changing away from bundled SSR resources', async () => {+ const i18n = createWorkbenchI18n('en-US', {+ verify: { 'acceptance.tabs.checks': 'Checklist' },+ });+ const initialized = i18n.init({ initAsync: false });+ expect(i18n.instance.isInitialized).toBe(true);+ await initialized;+ expect(i18n.instance.t('acceptance.tabs.checks')).toBe('Checklist');+ await i18n.changeLanguage('zh-CN');+ expect(i18n.instance.t('acceptance.tabs.checks')).toBe('检查清单');+ await i18n.changeLanguage('en-US');+ expect(i18n.instance.t('acceptance.tabs.checks')).toBe('Checklist');+ });++ it('keeps the latest bundled locale when an earlier locale load finishes later', async () => {+ const i18n = createWorkbenchI18n('en-US', {+ verify: { 'acceptance.tabs.checks': 'Checklist' },+ });+ await i18n.init({ initAsync: false });+ const finishChinese = delayFirstNamespaceLoad(i18n);++ const chinese = i18n.changeLanguage('zh-CN');+ const english = i18n.changeLanguage('en-US');+ await english;+ finishChinese();+ await chinese;++ expect(i18n.instance.language).toBe('en-US');+ expect(i18n.instance.t('acceptance.tabs.checks')).toBe('Checklist');+ });++ it('keeps the latest locale when asynchronous locale loads finish out of order', async () => {+ const i18n = createWorkbenchI18n('en-US', {+ verify: { 'acceptance.tabs.checks': 'Checklist' },+ });+ await i18n.init({ initAsync: false });+ const finishChinese = delayFirstNamespaceLoad(i18n);++ const chinese = i18n.changeLanguage('zh-CN');+ const japanese = i18n.changeLanguage('ja-JP');+ await japanese;+ finishChinese();+ await chinese;++ expect(i18n.instance.language).toBe('ja-JP');+ expect(i18n.instance.t('acceptance.tabs.checks')).toBe('チェックリスト');+ });+});diff --git a/apps/workbench/src/shell/createWorkbenchI18n.ts b/apps/workbench/src/shell/createWorkbenchI18n.tsindex 7221d71dfca..fd9a72e97aa 100644--- a/apps/workbench/src/shell/createWorkbenchI18n.ts+++ b/apps/workbench/src/shell/createWorkbenchI18n.ts@@ -39,8 +39,20 @@ export const createWorkbenchI18n = (lang?: string, bundledResources?: Record<str.createInstance().use(initReactI18next).use(resourcesToBackend(loadWorkbenchNamespace));+ let languageRequest = 0;return {+ changeLanguage: async (nextLocale: string) => {+ const request = ++languageRequest;+ // Register namespaces only for live changes: SSR must use its bundled resources synchronously.+ await instance.loadNamespaces([...workbenchNamespaces]);+ if (request !== languageRequest) return;++ await instance.loadLanguages(nextLocale);+ if (request !== languageRequest) return;++ await instance.changeLanguage(nextLocale);+ },init: (params: { initAsync?: boolean } = {}) =>instance.init({defaultNS: 'verify',diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 261fd1cadd6..73cfdcf6fb5 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -123,6 +123,7 @@"acceptance.comments.reply": "Reply","acceptance.comments.replyPlaceholder": "Reply…","acceptance.comments.resolve": "Mark resolved",+ "acceptance.comments.resolved": "Resolved","acceptance.comments.resolvedSummary": "Resolved · {{name}} · {{count}} message(s)","acceptance.comments.roundCompletedBy": "{{name}} completed round {{round}}","acceptance.comments.roundContext": "Round {{round}}",@@ -283,6 +284,13 @@"acceptance.roundStatus.repairing": "Repairing","acceptance.roundStatus.uncertain": "Uncertain","acceptance.roundStatus.verifying": "In progress",+ "acceptance.share.copyFailed": "Could not copy the link. Copy it from the address bar.",+ "acceptance.share.makePrivate": "Restrict access",+ "acceptance.share.makePublic": "Allow access with the link",+ "acceptance.share.privateHint": "Only the creator and workspace members will be able to read this acceptance and its rounds. Copies already downloaded cannot be recalled.",+ "acceptance.share.publicHint": "Anyone with the link will be able to read this acceptance, all its rounds, evidence and comments. Signed-in visitors can also comment and annotate. Review the content before making it public.",+ "acceptance.share.saved": "Sharing permissions updated",+ "acceptance.share.title": "Share","acceptance.shell.back": "Back","acceptance.shell.menu": "Show Acceptance menu","acceptance.stats.failed": "{{count}} failed",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex 7e5b3b6cdbc..fda36041a5c 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -123,6 +123,7 @@"acceptance.comments.reply": "回复","acceptance.comments.replyPlaceholder": "回复…","acceptance.comments.resolve": "标记为已解决",+ "acceptance.comments.resolved": "已解决","acceptance.comments.resolvedSummary": "已解决 · {{name}} · {{count}} 条","acceptance.comments.roundCompletedBy": "{{name}} 已完成第 {{round}} 轮","acceptance.comments.roundContext": "第 {{round}} 轮",@@ -283,6 +284,13 @@"acceptance.roundStatus.repairing": "修复中","acceptance.roundStatus.uncertain": "不确定","acceptance.roundStatus.verifying": "进行中",+ "acceptance.share.copyFailed": "链接复制失败,请从地址栏复制。",+ "acceptance.share.makePrivate": "限制访问",+ "acceptance.share.makePublic": "允许通过链接访问",+ "acceptance.share.privateHint": "仅创建者和所属工作区成员可以阅读这条验收及其轮次。已下载的副本无法收回。",+ "acceptance.share.publicHint": "任何持有链接的人都可以阅读这条验收、全部轮次、证据和评论。已登录的访客还可以评论和标注。请先检查内容是否适合公开。",+ "acceptance.share.saved": "分享权限已更新",+ "acceptance.share.title": "分享","acceptance.shell.back": "返回","acceptance.shell.menu": "查看验收列表","acceptance.stats.failed": "{{count}} 失败",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex 6807ce61c7c..c1413c8104f 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -1,4 +1,13 @@export default {+ 'acceptance.share.title': 'Share',+ 'acceptance.share.makePublic': 'Allow access with the link',+ 'acceptance.share.makePrivate': 'Restrict access',+ 'acceptance.share.publicHint':+ 'Anyone with the link will be able to read this acceptance, all its rounds, evidence and comments. Signed-in visitors can also comment and annotate. Review the content before making it public.',+ 'acceptance.share.privateHint':+ 'Only the creator and workspace members will be able to read this acceptance and its rounds. Copies already downloaded cannot be recalled.',+ 'acceptance.share.saved': 'Sharing permissions updated',+ 'acceptance.share.copyFailed': 'Could not copy the link. Copy it from the address bar.','flow.graphView': 'Graph','flow.outlineView': 'Steps','flow.plan.requestChanges': 'Request changes',@@ -186,6 +195,7 @@ export default {'acceptance.comments.reply': 'Reply','acceptance.comments.addReaction': 'Add reaction','acceptance.comments.resolve': 'Mark resolved',+ 'acceptance.comments.resolved': 'Resolved','acceptance.comments.reopen': 'Reopen','acceptance.comments.resolvedSummary': 'Resolved · {{name}} · {{count}} message(s)','acceptance.comments.collapseThread': 'Collapse',diff --git a/src/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory.tsx b/src/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory.tsxindex 876398860e1..f06e82f0dcf 100644--- a/src/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory.tsx+++ b/src/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory.tsx@@ -34,6 +34,7 @@ import {userReviewState,} from './checkState';import { EMPTY_ID_SET, setAggregateEntry } from './expandState';+import { collectGroupFeedback } from './readPresentation';const styles = createStaticStyles(({ css }) => ({filters: css`@@ -222,12 +223,7 @@ const AcceptanceCheckInventory = ({: [];const allGroupsCollapsed =groupKeys.length > 0 && groupKeys.every((key) => collapsedGroups.has(key));- const groupFeedback = data.rounds.flatMap((round) =>- (round.run.decisionDetail?.groupFeedback ?? []).map((entry) => ({- ...entry,- roundIndex: round.run.roundIndex ?? 0,- })),- );+ const groupFeedback = collectGroupFeedback(data.rounds);const currentRound = data.rounds.at(-1)?.run.roundIndex ?? 0;return (diff --git a/src/features/Acceptance/Viewer/Checks/CheckList.tsx b/src/features/Acceptance/Viewer/Checks/CheckList.tsxindex c511d11064c..cfb5253dc8d 100644--- a/src/features/Acceptance/Viewer/Checks/CheckList.tsx+++ b/src/features/Acceptance/Viewer/Checks/CheckList.tsx@@ -4,7 +4,6 @@ import type { AcceptanceGroupFeedback } from '@lobechat/types';import { Empty, Flexbox, Icon } from '@lobehub/ui';import { ActionIcon, Button, Text } from '@lobehub/ui/base-ui';import { cssVar } from 'antd-style';-import dayjs from 'dayjs';import {BadgeCheck,ChevronRight,@@ -17,9 +16,6 @@ import {import { Fragment, memo, useState } from 'react';import { useTranslation } from 'react-i18next';-import { useIsHydrated } from '@/hooks/useIsHydrated';--import { AttachmentThumbs } from '../Evidence/attachments';import { hasVisualEvidence } from '../Evidence/evidence';import { openGroupFeedbackModal } from '../Review/modals';import { AcceptanceCheckRow } from './CheckRow';@@ -33,6 +29,7 @@ import {shouldGroupChecks,userReviewState,} from './checkState';+import { GroupFeedbackTrail } from './GroupFeedbackTrail';import { styles } from './styles';import type { AcceptanceCheck, CheckReviewInput, ProposalDismissInput } from './types';@@ -89,7 +86,6 @@ const CheckList = memo<CheckListProps>(reviewPending,}) => {const { t } = useTranslation('verify');- const hydrated = useIsHydrated();const [acceptingGroup, setAcceptingGroup] = useState<string | null>(null);const visible = (check: AcceptanceCheck) =>@@ -365,40 +361,8 @@ const CheckList = memo<CheckListProps>(</Flexbox>{/* Group feedback trail — newest first; entries consumed by alater round stay readable but visually recede. */}- {!collapsed && feedbackEntries.length > 0 && (- <Flexbox gap={10} paddingBlock={10} paddingInline={16}>- {[...feedbackEntries].reverse().map((entry) => {- const stale = entry.roundIndex < currentRound;- return (- <Flexbox- gap={4}- key={`${entry.createdAt}-${entry.roundIndex}`}- style={stale ? { opacity: 0.55 } : undefined}- >- <Flexbox horizontal align={'center'} gap={6}>- <Icon- color={stale ? cssVar.colorTextQuaternary : cssVar.colorError}- icon={MessageSquareText}- size={13}- />- <Text- style={{- color: stale ? cssVar.colorTextTertiary : cssVar.colorError,- fontSize: 12,- }}- >- {t('acceptance.group.feedbackLabel')}- </Text>- <Text fontSize={12} type={'secondary'}>- {hydrated ? dayjs(entry.createdAt).format('MM-DD HH:mm') : null}- </Text>- </Flexbox>- <Text style={{ fontSize: 12 }}>{entry.comment}</Text>- <AttachmentThumbs attachments={entry.attachments} />- </Flexbox>- );- })}- </Flexbox>+ {!collapsed && (+ <GroupFeedbackTrail currentRound={currentRound} entries={feedbackEntries} />)}{!collapsed &&rows.map((check) => (diff --git a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx b/src/features/Acceptance/Viewer/Checks/CheckRow.tsxindex 2dc59bc9364..517138cadaf 100644--- a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx+++ b/src/features/Acceptance/Viewer/Checks/CheckRow.tsx@@ -56,6 +56,7 @@ import {} from './CheckHistory';import { shouldCollapseAfterReview, userReviewState } from './checkState';import { STATE_META } from './checkStatus';+import { splitCheckReviews } from './readPresentation';import { checkRowDisclosure } from './rowDisclosure';import { styles } from './styles';import type { AcceptanceCheck, CheckReviewInput, ProposalDismissInput } from './types';@@ -126,11 +127,8 @@ export const AcceptanceCheckRow = memo<{// The decision is stamped on the check's result row — a never-executed// check has no evidence to judge, so it exposes no review actions.const reviewable = canReview && Boolean(check.result);- const activeReview =- check.userReview && !check.userReview.stale- ? check.reviews.at(-1) // the standing verdict is always the newest entry- : undefined;- const historyReviews = check.reviews.filter((entry) => entry !== activeReview);+ // The standing verdict is always the newest entry; consumed verdicts belong to history.+ const { activeReview, historyReviews } = splitCheckReviews(check);const evidenceById = collectEvidenceById(check);// Regions the proposal wants drawn on the evidence images already in thisdiff --git a/src/features/Acceptance/Viewer/Checks/GroupFeedbackTrail.tsx b/src/features/Acceptance/Viewer/Checks/GroupFeedbackTrail.tsxnew file mode 100644index 00000000000..0d5a08d25ed--- /dev/null+++ b/src/features/Acceptance/Viewer/Checks/GroupFeedbackTrail.tsx@@ -0,0 +1,63 @@+'use client';++import type { AcceptanceGroupFeedback } from '@lobechat/types';+import { Flexbox, Icon } from '@lobehub/ui';+import { Text } from '@lobehub/ui/base-ui';+import { cssVar } from 'antd-style';+import dayjs from 'dayjs';+import { MessageSquareText } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useIsHydrated } from '@/hooks/useIsHydrated';++import { AttachmentThumbs } from '../Evidence/attachments';++/** Read-only group feedback trail shared by the full viewer and lightweight embeds. */+export const GroupFeedbackTrail = memo<{+ currentRound: number;+ entries: AcceptanceGroupFeedback[];+}>(({ currentRound, entries }) => {+ const { t } = useTranslation('verify');+ const hydrated = useIsHydrated();++ if (entries.length === 0) return null;++ return (+ <Flexbox gap={10} paddingBlock={10} paddingInline={16}>+ {[...entries].reverse().map((entry) => {+ const stale = entry.roundIndex < currentRound;+ return (+ <Flexbox+ gap={4}+ key={`${entry.createdAt}-${entry.roundIndex}`}+ style={stale ? { opacity: 0.55 } : undefined}+ >+ <Flexbox horizontal align={'center'} gap={6}>+ <Icon+ color={stale ? cssVar.colorTextQuaternary : cssVar.colorError}+ icon={MessageSquareText}+ size={13}+ />+ <Text+ style={{+ color: stale ? cssVar.colorTextTertiary : cssVar.colorError,+ fontSize: 12,+ }}+ >+ {t('acceptance.group.feedbackLabel')}+ </Text>+ <Text fontSize={12} type={'secondary'}>+ {hydrated ? dayjs(entry.createdAt).format('MM-DD HH:mm') : null}+ </Text>+ </Flexbox>+ <Text style={{ fontSize: 12 }}>{entry.comment}</Text>+ <AttachmentThumbs attachments={entry.attachments} />+ </Flexbox>+ );+ })}+ </Flexbox>+ );+});++GroupFeedbackTrail.displayName = 'AcceptanceGroupFeedbackTrail';diff --git a/src/features/Acceptance/Viewer/Checks/readPresentation.test.ts b/src/features/Acceptance/Viewer/Checks/readPresentation.test.tsnew file mode 100644index 00000000000..8393d011002--- /dev/null+++ b/src/features/Acceptance/Viewer/Checks/readPresentation.test.ts@@ -0,0 +1,70 @@+import { describe, expect, it } from 'vitest';++import {+ collectGroupFeedback,+ historicalEvidenceContext,+ splitCheckReviews,+} from './readPresentation';+import type { AcceptanceCheck } from './types';++describe('read-only check presentation', () => {+ it('retains group feedback attachments and stamps each entry with its source round', () => {+ const attachment = { id: 'file', url: 'https://example.com/file.png' };+ const rounds = [+ {+ run: {+ decisionDetail: {+ groupFeedback: [+ {+ attachments: [attachment],+ category: 'UX',+ comment: 'Keep this concern visible',+ createdAt: '2026-09-01T00:00:00.000Z',+ },+ ],+ },+ roundIndex: 4,+ },+ },+ ];++ expect(collectGroupFeedback(rounds as never)).toEqual([+ expect.objectContaining({ attachments: [attachment], category: 'UX', roundIndex: 4 }),+ ]);+ });++ it('separates the standing verdict from stale review history', () => {+ const oldReview = { id: 'old', roundIndex: 1 };+ const standingReview = { id: 'standing', roundIndex: 2 };+ const check = {+ reviews: [oldReview, standingReview],+ userReview: { action: 'reject', stale: false },+ } as AcceptanceCheck;++ expect(splitCheckReviews(check)).toEqual({+ activeReview: standingReview,+ historyReviews: [oldReview],+ });+ });++ it('keeps all reviews in history when the verdict was consumed by a newer round', () => {+ const reviews = [{ id: 'old', roundIndex: 1 }];+ const check = { reviews, userReview: { action: 'reject', stale: true } } as AcceptanceCheck;++ expect(splitCheckReviews(check)).toEqual({ historyReviews: reviews });+ });++ it('resolves a replaced region to its original evidence and round', () => {+ const oldEvidence = { id: 'old-image', type: 'screenshot' };+ const check = {+ evidence: [{ id: 'current-image', type: 'screenshot' }],+ timeline: [{ evidence: [oldEvidence], roundIndex: 3 }],+ } as AcceptanceCheck;++ expect(historicalEvidenceContext(check, 'old-image')).toEqual({+ evidence: oldEvidence,+ roundIndex: 3,+ });+ expect(historicalEvidenceContext(check, 'current-image')).toBeUndefined();+ });+});diff --git a/src/features/Acceptance/Viewer/Checks/readPresentation.ts b/src/features/Acceptance/Viewer/Checks/readPresentation.tsnew file mode 100644index 00000000000..8789d79ea21--- /dev/null+++ b/src/features/Acceptance/Viewer/Checks/readPresentation.ts@@ -0,0 +1,40 @@+import type { AcceptanceGroupFeedback } from '@lobechat/types';++import type { AcceptanceBundle } from '@/services/verify';++import type { AcceptanceCheck, AcceptanceCheckReviewEntry, AcceptanceEvidence } from './types';++export const collectGroupFeedback = (+ rounds: AcceptanceBundle['rounds'],+): AcceptanceGroupFeedback[] =>+ rounds.flatMap((round) =>+ (round.run.decisionDetail?.groupFeedback ?? []).map((entry) => ({+ ...entry,+ roundIndex: round.run.roundIndex ?? 0,+ })),+ );++export const splitCheckReviews = (+ check: AcceptanceCheck,+): { activeReview?: AcceptanceCheckReviewEntry; historyReviews: AcceptanceCheckReviewEntry[] } => {+ const activeReview =+ check.userReview && !check.userReview.stale ? check.reviews.at(-1) : undefined;++ return {+ activeReview,+ historyReviews: check.reviews.filter((review) => review !== activeReview),+ };+};++export const historicalEvidenceContext = (+ check: AcceptanceCheck,+ evidenceId: string | null | undefined,+): { evidence: AcceptanceEvidence; roundIndex: number } | undefined => {+ if (!evidenceId || check.evidence.some((evidence) => evidence.id === evidenceId))+ return undefined;+ const step = check.timeline.find((entry) =>+ entry.evidence.some((evidence) => evidence.id === evidenceId),+ );+ const evidence = step?.evidence.find((item) => item.id === evidenceId);+ return step && evidence ? { evidence, roundIndex: step.roundIndex } : undefined;+};diff --git a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsxindex 5e554ee4fa2..771758862a8 100644--- a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx+++ b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx@@ -1,7 +1,7 @@'use client';import type { AcceptanceCommentItem } from '@lobechat/types';-import { Flexbox, Icon } from '@lobehub/ui';+import { Flexbox } from '@lobehub/ui';import { Button, Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar, cx } from 'antd-style';import { BadgeCheck, GitCommitHorizontal } from 'lucide-react';@@ -9,7 +9,6 @@ import { nanoid } from 'nanoid';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';-import { useActivityTime } from '@/hooks/useActivityTime';import { useUserStore } from '@/store/user';import { authSelectors, userProfileSelectors } from '@/store/user/selectors';import { buildAuthReturnUrl, currentReturnPath } from '@/utils/authReturnUrl';@@ -23,6 +22,7 @@ import type { DiscussionEntry } from './discussionTimeline';import { buildDiscussionTimeline } from './discussionTimeline';import { useAcceptanceComments } from './hooks';import { styles, TIMELINE_NODE } from './styles';+import TimelineEvent from './TimelineEvent';/** Enough room to start writing without the box dominating the column. */const COMPOSER_MIN_HEIGHT = 80;@@ -71,33 +71,6 @@ const local = createStaticStyles(({ css }) => ({`,}));-/** A round landing or an approval — a dot on the rail and one line of text. */-const TimelineEvent = memo<{ at: Date; icon: typeof BadgeCheck; text: string }>(- ({ at, icon, text }) => {- const time = useActivityTime(at);- return (- <Flexbox- horizontal- align={'center'}- className={cx(styles.timelineEntry, styles.eventEntry)}- gap={12}- >- <span className={styles.eventDot}>- <Icon icon={icon} size={12} />- </span>- <Flexbox horizontal align={'center'} className={styles.event} gap={8} wrap={'wrap'}>- <span>{text}</span>- <span className={styles.meta} title={time.title}>- {time.text}- </span>- </Flexbox>- </Flexbox>- );- },-);--TimelineEvent.displayName = 'AcceptanceTimelineEvent';-/*** A round. With a note it IS the agent's turn: one entry whose header says* "<agent> completed round N" and whose body is what they wrote. The landingdiff --git a/src/features/Acceptance/Viewer/Comments/CommentCard.tsx b/src/features/Acceptance/Viewer/Comments/CommentCard.tsxindex c4c070e181b..f444fbeb19a 100644--- a/src/features/Acceptance/Viewer/Comments/CommentCard.tsx+++ b/src/features/Acceptance/Viewer/Comments/CommentCard.tsx@@ -21,8 +21,8 @@ import { useActivityTime } from '@/hooks/useActivityTime';import { useUserStore } from '@/store/user';import { userProfileSelectors } from '@/store/user/selectors';-import { AttachmentThumbs } from '../Evidence/attachments';import { commentAnchorUrl } from './anchor';+import CommentContent from './CommentContent';import CommentReactions from './CommentReactions';import { styles } from './styles';@@ -211,17 +211,7 @@ const CommentCard = memo<CommentCardProps>()}</Flexbox><div className={variant === 'boxed' ? styles.body : styles.panelBody}>- {comment.deletedAt ? (- <span className={styles.deleted}>{t('acceptance.comments.deleted')}</span>- ) : (- comment.content- )}- {/* Exhibits, under the words rather than inside them. */}- {comment.attachments.length > 0 && (- <div className={styles.attachments}>- <AttachmentThumbs attachments={comment.attachments} size={'comment'} />- </div>- )}+ <CommentContent comment={comment} />{onReact && (<CommentReactionsreactions={comment.reactions}diff --git a/src/features/Acceptance/Viewer/Comments/CommentContent.tsx b/src/features/Acceptance/Viewer/Comments/CommentContent.tsxnew file mode 100644index 00000000000..ca5dd6c992e--- /dev/null+++ b/src/features/Acceptance/Viewer/Comments/CommentContent.tsx@@ -0,0 +1,27 @@+import type { AcceptanceCommentItem } from '@lobechat/types';+import { useTranslation } from 'react-i18next';++import { AttachmentThumbs } from '../Evidence/attachments';+import { styles } from './styles';++/** The persisted words and exhibits, without a composer or mutation controls. */+const CommentContent = ({ comment }: { comment: AcceptanceCommentItem }) => {+ const { t } = useTranslation('verify');++ return (+ <>+ {comment.deletedAt ? (+ <span className={styles.deleted}>{t('acceptance.comments.deleted')}</span>+ ) : (+ comment.content+ )}+ {comment.attachments.length > 0 && (+ <div className={styles.attachments}>+ <AttachmentThumbs attachments={comment.attachments} size={'comment'} />+ </div>+ )}+ </>+ );+};++export default CommentContent;diff --git a/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsxnew file mode 100644index 00000000000..de314f6229c--- /dev/null+++ b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx@@ -0,0 +1,32 @@+import { Flexbox, Icon } from '@lobehub/ui';+import { cx } from 'antd-style';+import type { LucideIcon } from 'lucide-react';++import { useActivityTime } from '@/hooks/useActivityTime';++import { styles } from './styles';++/** A persisted event, shared by the interactive discussion and read-only report. */+const TimelineEvent = ({ at, icon, text }: { at: Date; icon: LucideIcon; text: string }) => {+ const time = useActivityTime(at);+ return (+ <Flexbox+ horizontal+ align={'center'}+ className={cx(styles.timelineEntry, styles.eventEntry)}+ gap={12}+ >+ <span className={styles.eventDot}>+ <Icon icon={icon} size={12} />+ </span>+ <Flexbox horizontal align={'center'} className={styles.event} gap={8} wrap={'wrap'}>+ <span>{text}</span>+ <span className={styles.meta} title={time.title}>+ {time.text}+ </span>+ </Flexbox>+ </Flexbox>+ );+};++export default TimelineEvent;diff --git a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.tsindex 7490891e642..30559fc9f64 100644--- a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts+++ b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts@@ -2,6 +2,7 @@ import type { AcceptanceCommentItem, AcceptanceCommentThread } from '@lobechat/timport { describe, expect, it } from 'vitest';import { buildDiscussionTimeline, messageThreads, regionThreads } from './discussionTimeline';+import { groupCommentThreads } from './threads';let seq = 0;const item = (overrides: Partial<AcceptanceCommentItem> = {}): AcceptanceCommentItem => {@@ -96,6 +97,56 @@ describe('discussion split', () => {});describe('buildDiscussionTimeline', () => {+ it('preserves approvals and interleaves replies from separate threads with round events', () => {+ const first = item({ createdAt: new Date('2026-09-01T10:00:00Z'), id: 'first' });+ const second = item({ createdAt: new Date('2026-09-01T10:10:00Z'), id: 'second' });+ const approval = item({+ createdAt: new Date('2026-09-01T10:15:00Z'),+ id: 'approval',+ kind: 'approval',+ });+ const reply = item({+ createdAt: new Date('2026-09-01T10:20:00Z'),+ id: 'reply',+ parentCommentId: first.id,+ });+ const items = [first, second, approval, reply];+ const timeline = buildDiscussionTimeline({+ approvals: items.filter((item) => item.kind === 'approval'),+ items,+ rounds: [{ createdAt: '2026-09-01T10:05:00Z', id: 'run', roundIndex: 2 }],+ threads: groupCommentThreads(items),+ });++ expect(+ timeline.map((entry) =>+ entry.kind === 'message'+ ? entry.comment.id+ : entry.kind === 'approval'+ ? entry.approval.id+ : `round-${entry.roundIndex}`,+ ),+ ).toEqual(['first', 'round-2', 'second', 'approval', 'reply']);+ });++ it('uses the surviving latest proposal once in its round, not as a discussion message', () => {+ const old = item({ contextRunId: 'run', id: 'old', kind: 'proposal' });+ const latest = item({ contextRunId: 'run', id: 'latest', kind: 'proposal' });+ const deleted = item({ contextRunId: 'run', deletedAt: new Date(), kind: 'proposal' });+ const items = [old, latest, deleted];+ const threads = groupCommentThreads(items);+ const timeline = buildDiscussionTimeline({+ approvals: [],+ items,+ rounds: [{ createdAt: '2026-09-01T10:00:00Z', id: 'run', roundIndex: 2 }],+ threads,+ });++ expect(messageThreads(threads)).toEqual([]);+ expect(timeline).toHaveLength(1);+ expect(timeline[0]).toMatchObject({ kind: 'round', proposal: { id: 'latest' }, roundIndex: 2 });+ });+it('interleaves messages, rounds and approvals oldest first', () => {const early = thread(item({ createdAt: new Date(2026, 8, 9, 10, 0) }));const late = thread(item({ createdAt: new Date(2026, 8, 9, 12, 0) }));diff --git a/src/features/Acceptance/Viewer/Comments/hooks.ts b/src/features/Acceptance/Viewer/Comments/hooks.tsindex 8df564eceae..8edc56777e2 100644--- a/src/features/Acceptance/Viewer/Comments/hooks.ts+++ b/src/features/Acceptance/Viewer/Comments/hooks.ts@@ -1,8 +1,6 @@import type { AcceptanceCommentList, CreateAcceptanceCommentInput } from '@lobechat/types';import { useCallback, useMemo } from 'react';-import { useClientDataSWR } from '@/libs/swr';-import { acceptanceCommentKeys } from '@/libs/swr/keys';import { acceptanceCommentService } from '@/services/acceptanceComment';import {@@ -11,6 +9,7 @@ import {summarizeApprovals,toggleReaction,} from './threads';+import { useAcceptanceCommentList } from './useAcceptanceCommentList';const EMPTY: AcceptanceCommentList = { canApprove: false, canComment: false, items: [] };@@ -20,11 +19,7 @@ const EMPTY: AcceptanceCommentList = { canApprove: false, canComment: false, ite* the bundle itself never changes because of a comment.*/export const useAcceptanceComments = (acceptanceId: string | undefined) => {- const swr = useClientDataSWR<AcceptanceCommentList>(- acceptanceId ? acceptanceCommentKeys.list(acceptanceId) : null,- () => acceptanceCommentService.list(acceptanceId!),- { revalidateOnFocus: true },- );+ const swr = useAcceptanceCommentList(acceptanceId);const data = swr.data ?? EMPTY;const { mutate } = swr;diff --git a/src/features/Acceptance/Viewer/Comments/useAcceptanceCommentList.ts b/src/features/Acceptance/Viewer/Comments/useAcceptanceCommentList.tsnew file mode 100644index 00000000000..04008849734--- /dev/null+++ b/src/features/Acceptance/Viewer/Comments/useAcceptanceCommentList.ts@@ -0,0 +1,13 @@+import type { AcceptanceCommentList } from '@lobechat/types';++import { useClientDataSWR } from '@/libs/swr';+import { acceptanceCommentKeys } from '@/libs/swr/keys';+import { acceptanceCommentService } from '@/services/acceptanceComment';++/** Read access only. Hosts that display discussion need not mount its write actions. */+export const useAcceptanceCommentList = (acceptanceId?: string) =>+ useClientDataSWR<AcceptanceCommentList>(+ acceptanceId ? acceptanceCommentKeys.list(acceptanceId) : null,+ () => acceptanceCommentService.list(acceptanceId!),+ { revalidateOnFocus: true },+ );diff --git a/src/features/Acceptance/Viewer/Header/AcceptanceShare.tsx b/src/features/Acceptance/Viewer/Header/AcceptanceShare.tsxnew file mode 100644index 00000000000..5fa296b43b3--- /dev/null+++ b/src/features/Acceptance/Viewer/Header/AcceptanceShare.tsx@@ -0,0 +1,73 @@+import { Button, confirmModal, DropdownMenu, toast } from '@lobehub/ui/base-ui';+import { Share2 } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import { mutate as globalMutate } from '@/libs/swr';+import { isAcceptanceListKey } from '@/libs/swr/keys';+import { verifyService } from '@/services/verify';++import { useAcceptanceScope } from '../AcceptanceScope';+import { useAcceptanceBundle } from '../useAcceptanceBundle';+import { canReviewAcceptance } from '../visibility';++/** A write capability: read-only hosts never mount sharing controls. */+const AcceptanceShare = () => {+ const { t } = useTranslation('verify');+ const { acceptanceId } = useAcceptanceScope();+ const { data, mutate } = useAcceptanceBundle(acceptanceId);+ if (!canReviewAcceptance(data)) return null;++ const isPublic = data?.acceptance.visibility === 'public';+ const changeVisibility = () =>+ confirmModal({+ cancelText: t('actions.cancel'),+ content: t(isPublic ? 'acceptance.share.privateHint' : 'acceptance.share.publicHint'),+ okText: t(isPublic ? 'acceptance.share.makePrivate' : 'acceptance.share.makePublic'),+ title: t(isPublic ? 'acceptance.share.makePrivate' : 'acceptance.share.makePublic'),+ onOk: async () => {+ try {+ await verifyService.setAcceptanceVisibility(+ acceptanceId,+ isPublic ? 'private' : 'public',+ );+ await mutate();+ void globalMutate(isAcceptanceListKey);+ toast.success(t('acceptance.share.saved'));+ } catch (error) {+ toast.error(t('acceptance.actionError'));+ throw error;+ }+ },+ });++ return (+ <DropdownMenu+ items={[+ {+ key: 'visibility',+ label: t(isPublic ? 'acceptance.share.makePrivate' : 'acceptance.share.makePublic'),+ onClick: changeVisibility,+ },+ {+ key: 'copy',+ label: t('report.actions.copyLink'),+ onClick: async () => {+ try {+ const url = new URL(`/acceptance/${acceptanceId}`, window.location.origin);+ await navigator.clipboard.writeText(url.toString());+ toast.success(t('report.actions.copyLinkSuccess'));+ } catch {+ toast.error(t('acceptance.share.copyFailed'));+ }+ },+ },+ ]}+ >+ <Button icon={Share2} size={'small'}>+ {t('acceptance.share.title')}+ </Button>+ </DropdownMenu>+ );+};++export default AcceptanceShare;diff --git a/src/features/Acceptance/Viewer/ReadOnly/Checks.tsx b/src/features/Acceptance/Viewer/ReadOnly/Checks.tsxnew file mode 100644index 00000000000..356b7669261--- /dev/null+++ b/src/features/Acceptance/Viewer/ReadOnly/Checks.tsx@@ -0,0 +1,244 @@+import { Empty, Flexbox, Icon } from '@lobehub/ui';+import { Select, Text } from '@lobehub/ui/base-ui';+import { createStaticStyles, cssVar } from 'antd-style';+import { type Dispatch, type SetStateAction, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { hasRenderableEvidence, readVisualizationManifest } from '../../Report/visualization';+import { VisualizationRenderer } from '../../Report/VisualizationRenderer';+import { checkDisplayTitle } from '../../utils';+import { useAcceptanceScope } from '../AcceptanceScope';+import { collectEvidenceById, FeedbackCard, IterationTimeline } from '../Checks/CheckHistory';+import { type CheckFilter, checkFilterState, groupChecks } from '../Checks/checkState';+import { checkHeadMeta } from '../Checks/checkStatus';+import { GroupFeedbackTrail } from '../Checks/GroupFeedbackTrail';+import {+ collectGroupFeedback,+ historicalEvidenceContext,+ splitCheckReviews,+} from '../Checks/readPresentation';+import type { AcceptanceCheck } from '../Checks/types';+import ThreadEvidence from '../Comments/ThreadEvidence';+import { groupCommentThreads, threadsForCheck } from '../Comments/threads';+import { useAcceptanceCommentList } from '../Comments/useAcceptanceCommentList';+import { EvidenceList } from '../Evidence/EvidenceList';+import type { EvidenceOverlayMap } from '../Evidence/overlay';+import { useAcceptanceBundle } from '../useAcceptanceBundle';+import { ReadComment } from './Discussion';++const styles = createStaticStyles(({ css }) => ({+ check: css`+ overflow: hidden;+ border: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: ${cssVar.borderRadiusLG};+ `,+ history: css`+ padding-block: 8px;++ & > summary {+ cursor: pointer;+ color: ${cssVar.colorTextSecondary};+ }+ `,+ summary: css`+ cursor: pointer;+ padding: 16px;+ font-size: ${cssVar.fontSize};+ overflow-wrap: anywhere;++ &:focus-visible {+ outline: 2px solid ${cssVar.colorPrimary};+ outline-offset: -2px;+ }+ `,+}));++const ReadCheck = ({+ check,+ historyOpen,+ onHistoryToggle,+ onToggle,+ open,+}: {+ check: AcceptanceCheck;+ historyOpen: boolean;+ onHistoryToggle: (open: boolean) => void;+ onToggle: (open: boolean) => void;+ open: boolean;+}) => {+ const { t } = useTranslation('verify');+ const { acceptanceId } = useAcceptanceScope();+ const { data: discussion } = useAcceptanceCommentList(acceptanceId);+ const meta = checkHeadMeta(check);+ const threads = threadsForCheck(groupCommentThreads(discussion?.items ?? []), check.id);+ const comments = threads.flatMap(({ root, replies }) => [root, ...replies]);+ const overlays: EvidenceOverlayMap = new Map();+ for (const comment of comments) {+ if (!comment.evidenceId || !comment.rect || comment.deletedAt) continue;+ const entries = overlays.get(comment.evidenceId) ?? [];+ entries.push({ comment: comment.content, rect: comment.rect });+ overlays.set(comment.evidenceId, entries);+ }++ const visualization = readVisualizationManifest(check.result?.metadata);+ const evidenceById = collectEvidenceById(check);+ const { activeReview, historyReviews } = splitCheckReviews(check);+ const hasHistory = check.timeline.length > 0 || historyReviews.length > 0;++ return (+ <details+ className={styles.check}+ open={open}+ onToggle={(event) => onToggle(event.currentTarget.open)}+ >+ <summary className={styles.summary}>+ <Icon color={meta.color} icon={meta.icon} size={16} />{' '}+ {checkDisplayTitle(check.title, t('acceptance.checks.holisticTitle'))}+ <Text fontSize={12} style={{ marginInlineStart: 8 }} type={'secondary'}>+ {t(`report.verdict.${check.state === 'not_executed' ? 'notExecuted' : check.state}`)}+ </Text>+ </summary>+ <Flexbox gap={16} padding={16} style={{ paddingBlockStart: 0 }}>+ {check.result?.toulmin?.evidence && (+ <Text style={{ whiteSpace: 'pre-wrap' }}>{check.result.toulmin.evidence}</Text>+ )}+ {visualization && <VisualizationRenderer manifest={visualization} />}+ <EvidenceList evidence={check.evidence} overlays={overlays} />+ {check.state === 'not_executed' ? (+ <Text fontSize={12} type={'secondary'}>+ {t('acceptance.focus.verifierDescription.notExecuted')}+ </Text>+ ) : check.result?.toulmin?.reasoning ? (+ <Flexbox gap={4} paddingBlock={8} paddingInline={10}>+ <Text fontSize={11} type={'secondary'}>+ {t('acceptance.checks.judgeReason')}+ </Text>+ <Text fontSize={12} style={{ whiteSpace: 'pre-wrap' }}>+ {check.result.toulmin.reasoning}+ </Text>+ </Flexbox>+ ) : check.result && !hasRenderableEvidence(check.evidence.length, visualization) ? (+ <Text fontSize={12} type={'secondary'}>+ {t('acceptance.evidence.empty')}+ </Text>+ ) : null}++ {activeReview && <FeedbackCard evidenceById={evidenceById} review={activeReview} />}++ {threads.map(({ root, replies }) => {+ const historical = historicalEvidenceContext(check, root.evidenceId);+ return (+ <Flexbox horizontal align={'flex-start'} gap={12} key={root.id} wrap={'wrap'}>+ {historical && (+ <ThreadEvidence+ stale+ comment={root}+ evidence={historical.evidence}+ roundIndex={historical.roundIndex}+ />+ )}+ <Flexbox flex={1} gap={8} style={{ minWidth: 200 }}>+ <ReadComment comment={root} />+ {replies.map((reply) => (+ <ReadComment comment={reply} key={reply.id} />+ ))}+ </Flexbox>+ </Flexbox>+ );+ })}++ {hasHistory && (+ <details+ className={styles.history}+ open={historyOpen}+ onToggle={(event) => onHistoryToggle(event.currentTarget.open)}+ >+ <summary>{t('acceptance.checks.iterationHistory', { count: check.revisions })}</summary>+ <Flexbox style={{ paddingBlockStart: 12 }}>+ <IterationTimeline+ check={check}+ evidenceById={evidenceById}+ historyReviews={historyReviews}+ />+ </Flexbox>+ </details>+ )}+ </Flexbox>+ </details>+ );+};++/** A readable checklist owns disclosure/filter state, but never mounts review actions. */+const ReadChecks = () => {+ const { t } = useTranslation('verify');+ const { acceptanceId } = useAcceptanceScope();+ const { data } = useAcceptanceBundle(acceptanceId);+ const [filter, setFilter] = useState<CheckFilter>('all');+ const [openChecks, setOpenChecks] = useState<Set<string>>(() => new Set());+ const [openHistories, setOpenHistories] = useState<Set<string>>(() => new Set());+ if (!data) return null;+ const visible = data.checks.filter(+ (check) => filter === 'all' || checkFilterState(check) === filter,+ );+ const groups = groupChecks(visible, t('acceptance.group.uncategorized'));+ const groupFeedback = collectGroupFeedback(data.rounds);+ const currentRound = data.rounds.at(-1)?.run.roundIndex ?? 0;+ const updateDisclosure = (+ setter: Dispatch<SetStateAction<Set<string>>>,+ id: string,+ open: boolean,+ ) =>+ setter((current) => {+ const next = new Set(current);+ if (open) next.add(id);+ else next.delete(id);+ return next;+ });++ return (+ <Flexbox gap={16}>+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'} wrap={'wrap'}>+ <Text strong>{t('acceptance.checks.title')}</Text>+ <Select+ value={filter}+ options={(['all', 'pending', 'needsFix', 'accepted', 'ignored'] as const).map(+ (value) => ({+ label: t(`acceptance.filter.${value}`, {+ count: data.checks.filter(+ (check) => value === 'all' || checkFilterState(check) === value,+ ).length,+ }),+ value,+ }),+ )}+ onChange={(value) => setFilter(value as CheckFilter)}+ />+ </Flexbox>+ {groups.length === 0 && <Empty description={t('report.filterEmpty')} />}+ {groups.map((group) => {+ const category = group.key === 'uncategorized' ? '' : group.label;+ return (+ <Flexbox gap={12} key={group.key}>+ {groups.length > 1 && <Text strong>{group.label}</Text>}+ <GroupFeedbackTrail+ currentRound={currentRound}+ entries={groupFeedback.filter((entry) => entry.category === category)}+ />+ {group.checks.map((check) => (+ <ReadCheck+ check={check}+ historyOpen={openHistories.has(check.id)}+ key={check.id}+ open={openChecks.has(check.id)}+ onHistoryToggle={(open) => updateDisclosure(setOpenHistories, check.id, open)}+ onToggle={(open) => updateDisclosure(setOpenChecks, check.id, open)}+ />+ ))}+ </Flexbox>+ );+ })}+ </Flexbox>+ );+};++export default ReadChecks;diff --git a/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx b/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsxnew file mode 100644index 00000000000..3828eb182fd--- /dev/null+++ b/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx@@ -0,0 +1,138 @@+import type { AcceptanceCommentItem } from '@lobechat/types';+import { Empty, Flexbox } from '@lobehub/ui';+import { Avatar, Button, Text } from '@lobehub/ui/base-ui';+import { BadgeCheck, GitCommitHorizontal } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';+import { useActivityTime } from '@/hooks/useActivityTime';++import { useAcceptanceScope } from '../AcceptanceScope';+import CommentContent from '../Comments/CommentContent';+import { buildDiscussionTimeline } from '../Comments/discussionTimeline';+import { styles } from '../Comments/styles';+import { groupCommentThreads } from '../Comments/threads';+import TimelineEvent from '../Comments/TimelineEvent';+import { useAcceptanceCommentList } from '../Comments/useAcceptanceCommentList';+import { useAcceptanceBundle } from '../useAcceptanceBundle';++export const ReadComment = ({+ comment,+ nameOverride,+ threaded = true,+}: {+ comment: AcceptanceCommentItem;+ nameOverride?: string;+ threaded?: boolean;+}) => {+ const { t } = useTranslation('verify');+ const time = useActivityTime(comment.createdAt);+ const name = comment.author.fullName || comment.author.username || '—';++ return (+ <Flexbox+ className={styles.box}+ style={{ marginInlineStart: threaded && comment.parentCommentId ? 24 : 0 }}+ >+ <Flexbox horizontal align={'center'} className={styles.boxHeader} gap={8} wrap={'wrap'}>+ <Avatar avatar={comment.author.avatar || name.slice(0, 1)} size={20} />+ <Text weight={600}>{nameOverride ?? name}</Text>+ <Text fontSize={12} title={time.title} type={'secondary'}>+ {time.text}+ </Text>+ {comment.resolvedAt && <Text fontSize={12}>{t('acceptance.comments.resolved')}</Text>}+ </Flexbox>+ <div className={styles.body}>+ <CommentContent comment={comment} />+ {comment.reactions.length > 0 && (+ <Flexbox horizontal gap={8} style={{ paddingBlockStart: 8 }} wrap={'wrap'}>+ {comment.reactions.map((reaction) => (+ <span key={reaction.emoji}>+ {reaction.emoji} {reaction.count}+ </span>+ ))}+ </Flexbox>+ )}+ </div>+ </Flexbox>+ );+};++const ReadDiscussion = () => {+ const { t } = useTranslation('verify');+ const { acceptanceId } = useAcceptanceScope();+ const { data: bundle } = useAcceptanceBundle(acceptanceId);+ const { data, error, isLoading, mutate } = useAcceptanceCommentList(acceptanceId);++ if (!data && isLoading) return <NeuralNetworkLoading size={32} />;+ if (!data && error)+ return (+ <Empty description={t('acceptance.comments.loadFailed')}>+ <Button onClick={() => void mutate()}>{t('report.actions.retry')}</Button>+ </Empty>+ );++ const items = data?.items ?? [];+ const timeline = buildDiscussionTimeline({+ approvals: items.filter((item) => item.kind === 'approval'),+ items,+ rounds: (bundle?.rounds ?? []).map(({ run }) => ({+ createdAt: run.createdAt,+ id: run.id,+ roundIndex: run.roundIndex,+ })),+ threads: groupCommentThreads(items),+ });+ if (timeline.length === 0) return <Empty description={t('acceptance.comments.empty')} />;++ return (+ <Flexbox gap={16}>+ {timeline.map((entry) => {+ if (entry.kind === 'round') {+ const proposal = entry.proposal;+ return proposal ? (+ <ReadComment+ comment={proposal}+ key={`round-${entry.roundIndex}`}+ threaded={false}+ nameOverride={t('acceptance.comments.roundCompletedBy', {+ name: proposal.author.fullName || proposal.author.username || '—',+ round: entry.roundIndex,+ })}+ />+ ) : (+ <TimelineEvent+ at={entry.at}+ icon={GitCommitHorizontal}+ key={`round-${entry.roundIndex}`}+ text={t('acceptance.comments.roundLanded', { round: entry.roundIndex })}+ />+ );+ }+ if (entry.kind === 'approval') {+ const who = t(+ entry.approval.contextRoundIndex === null+ ? 'acceptance.comments.approvedBy'+ : 'acceptance.comments.approvedByAtRound',+ {+ name: entry.approval.author.fullName || entry.approval.author.username || '—',+ round: entry.approval.contextRoundIndex ?? 0,+ },+ );+ const said = entry.approval.content.trim();+ return (+ <TimelineEvent+ at={entry.at}+ icon={BadgeCheck}+ key={entry.approval.id}+ text={said ? `${who} · ${said}` : who}+ />+ );+ }+ return <ReadComment comment={entry.comment} key={entry.comment.id} threaded={false} />;+ })}+ </Flexbox>+ );+};++export default ReadDiscussion;diff --git a/src/hooks/useIsDark.test.ts b/src/hooks/useIsDark.test.tsnew file mode 100644index 00000000000..d3f48109c82--- /dev/null+++ b/src/hooks/useIsDark.test.ts@@ -0,0 +1,29 @@+import { renderHook } from '@testing-library/react';+import { createElement, type PropsWithChildren } from 'react';+import { afterEach, describe, expect, it } from 'vitest';++import NextThemeProvider from '@/layout/GlobalProvider/NextThemeProvider';++import { useIsDark } from './useIsDark';++describe('forced embed appearance', () => {+ afterEach(() => localStorage.removeItem('theme'));++ it('switches component tokens with the forced theme without persisting a preference', () => {+ localStorage.setItem('theme', 'light');+ let forcedTheme: 'dark' | 'light' = 'dark';+ const { result, rerender } = renderHook(useIsDark, {+ wrapper: ({ children }: PropsWithChildren) =>+ createElement(NextThemeProvider, { children, forcedTheme }),+ });+ expect(result.current).toBe(true);+ expect(document.documentElement.dataset.theme).toBe('dark');+ expect(localStorage.getItem('theme')).toBe('light');++ forcedTheme = 'light';+ rerender();+ expect(result.current).toBe(false);+ expect(document.documentElement.dataset.theme).toBe('light');+ expect(localStorage.getItem('theme')).toBe('light');+ });+});diff --git a/src/hooks/useIsDark.ts b/src/hooks/useIsDark.tsindex 4be037bacee..9b6ebd3cb49 100644--- a/src/hooks/useIsDark.ts+++ b/src/hooks/useIsDark.ts@@ -5,7 +5,7 @@ import { useTheme as useNextThemesTheme } from 'next-themes';* @returns boolean - true if current theme is dark, false otherwise*/export const useIsDark = (): boolean => {- const { resolvedTheme } = useNextThemesTheme();+ const { forcedTheme, resolvedTheme } = useNextThemesTheme();- return resolvedTheme === 'dark';+ return (forcedTheme ?? resolvedTheme) === 'dark';};diff --git a/src/layout/GlobalProvider/NextThemeProvider.tsx b/src/layout/GlobalProvider/NextThemeProvider.tsxindex 2d488760141..b8fc3f04b91 100644--- a/src/layout/GlobalProvider/NextThemeProvider.tsx+++ b/src/layout/GlobalProvider/NextThemeProvider.tsx@@ -5,16 +5,17 @@ import { type ReactNode } from 'react';interface NextThemeProviderProps {children: ReactNode;+ forcedTheme?: 'dark' | 'light';}-export default function NextThemeProvider({ children }: NextThemeProviderProps) {+export default function NextThemeProvider({ children, forcedTheme }: NextThemeProviderProps) {return (<NextThemesProviderdisableTransitionOnChangeenableSystemattribute="data-theme"defaultTheme="system"- forcedTheme={undefined}+ forcedTheme={forcedTheme}>{children}</NextThemesProvider>diff --git a/src/services/verify.ts b/src/services/verify.tsindex 49e822b98f5..b892650b38d 100644--- a/src/services/verify.ts+++ b/src/services/verify.ts@@ -177,6 +177,9 @@ export class VerifyService {getAcceptanceBundle = (id: string): Promise<AcceptanceBundle> =>lambdaClient.acceptance.getBundle.query({ id });+ setAcceptanceVisibility = (id: string, visibility: 'private' | 'public') =>+ lambdaClient.acceptance.setVisibility.mutate({ id, visibility });+/** The acceptance aggregate for a subject (topic/task/document), or null. */getAcceptanceBySubject = (subjectType: AcceptanceSubjectType, subjectId: string) =>lambdaClient.acceptance.getBySubject.query({ subjectId, subjectType });diff --git a/vitest.config.mts b/vitest.config.mtsindex d2b1dd40406..7ab2f94d08b 100644--- a/vitest.config.mts+++ b/vitest.config.mts@@ -78,7 +78,7 @@ export default defineConfig({include: ['@lobehub/tts'],},plugins: [- tsconfigPaths({ projects: ['.'] }),+ tsconfigPaths({ projects: ['.', './apps/workbench'] }),// Let `.md` imports resolve to their raw text content so Rollup/Vitest// doesn't try to parse Markdown as JavaScript.{