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.

✨ feat(topic): add a Labs slot to report a topic to support (#21063)

AmAzing-e56465fac9f7
diff --git a/locales/en-US/labs.json b/locales/en-US/labs.json
index e2c5980994d..98399b0e8f0 100644
--- a/locales/en-US/labs.json
+++ b/locales/en-US/labs.json
@@ -44,6 +44,8 @@
"features.selfLearning.title": "Self-evolving",
"features.taskVerify.desc": "Add an Acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.",
"features.taskVerify.title": "Acceptance",
+ "features.topicBugReport.desc": "Adds Report a Problem to the topic menu. It sends the topic's IDs and your app environment to the LobeHub support team, who look into what happened from there.",
+ "features.topicBugReport.title": "Report a Problem with a Topic",
"group.desktop": "Desktop",
"group.general": "General",
"stage.alpha.desc": "Internal testing only. Not recommended for daily use yet — it may change or break at any time.",
diff --git a/locales/en-US/topic.json b/locales/en-US/topic.json
index cecface181a..f6a6db2b5db 100644
--- a/locales/en-US/topic.json
+++ b/locales/en-US/topic.json
@@ -45,6 +45,7 @@
"actions.removeUnstarred": "Delete Unstarred Topics",
"actions.removeUnstarredOwn": "Delete My Unstarred Topics",
"actions.removeUnstarredWorkspace": "Delete All Unstarred Topics",
+ "actions.reportProblem": "Report a Problem",
"actions.unfavorite": "Unfavorite",
"actions.unmarkCompleted": "Unarchive",
"defaultTitle": "Default Topic",
@@ -259,6 +260,14 @@
"projectStatus.waitingForHuman_other": "{{count}} topics awaiting input",
"renameModal.description": "Keep it short and easy to recognize.",
"renameModal.title": "Rename Topic",
+ "reportProblem.desc": "This topic's IDs and your app environment are sent to the LobeHub support team, who can then look into this topic's runs, errors and conversation.",
+ "reportProblem.failed": "Couldn't submit the report. Try again.",
+ "reportProblem.placeholder": "What went wrong? (optional)",
+ "reportProblem.rateLimited": "You've sent a lot of reports recently. Try again later.",
+ "reportProblem.submit": "Submit",
+ "reportProblem.success": "Report submitted",
+ "reportProblem.successDesc": "Report ID: {{id}}",
+ "reportProblem.title": "Report a Problem",
"scheduledStatusTip": "Scheduled to run at {{time}}.",
"searchPlaceholder": "Search Topics...",
"searchResultEmpty": "No search results found.",
diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.json
index ffeec583e6c..a7dbad88657 100644
--- a/locales/zh-CN/labs.json
+++ b/locales/zh-CN/labs.json
@@ -44,6 +44,8 @@
"features.selfLearning.title": "自进化",
"features.taskVerify.desc": "在任务详情里增加「交付验收」模块:一句话描述验收要求,AI 自动生成可编辑的验收项。",
"features.taskVerify.title": "任务交付验收",
+ "features.topicBugReport.desc": "在话题菜单中增加「上报问题」,把这个话题的 ID 和你的应用环境提交给 LobeHub 支持团队,由团队据此排查。",
+ "features.topicBugReport.title": "上报话题问题",
"group.desktop": "桌面端",
"group.general": "通用",
"stage.alpha.desc": "仅供内部测试,暂不建议尝鲜,随时可能变动或损坏。",
diff --git a/locales/zh-CN/topic.json b/locales/zh-CN/topic.json
index 7fee36c425b..c4512c60e27 100644
--- a/locales/zh-CN/topic.json
+++ b/locales/zh-CN/topic.json
@@ -45,6 +45,7 @@
"actions.removeUnstarred": "删除未收藏话题",
"actions.removeUnstarredOwn": "删除我创建的未收藏话题",
"actions.removeUnstarredWorkspace": "删除全部未收藏话题",
+ "actions.reportProblem": "上报问题",
"actions.unfavorite": "取消收藏",
"actions.unmarkCompleted": "取消归档",
"defaultTitle": "默认话题",
@@ -259,6 +260,14 @@
"projectStatus.waitingForHuman_other": "{{count}} 个等待处理的话题",
"renameModal.description": "保持简短且易于识别。",
"renameModal.title": "重命名话题",
+ "reportProblem.desc": "会把这个话题的 ID 和你的应用环境提交给 LobeHub 支持团队,团队会据此查看这个话题的运行记录、报错和对话内容。",
+ "reportProblem.failed": "提交失败,请重试。",
+ "reportProblem.placeholder": "遇到了什么问题?(选填)",
+ "reportProblem.rateLimited": "最近提交的报告较多,请稍后再试。",
+ "reportProblem.submit": "提交",
+ "reportProblem.success": "已提交",
+ "reportProblem.successDesc": "报告 ID:{{id}}",
+ "reportProblem.title": "上报问题",
"scheduledStatusTip": "将于 {{time}} 运行",
"searchPlaceholder": "搜索话题…",
"searchResultEmpty": "暂无搜索结果",
diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.ts
index 023fe7d70e1..1edf8073286 100644
--- a/packages/locales/src/default/labs.ts
+++ b/packages/locales/src/default/labs.ts
@@ -66,6 +66,9 @@ export default {
'features.selfLearning.desc':
'Let every agent learn from your conversations in the background: it remembers facts, refines skills, collects lessons, and reviews its day each night. Rounds you send back become rules. Each nightly review covers at most 50 conversations. See it all under Memory → Self-evolving.',
'features.selfLearning.title': 'Self-evolving',
+ 'features.topicBugReport.desc':
+ "Adds Report a Problem to the topic menu. It sends the topic's IDs and your app environment to the LobeHub support team, who look into what happened from there.",
+ 'features.topicBugReport.title': 'Report a Problem with a Topic',
'group.desktop': 'Desktop',
'group.general': 'General',
'stage.alpha.desc':
diff --git a/packages/locales/src/default/topic.ts b/packages/locales/src/default/topic.ts
index a885c2d87f4..9553114ab07 100644
--- a/packages/locales/src/default/topic.ts
+++ b/packages/locales/src/default/topic.ts
@@ -35,6 +35,7 @@ export default {
'actions.copyLinkSuccess': 'Link copied',
'actions.copySessionId': 'Copy Topic ID',
'actions.copySessionIdSuccess': 'Topic ID copied',
+ 'actions.reportProblem': 'Report a Problem',
'actions.copyTopicPrompt': 'Copy Topic Prompt',
'actions.copyTopicPromptSuccess': 'Topic prompt copied',
'actions.copyWorkingDirectory': 'Copy Working Directory',
@@ -285,6 +286,15 @@ export default {
'management.view.card': 'Card',
'management.view.list': 'List',
'newTopic': 'New Topic',
+ 'reportProblem.desc':
+ "This topic's IDs and your app environment are sent to the LobeHub support team, who can then look into this topic's runs, errors and conversation.",
+ 'reportProblem.failed': "Couldn't submit the report. Try again.",
+ 'reportProblem.rateLimited': "You've sent a lot of reports recently. Try again later.",
+ 'reportProblem.placeholder': 'What went wrong? (optional)',
+ 'reportProblem.submit': 'Submit',
+ 'reportProblem.success': 'Report submitted',
+ 'reportProblem.successDesc': 'Report ID: {{id}}',
+ 'reportProblem.title': 'Report a Problem',
'renameModal.description': 'Keep it short and easy to recognize.',
'renameModal.title': 'Rename Topic',
'scheduledStatusTip': 'Scheduled to run at {{time}}.',
diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.ts
index 612221acd8c..1514810d348 100644
--- a/packages/types/src/user/preference.ts
+++ b/packages/types/src/user/preference.ts
@@ -218,6 +218,11 @@ export const UserLabSchema = z.object({
enableTaskVerify: z.boolean().optional(),
/** Capture a conversation turn as an eval test case (developer-facing). */
enableEvalCapture: z.boolean().optional(),
+ /**
+ * show "Report a problem" in the topic menu, which sends where the topic is
+ * (its ids and the client environment) to the support team
+ */
+ enableTopicBugReport: z.boolean().optional(),
/**
* enable Goals: hand the agent a goal it plans into tasks, tracks and delivers
*/
diff --git a/src/business/client/hooks/useTopicBugReportMenuItem.ts b/src/business/client/hooks/useTopicBugReportMenuItem.ts
new file mode 100644
index 00000000000..55d6a825ac1
--- /dev/null
+++ b/src/business/client/hooks/useTopicBugReportMenuItem.ts
@@ -0,0 +1,16 @@
+import type { DropdownItem } from '@lobehub/ui';
+
+/** The topic a report is about, as the conversation header knows it. */
+export interface TopicBugReportTarget {
+ agentId?: string;
+ threadId?: string;
+ topicId?: string;
+}
+
+/**
+ * "Report a problem" in the topic menu, which submits where the topic is to a
+ * support inbox. Nothing by default: only a deployment with such an inbox can
+ * act on it.
+ */
+export const useTopicBugReportMenuItem = (_target: TopicBugReportTarget): DropdownItem | null =>
+ null;
diff --git a/src/features/Settings/labs/features.test.ts b/src/features/Settings/labs/features.test.ts
new file mode 100644
index 00000000000..52bbb5b5a22
--- /dev/null
+++ b/src/features/Settings/labs/features.test.ts
@@ -0,0 +1,29 @@
+import { describe, expect, it } from 'vitest';
+
+import { filterAvailableLabFeatures, type LabFeatureItem } from './features';
+
+const features: LabFeatureItem[] = [
+ { flag: 'enableGoals', i18nKey: 'goals', searchKeywords: [], stage: 'beta' },
+ {
+ businessOnly: true,
+ flag: 'enableTopicBugReport',
+ i18nKey: 'topicBugReport',
+ searchKeywords: [],
+ stage: 'alpha',
+ },
+];
+
+describe('filterAvailableLabFeatures', () => {
+ it('hides business-only experiments when business features are off', () => {
+ expect(filterAvailableLabFeatures(features, false).map(({ flag }) => flag)).toEqual([
+ 'enableGoals',
+ ]);
+ });
+
+ it('offers business-only experiments when business features are on', () => {
+ expect(filterAvailableLabFeatures(features, true).map(({ flag }) => flag)).toEqual([
+ 'enableGoals',
+ 'enableTopicBugReport',
+ ]);
+ });
+});
diff --git a/src/features/Settings/labs/features.ts b/src/features/Settings/labs/features.ts
index 3d42f32e943..1278ba111d1 100644
--- a/src/features/Settings/labs/features.ts
+++ b/src/features/Settings/labs/features.ts
@@ -1,3 +1,5 @@
+import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
+
import { type labPreferSelectors } from '@/store/user/slices/preference/selectors/labPrefer';
/**
@@ -28,9 +30,15 @@ type LabFeatureI18nKey =
| 'oauthApps'
| 'persistentSandbox'
| 'projects'
- | 'selfLearning';
+ | 'selfLearning'
+ | 'topicBugReport';
export interface LabFeatureItem {
+ /**
+ * Only offered when business features are on: the experiment needs a service
+ * that a self-hosted deployment does not have, so its toggle would do nothing.
+ */
+ businessOnly?: boolean;
/** Only rendered (and searchable) in the Electron shell */
desktopOnly?: boolean;
/** Lab flag, also the search anchor suffix (`labs-${flag}`) */
@@ -42,13 +50,7 @@ export interface LabFeatureItem {
stage: LabStage;
}
-/**
- * Single source of truth for the lab experiments: the Labs settings page
- * renders this list (general first, then desktop-only), and the settings
- * search index derives its entries from it — adding a flag here makes it both
- * visible and searchable without a second registration.
- */
-export const LAB_FEATURES: LabFeatureItem[] = [
+const ALL_LAB_FEATURES: LabFeatureItem[] = [
{
flag: 'enableAgentGraphConfig',
i18nKey: 'agentGraphConfig',
@@ -87,6 +89,13 @@ export const LAB_FEATURES: LabFeatureItem[] = [
searchKeywords: ['eval', 'test case', 'capture', 'regression', 'benchmark'],
stage: 'alpha',
},
+ {
+ businessOnly: true,
+ flag: 'enableTopicBugReport',
+ i18nKey: 'topicBugReport',
+ searchKeywords: ['bug', 'report', 'feedback', 'issue', 'support'],
+ stage: 'alpha',
+ },
{
flag: 'enableGoals',
i18nKey: 'goals',
@@ -167,3 +176,20 @@ export const LAB_FEATURES: LabFeatureItem[] = [
stage: 'beta',
},
];
+
+export const filterAvailableLabFeatures = (
+ features: LabFeatureItem[],
+ enableBusinessFeatures: boolean,
+): LabFeatureItem[] =>
+ features.filter((feature) => enableBusinessFeatures || !feature.businessOnly);
+
+/**
+ * Single source of truth for the lab experiments: the Labs settings page
+ * renders this list (general first, then desktop-only), and the settings
+ * search index derives its entries from it — adding a flag here makes it both
+ * visible and searchable without a second registration.
+ */
+export const LAB_FEATURES: LabFeatureItem[] = filterAvailableLabFeatures(
+ ALL_LAB_FEATURES,
+ ENABLE_BUSINESS_FEATURES,
+);
diff --git a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.test.tsx b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.test.tsx
index 497f6d115c7..82111f21186 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.test.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.test.tsx
@@ -15,11 +15,30 @@ const autoRenameTopicTitleMock = vi.hoisted(() => vi.fn());
const removeTopicMock = vi.hoisted(() => vi.fn());
const updateTopicTitleMock = vi.hoisted(() => vi.fn());
const useLocationMock = vi.hoisted(() => vi.fn());
+const labState = vi.hoisted(() => ({ enableTopicBugReport: false }));
+const bugReportTargetMock = vi.hoisted(() => vi.fn());
vi.mock('@/business/client/hooks/useAuthorInfo', () => ({
useAuthorInfo: () => ({ fullName: 'Miao Miao' }),
}));
+vi.mock('@/business/client/hooks/useTopicBugReportMenuItem', () => ({
+ useTopicBugReportMenuItem: (target: unknown) => {
+ bugReportTargetMock(target);
+ return { key: 'reportProblem', label: 'topic:actions.reportProblem' };
+ },
+}));
+
+vi.mock('@/store/user', () => ({
+ useUserStore: (selector: (state: typeof labState) => unknown) => selector(labState),
+}));
+
+vi.mock('@/store/user/selectors', () => ({
+ labPreferSelectors: {
+ enableTopicBugReport: (state: typeof labState) => state.enableTopicBugReport,
+ },
+}));
+
vi.mock('@/components/RenameModal', () => ({
openRenameModal: vi.fn(),
}));
@@ -116,6 +135,7 @@ const isActionItem = (
describe('Conversation header action menu', () => {
afterEach(() => {
+ labState.enableTopicBugReport = false;
vi.restoreAllMocks();
Reflect.deleteProperty(document, 'execCommand');
});
@@ -192,4 +212,23 @@ describe('Conversation header action menu', () => {
expect(screen.getByText('topic:info.title')).toBeInTheDocument();
expect(screen.getByText(/Miao Miao.*topic:info.updatedAt/)).toBeInTheDocument();
});
+
+ it('offers the problem report only when its lab is on', () => {
+ useLocationMock.mockReturnValue({ pathname: '/agent/agent-1' });
+ const findReportItem = (items: unknown[]) =>
+ items.find((item) => isActionItem(item) && item.key === 'reportProblem');
+
+ const { rerender, result } = renderHook(() => useMenu());
+ expect(findReportItem(result.current.menuItems())).toBeUndefined();
+
+ labState.enableTopicBugReport = true;
+ rerender();
+
+ expect(findReportItem(result.current.menuItems())).toBeDefined();
+ expect(bugReportTargetMock).toHaveBeenLastCalledWith({
+ agentId: 'agent-1',
+ threadId: undefined,
+ topicId: 'topic-1',
+ });
+ });
});
diff --git a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx
index a84aaf0a1a3..e41c8d80e58 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/HeaderActions/useMenu.tsx
@@ -28,6 +28,7 @@ import { useTranslation } from 'react-i18next';
import { useLocation, useParams } from 'react-router';
import { useAuthorInfo } from '@/business/client/hooks/useAuthorInfo';
+import { useTopicBugReportMenuItem } from '@/business/client/hooks/useTopicBugReportMenuItem';
import { openRenameModal } from '@/components/RenameModal';
import { DOCUMENT_HISTORY_QUERY_LIST_LIMIT } from '@/const/documentHistory';
import { isDesktop } from '@/const/version';
@@ -45,6 +46,8 @@ import { topicSelectors } from '@/store/chat/selectors';
import { useDocumentStore } from '@/store/document';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
interface TopicInfoHeaderProps {
authorName: string;
@@ -84,7 +87,7 @@ export const useMenu = (): { menuHeader?: ReactNode; menuItems: () => DropdownIt
]);
const openTopicInNewWindow = useGlobalStore((s) => s.openTopicInNewWindow);
- const { agentId: activeAgentId, topicId: routeTopicId } = useAgentContext();
+ const { agentId: activeAgentId, threadId, topicId: routeTopicId } = useAgentContext();
const activeTopic = useChatStore((s) =>
routeTopicId ? topicSelectors.getTopicById(routeTopicId)(s) : undefined,
);
@@ -193,6 +196,14 @@ export const useMenu = (): { menuHeader?: ReactNode; menuItems: () => DropdownIt
const topicId = activeTopic?.id;
const topicTitle = activeTopic?.title ?? '';
const isFavorite = !!activeTopic?.favorite;
+
+ const enableTopicBugReport = useUserStore(labPreferSelectors.enableTopicBugReport);
+ const bugReportItem = useTopicBugReportMenuItem({
+ agentId: activeAgentId,
+ threadId: threadId ?? undefined,
+ topicId,
+ });
+
const menuHeader = useMemo<ReactNode | undefined>(() => {
if (!authorInfo?.fullName || !topicId) return undefined;
@@ -292,6 +303,7 @@ export const useMenu = (): { menuHeader?: ReactNode; menuItems: () => DropdownIt
toast.success(t('actions.copySessionIdSuccess', { ns: 'topic' }));
},
},
+ ...(enableTopicBugReport && bugReportItem ? [bugReportItem] : []),
{ type: 'divider' as const },
);
}
@@ -343,6 +355,8 @@ export const useMenu = (): { menuHeader?: ReactNode; menuItems: () => DropdownIt
}, [
topicId,
topicTitle,
+ bugReportItem,
+ enableTopicBugReport,
isFavorite,
activeAgentId,
pathname,
diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.ts
index 6c795e21c64..6adf226fed9 100644
--- a/src/store/user/slices/preference/selectors/labPrefer.ts
+++ b/src/store/user/slices/preference/selectors/labPrefer.ts
@@ -35,4 +35,5 @@ export const labPreferSelectors = {
enableGoals: (s: UserState): boolean =>
s.preference.lab?.enableTopicAcceptance ?? s.preference.lab?.enableGoals ?? false,
enableTaskVerify: (s: UserState): boolean => s.preference.lab?.enableTaskVerify ?? false,
+ enableTopicBugReport: (s: UserState): boolean => s.preference.lab?.enableTopicBugReport ?? false,
};