🤯 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): workspace mine/team view for HomeInbox (#17360)
Arvin Xuc1ff135fbe66
diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 859603287bf..5d4dbcdba68 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -44,12 +44,16 @@"homePromoBanner.cta": "Try now","homePromoBanner.dismiss": "Dismiss","homePromoBanner.label": "{{model}} is now available",+ "inbox.author.scheduled": "Scheduled","inbox.needsYou.title": "Needs you","inbox.news.markAllRead": "Mark all read","inbox.news.subtitle": "Nothing to decide — just a glance","inbox.news.title": "Daily brief","inbox.running.title": "{{count}} task running","inbox.running.title_plural": "{{count}} tasks running",+ "inbox.scope.mine": "Mine",+ "inbox.scope.onlyMe": "Only mine",+ "inbox.scope.team": "Team","inbox.unread.followUp": "Follow up","inbox.unread.followUpPlaceholder": "Reply to continue this run…","inbox.unread.title": "Unread",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex 551d69b4844..b879c47953f 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -44,12 +44,16 @@"homePromoBanner.cta": "立即体验","homePromoBanner.dismiss": "关闭","homePromoBanner.label": "{{model}} 现已上线",+ "inbox.author.scheduled": "定时触发","inbox.needsYou.title": "需要你处理","inbox.news.markAllRead": "全部已读","inbox.news.subtitle": "不需要你做决定,扫一眼就行","inbox.news.title": "今日简报","inbox.running.title": "{{count}} 个任务正在执行","inbox.running.title_plural": "{{count}} 个任务正在执行",+ "inbox.scope.mine": "我的",+ "inbox.scope.onlyMe": "仅我",+ "inbox.scope.team": "团队","inbox.unread.followUp": "继续追问","inbox.unread.followUpPlaceholder": "回复以继续这次运行…","inbox.unread.title": "未读",diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex e7947841b4b..efaf77d1ce8 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -46,12 +46,16 @@ export default {'homePromoBanner.cta': 'Try now','homePromoBanner.dismiss': 'Dismiss','homePromoBanner.label': '{{model}} is now available',+ 'inbox.author.scheduled': 'Scheduled','inbox.needsYou.title': 'Needs you','inbox.news.markAllRead': 'Mark all read','inbox.news.subtitle': 'Nothing to decide — just a glance','inbox.news.title': 'Daily brief','inbox.running.title': '{{count}} task running','inbox.running.title_plural': '{{count}} tasks running',+ 'inbox.scope.mine': 'Mine',+ 'inbox.scope.onlyMe': 'Only mine',+ 'inbox.scope.team': 'Team','inbox.unread.followUp': 'Follow up','inbox.unread.followUpPlaceholder': 'Reply to continue this run…','inbox.unread.title': 'Unread',diff --git a/src/business/client/hooks/useWorkspaceMemberProfiles.ts b/src/business/client/hooks/useWorkspaceMemberProfiles.tsnew file mode 100644index 00000000000..f053c61b73e--- /dev/null+++ b/src/business/client/hooks/useWorkspaceMemberProfiles.ts@@ -0,0 +1,20 @@+/**+ * userId → display profile for the members of the active workspace.+ *+ * Business slot. In personal mode (and in OSS, which has no workspace concept)+ * this is an empty map, so a home surface that resolves a topic's triggerer+ * through it simply renders no author — degrading to the personal inbox with no+ * extra branching. The cloud override fills it from the workspace member store.+ *+ * A workspace topic already carries `userId` (its creator / triggerer); this is+ * the client-side lookup that turns that id into a face and a name.+ */+export interface WorkspaceMemberProfile {+ avatar?: string | null;+ fullName?: string | null;+ username?: string | null;+}++const EMPTY: ReadonlyMap<string, WorkspaceMemberProfile> = new Map();++export const useWorkspaceMemberProfiles = (): ReadonlyMap<string, WorkspaceMemberProfile> => EMPTY;diff --git a/src/features/HomeInbox/AuthorChip.tsx b/src/features/HomeInbox/AuthorChip.tsxnew file mode 100644index 00000000000..b12db97b340--- /dev/null+++ b/src/features/HomeInbox/AuthorChip.tsx@@ -0,0 +1,71 @@+import { DEFAULT_USER_AVATAR_URL } from '@lobechat/const';+import { Avatar, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';+import { createStaticStyles, cssVar } from 'antd-style';+import { AlarmClockIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useWorkspaceMemberProfiles } from '@/business/client/hooks/useWorkspaceMemberProfiles';++const AVATAR_SIZE = 16;++const styles = createStaticStyles(({ css, cssVar }) => ({+ chip: css`+ flex: none;+ `,+ label: css`+ font-size: 11px;+ color: ${cssVar.colorTextTertiary};+ white-space: nowrap;+ `,+}));++interface AuthorChipProps {+ /** `topic.trigger` — a `cron` run has no human triggerer, only an owning schedule. */+ trigger?: string | null;+ /** `topic.userId` — the member who started (or owns) this run. */+ userId?: string;+}++/**+ * Who triggered a run, on the team view of a workspace inbox. A row the current+ * user didn't start needs a face to be legible — "whose is this?" is the first+ * question when the feed widens past your own work.+ *+ * A `cron`-triggered run has no person behind it, so it reads as a schedule+ * rather than borrowing its owner's face (which would imply they just ran it).+ */+const AuthorChip = memo<AuthorChipProps>(({ userId, trigger }) => {+ const { t } = useTranslation('home');+ const profiles = useWorkspaceMemberProfiles();++ if (trigger === 'cron')+ return (+ <Flexbox horizontal align={'center'} className={styles.chip} gap={4}>+ <Icon color={cssVar.colorTextQuaternary} icon={AlarmClockIcon} size={12} />+ <span className={styles.label}>{t('inbox.author.scheduled')}</span>+ </Flexbox>+ );++ const profile = userId ? profiles.get(userId) : undefined;+ if (!profile) return null;++ const name = profile.fullName || profile.username || '';++ return (+ <Flexbox horizontal align={'center'} className={styles.chip} gap={4}>+ <Tooltip title={name}>+ <Avatar+ avatar={profile.avatar || DEFAULT_USER_AVATAR_URL}+ shape={'circle'}+ size={AVATAR_SIZE}+ />+ </Tooltip>+ <Text ellipsis className={styles.label} style={{ maxWidth: 72 }}>+ {name}+ </Text>+ </Flexbox>+ );+});++export default AuthorChip;diff --git a/src/features/HomeInbox/RunningTasksCard.tsx b/src/features/HomeInbox/RunningTasksCard.tsxindex 3eb36270b42..531bda5c6cd 100644--- a/src/features/HomeInbox/RunningTasksCard.tsx+++ b/src/features/HomeInbox/RunningTasksCard.tsx@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';import RingLoadingIcon from '@/components/RingLoading';import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';+import AuthorChip from './AuthorChip';import TopicRow from './TopicRow';import { type InboxTopic } from './useHomeInboxTopics';@@ -104,6 +105,8 @@ const RING_COLOR = `color-mix(in srgb, ${cssVar.colorWarning} 45%, transparent)`interface RunningTasksCardProps {running: InboxTopic[];+ /** Team view: tag each expanded row with whose run it is. */+ showAuthor?: boolean;}/**@@ -111,7 +114,7 @@ interface RunningTasksCardProps {* single line by default and only opens on demand. Nothing here is actionable;* it exists so the user knows work is in flight.*/-const RunningTasksCard = memo<RunningTasksCardProps>(({ running }) => {+const RunningTasksCard = memo<RunningTasksCardProps>(({ running, showAuthor }) => {const { t } = useTranslation('home');const [open, setOpen] = useState(false);@@ -151,6 +154,11 @@ const RunningTasksCard = memo<RunningTasksCardProps>(({ running }) => {style={{ color: cssVar.colorWarning }}/>}+ trailing={+ showAuthor ? (+ <AuthorChip trigger={topic.trigger} userId={topic.userId} />+ ) : undefined+ }/>))}</Flexbox>diff --git a/src/features/HomeInbox/UnreadTopicList.tsx b/src/features/HomeInbox/UnreadTopicList.tsxindex c88c459ac01..e7735a609b3 100644--- a/src/features/HomeInbox/UnreadTopicList.tsx+++ b/src/features/HomeInbox/UnreadTopicList.tsx@@ -13,6 +13,7 @@ import Time from '@/routes/(main)/home/features/components/Time';import { useChatStore } from '@/store/chat';import { useTaskStore } from '@/store/task';+import AuthorChip from './AuthorChip';import { type InboxTopic } from './useHomeInboxTopics';const DOT_WIDTH = 14;@@ -56,6 +57,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({interface UnreadTopicItemProps {onFollowUpSent?: (topicId: string) => void;+ /** Team view: show who triggered the run, right of the title. */+ showAuthor?: boolean;topic: InboxTopic;}@@ -66,7 +69,7 @@ interface UnreadTopicItemProps {* already said "I want to read this". The full thread lives one click deeper, in* the chat drawer.*/-const UnreadTopicItem = memo<UnreadTopicItemProps>(({ topic, onFollowUpSent }) => {+const UnreadTopicItem = memo<UnreadTopicItemProps>(({ topic, onFollowUpSent, showAuthor }) => {const { t } = useTranslation('home');const agent = useAgentDisplayMeta(topic.agentId);const openTopicDrawer = useTaskStore((s) => s.openTopicDrawer);@@ -146,6 +149,7 @@ const UnreadTopicItem = memo<UnreadTopicItemProps>(({ topic, onFollowUpSent }) =<Text ellipsis style={{ flex: 1, minWidth: 0 }} weight={read ? 400 : 500}>{topic.title}</Text>+ {showAuthor && <AuthorChip trigger={topic.trigger} userId={topic.userId} />}<Time date={topic.updatedAt ?? topic.createdAt} /><Iconcolor={cssVar.colorTextQuaternary}@@ -194,6 +198,8 @@ const UnreadTopicItem = memo<UnreadTopicItemProps>(({ topic, onFollowUpSent }) =interface UnreadTopicListProps {onFollowUpSent?: (topicId: string) => void;+ /** Team view: tag each row with who triggered it. */+ showAuthor?: boolean;topics: InboxTopic[];}@@ -201,10 +207,15 @@ interface UnreadTopicListProps {* Runs that finished while you were away. One line each, like the news list —* a week of finished runs still fits on screen, and the reply is one click deep.*/-const UnreadTopicList = memo<UnreadTopicListProps>(({ topics, onFollowUpSent }) => (+const UnreadTopicList = memo<UnreadTopicListProps>(({ topics, onFollowUpSent, showAuthor }) => (<Flexbox className={styles.list}>{topics.map((topic) => (- <UnreadTopicItem key={topic.id} topic={topic} onFollowUpSent={onFollowUpSent} />+ <UnreadTopicItem+ key={topic.id}+ showAuthor={showAuthor}+ topic={topic}+ onFollowUpSent={onFollowUpSent}+ />))}</Flexbox>));diff --git a/src/features/HomeInbox/index.tsx b/src/features/HomeInbox/index.tsxindex 3141bae0793..481c00dfac8 100644--- a/src/features/HomeInbox/index.tsx+++ b/src/features/HomeInbox/index.tsx@@ -1,8 +1,10 @@import { Flexbox } from '@lobehub/ui';+import { Segmented } from '@lobehub/ui/base-ui';import { createStaticStyles } from 'antd-style';-import { memo, type ReactNode, useMemo } from 'react';+import { memo, type ReactNode, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import { useWorkspaceMemberProfiles } from '@/business/client/hooks/useWorkspaceMemberProfiles';import AsyncError from '@/components/AsyncError';import TopicChatDrawer from '@/features/AgentTasks/AgentTaskDetail/TopicChatDrawer';import { BriefCardSkeleton } from '@/features/DailyBrief/BriefCardSkeleton';@@ -12,7 +14,7 @@ import GroupBlock from '@/routes/(main)/home/features/components/GroupBlock';import { useBriefStore } from '@/store/brief';import { briefListSelectors } from '@/store/brief/selectors';import { useUserStore } from '@/store/user';-import { authSelectors } from '@/store/user/slices/auth/selectors';+import { authSelectors, userProfileSelectors } from '@/store/user/slices/auth/selectors';import InboxBriefCard from './InboxBriefCard';import MarkAllReadButton from './MarkAllReadButton';@@ -28,6 +30,16 @@ const styles = createStaticStyles(({ css, cssVar }) => ({font-variant-numeric: tabular-nums;color: ${cssVar.colorTextQuaternary};`,+ onlyMe: css`+ margin-inline-start: 8px;+ padding-inline: 5px;+ border-radius: 3px;++ font-size: 11px;+ color: ${cssVar.colorTextTertiary};++ background: ${cssVar.colorFillQuaternary};+ `,subtitle: css`margin-inline-start: 8px;font-size: 12px;@@ -68,12 +80,20 @@ const titleWithCount = (label: string, count: number, subtitle?: string): ReactN* - **News** — `insight` + `result` briefs (reports of finished work); read them* or don't.*+ * **Workspace mode** adds a mine/team split, but only over the sections it can+ * honestly widen. Topics are workspace-shared, so the unread + running feeds+ * already carry every member's runs — the toggle filters them by triggerer, and+ * team view tags each row with whose it is. Briefs are per-user by a deliberate+ * ownership rule (a member never sees another's brief), so Needs-you and News+ * stay mine in both views; team view marks News as such rather than pretending.+ ** Sections are siblings, never nested: each names itself and carries its own* count, and one absent section never hides another's heading.*/const HomeInbox = memo(() => {const { t } = useTranslation('home');const isLogin = useUserStore(authSelectors.isLogin);+ const myId = useUserStore(userProfileSelectors.userId);const useFetchBriefs = useBriefStore((s) => s.useFetchBriefs);const briefsSWR = useFetchBriefs(isLogin);@@ -83,8 +103,29 @@ const HomeInbox = memo(() => {const topics = useHomeInboxTopics(isLogin);const recommendationsVisible = useRecommendationsVisible();+ // A team context is a workspace with more than the viewer in it. In personal+ // mode this map is empty, so `isTeam` is false and the whole mine/team layer+ // stays dark — the inbox is byte-for-byte the personal one.+ const memberProfiles = useWorkspaceMemberProfiles();+ const isTeam = memberProfiles.size > 1;++ const [scope, setScope] = useState<'mine' | 'team'>('mine');+ const teamView = isTeam && scope === 'team';+const { needsYou, news } = 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+ // filter is a no-op there.+ const unreadTopics = useMemo(+ () => (teamView ? topics.unread : topics.unread.filter((topic) => topic.userId === myId)),+ [teamView, topics.unread, myId],+ );+ const runningTopics = useMemo(+ () => (teamView ? topics.running : topics.running.filter((topic) => topic.userId === myId)),+ [teamView, topics.running, myId],+ );+if (!isLogin) return null;// Both overlays open from a card in here and must outlive it — a followed-up@@ -126,10 +167,32 @@ const HomeInbox = memo(() => {);}+ // Mine/team lives at page level (governs the topic sections), so it rides on+ // the first titled section's header — the primary "Needs you", or Unread when+ // there's nothing to handle. Only shown in a team workspace.+ const scopeToggle = isTeam ? (+ <Segmented+ size={'small'}+ value={scope}+ options={[+ { label: t('inbox.scope.mine'), value: 'mine' },+ { label: t('inbox.scope.team'), value: 'team' },+ ]}+ onChange={(value) => setScope(value as 'mine' | 'team')}+ />+ ) : undefined;+ let toggleSectionKey: string | undefined;+ const placeToggle = (key: string): ReactNode => {+ if (!scopeToggle || toggleSectionKey) return undefined;+ toggleSectionKey = key;+ return scopeToggle;+ };+const sections: InboxSection[] = [];if (needsYou.length > 0)sections.push({+ action: placeToggle('needsYou'),key: 'needsYou',node: (<Flexbox gap={12}>@@ -150,23 +213,40 @@ const HomeInbox = memo(() => {title: t('inbox.unread.title'),});- if (topics.unread.length > 0)+ if (unreadTopics.length > 0)sections.push({+ action: placeToggle('unread'),key: 'unread',- node: <UnreadTopicList topics={topics.unread} onFollowUpSent={topics.promoteToRunning} />,- title: titleWithCount(t('inbox.unread.title'), topics.unread.length),+ node: (+ <UnreadTopicList+ showAuthor={teamView}+ topics={unreadTopics}+ onFollowUpSent={topics.promoteToRunning}+ />+ ),+ title: titleWithCount(t('inbox.unread.title'), unreadTopics.length),});// No title: the card already says "3 tasks running" on its own head.- if (topics.running.length > 0)- sections.push({ key: 'running', node: <RunningTasksCard running={topics.running} /> });+ if (runningTopics.length > 0)+ sections.push({+ key: 'running',+ node: <RunningTasksCard running={runningTopics} showAuthor={teamView} />,+ });if (news.length > 0)sections.push({action: <MarkAllReadButton news={news} />,key: 'news',node: <NewsList news={news} />,- title: titleWithCount(t('inbox.news.title'), news.length, t('inbox.news.subtitle')),+ // 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.+ title: (+ <>+ {titleWithCount(t('inbox.news.title'), news.length, t('inbox.news.subtitle'))}+ {teamView && <span className={styles.onlyMe}>{t('inbox.scope.onlyMe')}</span>}+ </>+ ),});if (sections.length === 0) {@@ -189,7 +269,12 @@ const HomeInbox = memo(() => {<Flexbox gap={32}>{sections.map(({ action, key, node, title }) =>title ? (- <GroupBlock action={action} key={key} title={title}>+ <GroupBlock+ action={action}+ actionAlwaysVisible={key === toggleSectionKey}+ key={key}+ title={title}+ >{node}</GroupBlock>) : (