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(settings): regroup the settings sidebar by user task (#22594)

Arvin Xu0e02f48ce70a
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index e868f709c08..cced9818b0d 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -922,11 +922,11 @@
"environments.visibility.tabs.workspace": "Workspace",
"group.aiConfig": "Agent",
"group.common": "General",
- "group.developer": "Developer",
- "group.personal": "Personal",
+ "group.connection": "Connections",
"group.profile": "Account",
- "group.subscription": "Plans",
- "group.system": "System",
+ "group.resource": "Runtime",
+ "group.subscription": "Plans & Billing",
+ "group.systemDeveloper": "System & Developer",
"groupTab.chat": "Chat",
"groupTab.members": "Members",
"groupTab.meta": "Basic Info",
@@ -3922,7 +3922,6 @@
"workspaceSetting.devices.unknownEnroller": "an unknown member",
"workspaceSetting.group.admin": "Admin",
"workspaceSetting.group.agent": "Agent",
- "workspaceSetting.group.resource": "Resources",
"workspaceSetting.group.workspace": "Workspace",
"workspaceSetting.labels.actions.archive": "Archive",
"workspaceSetting.labels.actions.create": "New label",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 8f11f148e92..902e8f343aa 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -922,11 +922,11 @@
"environments.visibility.tabs.workspace": "工作区",
"group.aiConfig": "智能体",
"group.common": "通用",
- "group.developer": "开发者",
- "group.personal": "个人",
+ "group.connection": "连接",
"group.profile": "账号",
- "group.subscription": "套餐",
- "group.system": "系统",
+ "group.resource": "运行资源",
+ "group.subscription": "订阅与账单",
+ "group.systemDeveloper": "系统与开发者",
"groupTab.chat": "对话",
"groupTab.members": "成员",
"groupTab.meta": "基本信息",
@@ -3922,7 +3922,6 @@
"workspaceSetting.devices.unknownEnroller": "未知成员",
"workspaceSetting.group.admin": "管理",
"workspaceSetting.group.agent": "智能体",
- "workspaceSetting.group.resource": "资源",
"workspaceSetting.group.workspace": "工作区",
"workspaceSetting.labels.actions.archive": "归档",
"workspaceSetting.labels.actions.create": "新建标签",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index fe298b75222..e96ac2e833d 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -963,11 +963,11 @@ export default {
'defaultAgent.title': 'New Agent',
'group.aiConfig': 'Agent',
'group.common': 'General',
- 'group.developer': 'Developer',
- 'group.personal': 'Personal',
+ 'group.connection': 'Connections',
'group.profile': 'Account',
- 'group.subscription': 'Plans',
- 'group.system': 'System',
+ 'group.resource': 'Runtime',
+ 'group.subscription': 'Plans & Billing',
+ 'group.systemDeveloper': 'System & Developer',
'groupTab.chat': 'Chat',
'groupTab.members': 'Members',
'groupTab.meta': 'Basic Info',
@@ -4868,7 +4868,6 @@ When I am ___, I need ___
'subscriptionAccounts.summary': '{{inRotation}} of {{count}} in rotation',
'subscriptionAccounts.updateFailed': "Couldn't update the account. Try again.",
'tab.subscriptionAccounts': 'Subscription Accounts',
- 'workspaceSetting.group.resource': 'Resources',
'taskLabels.actions.addToGroup': 'Add label to group',
'taskLabels.actions.create': 'New label',
'taskLabels.actions.createGroup': 'New group',
diff --git a/src/features/Settings/Layout/Body/index.tsx b/src/features/Settings/Layout/Body/index.tsx
index e69031059b8..56d55a717ea 100644
--- a/src/features/Settings/Layout/Body/index.tsx
+++ b/src/features/Settings/Layout/Body/index.tsx
@@ -12,6 +12,7 @@ import { SettingsTabs } from '@/store/global/initialState';
import { isModifierClick } from '@/utils/navigation';
import { SettingsGroupKey, useCategory } from '../../hooks/useCategory';
+import { useExpandedSettingsGroups } from '../../hooks/useExpandedSettingsGroups';
const Body = memo(() => {
const categoryGroups = useCategory();
@@ -29,6 +30,12 @@ const Body = memo(() => {
return SettingsTabs.Profile;
}, [location.pathname]);
+ const { expandedGroups, onExpandedGroupsChange } = useExpandedSettingsGroups(
+ categoryGroups,
+ activeTab,
+ SettingsGroupKey.System,
+ );
+
return (
<Flexbox gap={4} paddingInline={4}>
<SearchSection scope={searchScope}>
@@ -36,14 +43,7 @@ const Body = memo(() => {
gap={8}
indicatorPlacement="inline"
styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
- defaultValue={[
- SettingsGroupKey.Account,
- SettingsGroupKey.General,
- SettingsGroupKey.Subscription,
- SettingsGroupKey.Agent,
- SettingsGroupKey.System,
- SettingsGroupKey.Developer,
- ]}
+ value={expandedGroups}
items={categoryGroups.map((group) => ({
key: group.key,
title: (
@@ -76,6 +76,7 @@ const Body = memo(() => {
</Flexbox>
),
}))}
+ onValueChange={(keys) => onExpandedGroupsChange(keys as SettingsGroupKey[])}
/>
</SearchSection>
</Flexbox>
diff --git a/src/features/Settings/hooks/useCategory.test.tsx b/src/features/Settings/hooks/useCategory.test.tsx
index 84c3732680e..6158fb7ba12 100644
--- a/src/features/Settings/hooks/useCategory.test.tsx
+++ b/src/features/Settings/hooks/useCategory.test.tsx
@@ -58,45 +58,52 @@ afterEach(() => {
});
describe('settings useCategory', () => {
- // Account-level settings (profile / appearance / hotkeys) form their own
- // group so the workspace sidebar can mirror exactly this set; the General
- // group keeps the personal-scoped data pages.
- it('splits account-level tabs into a leading Account group', () => {
+ const groupKeys = (key: SettingsGroupKey, enableBusinessFeatures = false) => {
const { result } = renderHook(() => useCategory(), {
- wrapper: createWrapper(true),
+ wrapper: createWrapper(true, enableBusinessFeatures),
});
- const accountGroup = result.current.find((group) => group.key === SettingsGroupKey.Account);
- const generalGroup = result.current.find((group) => group.key === SettingsGroupKey.General);
- expect(result.current[0]?.key).toBe(SettingsGroupKey.Account);
- expect(accountGroup?.items.map((item) => item.key)).toEqual([
+ return result.current.find((group) => group.key === key)?.items.map((item) => item.key);
+ };
+
+ it('orders groups with Plans & Billing right after Account', () => {
+ const { result } = renderHook(() => useCategory(), {
+ wrapper: createWrapper(true, true),
+ });
+
+ expect(result.current.map((group) => group.key)).toEqual([
+ SettingsGroupKey.Account,
+ SettingsGroupKey.Subscription,
+ SettingsGroupKey.Agent,
+ SettingsGroupKey.Connection,
+ SettingsGroupKey.Resource,
+ SettingsGroupKey.System,
+ ]);
+ });
+
+ it('keeps preferences, notifications and stats in the Account group', () => {
+ expect(groupKeys(SettingsGroupKey.Account, true)).toEqual([
SettingsTabs.Profile,
SettingsTabs.Appearance,
SettingsTabs.Hotkey,
- SettingsTabs.Integrations,
- ]);
- // Environments is there with no lab switch: a code environment is a
- // definition, written down whether or not there is a drive to run it on.
- expect(generalGroup?.items.map((item) => item.key)).toEqual([
+ SettingsTabs.Notification,
SettingsTabs.Stats,
- SettingsTabs.Devices,
- SettingsTabs.Environments,
]);
- expect(
- result.current.find((group) => group.key === SettingsGroupKey.Agent)?.items.map((i) => i.key),
- ).not.toContain(SettingsTabs.Messenger);
+ });
+
+ it('puts every outside service in the Connection group', () => {
+ expect(groupKeys(SettingsGroupKey.Connection, true)).toEqual([
+ SettingsTabs.Messenger,
+ SettingsTabs.Integrations,
+ SettingsTabs.Connector,
+ SettingsTabs.Creds,
+ ]);
});
// Messenger bots are LobeHub-operated and only configurable from the cloud
// admin, so the tab is a dead end on self-hosted deployments.
- it('shows Messenger in the Account group only with business features on', () => {
+ it('hides Messenger without business features', () => {
expect(getItemKeys()).not.toContain(SettingsTabs.Messenger);
-
- const { result } = renderHook(() => useCategory(), {
- wrapper: createWrapper(true, true),
- });
- const accountGroup = result.current.find((group) => group.key === SettingsGroupKey.Account);
- expect(accountGroup?.items.map((item) => item.key)).toContain(SettingsTabs.Messenger);
});
it('keeps Provider visible when provider settings are enabled', () => {
@@ -120,15 +127,38 @@ describe('settings useCategory', () => {
// The sandbox drives moved to Docs → Sandbox Storage; settings keep only the
// environment definitions.
it('keeps Environments in settings without a sandbox storage tab', () => {
- const { result } = renderHook(() => useCategory(), {
- wrapper: createWrapper(true, true),
- });
- const generalGroup = result.current.find((group) => group.key === SettingsGroupKey.General);
- const keys = generalGroup!.items.map((item) => item.key);
+ const keys = groupKeys(SettingsGroupKey.Resource, true);
expect(keys).toContain(SettingsTabs.Environments);
expect(keys).not.toContain('drive');
});
+ it('lists API Key once when both of its flags are on', () => {
+ useUserStore.setState({
+ preference: {
+ ...initialUserStoreState.preference,
+ general: { ...initialUserStoreState.preference.general, isDevMode: true },
+ },
+ });
+
+ const { result } = renderHook(() => useCategory(), {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ <Provider
+ createStore={() =>
+ initServerConfigStore({
+ featureFlags: { ...mapFeatureFlagsEnvToState({}), showApiKeyManage: true },
+ serverConfig: { aiProvider: {}, telemetry: {} },
+ })
+ }
+ >
+ {children}
+ </Provider>
+ ),
+ });
+ const keys = result.current.flatMap((group) => group.items.map((item) => item.key));
+
+ expect(keys.filter((key) => key === SettingsTabs.APIKey)).toHaveLength(1);
+ });
+
it('shows OAuth Apps when the Labs preference is enabled', () => {
useUserStore.setState({
preference: {
@@ -140,10 +170,8 @@ describe('settings useCategory', () => {
const { result } = renderHook(() => useCategory(), {
wrapper: createWrapper(true),
});
- const developerGroup = result.current.find((group) => group.key === SettingsGroupKey.Developer);
const systemGroup = result.current.find((group) => group.key === SettingsGroupKey.System);
- expect(developerGroup?.items.map((item) => item.key)).toContain(SettingsTabs.OAuthApps);
- expect(systemGroup?.items.map((item) => item.key)).not.toContain(SettingsTabs.OAuthApps);
+ expect(systemGroup?.items.map((item) => item.key)).toContain(SettingsTabs.OAuthApps);
});
});
diff --git a/src/features/Settings/hooks/useCategory.tsx b/src/features/Settings/hooks/useCategory.tsx
index eed8cc57c6c..9288d16695d 100644
--- a/src/features/Settings/hooks/useCategory.tsx
+++ b/src/features/Settings/hooks/useCategory.tsx
@@ -6,10 +6,10 @@ import {
AppWindowIcon,
BellIcon,
Blocks,
- BlocksIcon,
Brain,
BrainCircuit,
ChartColumnBigIcon,
+ ChartPieIcon,
Coins,
ContainerIcon,
CreditCard,
@@ -26,6 +26,7 @@ import {
MessageCircleIcon,
MonitorSmartphoneIcon,
PaletteIcon,
+ PlugIcon,
Sparkles,
TagIcon,
TerminalSquare,
@@ -51,8 +52,8 @@ import { userGeneralSettingsSelectors } from '@/store/user/slices/settings/selec
export enum SettingsGroupKey {
Account = 'account',
Agent = 'agent',
- Developer = 'developer',
- General = 'general',
+ Connection = 'connection',
+ Resource = 'resource',
Subscription = 'subscription',
System = 'system',
}
@@ -97,9 +98,7 @@ export const useCategory = () => {
const categoryGroups: CategoryGroup[] = useMemo(() => {
const groups: CategoryGroup[] = [];
- // Account group — settings that follow the user everywhere (profile,
- // appearance, hotkeys, messenger bindings). Kept as its own group so the
- // workspace settings sidebar can mirror exactly this set.
+ // Account group — who the user is and how the app behaves for them.
const accountItems: CategoryItem[] = [
{
icon: avatarUrl ? <Avatar avatar={avatarUrl} shape={'square'} size={26} /> : undefined,
@@ -116,69 +115,32 @@ export const useCategory = () => {
key: SettingsTabs.Hotkey,
label: t('tab.hotkey'),
},
- // Messenger bindings are a per-user identity (owned by userId), so they
- // live with the account rather than the agent configuration. The bots
- // are LobeHub-operated: their credentials are only ever written by the
- // cloud admin, so a self-hosted deployment has nothing to bind to.
- enableBusinessFeatures && {
- icon: MessageCircleIcon,
- key: SettingsTabs.Messenger,
- label: t('tab.messenger'),
+ (enableBusinessFeatures || isDesktop) && {
+ icon: BellIcon,
+ key: SettingsTabs.Notification,
+ label: t('tab.notification'),
},
- // Third-party integrations (the GitHub App today) are bound to the user
- // or workspace that connected them, so they sit with the account.
- {
- icon: BlocksIcon,
- key: SettingsTabs.Integrations,
- label: t('tab.integrations'),
- },
- ].filter(Boolean) as CategoryItem[];
-
- groups.push({
- items: accountItems,
- key: SettingsGroupKey.Account,
- title: t('group.profile'),
- });
-
- // Personal group — personal-scoped data (stats, devices, notifications).
- const generalItems: CategoryItem[] = [
{
icon: ChartColumnBigIcon,
key: SettingsTabs.Stats,
label: tAuth('tab.stats'),
},
- {
- icon: MonitorSmartphoneIcon,
- key: SettingsTabs.Devices,
- label: t('tab.devices'),
- },
- // Always there: a code environment is a definition, written down before
- // anything runs it, and useful with or without a drive to run it on.
- {
- icon: ContainerIcon,
- key: SettingsTabs.Environments,
- label: t('tab.environments'),
- },
- (enableBusinessFeatures || isDesktop) && {
- icon: BellIcon,
- key: SettingsTabs.Notification,
- label: t('tab.notification'),
- },
].filter(Boolean) as CategoryItem[];
groups.push({
- items: generalItems,
- key: SettingsGroupKey.General,
- title: t('group.personal'),
+ items: accountItems,
+ key: SettingsGroupKey.Account,
+ title: t('group.profile'),
});
- // Personal subscription / billing items. Always shown when business
- // features are enabled — workspace settings live under a separate
- // `/:workspaceSlug/settings/*` surface and never share this sidebar.
+ // Personal subscription / billing items sit right under the account they
+ // belong to. Always shown when business features are enabled — workspace
+ // settings live under a separate `/:workspaceSlug/settings/*` surface and
+ // never share this sidebar.
if (enableBusinessFeatures) {
const subscriptionItems: CategoryItem[] = [
{ icon: Map, key: SettingsTabs.Plans, label: tSubscription('tab.plans') },
- { icon: ChartColumnBigIcon, key: SettingsTabs.Usage, label: t('tab.usage') },
+ { icon: ChartPieIcon, key: SettingsTabs.Usage, label: t('tab.usage') },
{ icon: Coins, key: SettingsTabs.Credits, label: tSubscription('tab.credits') },
{ icon: CreditCard, key: SettingsTabs.Billing, label: tSubscription('tab.billing') },
{ icon: Gift, key: SettingsTabs.Referral, label: tSubscription('tab.referral') },
@@ -191,7 +153,7 @@ export const useCategory = () => {
});
}
- // Agent group
+ // Agent group — which models an agent uses and what it can do.
const agentItems: CategoryItem[] = [
// Provider settings should not depend on Advanced tools: new users may need
// non-LobeHub providers, and desktop users often bring their own API keys.
@@ -210,46 +172,76 @@ export const useCategory = () => {
key: SettingsTabs.Skill,
label: t('tab.skill'),
},
+ ENABLE_TOOL_CHANNEL_SETTINGS && {
+ icon: Wrench,
+ key: SettingsTabs.Tools,
+ label: t('tab.tools'),
+ },
+ {
+ icon: BrainCircuit,
+ key: SettingsTabs.Memory,
+ label: t('tab.memory'),
+ },
{
icon: TagIcon,
key: SettingsTabs.Labels,
label: t('tab.labels'),
},
+ ].filter(Boolean) as CategoryItem[];
+
+ groups.push({
+ items: agentItems,
+ key: SettingsGroupKey.Agent,
+ title: t('group.aiConfig'),
+ });
+
+ // Connection group — the outside services agents can reach, whoever owns
+ // the binding. Every entry here is already the user's own.
+ const connectionItems: CategoryItem[] = [
+ // The bots are LobeHub-operated: their credentials are only ever written
+ // by the cloud admin, so a self-hosted deployment has nothing to bind to.
+ enableBusinessFeatures && {
+ icon: MessageCircleIcon,
+ key: SettingsTabs.Messenger,
+ label: t('tab.messenger'),
+ },
+ {
+ icon: PlugIcon,
+ key: SettingsTabs.Integrations,
+ label: t('tab.integrations'),
+ },
{
icon: Blocks,
key: SettingsTabs.Connector,
label: t('tab.connector'),
},
- {
- icon: BrainCircuit,
- key: SettingsTabs.Memory,
- label: t('tab.memory'),
- },
- ENABLE_TOOL_CHANNEL_SETTINGS && {
- icon: Wrench,
- key: SettingsTabs.Tools,
- label: t('tab.tools'),
- },
{
icon: KeyRound,
key: SettingsTabs.Creds,
label: t('tab.creds'),
},
- showApiKeyManage && {
- icon: KeyIcon,
- key: SettingsTabs.APIKey,
- label: tAuth('tab.apikey'),
- },
].filter(Boolean) as CategoryItem[];
groups.push({
- items: agentItems,
- key: SettingsGroupKey.Agent,
- title: t('group.aiConfig'),
+ items: connectionItems,
+ key: SettingsGroupKey.Connection,
+ title: t('group.connection'),
});
- // System group
- const systemItems: CategoryItem[] = [
+ // Resource group — where agents run.
+ const resourceItems: CategoryItem[] = [
+ {
+ icon: MonitorSmartphoneIcon,
+ key: SettingsTabs.Devices,
+ label: t('tab.devices'),
+ },
+ // Always there: a code environment is a definition, written down before
+ // anything runs it, and useful with or without a drive to run it on.
+ {
+ icon: ContainerIcon,
+ key: SettingsTabs.Environments,
+ label: t('tab.environments'),
+ },
isDesktop && {
icon: EthernetPort,
key: SettingsTabs.Proxy,
@@ -260,6 +252,17 @@ export const useCategory = () => {
key: SettingsTabs.SystemTools,
label: t('tab.systemTools'),
},
+ ].filter(Boolean) as CategoryItem[];
+
+ groups.push({
+ items: resourceItems,
+ key: SettingsGroupKey.Resource,
+ title: t('group.resource'),
+ });
+
+ // System & developer group — low-frequency, so the sidebar starts it
+ // collapsed. API Key has a single home whichever flag turned it on.
+ const systemItems: CategoryItem[] = [
{
icon: Database,
key: SettingsTabs.Storage,
@@ -270,28 +273,12 @@ export const useCategory = () => {
key: SettingsTabs.Trash,
label: t('tab.trash'),
},
- !hideDocs && {
- icon: Info,
- key: SettingsTabs.About,
- label: t('tab.about'),
- },
- ].filter(Boolean) as CategoryItem[];
-
- groups.push({
- items: systemItems,
- key: SettingsGroupKey.System,
- title: t('group.system'),
- });
-
- // Developer group. Advanced comes first, followed by the system-level API
- // Key (dev mode), OAuth apps (lab flag), and the Labs playground.
- const developerItems: CategoryItem[] = [
{
icon: EllipsisIcon,
key: SettingsTabs.Advanced,
label: t('tab.advanced'),
},
- isDevMode && {
+ (showApiKeyManage || isDevMode) && {
icon: KeyIcon,
key: SettingsTabs.APIKey,
label: tAuth('tab.apikey'),
@@ -306,12 +293,17 @@ export const useCategory = () => {
key: SettingsTabs.Labs,
label: tLabs('title'),
},
+ !hideDocs && {
+ icon: Info,
+ key: SettingsTabs.About,
+ label: t('tab.about'),
+ },
].filter(Boolean) as CategoryItem[];
groups.push({
- items: developerItems,
- key: SettingsGroupKey.Developer,
- title: t('group.developer'),
+ items: systemItems,
+ key: SettingsGroupKey.System,
+ title: t('group.systemDeveloper'),
});
return groups;
diff --git a/src/features/Settings/hooks/useExpandedSettingsGroups.test.ts b/src/features/Settings/hooks/useExpandedSettingsGroups.test.ts
new file mode 100644
index 00000000000..84b84c0b168
--- /dev/null
+++ b/src/features/Settings/hooks/useExpandedSettingsGroups.test.ts
@@ -0,0 +1,64 @@
+import { act, renderHook } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { useExpandedSettingsGroups } from './useExpandedSettingsGroups';
+
+const groups = [
+ { items: [{ key: 'profile' }], key: 'account' },
+ { items: [{ key: 'about' }, { key: 'labs' }], key: 'system' },
+];
+
+const setup = (activeTab: string) =>
+ renderHook((tab: string) => useExpandedSettingsGroups(groups, tab, 'system'), {
+ initialProps: activeTab,
+ });
+
+describe('useExpandedSettingsGroups', () => {
+ it('starts the collapsed group closed on any other page', () => {
+ expect(setup('profile').result.current.expandedGroups).toEqual(['account']);
+ });
+
+ it('opens the collapsed group on a deep link into it', () => {
+ expect(setup('about').result.current.expandedGroups).toEqual(['account', 'system']);
+ });
+
+ it('reopens the group when navigation moves into it', () => {
+ const { rerender, result } = setup('profile');
+
+ rerender('labs');
+
+ expect(result.current.expandedGroups).toEqual(['account', 'system']);
+ });
+
+ it('keeps a group the user collapsed on its own page closed', () => {
+ const { result } = setup('about');
+
+ act(() => result.current.onExpandedGroupsChange(['account']));
+
+ expect(result.current.expandedGroups).toEqual(['account']);
+ });
+
+ it('opens the collapsed group when the active entry appears after first render', () => {
+ const { rerender, result } = renderHook(
+ (list: typeof groups) => useExpandedSettingsGroups(list, 'apikey', 'system'),
+ { initialProps: groups },
+ );
+
+ expect(result.current.expandedGroups).toEqual(['account']);
+
+ rerender([groups[0], { items: [{ key: 'apikey' }], key: 'system' }]);
+
+ expect(result.current.expandedGroups).toEqual(['account', 'system']);
+ });
+
+ it('opens a group that appears after first render', () => {
+ const { rerender, result } = renderHook(
+ (list: typeof groups) => useExpandedSettingsGroups(list, 'profile', 'system'),
+ { initialProps: groups },
+ );
+
+ rerender([...groups, { items: [{ key: 'storage' }], key: 'admin' }]);
+
+ expect(result.current.expandedGroups).toEqual(['account', 'admin']);
+ });
+});
diff --git a/src/features/Settings/hooks/useExpandedSettingsGroups.ts b/src/features/Settings/hooks/useExpandedSettingsGroups.ts
new file mode 100644
index 00000000000..797faaa90d1
--- /dev/null
+++ b/src/features/Settings/hooks/useExpandedSettingsGroups.ts
@@ -0,0 +1,41 @@
+import { useState } from 'react';
+
+interface SidebarGroup<GroupKey, TabKey> {
+ items: { key: TabKey }[];
+ key: GroupKey;
+}
+
+/**
+ * Open groups of a settings sidebar, with `collapsedGroup` starting closed.
+ * Tracked as the closed set, so groups that appear later (permissions resolve
+ * after first paint) open by default. Landing on a page inside a closed group
+ * reopens it, including when the page's entry only appears later, so the
+ * active item is never hidden; collapsing the group of the current page
+ * afterwards stays the user's choice.
+ */
+export const useExpandedSettingsGroups = <GroupKey, TabKey>(
+ groups: SidebarGroup<GroupKey, TabKey>[],
+ activeTab: TabKey,
+ collapsedGroup: GroupKey,
+) => {
+ const activeGroup = groups.find((group) =>
+ group.items.some((item) => item.key === activeTab),
+ )?.key;
+
+ const [closedGroups, setClosedGroups] = useState<GroupKey[]>([collapsedGroup]);
+ const [revealed, setRevealed] = useState<{ group?: GroupKey; tab: TabKey }>();
+
+ if (revealed?.tab !== activeTab || revealed.group !== activeGroup) {
+ setRevealed({ group: activeGroup, tab: activeTab });
+ setClosedGroups(closedGroups.filter((key) => key !== activeGroup));
+ }
+
+ const groupKeys = groups.map((group) => group.key);
+
+ return {
+ expandedGroups: groupKeys.filter((key) => !closedGroups.includes(key)),
+ onExpandedGroupsChange: (next: GroupKey[]) => {
+ setClosedGroups(groupKeys.filter((key) => !next.includes(key)));
+ },
+ };
+};
diff --git a/src/features/WorkspaceSetting/SideBar/Body.tsx b/src/features/WorkspaceSetting/SideBar/Body.tsx
index c3d5eaa9ed5..6c329d20e50 100644
--- a/src/features/WorkspaceSetting/SideBar/Body.tsx
+++ b/src/features/WorkspaceSetting/SideBar/Body.tsx
@@ -6,6 +6,7 @@ import { Link } from 'react-router';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
import NavItem from '@/features/NavPanel/components/NavItem';
+import { useExpandedSettingsGroups } from '@/features/Settings/hooks/useExpandedSettingsGroups';
import { SearchSection } from '@/features/SettingsSearch';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveLocation } from '@/hooks/useActiveLocation';
@@ -34,6 +35,12 @@ const Body = memo(() => {
: DEFAULT_WORKSPACE_SETTINGS_TAB;
}, [location.pathname, slug]);
+ const { expandedGroups, onExpandedGroupsChange } = useExpandedSettingsGroups(
+ groups,
+ activeTab,
+ WorkspaceSettingsGroupKey.System,
+ );
+
if (!slug) return null;
return (
@@ -43,16 +50,7 @@ const Body = memo(() => {
gap={8}
indicatorPlacement="inline"
styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
- defaultValue={[
- WorkspaceSettingsGroupKey.Account,
- WorkspaceSettingsGroupKey.General,
- WorkspaceSettingsGroupKey.Resource,
- WorkspaceSettingsGroupKey.Subscription,
- WorkspaceSettingsGroupKey.Agent,
- WorkspaceSettingsGroupKey.Admin,
- WorkspaceSettingsGroupKey.System,
- WorkspaceSettingsGroupKey.Developer,
- ]}
+ value={expandedGroups}
items={groups.map((group) => ({
key: group.key,
title: (
@@ -85,6 +83,7 @@ const Body = memo(() => {
</Flexbox>
),
}))}
+ onValueChange={(keys) => onExpandedGroupsChange(keys as WorkspaceSettingsGroupKey[])}
/>
</SearchSection>
</Flexbox>
diff --git a/src/features/WorkspaceSetting/hooks/useCategory.test.tsx b/src/features/WorkspaceSetting/hooks/useCategory.test.tsx
index cd7246bebd0..630ae11409e 100644
--- a/src/features/WorkspaceSetting/hooks/useCategory.test.tsx
+++ b/src/features/WorkspaceSetting/hooks/useCategory.test.tsx
@@ -85,7 +85,6 @@ describe('workspace settings useCategory', () => {
WorkspaceSettingsTabs.Hotkey,
WorkspaceSettingsTabs.ChatPreference,
WorkspaceSettingsTabs.Messenger,
- WorkspaceSettingsTabs.Integrations,
]);
expect(generalGroup?.items.map((item) => item.key)).not.toContain(
WorkspaceSettingsTabs.Profile,
@@ -97,12 +96,11 @@ describe('workspace settings useCategory', () => {
expect(systemGroup?.items.map((item) => item.key)).toEqual([
WorkspaceSettingsTabs.Trash,
+ WorkspaceSettingsTabs.Advanced,
+ WorkspaceSettingsTabs.Labs,
WorkspaceSettingsTabs.About,
]);
- expect(result.current.map((group) => group.key).slice(-2)).toEqual([
- WorkspaceSettingsGroupKey.System,
- WorkspaceSettingsGroupKey.Developer,
- ]);
+ expect(result.current.at(-1)?.key).toBe(WorkspaceSettingsGroupKey.System);
});
// The drives need no opt-in: every member sees the tab, which shows the
@@ -117,9 +115,12 @@ describe('workspace settings useCategory', () => {
(group) => group.key === WorkspaceSettingsGroupKey.General,
);
- expect(keys.indexOf(WorkspaceSettingsGroupKey.Resource)).toBe(
+ expect(keys.indexOf(WorkspaceSettingsGroupKey.Subscription)).toBe(
keys.indexOf(WorkspaceSettingsGroupKey.General) + 1,
);
+ expect(keys.indexOf(WorkspaceSettingsGroupKey.Resource)).toBe(
+ keys.indexOf(WorkspaceSettingsGroupKey.Connection) + 1,
+ );
expect(resourceGroup?.items.map((item) => item.key)).toEqual([
WorkspaceSettingsTabs.Devices,
WorkspaceSettingsTabs.SubscriptionAccounts,
@@ -132,11 +133,11 @@ describe('workspace settings useCategory', () => {
const adminGroup = result.current.find(
(group) => group.key === WorkspaceSettingsGroupKey.Admin,
);
- const developerGroup = result.current.find(
- (group) => group.key === WorkspaceSettingsGroupKey.Developer,
+ const systemGroup = result.current.find(
+ (group) => group.key === WorkspaceSettingsGroupKey.System,
);
- expect(developerGroup?.items.map((item) => item.key)).toContain(WorkspaceSettingsTabs.APIKey);
+ expect(systemGroup?.items.map((item) => item.key)).toContain(WorkspaceSettingsTabs.APIKey);
expect(adminGroup?.items.map((item) => item.key)).not.toContain(WorkspaceSettingsTabs.APIKey);
const itemKeys = result.current.flatMap((group) => group.items.map((item) => item.key));
@@ -148,11 +149,11 @@ describe('workspace settings useCategory', () => {
expect(itemKeys).toContain(WorkspaceSettingsTabs.Credits);
expect(itemKeys).toContain(WorkspaceSettingsTabs.Billing);
- const accountGroup = result.current.find(
- (group) => group.key === WorkspaceSettingsGroupKey.Account,
+ const connectionGroup = result.current.find(
+ (group) => group.key === WorkspaceSettingsGroupKey.Connection,
);
- expect(accountGroup?.items.map((item) => item.key)).toContain(
+ expect(connectionGroup?.items.map((item) => item.key)).toContain(
WorkspaceSettingsTabs.Integrations,
);
});
@@ -175,16 +176,14 @@ describe('workspace settings useCategory', () => {
});
const { result } = renderHook(() => useWorkspaceSettingCategory(), { wrapper });
- const developerGroup = result.current.find(
- (group) => group.key === WorkspaceSettingsGroupKey.Developer,
+ const systemGroup = result.current.find(
+ (group) => group.key === WorkspaceSettingsGroupKey.System,
);
const agentGroup = result.current.find(
(group) => group.key === WorkspaceSettingsGroupKey.Agent,
);
- expect(developerGroup?.items.map((item) => item.key)).toContain(
- WorkspaceSettingsTabs.OAuthApps,
- );
+ expect(systemGroup?.items.map((item) => item.key)).toContain(WorkspaceSettingsTabs.OAuthApps);
expect(agentGroup?.items.map((item) => item.key)).not.toContain(
WorkspaceSettingsTabs.OAuthApps,
);
@@ -204,22 +203,24 @@ describe('workspace settings useCategory', () => {
// Viewers hold no `API_KEY_*` grant, so the tab would open onto a list
// request that immediately 403s.
- it('hides API Key from viewers but keeps Advanced and Labs in the Developer group', () => {
+ it('hides API Key from viewers but keeps Advanced and Labs in the System group', () => {
mocks.canCreateContent = false;
mocks.canManageWorkspace = false;
const { result } = renderHook(() => useWorkspaceSettingCategory(), { wrapper });
- const developerGroup = result.current.find(
- (group) => group.key === WorkspaceSettingsGroupKey.Developer,
+ const systemGroup = result.current.find(
+ (group) => group.key === WorkspaceSettingsGroupKey.System,
);
- expect(developerGroup?.items.map((item) => item.key)).toEqual([
+ expect(systemGroup?.items.map((item) => item.key)).toEqual([
+ WorkspaceSettingsTabs.Trash,
WorkspaceSettingsTabs.Advanced,
WorkspaceSettingsTabs.Labs,
+ WorkspaceSettingsTabs.About,
]);
});
- it('adds OAuth Apps to the viewer Developer group when the Labs preference is enabled', () => {
+ it('adds OAuth Apps to the viewer System group when the Labs preference is enabled', () => {
mocks.canCreateContent = false;
mocks.canManageWorkspace = false;
useUserStore.setState({
@@ -230,14 +231,16 @@ describe('workspace settings useCategory', () => {
});
const { result } = renderHook(() => useWorkspaceSettingCategory(), { wrapper });
- const developerGroup = result.current.find(
- (group) => group.key === WorkspaceSettingsGroupKey.Developer,
+ const systemGroup = result.current.find(
+ (group) => group.key === WorkspaceSettingsGroupKey.System,
);
- expect(developerGroup?.items.map((item) => item.key)).toEqual([
+ expect(systemGroup?.items.map((item) => item.key)).toEqual([
+ WorkspaceSettingsTabs.Trash,
WorkspaceSettingsTabs.Advanced,
WorkspaceSettingsTabs.OAuthApps,
WorkspaceSettingsTabs.Labs,
+ WorkspaceSettingsTabs.About,
]);
});
diff --git a/src/features/WorkspaceSetting/hooks/useCategory.tsx b/src/features/WorkspaceSetting/hooks/useCategory.tsx
index e1cb081c60e..796353c909a 100644
--- a/src/features/WorkspaceSetting/hooks/useCategory.tsx
+++ b/src/features/WorkspaceSetting/hooks/useCategory.tsx
@@ -5,10 +5,10 @@ import {
AppWindowIcon,
BellIcon,
Blocks,
- BlocksIcon,
Brain,
Building2,
ChartColumnBigIcon,
+ ChartPieIcon,
Coins,
ContainerIcon,
CreditCard,
@@ -26,6 +26,7 @@ import {
MessagesSquareIcon,
MonitorSmartphoneIcon,
PaletteIcon,
+ PlugIcon,
ScrollText,
Sparkles,
TagIcon,
@@ -48,7 +49,7 @@ export enum WorkspaceSettingsGroupKey {
Account = 'account',
Admin = 'admin',
Agent = 'agent',
- Developer = 'developer',
+ Connection = 'connection',
General = 'general',
Resource = 'resource',
Subscription = 'subscription',
@@ -139,13 +140,6 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsTabs.Messenger,
label: t('tab.messenger'),
},
- // An installation connected here belongs to the workspace, so
- // every member sees the same one.
- {
- icon: BlocksIcon,
- key: WorkspaceSettingsTabs.Integrations,
- label: t('tab.integrations'),
- },
],
key: WorkspaceSettingsGroupKey.Account,
title: t('group.profile'),
@@ -181,34 +175,6 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsGroupKey.General,
title: t('workspaceSetting.group.workspace'),
},
- // What the workspace's agents run on and spend: machines, coding-agent
- // subscriptions, code environments and the drive. Each item keeps its
- // own gate; the group only puts the shared capacity in one place.
- {
- items: [
- {
- icon: MonitorSmartphoneIcon,
- key: WorkspaceSettingsTabs.Devices,
- label: t('tab.devices'),
- },
- // The coding-agent accounts are shared capacity every agent routes
- // onto, so taking one in or out of rotation is an admin decision.
- canManageWorkspace && {
- icon: GaugeIcon,
- key: WorkspaceSettingsTabs.SubscriptionAccounts,
- label: t('tab.subscriptionAccounts'),
- },
- // Always there: a code environment is a definition, written down before
- // anything runs it, and useful with or without a drive to run it on.
- {
- icon: ContainerIcon,
- key: WorkspaceSettingsTabs.Environments,
- label: t('tab.environments'),
- },
- ].filter(Boolean) as WorkspaceSettingCategoryItem[],
- key: WorkspaceSettingsGroupKey.Resource,
- title: t('workspaceSetting.group.resource'),
- },
{
items: [
{
@@ -217,7 +183,7 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
label: tSubscription('tab.plans'),
},
{
- icon: ChartColumnBigIcon,
+ icon: ChartPieIcon,
key: WorkspaceSettingsTabs.Usage,
label: t('tab.usage'),
},
@@ -273,6 +239,22 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsTabs.Labels,
label: t('workspaceSetting.tab.labels'),
},
+ ].filter(Boolean) as WorkspaceSettingCategoryItem[],
+ key: WorkspaceSettingsGroupKey.Agent,
+ title: t('workspaceSetting.group.agent'),
+ },
+ // Outside services the workspace's agents can reach. These bindings
+ // belong to the workspace; Messenger stays in Account because it is a
+ // per-user binding.
+ {
+ items: [
+ // An installation connected here belongs to the workspace, so
+ // every member sees the same one.
+ {
+ icon: PlugIcon,
+ key: WorkspaceSettingsTabs.Integrations,
+ label: t('tab.integrations'),
+ },
{
icon: Blocks,
key: WorkspaceSettingsTabs.Connector,
@@ -283,11 +265,37 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsTabs.Creds,
label: t('tab.creds'),
},
- // Messenger lives in the Account group above — it is a per-user
- // binding, not workspace configuration.
+ ],
+ key: WorkspaceSettingsGroupKey.Connection,
+ title: t('group.connection'),
+ },
+ // What the workspace's agents run on and spend: machines, coding-agent
+ // subscriptions, code environments and the drive. Each item keeps its
+ // own gate; the group only puts the shared capacity in one place.
+ {
+ items: [
+ {
+ icon: MonitorSmartphoneIcon,
+ key: WorkspaceSettingsTabs.Devices,
+ label: t('tab.devices'),
+ },
+ // The coding-agent accounts are shared capacity every agent routes
+ // onto, so taking one in or out of rotation is an admin decision.
+ canManageWorkspace && {
+ icon: GaugeIcon,
+ key: WorkspaceSettingsTabs.SubscriptionAccounts,
+ label: t('tab.subscriptionAccounts'),
+ },
+ // Always there: a code environment is a definition, written down before
+ // anything runs it, and useful with or without a drive to run it on.
+ {
+ icon: ContainerIcon,
+ key: WorkspaceSettingsTabs.Environments,
+ label: t('tab.environments'),
+ },
].filter(Boolean) as WorkspaceSettingCategoryItem[],
- key: WorkspaceSettingsGroupKey.Agent,
- title: t('workspaceSetting.group.agent'),
+ key: WorkspaceSettingsGroupKey.Resource,
+ title: t('group.resource'),
},
// The Admin group is available to Admin and Owner.
canManageWorkspace && {
@@ -306,9 +314,12 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsGroupKey.Admin,
title: t('workspaceSetting.group.admin'),
},
- // System group: Storage stays in Admin because it is workspace-scoped
- // there. Trash is visible to every role — the server shows owners the
- // whole bin and members only what they deleted. About is informational.
+ // System & developer sits last and starts collapsed, mirroring the
+ // personal sidebar. Storage stays in Admin because it is
+ // workspace-scoped there. Trash is visible to every role — the server
+ // shows owners the whole bin and members only what they deleted.
+ // Advanced and Labs are user preferences; API Key / OAuth apps keep
+ // their gates.
{
items: [
{
@@ -316,20 +327,6 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsTabs.Trash,
label: t('tab.trash'),
},
- !hideDocs && {
- icon: Info,
- key: WorkspaceSettingsTabs.About,
- label: t('tab.about'),
- },
- ].filter(Boolean) as WorkspaceSettingCategoryItem[],
- key: WorkspaceSettingsGroupKey.System,
- title: t('group.system'),
- },
- // Developer group sits last, mirroring the personal sidebar: Advanced
- // and Labs are user preferences (always shown), API Key / OAuth apps
- // keep their gates.
- {
- items: [
{
icon: EllipsisIcon,
key: WorkspaceSettingsTabs.Advanced,
@@ -350,9 +347,14 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =
key: WorkspaceSettingsTabs.Labs,
label: tLabs('title'),
},
+ !hideDocs && {
+ icon: Info,
+ key: WorkspaceSettingsTabs.About,
+ label: t('tab.about'),
+ },
].filter(Boolean) as WorkspaceSettingCategoryItem[],
- key: WorkspaceSettingsGroupKey.Developer,
- title: t('group.developer'),
+ key: WorkspaceSettingsGroupKey.System,
+ title: t('group.systemDeveloper'),
},
].filter(Boolean) as WorkspaceSettingCategoryGroup[],
[
diff --git a/src/routes/(mobile)/me/settings/features/useCategory.test.tsx b/src/routes/(mobile)/me/settings/features/useCategory.test.tsx
index 64f2084d0a9..0f1fee177a2 100644
--- a/src/routes/(mobile)/me/settings/features/useCategory.test.tsx
+++ b/src/routes/(mobile)/me/settings/features/useCategory.test.tsx
@@ -104,10 +104,8 @@ describe('mobile settings useCategory', () => {
wrapper: createWrapper(true),
});
- const developerGroup = result.current.find((group) => group.key === SettingsGroupKey.Developer);
const systemGroup = result.current.find((group) => group.key === SettingsGroupKey.System);
- expect(developerGroup?.items.map((item) => item.key)).toContain(SettingsTabs.OAuthApps);
- expect(systemGroup?.items.map((item) => item.key)).not.toContain(SettingsTabs.OAuthApps);
+ expect(systemGroup?.items.map((item) => item.key)).toContain(SettingsTabs.OAuthApps);
});
});
diff --git a/src/routes/(mobile)/me/settings/features/useCategory.tsx b/src/routes/(mobile)/me/settings/features/useCategory.tsx
index 00535a3e4f0..1919c43a5fc 100644
--- a/src/routes/(mobile)/me/settings/features/useCategory.tsx
+++ b/src/routes/(mobile)/me/settings/features/useCategory.tsx
@@ -6,6 +6,7 @@ import {
Brain,
BrainCircuit,
ChartColumnBigIcon,
+ ChartPieIcon,
Coins,
CreditCard,
Database,
@@ -38,7 +39,7 @@ import { userGeneralSettingsSelectors } from '@/store/user/slices/settings/selec
export enum SettingsGroupKey {
Agent = 'agent',
- Developer = 'developer',
+ Connection = 'connection',
General = 'general',
Subscription = 'subscription',
System = 'system',
@@ -85,7 +86,7 @@ export const useCategory = (): CategoryGroup[] => {
? [
makeItem({ icon: Map, key: SettingsTabs.Plans, label: t('subscription:tab.plans') }),
makeItem({
- icon: ChartColumnBigIcon,
+ icon: ChartPieIcon,
key: SettingsTabs.Usage,
label: t('setting:tab.usage'),
}),
@@ -119,33 +120,31 @@ export const useCategory = (): CategoryGroup[] => {
}),
makeItem({ icon: SkillsIcon, key: SettingsTabs.Skill, label: t('setting:tab.skill') }),
makeItem({ icon: TagIcon, key: SettingsTabs.Labels, label: t('setting:tab.labels') }),
- makeItem({ icon: Blocks, key: SettingsTabs.Connector, label: t('setting:tab.connector') }),
makeItem({ icon: BrainCircuit, key: SettingsTabs.Memory, label: t('setting:tab.memory') }),
ENABLE_TOOL_CHANNEL_SETTINGS &&
makeItem({ icon: Wrench, key: SettingsTabs.Tools, label: t('setting:tab.tools') }),
- makeItem({ icon: KeyRound, key: SettingsTabs.Creds, label: t('setting:tab.creds') }),
- showApiKeyManage &&
- makeItem({ icon: KeyIcon, key: SettingsTabs.APIKey, label: t('auth:tab.apikey') }),
].filter((item): item is CategoryItem => Boolean(item));
- const developer: CategoryItem[] = [
- enableOAuthApps &&
- makeItem({
- icon: AppWindowIcon,
- key: SettingsTabs.OAuthApps,
- label: t('auth:tab.oauthApps'),
- }),
- ].filter((item): item is CategoryItem => Boolean(item));
+ const connection: CategoryItem[] = [
+ makeItem({ icon: Blocks, key: SettingsTabs.Connector, label: t('setting:tab.connector') }),
+ makeItem({ icon: KeyRound, key: SettingsTabs.Creds, label: t('setting:tab.creds') }),
+ ];
const system: CategoryItem[] = [
makeItem({ icon: Database, key: SettingsTabs.Storage, label: t('setting:tab.storage') }),
- isDevMode &&
- makeItem({ icon: KeyIcon, key: SettingsTabs.APIKey, label: t('auth:tab.apikey') }),
makeItem({
icon: EllipsisIcon,
key: SettingsTabs.Advanced,
label: t('setting:tab.advanced'),
}),
+ (showApiKeyManage || isDevMode) &&
+ makeItem({ icon: KeyIcon, key: SettingsTabs.APIKey, label: t('auth:tab.apikey') }),
+ enableOAuthApps &&
+ makeItem({
+ icon: AppWindowIcon,
+ key: SettingsTabs.OAuthApps,
+ label: t('auth:tab.oauthApps'),
+ }),
!hideDocs && makeItem({ icon: Info, key: SettingsTabs.About, label: t('setting:tab.about') }),
].filter((item): item is CategoryItem => Boolean(item));
@@ -157,12 +156,8 @@ export const useCategory = (): CategoryGroup[] => {
title: t('setting:group.subscription'),
},
{ items: agent, key: SettingsGroupKey.Agent, title: t('setting:group.aiConfig') },
- { items: system, key: SettingsGroupKey.System, title: t('setting:group.system') },
- {
- items: developer,
- key: SettingsGroupKey.Developer,
- title: t('setting:group.developer'),
- },
+ { items: connection, key: SettingsGroupKey.Connection, title: t('setting:group.connection') },
+ { items: system, key: SettingsGroupKey.System, title: t('setting:group.systemDeveloper') },
].filter((group) => group.items.length > 0);
}, [
t,