🤯 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(acceptance): preserve anonymous access to public reports (#19932)
AmAzing-c44265269e0e
diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 9196e8eff31..9f579de9634 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -383,6 +383,7 @@"acceptance.workspace.deleteError": "Failed to delete acceptance","acceptance.workspace.deleteSuccess": "Acceptance deleted","acceptance.workspace.emptyDetail.description": "Open the Acceptance menu to pick a record and inspect its checks, rounds and evidence.",+ "acceptance.workspace.emptyDetail.signInDescription": "Sign in to view your acceptances.","acceptance.workspace.emptyDetail.title": "Select an acceptance","acceptance.workspace.filters.active": "In progress","acceptance.workspace.filters.all": "All acceptances",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex d1666aa347b..1f67ab0af83 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -383,6 +383,7 @@"acceptance.workspace.deleteError": "删除验收失败","acceptance.workspace.deleteSuccess": "验收已删除","acceptance.workspace.emptyDetail.description": "打开交付列表,选择一条验收记录,查看它的检查项、轮次与证据。",+ "acceptance.workspace.emptyDetail.signInDescription": "登录后查看你的验收记录。","acceptance.workspace.emptyDetail.title": "选择一条验收","acceptance.workspace.filters.active": "进行中","acceptance.workspace.filters.all": "全部验收",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex 8215f593af0..658af115ffe 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -520,6 +520,7 @@ export default {'acceptance.workspace.deleteSuccess': 'Acceptance deleted','acceptance.workspace.emptyDetail.description':'Open the Acceptance menu to pick a record and inspect its checks, rounds and evidence.',+ 'acceptance.workspace.emptyDetail.signInDescription': 'Sign in to view your acceptances.','acceptance.workspace.emptyDetail.title': 'Select an acceptance','acceptance.workspace.filters.active': 'In progress','acceptance.workspace.filters.all': 'All acceptances',diff --git a/src/features/Acceptance/Workspace/EmptyDetail.tsx b/src/features/Acceptance/Workspace/EmptyDetail.tsxindex 9cbca3995dc..1aff9d19e44 100644--- a/src/features/Acceptance/Workspace/EmptyDetail.tsx+++ b/src/features/Acceptance/Workspace/EmptyDetail.tsx@@ -1,20 +1,39 @@'use client';import { Center, Empty } from '@lobehub/ui';+import { Button } from '@lobehub/ui/base-ui';import { ScrollText } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import { useUserStore } from '@/store/user';+import { authSelectors } from '@/store/user/selectors';+import { buildAuthReturnUrl } from '@/utils/authReturnUrl';+/** Right-pane placeholder shown at `/acceptance` when no aggregate is selected yet. */const AcceptanceEmptyDetail = memo(() => {- const { t } = useTranslation('verify');+ const { t } = useTranslation(['verify', 'auth']);+ const isSignedOut = useUserStore(authSelectors.isLogin) === false;+return (<Center height={'100%'} width={'100%'}><Empty- description={t('acceptance.workspace.emptyDetail.description')}icon={ScrollText}- title={t('acceptance.workspace.emptyDetail.title')}- />+ description={t(+ isSignedOut+ ? 'acceptance.workspace.emptyDetail.signInDescription'+ : 'acceptance.workspace.emptyDetail.description',+ )}+ title={t(+ isSignedOut ? 'acceptance.workspace.title' : 'acceptance.workspace.emptyDetail.title',+ )}+ >+ {isSignedOut && (+ <Button href={buildAuthReturnUrl('signin', '/acceptance')} type={'primary'}>+ {t('auth:login')}+ </Button>+ )}+ </Empty></Center>);});diff --git a/src/features/Acceptance/Workspace/index.test.ts b/src/features/Acceptance/Workspace/index.test.tsindex 612cd79342f..955047b7494 100644--- a/src/features/Acceptance/Workspace/index.test.ts+++ b/src/features/Acceptance/Workspace/index.test.ts@@ -1,6 +1,115 @@-import { describe, expect, it } from 'vitest';+import { act, cleanup, render, screen } from '@testing-library/react';+import type { ReactNode } from 'react';+import { createElement } from 'react';+import { MemoryRouter, Route, Routes } from 'react-router';+import { afterEach, describe, expect, it, vi } from 'vitest';-import { shouldShowAcceptanceOnboarding } from './index';+import { useUserStore } from '@/store/user';++import AcceptanceEmptyDetail from './EmptyDetail';+import AcceptanceWorkspace, { shouldShowAcceptanceOnboarding } from './index';++const { panel, listRead } = vi.hoisted(() => ({+ listRead: vi.fn<(enabled: boolean, options: unknown) => object>(() => ({})),+ panel: { expand: true, isNarrow: false, pinned: true, setExpand: vi.fn() },+}));++vi.mock('../hooks', () => ({ useAcceptanceList: listRead }));+vi.mock('./useReportPanelExpand', () => ({ useReportPanelExpand: () => panel }));+vi.mock('./AcceptanceListPanel', () => ({+ default: () => createElement('div', { 'data-testid': 'private-list' }),+}));+vi.mock('./AcceptanceProjectActions', () => ({ useAcceptanceProjectActionItems: () => vi.fn() }));+vi.mock('@/features/RouteMeta', () => ({ RouteMetaBridge: () => null }));+vi.mock('@/features/PageShell', () => ({+ ShellTopBar: ({ titleExtra }: { titleExtra?: ReactNode }) =>+ createElement('header', null, titleExtra),+}));++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+ useUserStore.setState({ isSignedIn: undefined });+});++describe('AcceptanceWorkspace public access', () => {+ const renderWorkspace = (path = '/acceptance/public-report') =>+ render(+ createElement(+ MemoryRouter,+ { initialEntries: [path] },+ createElement(+ Routes,+ null,+ createElement(+ Route,+ { element: createElement(AcceptanceWorkspace), path: '/acceptance' },+ createElement(Route, { element: createElement(AcceptanceEmptyDetail), index: true }),+ createElement(Route, {+ element: createElement('main', null, 'Public report'),+ path: ':acceptanceId',+ }),+ ),+ ),+ ),+ );++ it.each([+ { isNarrow: false, pinned: true },+ { isNarrow: false, pinned: false },+ { isNarrow: true, pinned: true },+ ])('does not mount private lists for guests in layout %j', (layout) => {+ Object.assign(panel, layout);+ useUserStore.setState({ isSignedIn: false });+ renderWorkspace();++ expect(screen.getByText('Public report')).toBeInTheDocument();+ expect(screen.queryByTestId('private-list')).not.toBeInTheDocument();+ expect(screen.getByRole('banner')).toBeEmptyDOMElement();+ expect(listRead.mock.calls.every(([enabled]) => !enabled)).toBe(true);+ });++ it('waits for sign-in before mounting the list and removes it on sign-out', () => {+ Object.assign(panel, { isNarrow: false, pinned: true });+ useUserStore.setState({ isSignedIn: undefined });+ renderWorkspace();++ expect(screen.queryByTestId('private-list')).not.toBeInTheDocument();+ act(() => useUserStore.setState({ isSignedIn: true }));+ expect(screen.getByTestId('private-list')).toBeInTheDocument();+ act(() => useUserStore.setState({ isSignedIn: false }));+ expect(screen.queryByTestId('private-list')).not.toBeInTheDocument();+ expect(screen.getByText('Public report')).toBeInTheDocument();+ });++ it('offers sign-in instead of a hidden menu on the anonymous collection index', () => {+ useUserStore.setState({ isSignedIn: false });+ renderWorkspace('/acceptance');++ expect(listRead.mock.calls.every(([enabled]) => !enabled)).toBe(true);+ expect(+ screen.getByText('acceptance.workspace.emptyDetail.signInDescription'),+ ).toBeInTheDocument();+ expect(+ screen.queryByText('acceptance.workspace.emptyDetail.description'),+ ).not.toBeInTheDocument();+ expect(screen.getByText('auth:login')).toHaveAttribute(+ 'href',+ '/signin?callbackUrl=%2Facceptance',+ );+ });++ it('keeps collection guidance for members without prompting during unresolved auth', () => {+ useUserStore.setState({ isSignedIn: undefined });+ renderWorkspace('/acceptance');+ expect(screen.queryByText('auth:login')).not.toBeInTheDocument();++ act(() => useUserStore.setState({ isSignedIn: true }));+ expect(screen.getByText('acceptance.workspace.emptyDetail.description')).toBeInTheDocument();+ expect(screen.queryByText('auth:login')).not.toBeInTheDocument();+ expect(listRead.mock.calls.some(([enabled]) => enabled)).toBe(true);+ });+});describe('shouldShowAcceptanceOnboarding', () => {it('uses the full-page onboarding only after the complete list resolves empty', () => {diff --git a/src/features/Acceptance/Workspace/index.tsx b/src/features/Acceptance/Workspace/index.tsxindex 22450a06ae9..6a4484a1850 100644--- a/src/features/Acceptance/Workspace/index.tsx+++ b/src/features/Acceptance/Workspace/index.tsx@@ -10,6 +10,8 @@ import { Outlet, useNavigate, useParams, useSearchParams } from 'react-router';import { ShellTopBar } from '@/features/PageShell';import { RouteMetaBridge } from '@/features/RouteMeta';+import { useUserStore } from '@/store/user';+import { authSelectors } from '@/store/user/selectors';import { useAcceptanceList } from '../hooks';import { acceptanceHomePath } from '../Viewer/routes';@@ -81,6 +83,7 @@ interface AcceptanceWorkspaceProps {const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {const { t } = useTranslation('verify');const navigate = useNavigate();+ const isSignedIn = useUserStore(authSelectors.isLogin);const panel = useReportPanelExpand();const projectActionItems = useAcceptanceProjectActionItems();const { acceptanceId, checkId } = useParams<{ acceptanceId: string; checkId: string }>();@@ -97,8 +100,10 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {* collapsing the rail hands the list back to the drawer.*/const standalone = !projectId;- const showList = !hasFocusedCheck;- const listInDrawer = standalone && (panel.isNarrow || !panel.pinned);+ // Public report readers must not mount the private collection: its 401 would+ // trigger the global sign-in redirect, even though the report is public.+ const showList = !!isSignedIn && !hasFocusedCheck;+ const listInDrawer = standalone && (!isSignedIn || panel.isNarrow || !panel.pinned);const [listOpen, setListOpen] = useState(false);// Picking a row is what the drawer was opened for; once the route has moved// on (or the rail has taken over) the drawer has nothing left to do.@@ -110,13 +115,13 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {data: allAcceptances,error,isLoading,- } = useAcceptanceList(standalone ? !acceptanceId : showList, {+ } = useAcceptanceList(!!isSignedIn && (standalone ? !acceptanceId : showList), {filter: 'all',projectId,});const isFirstUse = shouldShowAcceptanceOnboarding({data: allAcceptances,- enabled: standalone ? !acceptanceId : showList && !projectId,+ enabled: !!isSignedIn && (standalone ? !acceptanceId : showList && !projectId),error,hasDeepLink: Boolean(acceptanceId),isLoading,@@ -126,22 +131,24 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {<ShellTopBartitle={t('acceptance.workspace.title')}titleExtra={- <>- <ActionIcon- icon={Menu}- size={'small'}- title={t('acceptance.shell.menu')}- onClick={() => setListOpen(true)}- />- {!panel.isNarrow && (+ isSignedIn && (+ <><ActionIcon- icon={Pin}+ icon={Menu}size={'small'}- title={t('workspace.pin')}- onClick={() => panel.setExpand(true)}+ title={t('acceptance.shell.menu')}+ onClick={() => setListOpen(true)}/>- )}- </>+ {!panel.isNarrow && (+ <ActionIcon+ icon={Pin}+ size={'small'}+ title={t('workspace.pin')}+ onClick={() => panel.setExpand(true)}+ />+ )}+ </>+ )}onBack={() => navigate(acceptanceHomePath())}/>@@ -194,18 +201,20 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {<Flexbox height={'100dvh'} style={{ overflow: 'hidden' }} width={'100%'}><RouteMetaBridge />{topBar}- <Drawer- noHeader- closable={false}- containerMaxWidth={'100%'}- open={listOpen}- placement={'left'}- styles={{ bodyContent: { height: '100%', minHeight: 0, overflow: 'hidden', padding: 0 } }}- width={'min(360px, 88vw)'}- onClose={() => setListOpen(false)}- >- <AcceptanceListPanel hosted {...panel} projectActionItems={projectActionItems} />- </Drawer>+ {isSignedIn && (+ <Drawer+ noHeader+ closable={false}+ containerMaxWidth={'100%'}+ open={listOpen}+ placement={'left'}+ styles={{ bodyContent: { height: '100%', minHeight: 0, overflow: 'hidden', padding: 0 } }}+ width={'min(360px, 88vw)'}+ onClose={() => setListOpen(false)}+ >+ <AcceptanceListPanel hosted {...panel} projectActionItems={projectActionItems} />+ </Drawer>+ )}<Flexbox horizontal flex={1} style={{ minHeight: 0 }} width={'100%'}><div className={styles.main}><Outlet />