π€― 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
'use client';
import { Icon, Tooltip } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { Link2 } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { buildOperationSourcePath } from '@/features/Portal/Thread/sharePath';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
const styles = stylex.create({
link: {
display: 'inline-flex',
flexGrow: 0,
flexShrink: 1,
flexBasis: 'auto',
gap: '3px',
alignItems: 'center',
minInlineSize: '0',
maxInlineSize: '320px',
fontSize: '12px',
color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorTextSecondary },
},
label: { overflow: 'hidden', minInlineSize: '0', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
});
interface AgentSenderSourceLinkProps {
/**
* The group conversation the turn ran in, when it ran in one. A group's turns
* live under `/group/<chatGroupId>/<topicId>`; the agent route would open the
* supervisor's own conversation instead.
*/
chatGroupId?: string;
/** The thread the turn ran in, reopened via `?portalThread=<threadId>`. */
threadId?: string;
/**
* The agent that OWNS the source topic β the link's `/agent/<id>/` segment when
* the turn ran in a one-to-one topic. Not necessarily the sending agent: a
* heterogeneous `callSubAgent` child runs on its spawner's topic, and only the
* topic's own agent holds that conversation.
*/
topicAgentId: string;
/** The source topic id. */
topicId: string;
/**
* The source topic's own name. Shown as the link label; the generic caption is
* only the fallback for a topic that has none.
*/
topicTitle?: string | null;
}
/**
* Jump-back to the conversation an agent β agent turn was launched from. Sits
* before the sending agent's name so the authorship and its origin read as one
* cluster.
*
* Labels itself with the topic's OWN name rather than a generic "source topic"
* caption: the name is what tells a reader *which* conversation this came from,
* and repeating a caption on every such message is chrome. The caption appears
* on hover β and is the label for an untitled topic β so the affordance still
* explains itself without occupying the row.
*
* The destination is the conversation the turn actually ran in, not merely its
* topic: the group it belonged to, and the thread, when it ran in one.
*/
const AgentSenderSourceLink = memo<AgentSenderSourceLinkProps>(
({ chatGroupId, threadId, topicAgentId, topicId, topicTitle }) => {
const { t } = useTranslation('chat');
const caption = t('agentSender.sourceTopic');
const name = topicTitle?.trim();
const href = buildOperationSourcePath({
agentId: topicAgentId,
chatGroupId,
threadId,
topicId,
});
if (!href) return null;
return (
<Tooltip title={caption}>
{/* `WorkspaceLink`, not the bare router `Link`: these routes are mirrored
under `/:workspaceSlug`, so an unprefixed href would drop a workspace
reader into their personal route and the source would not load. */}
<WorkspaceLink className={stylex.props(styles.link).className} to={href}>
<Icon icon={Link2} size={12} />
<span {...stylex.props(styles.label)}>{name || caption}</span>
</WorkspaceLink>
</Tooltip>
);
},
);
AgentSenderSourceLink.displayName = 'AgentSenderSourceLink';
export default AgentSenderSourceLink;