🤯 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-inbox): route urgent briefs to Needs you and show brief priority icons (#20952)
Arvin Xudeb6ab1d3a31
diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 33fe5a172ce..08f5e168524 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -160,6 +160,9 @@"inbox.news.titleDay": "Brief · {{date}}","inbox.news.titleYesterday": "Yesterday's brief","inbox.news.viewChat": "View chat",+ "inbox.priority.info": "FYI",+ "inbox.priority.normal": "Normal",+ "inbox.priority.urgent": "Urgent","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 719d8f856c0..3a4ff0949a9 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -160,6 +160,9 @@"inbox.news.titleDay": "{{date}}简报","inbox.news.titleYesterday": "昨日简报","inbox.news.viewChat": "查看对话",+ "inbox.priority.info": "仅供参考",+ "inbox.priority.normal": "普通",+ "inbox.priority.urgent": "紧急","inbox.running.title": "{{count}} 个任务正在执行","inbox.running.title_plural": "{{count}} 个任务正在执行","inbox.scope.mine": "我的",diff --git a/packages/builtin-tool-brief/src/manifest.ts b/packages/builtin-tool-brief/src/manifest.tsindex fb3a7fc77b4..d88f70d3f1c 100644--- a/packages/builtin-tool-brief/src/manifest.ts+++ b/packages/builtin-tool-brief/src/manifest.ts@@ -32,7 +32,8 @@ export const BriefManifest: BuiltinToolManifest = {type: 'array',},priority: {- description: "Priority of the brief. Default is 'normal'.",+ description:+ "How soon the user should look. 'urgent': needs attention now — it is pinned to the user's \"Needs you\" queue until handled, so reserve it for blockers, risks, or time-sensitive findings. 'normal': worth reading today. 'info' (default): background, fine to skim.",enum: ['urgent', 'normal', 'info'],type: 'string',},diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex 3822411ee9b..428ec55af31 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -165,6 +165,9 @@ export default {'inbox.news.titleDay': 'Brief · {{date}}','inbox.news.titleYesterday': "Yesterday's brief",'inbox.news.viewChat': 'View chat',+ 'inbox.priority.info': 'FYI',+ 'inbox.priority.normal': 'Normal',+ 'inbox.priority.urgent': 'Urgent','inbox.running.title': '{{count}} task running','inbox.running.title_plural': '{{count}} tasks running','inbox.scope.mine': 'Mine',diff --git a/src/features/DailyBrief/BriefPriorityIcon.tsx b/src/features/DailyBrief/BriefPriorityIcon.tsxnew file mode 100644index 00000000000..4907bd92ca3--- /dev/null+++ b/src/features/DailyBrief/BriefPriorityIcon.tsx@@ -0,0 +1,50 @@+import { Tooltip } from '@lobehub/ui';+import { cssVar } from 'antd-style';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import PriorityLowIcon from '@/features/AgentTasks/features/icons/PriorityLowIcon';+import PriorityMediumIcon from '@/features/AgentTasks/features/icons/PriorityMediumIcon';+import PriorityUrgentIcon from '@/features/AgentTasks/features/icons/PriorityUrgentIcon';++import { type BriefPriority, resolveBriefPriority } from './briefPriority';++/** Same glyphs and urgent orange as task priority, so one scale reads everywhere. */+const PRIORITY_ICON = {+ info: PriorityLowIcon,+ normal: PriorityMediumIcon,+ urgent: PriorityUrgentIcon,+} satisfies Record<BriefPriority, unknown>;++interface BriefPriorityIconProps {+ /** A read or handled row recedes as one — urgent included: once handled it no longer needs you. */+ muted?: boolean;+ priority: string | null | undefined;+ size?: number;+}++const BriefPriorityIcon = memo<BriefPriorityIconProps>(({ muted, priority, size = 14 }) => {+ const { t } = useTranslation('home');+ const level = resolveBriefPriority(priority);+ const PriorityIcon = PRIORITY_ICON[level];+ const color = muted+ ? cssVar.colorTextQuaternary+ : level === 'urgent'+ ? cssVar.orange+ : cssVar.colorTextDescription;++ return (+ <Tooltip title={t(`inbox.priority.${level}`)}>+ {/* The svg glyph forwards no ref, so the tooltip anchors on this span. */}+ <span+ aria-label={t(`inbox.priority.${level}`)}+ role={'img'}+ style={{ color, display: 'inline-flex', flex: 'none' }}+ >+ <PriorityIcon size={size} />+ </span>+ </Tooltip>+ );+});++export default BriefPriorityIcon;diff --git a/src/features/DailyBrief/briefPriority.ts b/src/features/DailyBrief/briefPriority.tsnew file mode 100644index 00000000000..16b486abe1d--- /dev/null+++ b/src/features/DailyBrief/briefPriority.ts@@ -0,0 +1,14 @@+export type BriefPriority = 'info' | 'normal' | 'urgent';++const PRIORITY_RANK: Record<BriefPriority, number> = { info: 2, normal: 1, urgent: 0 };++/**+ * The column is free text with an `info` default, and older or tool-written rows+ * may carry anything — read every unknown value as `info`, the same bucket the+ * server's unresolved-feed ordering drops it into.+ */+export const resolveBriefPriority = (priority: string | null | undefined): BriefPriority =>+ priority === 'urgent' || priority === 'normal' ? priority : 'info';++export const briefPriorityRank = (priority: string | null | undefined): number =>+ PRIORITY_RANK[resolveBriefPriority(priority)];diff --git a/src/features/HomeInbox/InboxBriefCard.tsx b/src/features/HomeInbox/InboxBriefCard.tsxindex ddf3076f58a..9d8a736412d 100644--- a/src/features/HomeInbox/InboxBriefCard.tsx+++ b/src/features/HomeInbox/InboxBriefCard.tsx@@ -12,6 +12,7 @@ import { taskDetailPath } from '@/features/AgentTasks/shared/taskDetailPath';import BriefCardActions from '@/features/DailyBrief/BriefCardActions';import BriefCardArtifacts from '@/features/DailyBrief/BriefCardArtifacts';import BriefCardSummary from '@/features/DailyBrief/BriefCardSummary';+import BriefPriorityIcon from '@/features/DailyBrief/BriefPriorityIcon';import SelfReviewBriefDetails from '@/features/DailyBrief/SelfReviewBriefDetails';import { styles as briefStyles } from '@/features/DailyBrief/style';import { type BriefItem } from '@/features/DailyBrief/types';@@ -139,6 +140,9 @@ const InboxBriefCard = memo<InboxBriefCardProps>(({ bare, brief }) => {)}<Flexbox flex={1} gap={6} style={{ minWidth: 0 }}><Flexbox horizontal align={'center'} gap={8}>+ {/* Priority sits in one place on every card — right before the title — so+ a scan down the queue reads levels in a single column. */}+ <BriefPriorityIcon priority={brief.priority} /><Text ellipsis className={homeType.itemTitle} style={{ flex: 1, minWidth: 0 }}>{selfReview?.title ?? brief.title}</Text>diff --git a/src/features/HomeInbox/NewsList.tsx b/src/features/HomeInbox/NewsList.tsxindex 0c76419087f..703a7308b14 100644--- a/src/features/HomeInbox/NewsList.tsx+++ b/src/features/HomeInbox/NewsList.tsx@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';import BriefCardArtifacts from '@/features/DailyBrief/BriefCardArtifacts';import BriefIcon from '@/features/DailyBrief/BriefIcon';+import BriefPriorityIcon from '@/features/DailyBrief/BriefPriorityIcon';import SelfReviewBriefDetails from '@/features/DailyBrief/SelfReviewBriefDetails';import { type BriefItem } from '@/features/DailyBrief/types';import { useSelfReviewBriefView } from '@/features/DailyBrief/useSelfReviewBriefView';@@ -20,7 +21,11 @@ import NewsChatActions from './NewsChatActions';const Markdown = lazy(() => import('@lobehub/ui/es/Markdown/index'));const AVATAR_SIZE = 20;+/** The leading priority glyph (BriefPriorityIcon's default size). */+const PRIORITY_SIZE = 14;const ROW_GAP = 10;+/** How far the headline sits from the row's inline start: priority glyph, avatar, two gaps. */+const HEADLINE_INSET = PRIORITY_SIZE + AVATAR_SIZE + ROW_GAP * 2;const ROW_PADDING_INLINE = 14;const BARE_PADDING_INLINE = 8;@@ -28,10 +33,10 @@ const BARE_PADDING_INLINE = 8;const RAIL_COLLAPSED_COUNT = 6;const styles = createStaticStyles(({ css, cssVar }) => ({- // Line the content up under the headline, past the leading avatar.+ // Line the content up under the headline, past the leading priority glyph and avatar.bareBody: css`padding-block-end: 8px;- padding-inline: ${BARE_PADDING_INLINE + AVATAR_SIZE + ROW_GAP}px ${BARE_PADDING_INLINE}px;+ padding-inline: ${BARE_PADDING_INLINE + HEADLINE_INSET}px ${BARE_PADDING_INLINE}px;`,// Inside a rail card the shell is already drawn; only the hover bleed remains.bareList: css`@@ -44,7 +49,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({`,body: css`padding-block-end: 12px;- padding-inline: ${ROW_PADDING_INLINE + AVATAR_SIZE + ROW_GAP}px ${ROW_PADDING_INLINE}px;+ padding-inline: ${ROW_PADDING_INLINE + HEADLINE_INSET}px ${ROW_PADDING_INLINE}px;`,list: css`overflow: hidden;@@ -121,6 +126,8 @@ const NewsItem = memo<NewsItemProps>(({ bare, brief, showTime }) => {<Flexbox className={bare ? undefined : styles.section}><Button className={cx(styles.row, bare && styles.bareRow)} type={'text'} onClick={toggle}><Flexbox horizontal align={'center'} gap={ROW_GAP} style={{ width: '100%' }}>+ {/* Priority leads the row, so a scan down the list reads levels first. */}+ <BriefPriorityIcon muted={read} priority={brief.priority} />{brief.agent?.avatar ? (<Avataravatar={brief.agent.avatar}diff --git a/src/features/HomeInbox/index.tsx b/src/features/HomeInbox/index.tsxindex f1f108326c4..a6623b853be 100644--- a/src/features/HomeInbox/index.tsx+++ b/src/features/HomeInbox/index.tsx@@ -41,7 +41,7 @@ import NewsList from './NewsList';import { ownsRailSections } from './railSectionPlacement';import RunningTasksCard from './RunningTasksCard';import { filterTopicsForInboxScope, resolveInboxScopeToggleSection } from './scopeTogglePlacement';-import { splitBriefs } from './splitBriefs';+import { arrangeDayNews, splitBriefs } from './splitBriefs';import UnreadTopicList from './UnreadTopicList';import { useHomeInboxTopics } from './useHomeInboxTopics';@@ -213,6 +213,9 @@ const HomeInbox = memo<HomeInboxProps>((props) => {const teamView = isTeam && scope === 'team';const { needsYou } = useMemo(() => splitBriefs(briefs), [briefs]);+ // Urgent briefs already waiting in "Needs you" leave the digest; the rest+ // lead with urgent, then normal, then info.+ const news = useMemo(() => arrangeDayNews(dayNews ?? [], briefs), [dayNews, 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@@ -434,7 +437,6 @@ const HomeInbox = memo<HomeInboxProps>((props) => {// 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);diff --git a/src/features/HomeInbox/splitBriefs.test.ts b/src/features/HomeInbox/splitBriefs.test.tsindex b35b8b1ae41..31d0d3fb648 100644--- a/src/features/HomeInbox/splitBriefs.test.ts+++ b/src/features/HomeInbox/splitBriefs.test.ts@@ -2,10 +2,10 @@ import { describe, expect, it } from 'vitest';import { type BriefItem } from '@/features/DailyBrief/types';-import { splitBriefs } from './splitBriefs';+import { arrangeDayNews, splitBriefs } from './splitBriefs';-const brief = (id: string, type: BriefItem['type']): BriefItem =>- ({ id, summary: '', title: id, type }) as BriefItem;+const brief = (id: string, type: BriefItem['type'], priority: string | null = 'info'): BriefItem =>+ ({ id, priority, readAt: null, resolvedAt: null, summary: '', title: id, type }) as BriefItem;describe('splitBriefs', () => {it('routes insight and result briefs to news and only decisions to needsYou', () => {@@ -70,4 +70,72 @@ describe('splitBriefs', () => {it('returns empty groups for an empty feed', () => {expect(splitBriefs([])).toEqual({ needsYou: [], news: [] });});++ it('promotes unresolved urgent insight and result briefs into needsYou', () => {+ const { needsYou, news } = splitBriefs([+ brief('urgent-insight', 'insight', 'urgent'),+ brief('urgent-result', 'result', 'urgent'),+ brief('normal-result', 'result', 'normal'),+ brief('info-insight', 'insight', 'info'),+ ]);++ expect(needsYou.map((b) => b.id)).toEqual(['urgent-insight', 'urgent-result']);+ expect(news.map((b) => b.id)).toEqual(['normal-result', 'info-insight']);+ });++ it('drops an urgent news brief from needsYou once resolved', () => {+ const resolved = {+ ...brief('urgent-insight', 'insight', 'urgent'),+ resolvedAt: '2026-10-15T00:00:00.000Z',+ } as BriefItem;++ expect(splitBriefs([resolved])).toEqual({ needsYou: [], news: [resolved] });+ });+});++describe('arrangeDayNews', () => {+ it('orders the day by priority, keeping server order within a level', () => {+ const day = [+ brief('info-new', 'insight', 'info'),+ brief('normal-new', 'result', 'normal'),+ brief('unknown', 'result', null),+ brief('urgent-done', 'insight', 'urgent'),+ brief('normal-old', 'result', 'normal'),+ ];+ day[3] = { ...day[3], resolvedAt: '2026-10-15T00:00:00.000Z' } as BriefItem;++ expect(arrangeDayNews(day, []).map((b) => b.id)).toEqual([+ 'urgent-done',+ 'normal-new',+ 'normal-old',+ 'info-new',+ 'unknown',+ ]);+ });++ it('hides urgent briefs already waiting in needsYou so they never show twice', () => {+ const urgent = brief('urgent', 'insight', 'urgent');+ const normal = brief('normal', 'result', 'normal');++ expect(arrangeDayNews([urgent, normal], [urgent]).map((b) => b.id)).toEqual(['normal']);+ });++ it('keeps an unresolved urgent brief the unresolved feed does not carry', () => {+ const urgent = brief('urgent', 'insight', 'urgent');++ expect(arrangeDayNews([urgent], []).map((b) => b.id)).toEqual(['urgent']);+ });++ it('returns a just-handled urgent brief to the day as resolved', () => {+ const stale = brief('urgent', 'insight', 'urgent');+ const fresh = {+ ...stale,+ resolvedAction: 'acknowledge',+ resolvedAt: '2026-10-15T00:00:00.000Z',+ } as BriefItem;++ const [shown] = arrangeDayNews([stale], [fresh]);+ expect(shown.resolvedAt).toBe(fresh.resolvedAt);+ expect(shown.resolvedAction).toBe('acknowledge');+ });});diff --git a/src/features/HomeInbox/splitBriefs.ts b/src/features/HomeInbox/splitBriefs.tsindex b4991b1bcd5..6bf86ac6834 100644--- a/src/features/HomeInbox/splitBriefs.ts+++ b/src/features/HomeInbox/splitBriefs.ts@@ -1,5 +1,6 @@import { HOME_FEED_EXCLUDED_BRIEF_TYPES, NEWS_BRIEF_TYPES } from '@lobechat/types';+import { briefPriorityRank } from '@/features/DailyBrief/briefPriority';import { type BriefItem } from '@/features/DailyBrief/types';export interface SplitBriefs {@@ -13,14 +14,26 @@ export interface SplitBriefs {* A `result` brief is a completion report: the work already happened, reading* it is enough. Splitting on the parent task's *runtime* status proved fragile* (a paused/completed recurring task flipped its whole report history back- * into the to-do pile), so results are news unconditionally — accepting a- * one-off delivery stays available from the task page.+ * into the to-do pile), so results are news by *type*, never by task status.+ * The one exception is the brief's own priority: an unresolved `urgent` result+ * is promoted into "Needs you" (see `isPromotedNews`), where its card offers the+ * same approve action as the task page — approving it there completes a+ * one-off task, while a recurring run's occurrence is only dismissed.*/const isNewsBrief = (brief: BriefItem): boolean => NEWS_BRIEF_TYPES.includes(brief.type);/**- * Splits the unresolved brief feed by whether the user has to *decide*- * something. `decision` briefs block an agent until answered; `insight` and+ * An unresolved `urgent` news brief is the agent saying "look at this now" —+ * it waits in "Needs you" until handled instead of sinking into a digest the+ * user may only skim. Once resolved it is plain news again.+ */+const isPromotedNews = (brief: BriefItem): boolean =>+ isNewsBrief(brief) && !brief.resolvedAt && brief.priority === 'urgent';++/**+ * Splits the unresolved brief feed by whether the user has to *act on*+ * something. `decision` briefs block an agent until answered, and an urgent+ * `insight` / `result` is promoted beside them; the rest of `insight` and* `result` are pure knowledge and belong in a scannable list, not in a to-do* pile. Run failures are not decisions — they live in the notification center,* so legacy `error` briefs are dropped here too (the server already filters@@ -35,8 +48,37 @@ export const splitBriefs = (briefs: BriefItem[]): SplitBriefs => ({// SWR cache revalidates. Hide it immediately so "Ignore" actually closes the// card instead of leaving a resolved tombstone in the queue until remount.!brief.resolvedAt &&- !isNewsBrief(brief) &&+ (!isNewsBrief(brief) || isPromotedNews(brief)) &&!HOME_FEED_EXCLUDED_BRIEF_TYPES.includes(brief.type),),- news: briefs.filter(isNewsBrief),+ news: briefs.filter((brief) => isNewsBrief(brief) && !isPromotedNews(brief)),});++/**+ * Arranges one day of the news digest against the unresolved feed.+ *+ * - The feed is the fresher copy of any brief both hold (an optimistic resolve+ * or read lands there first), so its read/resolve stamps win.+ * - A brief promoted into "Needs you" leaves the digest, so it never shows twice;+ * only promotions the feed actually carries are dropped — one missing from it+ * (still loading, past its cap) stays visible here rather than nowhere.+ * - Within the day, urgent leads, then normal, then info; a stable sort keeps+ * the server's newest-first order inside each level.+ */+export const arrangeDayNews = (dayNews: BriefItem[], feed: BriefItem[]): BriefItem[] => {+ const feedById = new Map(feed.map((brief) => [brief.id, brief]));++ return dayNews+ .map((brief) => {+ const fresh = feedById.get(brief.id);+ if (!fresh) return brief;+ return {+ ...brief,+ readAt: fresh.readAt ?? brief.readAt,+ resolvedAction: fresh.resolvedAction ?? brief.resolvedAction,+ resolvedAt: fresh.resolvedAt ?? brief.resolvedAt,+ };+ })+ .filter((brief) => !(feedById.has(brief.id) && isPromotedNews(brief)))+ .sort((a, b) => briefPriorityRank(a.priority) - briefPriorityRank(b.priority));+};diff --git a/src/store/brief/slices/list/action.test.ts b/src/store/brief/slices/list/action.test.tsindex 4d8b5a064a0..df461705d67 100644--- a/src/store/brief/slices/list/action.test.ts+++ b/src/store/brief/slices/list/action.test.ts@@ -148,6 +148,24 @@ describe('brief list replica', () => {});});+ it('refreshes the day digest when a news brief is resolved from the feed', async () => {+ await load([createBrief('b1')]);+ vi.spyOn(briefService, 'resolve').mockResolvedValue(undefined as never);+ const listNewsByDay = vi+ .spyOn(briefService, 'listNewsByDay')+ .mockResolvedValue({ data: [createBrief('b1')], hasEarlier: false } as never);+ const { result } = renderHook(+ () => useBriefStore((s) => s.useFetchNewsByDay)(true, scope, '2026-07-31'),+ { wrapper },+ );+ await waitFor(() => expect(result.current.data).toBeDefined());+ expect(listNewsByDay).toHaveBeenCalledTimes(1);++ await act(() => useBriefStore.getState().resolveBrief('b1', 'approve'));++ await waitFor(() => expect(listNewsByDay).toHaveBeenCalledTimes(2));+ });+it('drops the briefs resolved as read from the feed', async () => {await load([createBrief('b1'), createBrief('b2')]);vi.spyOn(briefService, 'resolveManyAsRead').mockResolvedValue({ data: ['b1'] } as never);diff --git a/src/store/brief/slices/list/action.ts b/src/store/brief/slices/list/action.tsindex a870d966641..c0623a8d3d8 100644--- a/src/store/brief/slices/list/action.ts+++ b/src/store/brief/slices/list/action.ts@@ -1,3 +1,4 @@+import { NEWS_BRIEF_TYPES } from '@lobechat/types';import dayjs from 'dayjs';import { type SWRResponse } from 'swr';@@ -111,8 +112,8 @@ export class BriefListActionImpl {};resolveBrief = async (id: string, action?: string, comment?: string) => {- const goal = this.#get().briefListMap[BRIEF_LIST_KEY]?.find((brief) => brief.id === id)- ?.metadata?.goal;+ const target = this.#get().briefListMap[BRIEF_LIST_KEY]?.find((brief) => brief.id === id);+ const goal = target?.metadata?.goal;await this.#briefs.optimistic(id,(brief) => ({@@ -122,6 +123,11 @@ export class BriefListActionImpl {}),() => briefService.resolve(id, { action, comment }),);+ // An urgent news brief is answered from "Needs you", and the day digest it+ // returns to holds its own unresolved copy — refresh it so the handled brief+ // does not come back there as unread once it leaves the unresolved feed.+ if (target && NEWS_BRIEF_TYPES.includes(target.type))+ void mutate((key) => Array.isArray(key) && key[0] === briefKeys.news.root);// A goal brief answered the goal itself: the island and the goal views// asking the same question have to drop it too.if (goal)