Skip to content

🤯 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.

💄 style(topics): show topic folder and git branch on separate card rows (#21428)

AmAzing-ff7509bf76b0
diff --git a/src/features/AgentTopicManager/TopicCard.tsx b/src/features/AgentTopicManager/TopicCard.tsx
index 66ba829e5df..95e9ed9838f 100644
--- a/src/features/AgentTopicManager/TopicCard.tsx
+++ b/src/features/AgentTopicManager/TopicCard.tsx
@@ -3,7 +3,14 @@
import { AGENT_CHAT_TOPIC_URL } from '@lobechat/const';
import { formatPrice, formatTokenNumber } from '@lobechat/utils/format';
import { Block, Checkbox, createStaticStyles, cssVar, Flexbox, Icon, Tag, Text } from '@lobehub/ui';
-import { CircleDollarSign, FolderIcon, MessageSquare, Star, Zap } from 'lucide-react';
+import {
+ CircleDollarSign,
+ FolderIcon,
+ GitBranchIcon,
+ MessageSquare,
+ Star,
+ Zap,
+} from 'lucide-react';
import { memo, type MouseEvent, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@@ -14,7 +21,7 @@ import type { ChatTopic } from '@/types/topic';
import StatusDot from './StatusDot';
import { useTopicsViewStore } from './store';
-import { getProjectLabel } from './utils';
+import { getProjectInfo } from './utils';
const styles = createStaticStyles(({ css }) => ({
card: css`
@@ -65,6 +72,22 @@ const styles = createStaticStyles(({ css }) => ({
padding-block-start: 10px;
border-block-start: 1px solid ${cssVar.colorSplit};
`,
+ projectLabel: css`
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ /* Long folder / branch names must truncate inside the card instead of
+ overflowing its border. */
+ projectTag: css`
+ align-self: flex-start;
+ min-width: 0;
+ max-width: 100%;
+
+ > :first-child {
+ flex-shrink: 0;
+ }
+ `,
title: css`
overflow: hidden;
display: -webkit-box;
@@ -114,7 +137,7 @@ const TopicCard = memo<TopicCardProps>(({ topic, agentId }) => {
e.stopPropagation();
}, []);
- const projectLabel = getProjectLabel(topic);
+ const project = getProjectInfo(topic);
const status = topic.status ?? 'active';
// Bot source platform icon (same identity mark as the sidebar topic item).
const botPlatform = topic.metadata?.bot?.platform;
@@ -168,10 +191,27 @@ const TopicCard = memo<TopicCardProps>(({ topic, agentId }) => {
</Text>
)}
- {projectLabel && (
- <Tag icon={<Icon icon={FolderIcon} size={11} />} size={'small'}>
- {projectLabel}
- </Tag>
+ {project && (
+ <Flexbox gap={4}>
+ <Tag
+ className={styles.projectTag}
+ icon={<Icon icon={FolderIcon} size={11} />}
+ size={'small'}
+ title={project.path}
+ >
+ <span className={styles.projectLabel}>{project.path}</span>
+ </Tag>
+ {project.branch && (
+ <Tag
+ className={styles.projectTag}
+ icon={<Icon icon={GitBranchIcon} size={11} />}
+ size={'small'}
+ title={project.branch}
+ >
+ <span className={styles.projectLabel}>{project.branch}</span>
+ </Tag>
+ )}
+ </Flexbox>
)}
<Flexbox horizontal align={'center'} className={styles.footer} justify={'space-between'}>
diff --git a/src/features/AgentTopicManager/utils.test.ts b/src/features/AgentTopicManager/utils.test.ts
index ccd5f8397f9..8759138b717 100644
--- a/src/features/AgentTopicManager/utils.test.ts
+++ b/src/features/AgentTopicManager/utils.test.ts
@@ -4,6 +4,7 @@ import {
buildBotChannelOptions,
getBotPlatformName,
getProjectFilterLabel,
+ getProjectInfo,
getProjectLabel,
matchesBotChannel,
matchesGroup,
@@ -37,6 +38,7 @@ describe('AgentTopicManager utils', () => {
expect(matchesGroup(topic, ['/repo-fix'])).toBe(false);
expect(getProjectFilterLabel(topic)).toBe('repo');
expect(getProjectLabel(topic)).toBe('repo/repo-fix · fix');
+ expect(getProjectInfo(topic)).toEqual({ branch: 'fix', path: 'repo/repo-fix' });
});
it('matches bot channel filters by metadata.bot.platform', () => {
diff --git a/src/features/AgentTopicManager/utils.ts b/src/features/AgentTopicManager/utils.ts
index 2da7faac5a9..dea3914cabe 100644
--- a/src/features/AgentTopicManager/utils.ts
+++ b/src/features/AgentTopicManager/utils.ts
@@ -114,7 +114,12 @@ export const getProjectFilterLabel = (topic: ChatTopic): string | undefined => {
return source ? getPathName(source) : undefined;
};
-export const getProjectLabel = (topic: ChatTopic): string | undefined => {
+export interface ProjectInfo {
+ branch?: string;
+ path: string;
+}
+
+export const getProjectInfo = (topic: ChatTopic): ProjectInfo | undefined => {
const source = getTopicWorkingDirectorySourcePath(topic);
const effective = getTopicWorkingDirectoryEffectivePath(topic);
const labelPath = effective ?? source;
@@ -122,10 +127,17 @@ export const getProjectLabel = (topic: ChatTopic): string | undefined => {
const label = getPathName(labelPath);
const sourceName = source ? getPathName(source) : undefined;
- const pathLabel = sourceName && sourceName !== label ? `${sourceName}/${label}` : label;
- const branch = topic.metadata?.workingDirectoryConfig?.git?.branch;
+ const path = sourceName && sourceName !== label ? `${sourceName}/${label}` : label;
+ const branch = topic.metadata?.workingDirectoryConfig?.git?.branch || undefined;
+
+ return { branch, path };
+};
+
+export const getProjectLabel = (topic: ChatTopic): string | undefined => {
+ const info = getProjectInfo(topic);
+ if (!info) return undefined;
- return branch ? `${pathLabel} · ${branch}` : pathLabel;
+ return info.branch ? `${info.path} · ${info.branch}` : info.path;
};
/** Client-side platform display names (server `PlatformDefinition.name`). */