🤯 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(home): day-scoped daily brief with day paging & mount run-trace drawer (#17958)
Arvin Xu435a86394800
diff --git a/.agents/acceptance/probe-mock-patterns.md b/.agents/acceptance/probe-mock-patterns.mdindex 4a54559554b..e123b02f7aa 100644--- a/.agents/acceptance/probe-mock-patterns.md+++ b/.agents/acceptance/probe-mock-patterns.md@@ -976,6 +976,24 @@ compositor paints, so they cluster inside the animation — \~9 frames in the 12those unmodified frames slowly with ffmpeg. Do not slow the product's own transition: the exit is aJS animation, so a CSS `transition-duration` override does nothing anyway.+### Day-scoped fixtures must use the browser's measured timezone, not an assumed one++**Situation:** seeding backdated rows (briefs, activity, digests) whose UI grouping is+by the viewer's _local calendar day_ (`dayjs().startOf('day')` on the client).++**Doesn't work:** computing the day boundaries from an assumed timezone (the user's+usual locale, the server tz, or the shell's). On this harness the agent-browser+Chromium reports `America/Los_Angeles`, so a "today 14:00 CST" timestamp lands on the+browser's _yesterday_ — the day view renders empty and reads exactly like the+feature not fetching, while the server endpoint returns the rows when probed with+the "correct" (assumed-tz) window.++**Works:** before seeding, read the tz the grouping actually uses —+`agent-browser eval 'Intl.DateTimeFormat().resolvedOptions().timeZone'` — and derive+every `[startAt, endAt)` from that. When a day view comes back empty, diff the+client's real request window (fetch wrapper on the batch URL) against the seeded+timestamps before suspecting the query.+## Detailed references- [Probe field notes](./references/probe-field-notes.md) — all historicaldiff --git a/apps/server/src/routers/lambda/__tests__/brief.test.ts b/apps/server/src/routers/lambda/__tests__/brief.test.tsindex a9f3517f15d..996ef386069 100644--- a/apps/server/src/routers/lambda/__tests__/brief.test.ts+++ b/apps/server/src/routers/lambda/__tests__/brief.test.ts@@ -50,4 +50,13 @@ describe('briefRouter — reads stay open to every workspace role', () => {it('does not gate list', async () => {await expect(createCaller().list({ limit: 50, offset: 0 })).rejects.not.toThrow(/^GATE:/);});++ it('does not gate listNewsByDay', async () => {+ await expect(+ createCaller().listNewsByDay({+ endAt: new Date('2026-08-06T00:00:00Z'),+ startAt: new Date('2026-08-05T00:00:00Z'),+ }),+ ).rejects.not.toThrow(/^GATE:/);+ });});diff --git a/apps/server/src/routers/lambda/brief.ts b/apps/server/src/routers/lambda/brief.tsindex ff267a62f08..8b29ab3d780 100644--- a/apps/server/src/routers/lambda/brief.ts+++ b/apps/server/src/routers/lambda/brief.ts@@ -153,6 +153,26 @@ export const briefRouter = router({}}),+ // Day-scoped news digest for the home inbox. The client computes the local+ // [startAt, endAt) day boundaries — the server has no per-user timezone on+ // this path, and absolute instants keep the query timezone-agnostic.+ listNewsByDay: briefProcedure+ .input(z.object({ endAt: z.coerce.date(), startAt: z.coerce.date() }))+ .query(async ({ input, ctx }) => {+ try {+ const service = new BriefService(ctx.serverDB, ctx.userId, ctx.workspaceId ?? undefined);+ const { data, hasEarlier } = await service.listNewsByDay(input);+ return { data, hasEarlier, success: true };+ } catch (error) {+ console.error('[brief:listNewsByDay]', error);+ throw new TRPCError({+ cause: error,+ code: 'INTERNAL_SERVER_ERROR',+ message: 'Failed to list news briefs',+ });+ }+ }),+listUnresolved: briefProcedure.query(async ({ ctx }) => {try {const service = new BriefService(ctx.serverDB, ctx.userId, ctx.workspaceId ?? undefined);diff --git a/apps/server/src/services/brief/index.test.ts b/apps/server/src/services/brief/index.test.tsindex 491664288e4..cab1de59206 100644--- a/apps/server/src/services/brief/index.test.ts+++ b/apps/server/src/services/brief/index.test.ts@@ -37,7 +37,9 @@ describe('BriefService', () => {const mockBriefModel = {findById: vi.fn(),+ hasNewsBefore: vi.fn(),list: vi.fn(),+ listNewsEnriched: vi.fn(),listUnresolved: vi.fn(),listUnresolvedEnriched: vi.fn(),resolve: vi.fn(),@@ -393,6 +395,42 @@ describe('BriefService', () => {});});+ describe('listNewsByDay', () => {+ it('should pass the range to the model and report hasEarlier alongside mapped rows', async () => {+ const service = new BriefService(db, userId);+ const range = {+ endAt: new Date('2026-08-06T00:00:00Z'),+ startAt: new Date('2026-08-05T00:00:00Z'),+ };++ mockBriefModel.listNewsEnriched.mockResolvedValue([+ {+ agentAvatar: '🤖',+ agentBackgroundColor: '#fff',+ agentRowId: 'agent-a',+ agentTitle: 'Agent A',+ brief: { agentId: 'agent-a', id: 'b1', taskId: null, title: 'Report' },+ taskStatus: null,+ },+ ]);+ mockBriefModel.hasNewsBefore.mockResolvedValue(true);++ const result = await service.listNewsByDay(range);++ expect(mockBriefModel.listNewsEnriched).toHaveBeenCalledWith(range);+ // `hasEarlier` must be measured against the day being viewed, not "now" —+ // it drives the pager's "older" arrow while browsing history.+ expect(mockBriefModel.hasNewsBefore).toHaveBeenCalledWith(range.startAt);+ expect(result.hasEarlier).toBe(true);+ expect(result.data).toHaveLength(1);+ expect(result.data[0]).toMatchObject({+ agent: { avatar: '🤖', id: 'agent-a', title: 'Agent A' },+ id: 'b1',+ taskStatus: null,+ });+ });+ });+describe('resolve', () => {it('should complete the task when approving a result brief on a non-scheduled task', async () => {const service = new BriefService(db, userId);diff --git a/apps/server/src/services/brief/index.ts b/apps/server/src/services/brief/index.tsindex 9d6198d8007..1c1766891cf 100644--- a/apps/server/src/services/brief/index.ts+++ b/apps/server/src/services/brief/index.ts@@ -11,6 +11,8 @@ export interface AgentAvatarInfo {avatar: string | null;backgroundColor: string | null;id: string;+ /** Personal name; renderers resolve the label with `agentDisplayName(agent, fallback)`. */+ name?: string | null;title: string | null;}@@ -160,36 +162,54 @@ export class BriefService {*/async listUnresolved(): Promise<BriefWithAgent[]> {const rows = await this.briefModel.listUnresolvedEnriched();- return rows.map(- ({- brief,- agentRowId,- agentAvatar,- agentBackgroundColor,- agentName,- agentTitle,- taskIdentifier,- taskName,- taskStatus,- }) => ({- ...brief,- agent: agentRowId- ? {- avatar: agentAvatar,- backgroundColor: agentBackgroundColor,- id: agentRowId,- name: agentName,- title: agentTitle,- }- : null,- agents: [],- taskIdentifier,- taskName,- taskStatus: (taskStatus as TaskStatus) ?? null,- }),- );+ return rows.map((row) => this.mapEnrichedRow(row));+ }++ /**+ * Day-scoped "news" digest for the home inbox. Unlike {@link listUnresolved}+ * this keeps resolved briefs — a day's digest is a record, not a queue — and+ * reports whether any older news exists so the client's day pager knows when+ * to stop.+ */+ async listNewsByDay(range: {+ endAt: Date;+ startAt: Date;+ }): Promise<{ data: BriefWithAgent[]; hasEarlier: boolean }> {+ const [rows, hasEarlier] = await Promise.all([+ this.briefModel.listNewsEnriched(range),+ this.briefModel.hasNewsBefore(range.startAt),+ ]);++ return { data: rows.map((row) => this.mapEnrichedRow(row)), hasEarlier };}+ private mapEnrichedRow = ({+ brief,+ agentRowId,+ agentAvatar,+ agentBackgroundColor,+ agentName,+ agentTitle,+ taskIdentifier,+ taskName,+ taskStatus,+ }: Awaited<ReturnType<BriefModel['listUnresolvedEnriched']>>[number]): BriefWithAgent => ({+ ...brief,+ agent: agentRowId+ ? {+ avatar: agentAvatar,+ backgroundColor: agentBackgroundColor,+ id: agentRowId,+ name: agentName,+ title: agentTitle,+ }+ : null,+ agents: [],+ taskIdentifier,+ taskName,+ taskStatus: (taskStatus as TaskStatus) ?? null,+ });+/*** Resolve a brief and propagate accept signals to the task lifecycle.*diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex d2f0a8749ba..f45c96811c6 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -98,10 +98,16 @@"inbox.author.scheduled": "Scheduled","inbox.error.title": "Run failed","inbox.needsYou.title": "Needs you",+ "inbox.news.emptyDay": "No briefs this day.",+ "inbox.news.emptyToday": "Nothing new yet today.","inbox.news.markAllRead": "Mark all read",+ "inbox.news.nextDay": "Next day",+ "inbox.news.prevDay": "Previous day","inbox.news.showAll": "Show all {{count}}","inbox.news.subtitle": "Nothing to decide — just a glance","inbox.news.title": "Daily brief",+ "inbox.news.titleDay": "Brief · {{date}}",+ "inbox.news.titleYesterday": "Yesterday's brief","inbox.running.title": "{{count}} task running","inbox.running.title_plural": "{{count}} tasks running","inbox.scope.mine": "Mine",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex 278ec1ee808..97ef4403800 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -98,10 +98,16 @@"inbox.author.scheduled": "定时触发","inbox.error.title": "运行失败","inbox.needsYou.title": "需要你处理",+ "inbox.news.emptyDay": "这一天没有简报",+ "inbox.news.emptyToday": "今天还没有简报","inbox.news.markAllRead": "全部已读",+ "inbox.news.nextDay": "后一天",+ "inbox.news.prevDay": "前一天","inbox.news.showAll": "查看全部 {{count}} 条","inbox.news.subtitle": "不需要你做决定,扫一眼就行","inbox.news.title": "今日简报",+ "inbox.news.titleDay": "{{date}}简报",+ "inbox.news.titleYesterday": "昨日简报","inbox.running.title": "{{count}} 个任务正在执行","inbox.running.title_plural": "{{count}} 个任务正在执行","inbox.scope.mine": "我的",diff --git a/packages/database/src/models/__tests__/brief.test.ts b/packages/database/src/models/__tests__/brief.test.tsindex e492fc43654..19bddac10c7 100644--- a/packages/database/src/models/__tests__/brief.test.ts+++ b/packages/database/src/models/__tests__/brief.test.ts@@ -283,6 +283,97 @@ describe('BriefModel', () => {});});+ describe('listNewsEnriched', () => {+ const day = (iso: string) => new Date(iso);++ it('should return only news-type briefs created within [startAt, endAt), keeping resolved ones', async () => {+ const model = new BriefModel(serverDB, userId);++ const inRangeResolved = await model.create({+ createdAt: day('2026-08-05T10:00:00Z'),+ summary: 'In range, already read',+ title: 'Resolved result',+ type: 'result',+ });+ await model.resolve(inRangeResolved.id, { action: 'read' });+ await model.create({+ createdAt: day('2026-08-05T00:00:00Z'),+ summary: 'In range at the exact day start',+ title: 'Boundary insight',+ type: 'insight',+ });+ // Excluded: not a news type, even though it's in range.+ await model.create({+ createdAt: day('2026-08-05T12:00:00Z'),+ summary: 'Actionable',+ title: 'Decision',+ type: 'decision',+ });+ // Excluded: created the day before — the exact bug this feed fixes,+ // old unresolved reports leaking into "today".+ await model.create({+ createdAt: day('2026-08-04T23:59:59Z'),+ summary: 'Yesterday',+ title: 'Old insight',+ type: 'insight',+ });+ // Excluded: created exactly at endAt (exclusive upper bound).+ await model.create({+ createdAt: day('2026-08-06T00:00:00Z'),+ summary: 'Tomorrow',+ title: 'Next-day insight',+ type: 'insight',+ });+ // Excluded: another user's brief on the same day.+ await new BriefModel(serverDB, userId2).create({+ createdAt: day('2026-08-05T10:00:00Z'),+ summary: 'Not mine',+ title: 'Foreign insight',+ type: 'insight',+ });++ const rows = await model.listNewsEnriched({+ endAt: day('2026-08-06T00:00:00Z'),+ startAt: day('2026-08-05T00:00:00Z'),+ });++ expect(rows.map((r) => r.brief.title)).toEqual(['Resolved result', 'Boundary insight']);+ expect(rows[0].brief.resolvedAt).not.toBeNull();+ });+ });++ describe('hasNewsBefore', () => {+ it('should only count own news-type briefs created strictly before the date', async () => {+ const model = new BriefModel(serverDB, userId);+ const cutoff = new Date('2026-08-05T00:00:00Z');++ expect(await model.hasNewsBefore(cutoff)).toBe(false);++ // Non-news and foreign briefs must not light the pager's "older" arrow.+ await model.create({+ createdAt: new Date('2026-08-01T00:00:00Z'),+ summary: 'Old decision',+ title: 'Decision',+ type: 'decision',+ });+ await new BriefModel(serverDB, userId2).create({+ createdAt: new Date('2026-08-01T00:00:00Z'),+ summary: 'Foreign',+ title: 'Foreign insight',+ type: 'insight',+ });+ expect(await model.hasNewsBefore(cutoff)).toBe(false);++ await model.create({+ createdAt: new Date('2026-08-04T23:59:59Z'),+ summary: 'Older news',+ title: 'Old insight',+ type: 'insight',+ });+ expect(await model.hasNewsBefore(cutoff)).toBe(true);+ });+ });+describe('listUnresolvedByAgentAndTrigger', () => {/*** @examplediff --git a/packages/database/src/models/brief.ts b/packages/database/src/models/brief.tsindex 5ad5cbed29c..694937e1c31 100644--- a/packages/database/src/models/brief.ts+++ b/packages/database/src/models/brief.ts@@ -1,4 +1,5 @@-import { and, desc, eq, inArray, isNull, notInArray, type SQL, sql } from 'drizzle-orm';+import { NEWS_BRIEF_TYPES } from '@lobechat/types';+import { and, desc, eq, gte, inArray, isNull, lt, notInArray, type SQL, sql } from 'drizzle-orm';import { agents } from '../schemas/agent';import type { BriefItem, NewBrief } from '../schemas/task';@@ -100,18 +101,7 @@ export class BriefModel {async listUnresolvedEnriched(options?: { limit?: number }): Promise<UnresolvedBriefRow[]> {const { limit = 20 } = options ?? {};const rows = await this.db- .select({- agentAvatar: agents.avatar,- agentBackgroundColor: agents.backgroundColor,- agentRowId: agents.id,- agentName: agents.name,- agentSlug: agents.slug,- agentTitle: agents.title,- brief: briefs,- taskIdentifier: tasks.identifier,- taskName: tasks.name,- taskStatus: tasks.status,- })+ .select(this.enrichedSelection()).from(briefs).leftJoin(agents, eq(briefs.agentId, agents.id)).leftJoin(tasks, eq(briefs.taskId, tasks.id))@@ -126,7 +116,80 @@ export class BriefModel {).limit(limit);- return rows.map(({ agentSlug, ...row }) => ({+ return this.normalizeEnrichedRows(rows);+ }++ /**+ * Day-scoped news digest (`insight` + `result`): every brief created in+ * `[startAt, endAt)`, resolved or not. A day's digest is a record, not a+ * queue — dropping resolved rows would make every already-read day come+ * back empty. Plain chronological order: within one day the priority+ * buckets of the unresolved feed carry no meaning.+ *+ * The 50 cap is a deliberate scope cut, newest-first: a single user+ * producing 50+ news briefs in one local day is far outside current+ * product reality, and the day pager carries no same-day cursor. Revisit+ * with real pagination if daily volumes ever approach it.+ */+ async listNewsEnriched(options: {+ endAt: Date;+ limit?: number;+ startAt: Date;+ }): Promise<UnresolvedBriefRow[]> {+ const { endAt, limit = 50, startAt } = options;+ const rows = await this.db+ .select(this.enrichedSelection())+ .from(briefs)+ .leftJoin(agents, eq(briefs.agentId, agents.id))+ .leftJoin(tasks, eq(briefs.taskId, tasks.id))+ .where(+ and(+ this.ownership(),+ inArray(briefs.type, NEWS_BRIEF_TYPES),+ gte(briefs.createdAt, startAt),+ lt(briefs.createdAt, endAt),+ ),+ )+ .orderBy(desc(briefs.createdAt))+ .limit(limit);++ return this.normalizeEnrichedRows(rows);+ }++ /**+ * Whether any news brief exists before `date` — lets the day pager disable+ * its "older" arrow at the true start of history instead of paging into+ * empty days forever.+ */+ async hasNewsBefore(date: Date): Promise<boolean> {+ const rows = await this.db+ .select({ id: briefs.id })+ .from(briefs)+ .where(+ and(this.ownership(), inArray(briefs.type, NEWS_BRIEF_TYPES), lt(briefs.createdAt, date)),+ )+ .limit(1);++ return rows.length > 0;+ }++ private enrichedSelection = () => ({+ agentAvatar: agents.avatar,+ agentBackgroundColor: agents.backgroundColor,+ agentRowId: agents.id,+ agentName: agents.name,+ agentSlug: agents.slug,+ agentTitle: agents.title,+ brief: briefs,+ taskIdentifier: tasks.identifier,+ taskName: tasks.name,+ taskStatus: tasks.status,+ });++ private normalizeEnrichedRows = (+ rows: (UnresolvedBriefRow & { agentSlug: string | null })[],+ ): UnresolvedBriefRow[] =>+ rows.map(({ agentSlug, ...row }) => ({...row,agentAvatar: normalizeInboxAgentAvatar(row.agentAvatar, {slug: agentSlug,@@ -135,7 +198,6 @@ export class BriefModel {slug: agentSlug,}),}));- }/*** Lists unresolved briefs for one agent and trigger before applying the read cap.diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex b5a2a5fba95..af9c8ba9eee 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -102,10 +102,16 @@ export default {'inbox.author.scheduled': 'Scheduled','inbox.error.title': 'Run failed','inbox.needsYou.title': 'Needs you',+ 'inbox.news.emptyDay': 'No briefs this day.',+ 'inbox.news.emptyToday': 'Nothing new yet today.','inbox.news.markAllRead': 'Mark all read',+ 'inbox.news.nextDay': 'Next day',+ 'inbox.news.prevDay': 'Previous day','inbox.news.showAll': 'Show all {{count}}','inbox.news.subtitle': 'Nothing to decide — just a glance','inbox.news.title': 'Daily brief',+ 'inbox.news.titleDay': 'Brief · {{date}}',+ 'inbox.news.titleYesterday': "Yesterday's brief",'inbox.running.title': '{{count}} task running','inbox.running.title_plural': '{{count}} tasks running','inbox.scope.mine': 'Mine',diff --git a/packages/types/src/brief/index.ts b/packages/types/src/brief/index.tsindex 85737920974..a44292d2730 100644--- a/packages/types/src/brief/index.ts+++ b/packages/types/src/brief/index.ts@@ -36,6 +36,13 @@ export const DEFAULT_BRIEF_ACTIONS: Record<string, BriefAction[]> = {/** Brief type — must match DEFAULT_BRIEF_ACTIONS keys and DB schema comment */export type BriefType = 'decision' | 'error' | 'insight' | 'result';+/**+ * Brief types with nothing to decide — the home "news" digest. Shared between+ * the server day-feed query and the client feed split so the two can never+ * disagree on what counts as news.+ */+export const NEWS_BRIEF_TYPES: BriefType[] = ['insight', 'result'];+/*** A single artifact (currently only documents) referenced from a brief.* Programmatically collected during topic completion, not produced by the LLM.diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskBriefCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskBriefCard.tsxindex 0a9fa305bcb..9566a2925f9 100644--- a/src/features/AgentTasks/AgentTaskDetail/TaskBriefCard.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TaskBriefCard.tsx@@ -117,6 +117,7 @@ const TaskBriefCard = memo<TaskBriefCardProps>(<BriefCardArtifacts artifacts={brief.artifacts} /><BriefCardActionsactions={brief.actions}+ agentId={brief.agentId ?? brief.agent?.id}briefId={brief.id}briefType={brief.type}resolvedAction={brief.resolvedAction}diff --git a/src/features/DailyBrief/BriefCardActions.tsx b/src/features/DailyBrief/BriefCardActions.tsxindex b6a9bd0076d..f683cdd2704 100644--- a/src/features/DailyBrief/BriefCardActions.tsx+++ b/src/features/DailyBrief/BriefCardActions.tsx@@ -16,6 +16,12 @@ import { styles } from './style';export interface BriefCardActionsProps {/** Brief actions from the brief payload — falls back to DEFAULT_BRIEF_ACTIONS by type. */actions?: BriefAction[] | null;+ /**+ * Agent owning the run topic. Passed through to the drawer so it opens+ * immediately instead of waiting on the task-detail fetch — which may never+ * resolve when the parent task has been deleted.+ */+ agentId?: string | null;briefId: string;briefType: string;/** Hook invoked after a comment is successfully posted. */@@ -28,6 +34,8 @@ export interface BriefCardActionsProps {taskStatus?: TaskStatus | null;/** When set together with taskId, renders a "View run" shortcut to the topic drawer. */topicId?: string | null;+ /** Drawer header title until the run's activity metadata loads. */+ topicTitle?: string | null;}type CommentMode = { type: 'feedback' } | { key: string; type: 'comment' };@@ -42,6 +50,7 @@ const SuccessTag = memo<{ label: string }>(({ label }) => (const BriefCardActions = memo<BriefCardActionsProps>(({actions: actionsProp,+ agentId,briefId,briefType,onAfterAddComment,@@ -50,6 +59,7 @@ const BriefCardActions = memo<BriefCardActionsProps>(taskId,taskStatus,topicId,+ topicTitle,}) => {const { t } = useTranslation('home');const [commentMode, setCommentMode] = useState<CommentMode | null>(null);@@ -69,10 +79,15 @@ const BriefCardActions = memo<BriefCardActionsProps>(// setActiveTaskId hydrates `activeTaskId` so the drawer can resolve the// task's agentId / activity metadata (and clears any prior drawer topic// when switching tasks). openTopicDrawer must come after — setActiveTaskId- // resets activeTopicDrawerTopicId on task changes.+ // resets activeTopicDrawerTopicId AND the drawer's own agent/title, so+ // the explicit agentId has to ride this call, not precede it. Without it+ // the drawer's `open` gate stays false until the task detail fetch lands.setActiveTaskId(taskId);- openTopicDrawer(topicId);- }, [openTopicDrawer, setActiveTaskId, taskId, topicId]);+ openTopicDrawer(topicId, {+ agentId: agentId ?? undefined,+ title: topicTitle ?? undefined,+ });+ }, [agentId, openTopicDrawer, setActiveTaskId, taskId, topicId, topicTitle]);const viewRunButton = showViewRun ? (<ButtonclassName={'brief-view-run-btn'}diff --git a/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx b/src/features/DailyBrief/__tests__/BriefCardActions.test.tsxindex 7ff627b84ad..6c301d959b6 100644--- a/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx+++ b/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx@@ -6,6 +6,7 @@ import { MemoryRouter } from 'react-router';import { beforeEach, describe, expect, it, vi } from 'vitest';import { useBriefStore } from '@/store/brief';+import { useTaskStore } from '@/store/task';import BriefCardActions from '../BriefCardActions';@@ -54,6 +55,8 @@ vi.mock('../CommentInput', () => ({const mockResolveBrief = vi.fn();const mockSubmitFeedback = vi.fn();+const mockSetActiveTaskId = vi.fn();+const mockOpenTopicDrawer = vi.fn();const mockToastError = vi.spyOn(toast, 'error').mockReturnValue(undefined as never);const sampleActions: BriefAction[] = [@@ -67,6 +70,10 @@ beforeEach(() => {resolveBrief: mockResolveBrief,submitFeedback: mockSubmitFeedback,});+ useTaskStore.setState({+ openTopicDrawer: mockOpenTopicDrawer,+ setActiveTaskId: mockSetActiveTaskId,+ });});describe('BriefCardActions', () => {@@ -111,6 +118,33 @@ describe('BriefCardActions', () => {await waitFor(() => expect(onAfterResolve).toHaveBeenCalled());});+ it('should open the run drawer with the brief agent riding the open call', () => {+ renderWithRouter(+ <BriefCardActions+ agentId="agent-1"+ briefId="brief-1"+ briefType="error"+ taskId="task-1"+ topicId="topic-1"+ topicTitle="Nightly cleanup"+ />,+ );++ fireEvent.click(screen.getByText('View run'));++ expect(mockSetActiveTaskId).toHaveBeenCalledWith('task-1');+ // The agent/title must ride openTopicDrawer itself: setActiveTaskId clears+ // the drawer's agent state, so without this the drawer's `open` gate stays+ // false until (unless) the task-detail fetch resolves.+ expect(mockOpenTopicDrawer).toHaveBeenCalledWith('topic-1', {+ agentId: 'agent-1',+ title: 'Nightly cleanup',+ });+ expect(mockSetActiveTaskId.mock.invocationCallOrder[0]).toBeLessThan(+ mockOpenTopicDrawer.mock.invocationCallOrder[0],+ );+ });+it('should hide action buttons when comment button clicked', () => {const { container } = renderWithRouter(<BriefCardActionsdiff --git a/src/features/Home/index.tsx b/src/features/Home/index.tsxindex 5e3ddc16f7b..4d8dcb14693 100644--- a/src/features/Home/index.tsx+++ b/src/features/Home/index.tsx@@ -2,12 +2,14 @@import { Flexbox } from '@lobehub/ui';import { createStaticStyles, cx } from 'antd-style';-import { memo, useCallback, useState } from 'react';+import { lazy, memo, Suspense, useCallback, useState } from 'react';import HomeInbox from '@/features/HomeInbox';import { useChatStore } from '@/store/chat';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';+import { useTaskStore } from '@/store/task';+import { taskDetailSelectors } from '@/store/task/selectors';import { useUserStore } from '@/store/user';import { authSelectors } from '@/store/user/slices/auth/selectors';@@ -19,6 +21,13 @@ import PortraitBubble from './PortraitBubble';import { RAIL_INBOX_PROPS, resolveRailVisibility } from './railVisibility';import type { HomeMode } from './types';+// The "View run" button on brief cards only writes drawer state to the task+// store — some component must mount the drawer shell that reacts to it.+// TaskDetailPage mounts its own; home needs one too, or the click is a silent+// no-op. Lazy so the home bundle doesn't pay for the chat stack until a run is+// actually opened.+const TopicChatDrawer = lazy(() => import('@/features/AgentTasks/AgentTaskDetail/TopicChatDrawer'));+/** Trailing gutter that keeps the rail's cards off the page's scroll lane. */const RAIL_GUTTER = 14;const RAIL_CARD_WIDTH = 380;@@ -238,6 +247,12 @@ const Home = memo(() => {const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);const [mode, setMode] = useState<HomeMode>('chat');const [inputValue, setInputValue] = useState('');++ const drawerTopicId = useTaskStore(taskDetailSelectors.activeTopicDrawerTopicId);+ // Mount the drawer on first open and keep it mounted afterwards, so its+ // close animation can play instead of the panel vanishing with the state.+ const [drawerMounted, setDrawerMounted] = useState(false);+ if (drawerTopicId && !drawerMounted) setDrawerMounted(true);const railVisible = resolveRailVisibility({ hiddenWidgets, isLogin, showHomeRail });const railCollapsed = !railVisible;const portraitVisible = Boolean(isLogin && showHomePortrait);@@ -308,6 +323,14 @@ const Home = memo(() => {<HomeInbox {...RAIL_INBOX_PROPS} variant={'rail'} /></aside>)}++ {/* FloatingPanel portals to the app element, so where this sits in the+ tree doesn't affect its viewport-anchored position. */}+ {drawerMounted && (+ <Suspense fallback={null}>+ <TopicChatDrawer />+ </Suspense>+ )}</Flexbox>);});diff --git a/src/features/HomeInbox/InboxBriefCard.tsx b/src/features/HomeInbox/InboxBriefCard.tsxindex 3f0a4ab1df2..6b200b8f4ad 100644--- a/src/features/HomeInbox/InboxBriefCard.tsx+++ b/src/features/HomeInbox/InboxBriefCard.tsx@@ -127,12 +127,14 @@ const InboxBriefCard = memo<InboxBriefCardProps>(({ bare, brief }) => {<BriefCardActionsactions={brief.actions}+ agentId={brief.agentId ?? brief.agent?.id}briefId={brief.id}briefType={brief.type}resolvedAction={brief.resolvedAction}taskId={brief.taskId}taskStatus={brief.taskStatus}topicId={brief.topicId}+ topicTitle={brief.taskName}/></>);diff --git a/src/features/HomeInbox/MarkAllReadButton.tsx b/src/features/HomeInbox/MarkAllReadButton.tsxindex 8de4172cf44..efee490fdea 100644--- a/src/features/HomeInbox/MarkAllReadButton.tsx+++ b/src/features/HomeInbox/MarkAllReadButton.tsx@@ -8,6 +8,8 @@ import { useBriefStore } from '@/store/brief';interface MarkAllReadButtonProps {news: BriefItem[];+ /** Fired after the resolve lands — lets the day digest revalidate its own SWR cache. */+ onResolved?: () => void;}/**@@ -15,7 +17,7 @@ interface MarkAllReadButtonProps {* `read` action — reports are knowledge, so dismissing them wholesale must* never accept a delivery or complete a task.*/-const MarkAllReadButton = memo<MarkAllReadButtonProps>(({ news }) => {+const MarkAllReadButton = memo<MarkAllReadButtonProps>(({ news, onResolved }) => {const { t } = useTranslation('home');const resolveBriefsAsRead = useBriefStore((s) => s.resolveBriefsAsRead);const [loading, setLoading] = useState(false);@@ -24,6 +26,7 @@ const MarkAllReadButton = memo<MarkAllReadButtonProps>(({ news }) => {setLoading(true);try {await resolveBriefsAsRead(news.map((brief) => brief.id));+ onResolved?.();} catch (error) {// Without this the button just stops spinning and the pile stays put —// the tRPC client only console.errors non-401 failures.@@ -31,7 +34,7 @@ const MarkAllReadButton = memo<MarkAllReadButtonProps>(({ news }) => {} finally {setLoading(false);}- }, [news, resolveBriefsAsRead, t]);+ }, [news, onResolved, resolveBriefsAsRead, t]);return (<Buttondiff --git a/src/features/HomeInbox/NewsList.tsx b/src/features/HomeInbox/NewsList.tsxindex e1b4dcae926..53ade76c641 100644--- a/src/features/HomeInbox/NewsList.tsx+++ b/src/features/HomeInbox/NewsList.tsx@@ -84,12 +84,16 @@ const NewsItem = memo<NewsItemProps>(({ bare, brief }) => {const markBriefRead = useBriefStore((s) => s.markBriefRead);const [expanded, setExpanded] = useState(false);- const [read, setRead] = useState(Boolean(brief.readAt));+ const [localRead, setLocalRead] = useState(false);+ // Derived, not snapshotted: the day digest keeps resolved briefs in the list,+ // and a bulk mark-all-read updates them through an SWR revalidation — a+ // useState seeded from the first render would never pick that up.+ const read = localRead || Boolean(brief.readAt) || Boolean(brief.resolvedAt);const toggle = useCallback(() => {setExpanded((prev) => {if (!prev && !read) {- setRead(true);+ setLocalRead(true);void markBriefRead(brief.id);}return !prev;diff --git a/src/features/HomeInbox/index.tsx b/src/features/HomeInbox/index.tsxindex a41cd5f56f5..f3f1bbcc5ab 100644--- a/src/features/HomeInbox/index.tsx+++ b/src/features/HomeInbox/index.tsx@@ -1,6 +1,8 @@-import { Flexbox } from '@lobehub/ui';+import { ActionIcon, Flexbox } from '@lobehub/ui';import { Segmented } from '@lobehub/ui/base-ui';import { createStaticStyles, cx } from 'antd-style';+import dayjs from 'dayjs';+import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';import { Fragment, memo, type ReactNode, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -24,6 +26,7 @@ import { resolveInboxBlockState } from './inboxBlockState';import InboxBriefCard from './InboxBriefCard';import MarkAllReadButton from './MarkAllReadButton';import NeedsYouRailCard from './NeedsYouRailCard';+import { resolveShownNewsOffset } from './newsDayOffset';import NewsList from './NewsList';import { ownsRailSections } from './railSectionPlacement';import RunningTasksCard from './RunningTasksCard';@@ -47,6 +50,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({interface InboxSection {/** Header action revealed on hover (GroupBlock's action slot). */action?: ReactNode;+ /** Keep the action visible without hover — e.g. mid-interaction day paging. */+ actionAlwaysVisible?: boolean;/** Trailing marker on the heading, e.g. the team-view "only mine" chip. */badge?: ReactNode;count?: number;@@ -110,6 +115,7 @@ const HomeInbox = memo<HomeInboxProps>((props) => {const isMain = variant === 'main';const showRailSections = ownsRailSections({ inlineRail, variant });const { t } = useTranslation('home');+ const { t: tCommon } = useTranslation('common');const isLogin = useUserStore(authSelectors.isLogin);const myId = useUserStore(userProfileSelectors.userId);@@ -122,6 +128,27 @@ const HomeInbox = memo<HomeInboxProps>((props) => {const briefs = useBriefStore(briefListSelectors.briefs(cacheScope));const isBriefsInit = useBriefStore(briefListSelectors.isBriefsInit(cacheScope));+ // The news digest is day-scoped: it fetches only briefs *created* on the+ // viewed local day (today by default), resolved or not, with ‹ › paging into+ // earlier days. This replaces slicing news out of the unresolved feed, which+ // let week-old unread reports masquerade as "today's brief".+ const [newsDayOffset, setNewsDayOffset] = useState(0);+ // Recomputed every render on purpose (no memo): a Home left mounted across+ // local midnight must start querying the new day on its next render instead+ // of serving yesterday under a "Daily brief" label until remount.+ const newsDay = dayjs().subtract(newsDayOffset, 'day').format('YYYY-MM-DD');+ const useFetchNewsByDay = useBriefStore((s) => s.useFetchNewsByDay);+ const newsSWR = useFetchNewsByDay(isLogin === true && showRailSections, cacheScope, newsDay);+ const dayNews = newsSWR.data?.news;+ const hasEarlierNews = newsSWR.data?.hasEarlier ?? false;+ // `keepPreviousData` shows the previous day's payload while a page flip is in+ // flight, so everything the user SEES (title, empty copy, arrow gating) must+ // derive from the payload's own day — not from `newsDayOffset`, which has+ // already moved on. Otherwise a slow flip renders "Yesterday's brief" over+ // today's items. Clicks navigate relative to the shown day for the same+ // reason: WYSIWYG paging self-heals any offset/data divergence.+ const shownNewsOffset = newsSWR.data ? resolveShownNewsOffset(newsSWR.data.day) : 0;+const topics = useHomeInboxTopics(isLogin);const recommendationsVisible = useRecommendationsVisible();const hiddenWidgets = useGlobalStore(systemStatusSelectors.hiddenHomeWidgets);@@ -137,7 +164,7 @@ const HomeInbox = memo<HomeInboxProps>((props) => {const setScope = onScopeChange ?? setInternalScope;const teamView = isTeam && scope === 'team';- const { needsYou, news } = useMemo(() => splitBriefs(briefs), [briefs]);+ const { needsYou } = useMemo(() => splitBriefs(briefs), [briefs]);// Topics are already workspace-wide from the server; "mine" is the viewer's// own runs, "team" is everyone's. Personal mode has only the viewer's, so the@@ -314,20 +341,91 @@ const HomeInbox = memo<HomeInboxProps>((props) => {),});- if (showRailSections && news.length > 0)+ // A first-load failure of the day feed must not make the whole section+ // vanish — an absent "Daily brief" is indistinguishable from having no+ // briefs, so surface the error with a retry like the topic feed does.+ if (showRailSections && newsSWR.error && !dayNews)+ sections.push({+ key: 'news-error',+ label: t('inbox.news.title'),+ node: (+ <AsyncError+ error={newsSWR.error}+ variant={'inline'}+ onRetry={() => void newsSWR.mutate()}+ />+ ),+ });++ // Shown once the day feed has loaded, whenever there is anything to show *or*+ // anywhere to go: an empty today must still expose the pager when earlier+ // days hold briefs, and a browsed-to empty day must keep the way back.+ // Everything below renders from `shownNewsOffset` / the payload's own day —+ // see the comment at `shownNewsOffset` for why `newsDayOffset` must not be+ // used for display.+ const news = dayNews ?? [];+ const unresolvedNews = news.filter((brief) => !brief.resolvedAt);+ const showNewsSection =+ showRailSections && !!dayNews && (news.length > 0 || shownNewsOffset > 0 || hasEarlierNews);+ if (showNewsSection) {+ const newsDate = dayjs(newsSWR.data!.day);+ const newsLabel =+ shownNewsOffset === 0+ ? t('inbox.news.title')+ : shownNewsOffset === 1+ ? t('inbox.news.titleYesterday')+ : t('inbox.news.titleDay', {+ date: newsDate.format(+ tCommon(+ newsDate.isSame(dayjs(), 'year') ? 'time.formatThisYear' : 'time.formatOtherYear',+ ),+ ),+ });+sections.push({- action: <MarkAllReadButton news={news} />,+ action: (+ <Flexbox horizontal align={'center'} gap={4}>+ {unresolvedNews.length > 0 && (+ <MarkAllReadButton news={unresolvedNews} onResolved={() => void newsSWR.mutate()} />+ )}+ <ActionIcon+ disabled={!hasEarlierNews}+ icon={ChevronLeftIcon}+ size={'small'}+ title={t('inbox.news.prevDay')}+ onClick={() => setNewsDayOffset(shownNewsOffset + 1)}+ />+ <ActionIcon+ disabled={shownNewsOffset === 0}+ icon={ChevronRightIcon}+ size={'small'}+ title={t('inbox.news.nextDay')}+ onClick={() => setNewsDayOffset(Math.max(0, shownNewsOffset - 1))}+ />+ </Flexbox>+ ),+ // Mid-paging (or on an empty day) the arrows are the section's only+ // controls — they must not vanish when the pointer leaves the header.+ actionAlwaysVisible: shownNewsOffset > 0 || news.length === 0,// Team view: News is still only mine (briefs are per-user), so say so// rather than let a team-scoped page imply it spans the team.badge: teamView && (<span className={cx(homeType.meta, styles.onlyMe)}>{t('inbox.scope.onlyMe')}</span>),- count: news.length,+ count: news.length || undefined,key: 'news',- label: t('inbox.news.title'),- node: <NewsList bare={isRail} news={news} />,+ label: newsLabel,+ node:+ news.length === 0 ? (+ <span className={homeType.supporting}>+ {t(shownNewsOffset === 0 ? 'inbox.news.emptyToday' : 'inbox.news.emptyDay')}+ </span>+ ) : (+ <NewsList bare={isRail} news={news} />+ ),subtitle: t('inbox.news.subtitle'),});+ }const visibleSections = filterHiddenWidgetSections(sections, hiddenWidgets);@@ -357,50 +455,62 @@ const HomeInbox = memo<HomeInboxProps>((props) => {return (<Flexbox gap={isRail ? 12 : 32}>- {visibleSections.map(({ action, badge, count, key, label, node, selfShelled, subtitle }) => {- if (selfShelled) return <Fragment key={key}>{node}</Fragment>;+ {visibleSections.map(+ ({+ action,+ actionAlwaysVisible,+ badge,+ count,+ key,+ label,+ node,+ selfShelled,+ subtitle,+ }) => {+ if (selfShelled) return <Fragment key={key}>{node}</Fragment>;++ if (isRail)+ return (+ <RailCard+ action={action}+ count={count}+ key={key}+ title={+ label && (+ <>+ {label}+ {badge}+ </>+ )+ }+ >+ {node}+ </RailCard>+ );++ if (!label) return <Flexbox key={key}>{node}</Flexbox>;- if (isRail)return (- <RailCard+ <GroupBlockaction={action}+ actionAlwaysVisible={actionAlwaysVisible || key === toggleSectionKey}count={count}key={key}title={- label && (- <>- {label}- {badge}- </>- )+ <>+ {label}+ {subtitle && (+ <span className={cx(homeType.meta, styles.subtitle)}>· {subtitle}</span>+ )}+ {badge}+ </>}>{node}- </RailCard>+ </GroupBlock>);-- if (!label) return <Flexbox key={key}>{node}</Flexbox>;-- return (- <GroupBlock- action={action}- actionAlwaysVisible={key === toggleSectionKey}- count={count}- key={key}- title={- <>- {label}- {subtitle && (- <span className={cx(homeType.meta, styles.subtitle)}>· {subtitle}</span>- )}- {badge}- </>- }- >- {node}- </GroupBlock>- );- })}+ },+ )}{!isMain && <Recommendations variant={variant} />}</Flexbox>diff --git a/src/features/HomeInbox/newsDayOffset.test.ts b/src/features/HomeInbox/newsDayOffset.test.tsnew file mode 100644index 00000000000..60c2ef016b6--- /dev/null+++ b/src/features/HomeInbox/newsDayOffset.test.ts@@ -0,0 +1,22 @@+import { describe, expect, it } from 'vitest';++import { resolveShownNewsOffset } from './newsDayOffset';++describe('resolveShownNewsOffset', () => {+ it('maps the payload day to its offset from today', () => {+ const now = '2026-08-05T14:30:00';+ expect(resolveShownNewsOffset('2026-08-05', now)).toBe(0);+ expect(resolveShownNewsOffset('2026-08-04', now)).toBe(1);+ expect(resolveShownNewsOffset('2026-08-01', now)).toBe(4);+ });++ it('crosses month boundaries by calendar days, not by 24h buckets', () => {+ expect(resolveShownNewsOffset('2026-07-31', '2026-08-01T00:10:00')).toBe(1);+ });++ // The keepPreviousData race this helper exists for: a "today" payload still+ // on screen after local midnight must clamp to 0, not become "tomorrow".+ it('clamps a payload from a not-yet-refetched future day to today', () => {+ expect(resolveShownNewsOffset('2026-08-06', '2026-08-05T23:59:00')).toBe(0);+ });+});diff --git a/src/features/HomeInbox/newsDayOffset.ts b/src/features/HomeInbox/newsDayOffset.tsnew file mode 100644index 00000000000..2707a3de904--- /dev/null+++ b/src/features/HomeInbox/newsDayOffset.ts@@ -0,0 +1,15 @@+import dayjs, { type ConfigType } from 'dayjs';++/**+ * Days between `now`'s local date and a `YYYY-MM-DD` day string: 0 = today,+ * 1 = yesterday. The news section renders with `keepPreviousData`, so during a+ * page flip the payload on screen belongs to the *previous* day — every label,+ * empty-state and arrow-disabled decision must derive from the payload's own+ * day (this offset), never from the offset being fetched, or the new day's+ * title flashes over the old day's briefs.+ *+ * Clamped at 0: a payload from "today" fetched just before local midnight+ * would otherwise compute -1 and render a nonsense "tomorrow" state.+ */+export const resolveShownNewsOffset = (day: string, now?: ConfigType): number =>+ Math.max(0, dayjs(now).startOf('day').diff(dayjs(day).startOf('day'), 'day'));diff --git a/src/features/HomeInbox/splitBriefs.ts b/src/features/HomeInbox/splitBriefs.tsindex 6f230f16f26..ccde614052d 100644--- a/src/features/HomeInbox/splitBriefs.ts+++ b/src/features/HomeInbox/splitBriefs.ts@@ -1,3 +1,5 @@+import { NEWS_BRIEF_TYPES } from '@lobechat/types';+import { type BriefItem } from '@/features/DailyBrief/types';/**@@ -23,8 +25,7 @@ export interface SplitBriefs {* into the to-do pile), so results are news unconditionally — accepting a* one-off delivery stays available from the task page.*/-const isNewsBrief = (brief: BriefItem): boolean =>- brief.type === 'insight' || brief.type === 'result';+const isNewsBrief = (brief: BriefItem): boolean => NEWS_BRIEF_TYPES.includes(brief.type);/*** Splits the unresolved brief feed by whether the user has to *do* something.diff --git a/src/libs/swr/keys.ts b/src/libs/swr/keys.tsindex f68cfa8bfd0..e2240a78006 100644--- a/src/libs/swr/keys.ts+++ b/src/libs/swr/keys.ts@@ -316,6 +316,16 @@ export const briefKeys = {* served in another — its ids are unreachable there.*/list: def('brief:list', (isLogin: boolean, scope: string) => ['brief:list', isLogin, scope]),+ /**+ * Day-scoped news digest (`insight` + `result`, resolved included), keyed by+ * the viewer's local day (`YYYY-MM-DD`) on top of the identity scope.+ */+ news: def('brief:news', (isLogin: boolean, scope: string, day: string) => [+ 'brief:news',+ isLogin,+ scope,+ day,+ ]),};// ---- home inbox ---------------------------------------------------------diff --git a/src/services/brief.ts b/src/services/brief.tsindex b2e97096655..e203383ae37 100644--- a/src/services/brief.ts+++ b/src/services/brief.ts@@ -5,6 +5,10 @@ class BriefService {return lambdaClient.brief.delete.mutate({ id });};+ listNewsByDay = async (params: { endAt: Date; startAt: Date }) => {+ return lambdaClient.brief.listNewsByDay.query(params);+ };+listUnresolved = async () => {return lambdaClient.brief.listUnresolved.query();};diff --git a/src/store/brief/slices/list/action.ts b/src/store/brief/slices/list/action.tsindex 7e68aeaab3e..6ad1306dbe1 100644--- a/src/store/brief/slices/list/action.ts+++ b/src/store/brief/slices/list/action.ts@@ -1,8 +1,9 @@+import dayjs from 'dayjs';import isEqual from 'fast-deep-equal';import { useEffect } from 'react';import { type SWRResponse } from 'swr';-import { mutate, useClientDataSWRWithSync } from '@/libs/swr';+import { mutate, useClientDataSWR, useClientDataSWRWithSync } from '@/libs/swr';import { briefKeys } from '@/libs/swr/keys';import { getCacheScope } from '@/libs/swr/useCacheScope';import { briefService } from '@/services/brief';@@ -14,6 +15,19 @@ import { setNamespace } from '@/utils/storeDebug';const n = setNamespace('briefList');+export interface NewsDay {+ /**+ * The local day (`YYYY-MM-DD`) this payload belongs to. Carried in the data so+ * consumers rendering with `keepPreviousData` can label/gate from the day+ * actually shown instead of the day being fetched — otherwise a slow page+ * flip shows the new day's title over the old day's briefs.+ */+ day: string;+ /** Any news brief older than this day exists — the day pager's "older" arrow. */+ hasEarlier: boolean;+ news: BriefItem[];+}+type Setter = StoreSetter<BriefStore>;export const createBriefListSlice = (set: Setter, get: () => BriefStore, _api?: unknown) =>@@ -112,6 +126,29 @@ export class BriefListActionImpl {}};+ /**+ * Day-scoped news digest (`insight` + `result`, resolved included). Lives in+ * SWR only — no zustand bucket: the key already partitions by identity scope+ * and day, the list is read-mostly, and the one mutation that touches it+ * (mark-all-read) revalidates through the returned SWR handle. `day` is the+ * viewer's local `YYYY-MM-DD`; the [start, end) instants are computed here so+ * the server stays timezone-agnostic. `keepPreviousData` keeps the section+ * stable while the user pages between days.+ */+ useFetchNewsByDay = (enabled: boolean, scope: string, day: string): SWRResponse<NewsDay> =>+ useClientDataSWR<NewsDay>(+ enabled ? briefKeys.news(true, scope, day) : null,+ async () => {+ const startAt = dayjs(day).startOf('day');+ const result = await briefService.listNewsByDay({+ endAt: startAt.add(1, 'day').toDate(),+ startAt: startAt.toDate(),+ });+ return { day, hasEarlier: result.hasEarlier, news: result.data as BriefItem[] };+ },+ { keepPreviousData: true },+ );+/*** `scope` is the identity partition (`${userId}:${workspaceId}`) the caller is* rendering. Briefs are per-user AND per-workspace rows, so carrying a list