🤯 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(settings): merge environments and the vault into one entry with two tabs (#23547)
Rdmclin2c47510e35793
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex 953e9989855..c0bccbece3a 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -505,7 +505,6 @@"creds.form.uploadHint": "Click or drag file to upload","creds.form.valuePlaceholder": "Enter value","creds.form.values": "Key-Value Pairs",- "creds.listDesc": "Shared credentials everyone in this workspace can use, plus your private ones (marked with a lock). New credentials start private; publish one to share it with the workspace.","creds.oauth.noConnections": "No OAuth connections available. Please connect an account first.","creds.orgSetupRequired": "Community Profile not set up yet. Please complete the workspace Community Profile setup to manage credentials.","creds.owner.fromPersonal": "From your personal account",@@ -555,6 +554,9 @@"creds.viewerHint": "Viewers can't create credentials","creds.visibility.publish": "Publish to Workspace","creds.visibility.publishConfirmTitle": "Publish this credential to the workspace?",+ "creds.writeOnly.editHint": "Stored values are not shown. Leave the pairs empty to keep them, or enter every pair to replace them all.",+ "creds.writeOnly.tag": "Write-only",+ "creds.writeOnly.tooltip": "Shared with the workspace: its values are no longer shown in settings and can only be replaced.","danger.reset.action": "Reset Now","danger.reset.confirm": "Reset all settings?","danger.reset.currentVersion": "Current Version",@@ -771,6 +773,8 @@"devices.status.online": "Online","devices.status.onlineConnections_one": "Online · {{count}} connection","devices.status.onlineConnections_other": "Online · {{count}} connections",+ "devices.summary_one": "{{count}} device",+ "devices.summary_other": "{{count}} devices","devices.thisComputer": "This Computer","devices.title": "My Devices","devices.visibility.publish": "Publish to Workspace",@@ -1146,7 +1150,8 @@"environments.visibility.publish": "Publish to Workspace","environments.visibility.publishConfirmTitle": "Publish this environment to the workspace?","environments.visibility.readonlyHint": "Published to this workspace by its creator: you can initialize with this environment, but only they can change it.",- "environments.workspaceListDesc": "Environments published to this workspace, plus your private ones (marked with a lock). New environments start private; publish one to share it with the workspace.",+ "environmentsAndCreds.tabs.environments": "Environments",+ "environmentsAndCreds.tabs.vault": "Vault","group.aiConfig": "Agent","group.common": "General","group.connection": "Connections",@@ -2452,9 +2457,10 @@"tab.chatPreference": "Chat Preferences","tab.common": "Appearance","tab.connector": "Connectors",- "tab.creds": "Credentials",+ "tab.creds": "Vault","tab.devices": "Devices","tab.environments": "Environments",+ "tab.environmentsAndCreds": "Environments & Vault","tab.experiment": "Experiment","tab.hotkey": "Hotkeys","tab.image": "Image Generation",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex 9936521e904..acd456a4aa7 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -505,7 +505,6 @@"creds.form.uploadHint": "点击或拖拽文件上传","creds.form.valuePlaceholder": "输入值","creds.form.values": "键值对",- "creds.listDesc": "工作区成员都能使用的共享凭证,以及你的私人凭证(带锁图标)。新建的凭证默认私人,发布到工作区后成员即可使用。","creds.oauth.noConnections": "暂无可用的 OAuth 连接,请先连接账户。","creds.orgSetupRequired": "社区资料尚未设置,请先完成工作区的社区资料设置,再管理凭证。","creds.owner.fromPersonal": "来自个人账号",@@ -555,6 +554,9 @@"creds.viewerHint": "查看者无法创建凭证","creds.visibility.publish": "发布到工作区","creds.visibility.publishConfirmTitle": "将此凭证发布到工作区?",+ "creds.writeOnly.editHint": "已保存的值不会显示。键值对留空则保留原值;填写则用填写的全部键值对替换。",+ "creds.writeOnly.tag": "只写",+ "creds.writeOnly.tooltip": "已共享到工作区:设置里不再显示值,只能替换。","danger.reset.action": "立即重置","danger.reset.confirm": "确认重置所有设置吗?","danger.reset.currentVersion": "当前版本",@@ -771,6 +773,8 @@"devices.status.online": "在线","devices.status.onlineConnections_one": "在线 · {{count}} 个连接","devices.status.onlineConnections_other": "在线 · {{count}} 个连接",+ "devices.summary_one": "共 {{count}} 台设备",+ "devices.summary_other": "共 {{count}} 台设备","devices.thisComputer": "这台电脑","devices.title": "我的设备","devices.visibility.publish": "发布到工作区",@@ -1146,7 +1150,8 @@"environments.visibility.publish": "发布到工作区","environments.visibility.publishConfirmTitle": "把这个环境发布到工作区?","environments.visibility.readonlyHint": "由创建者发布到此工作区:你可以用这个环境做初始化,但只有创建者能修改它。",- "environments.workspaceListDesc": "发布到工作区的环境,以及你的私人环境(带锁图标)。新建的环境默认私人,发布到工作区后成员即可使用。",+ "environmentsAndCreds.tabs.environments": "环境",+ "environmentsAndCreds.tabs.vault": "密码库","group.aiConfig": "智能体","group.common": "通用","group.connection": "连接",@@ -2452,9 +2457,10 @@"tab.chatPreference": "对话偏好","tab.common": "外观","tab.connector": "连接器",- "tab.creds": "凭证管理",+ "tab.creds": "密码库","tab.devices": "设备","tab.environments": "环境",+ "tab.environmentsAndCreds": "环境与密码库","tab.experiment": "实验","tab.hotkey": "快捷键","tab.image": "绘画服务",diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex d6147939187..87426cabd8f 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1073,6 +1073,8 @@ export default {'devices.status.onlineConnections_one': 'Online · {{count}} connection','devices.status.onlineConnections_other': 'Online · {{count}} connections','devices.title': 'My Devices',+ 'devices.summary_one': '{{count}} device',+ 'devices.summary_other': '{{count}} devices','devices.visibility.publish': 'Publish to Workspace','devices.visibility.publishConfirmTitle': 'Publish this device to the workspace?','devices.visibilityTabs.private': 'Private',@@ -2311,7 +2313,7 @@ When I am ___, I need ___'tab.chatPreference': 'Chat Preferences','tab.common': 'Appearance','tab.connector': 'Connectors',- 'tab.creds': 'Credentials',+ 'tab.creds': 'Vault','tab.devices': 'Devices','tab.experiment': 'Experiment','tab.hotkey': 'Hotkeys',@@ -4800,6 +4802,14 @@ When I am ___, I need ___'tools.tabs.installed': 'Enabled','tools.title': 'Skills','tab.environments': 'Environments',+ 'tab.environmentsAndCreds': 'Environments & Vault',+ 'environmentsAndCreds.tabs.environments': 'Environments',+ 'environmentsAndCreds.tabs.vault': 'Vault',+ 'creds.writeOnly.tag': 'Write-only',+ 'creds.writeOnly.tooltip':+ 'Shared with the workspace: its values are no longer shown in settings and can only be replaced.',+ 'creds.writeOnly.editHint':+ 'Stored values are not shown. Leave the pairs empty to keep them, or enter every pair to replace them all.','environments.desc':"How to set up a project: the repository to check out, the setup command, the variables. Pick one from the environment menu under the chat input, and the conversation's working directory — a temporary sandbox or a folder on your drive — is initialized from it once.",'environments.create': 'New environment',@@ -5465,10 +5475,6 @@ When I am ___, I need ___'environments.form.bootstrapAfterRepositories':"Runs at the top of the working directory, after each repository's own setup. Setup for a single repository goes on that repository.",'environments.form.duplicateFolder': 'Another repository already uses this folder.',- 'creds.listDesc':- 'Shared credentials everyone in this workspace can use, plus your private ones (marked with a lock). New credentials start private; publish one to share it with the workspace.',- 'environments.workspaceListDesc':- 'Environments published to this workspace, plus your private ones (marked with a lock). New environments start private; publish one to share it with the workspace.','workspaceSetting.devices.enrollPrivateDesc':'Run this on the machine you want to connect. It starts private to you; publish it to the workspace from its card menu.',};diff --git a/src/components/VisibilityFilter/index.tsx b/src/components/VisibilityFilter/index.tsxindex bfd0c5e81d4..66eb26940bf 100644--- a/src/components/VisibilityFilter/index.tsx+++ b/src/components/VisibilityFilter/index.tsx@@ -16,8 +16,6 @@ const ICONS: Record<VisibilityFilterValue, LucideIcon> = {};interface VisibilityFilterProps {- /** Rows per option, shown beside its label. */- counts?: Record<VisibilityFilterValue, number>;onChange: (value: VisibilityFilterValue) => void;value: VisibilityFilterValue;}@@ -25,9 +23,11 @@ interface VisibilityFilterProps {/*** The header filter of a workspace resource list that shows private and shared* rows together (devices, subscription accounts, environments, credentials).- * It defaults to everything; the rows themselves carry the lock.+ * It defaults to everything; the rows themselves carry the lock. Options carry+ * no counts: a count per option ignores the page's other filters, so the+ * page's own summary reports how many rows the filters leave instead.*/-const VisibilityFilter = memo<VisibilityFilterProps>(({ counts, onChange, value }) => {+const VisibilityFilter = memo<VisibilityFilterProps>(({ onChange, value }) => {const { t } = useTranslation('common');return (@@ -40,9 +40,7 @@ const VisibilityFilter = memo<VisibilityFilterProps>(({ counts, onChange, valuelabel: (<Flexbox horizontal align={'center'} gap={6}><Icon icon={ICONS[option]} size={14} />- {counts- ? `${t(`visibilityFilter.${option}`)} · ${counts[option]}`- : t(`visibilityFilter.${option}`)}+ {t(`visibilityFilter.${option}`)}</Flexbox>),value: option,diff --git a/src/features/DeviceManager/DeviceManager.tsx b/src/features/DeviceManager/DeviceManager.tsxindex ff0545d258f..c75218b2107 100644--- a/src/features/DeviceManager/DeviceManager.tsx+++ b/src/features/DeviceManager/DeviceManager.tsx@@ -2,7 +2,16 @@import { isDesktop } from '@lobechat/const';import type { DeviceScope, DeviceVisibility } from '@lobechat/types';-import { Button, createStaticStyles, cssVar, Empty, Flexbox, Icon, Text } from '@lobehub/ui';+import {+ ActionIcon,+ Button,+ createStaticStyles,+ cssVar,+ Empty,+ Flexbox,+ Icon,+ Text,+} from '@lobehub/ui';import {ChevronRightIcon,FolderCogIcon,@@ -343,23 +352,8 @@ const DeviceManager = memo<DeviceManagerProps>((props) => {const renderActions = (size?: 'small') => (<Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>{showVisibilityFilter && (- <VisibilityFilter- value={visibilityFilter}- counts={{- all: devices.length,- private: devices.filter(isPrivateDevice).length,- workspace: devices.filter((d) => !isPrivateDevice(d)).length,- }}- onChange={setVisibilityFilter}- />+ <VisibilityFilter value={visibilityFilter} onChange={setVisibilityFilter} />)}- <Button- icon={<Icon icon={RefreshCwIcon} />}- loading={isValidating}- size={size}- title={t('devices.actions.refresh')}- onClick={() => mutate()}- />{showManagedDeviceCreate && (<ManagedDeviceCreateEntryplacement={'toolbar'}@@ -386,11 +380,27 @@ const DeviceManager = memo<DeviceManagerProps>((props) => {{t('devices.connectWizard.button')}</Button>)}+ {/* Last, as on the subscription accounts page: refreshing is secondary to+ adding a device. */}+ <ActionIcon+ loading={isValidating}+ size={size}+ title={t('devices.actions.refresh')}+ onClick={() => mutate()}+ icon={RefreshCwIcon}+ // A row that runs short of width shrinks its children; the icon keeps its square.+ style={{ flex: 'none' }}+ /></Flexbox>);+ // How many devices the filter leaves, on the left of the toolbar, as the+ // subscription accounts summary does.const toolbar = (- <Flexbox horizontal align={'center'} justify={'flex-end'}>+ <Flexbox horizontal align={'center'} gap={12} justify={'space-between'} wrap={'wrap'}>+ <Text fontSize={13} type={'secondary'}>+ {devices.length > 0 && t('devices.summary', { count: visibleDevices.length })}+ </Text>{renderActions()}</Flexbox>);diff --git a/src/features/EnvironmentManager/index.tsx b/src/features/EnvironmentManager/index.tsxindex 65c19eb136a..3590a1c328b 100644--- a/src/features/EnvironmentManager/index.tsx+++ b/src/features/EnvironmentManager/index.tsx@@ -2,6 +2,7 @@import type { EnvironmentVisibility } from '@lobechat/types';import {+ ActionIcon,Button,Center,createStaticStyles,@@ -77,10 +78,16 @@ interface EnvironmentManagerProps {headerLeading?: ReactNode;/** Open one environment's page. */onOpenEnvironment: (id: string) => void;+ /**+ * A filter the host owns, when one header filter narrows several lists at+ * once (environments and credentials share a page). The manager then shows+ * no filter of its own.+ */+ visibilityFilter?: VisibilityFilterValue;}const EnvironmentManager = memo<EnvironmentManagerProps>(- ({ createVisibility, headerLeading, onOpenEnvironment }) => {+ ({ createVisibility, headerLeading, onOpenEnvironment, visibilityFilter: hostFilter }) => {const { t } = useTranslation('setting');// `settled`: a list to paint — the stored one on a reload, confirmed behind// it. A stored empty list waits for the server.@@ -92,13 +99,15 @@ const EnvironmentManager = memo<EnvironmentManagerProps>(const list = environments ?? [];// Workspace pages only (where a new environment has a pool to land in):// narrow the one list to private or published environments.- const [visibilityFilter, setVisibilityFilter] = useState<VisibilityFilterValue>('all');+ const [ownFilter, setVisibilityFilter] = useState<VisibilityFilterValue>('all');+ const visibilityFilter = hostFilter ?? ownFilter;const isPrivateEnvironment = (environment: (typeof list)[number]) =>!!environment.workspaceId && environment.visibility === 'private';- const showVisibilityFilter = !!createVisibility && list.length > 0;- const visibleList = showVisibilityFilter- ? list.filter((e) => matchesVisibilityFilter(isPrivateEnvironment(e), visibilityFilter))- : list;+ const showVisibilityFilter = !hostFilter && !!createVisibility && list.length > 0;+ const visibleList =+ createVisibility || hostFilter+ ? list.filter((e) => matchesVisibilityFilter(isPrivateEnvironment(e), visibilityFilter))+ : list;// Open what was just made. Nothing is built: an environment is applied to// a working directory when a conversation picks it.@@ -130,22 +139,8 @@ const EnvironmentManager = memo<EnvironmentManagerProps>(// neighbour.<Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>{showVisibilityFilter && (- <VisibilityFilter- value={visibilityFilter}- counts={{- all: list.length,- private: list.filter(isPrivateEnvironment).length,- workspace: list.filter((e) => !isPrivateEnvironment(e)).length,- }}- onChange={setVisibilityFilter}- />+ <VisibilityFilter value={visibilityFilter} onChange={setVisibilityFilter} />)}- <Button- icon={<Icon icon={RefreshCwIcon} />}- loading={refreshing}- title={t('environments.refresh')}- onClick={refresh}- /><Buttonicon={<Icon icon={PlusIcon} />}type={'primary'}@@ -153,6 +148,15 @@ const EnvironmentManager = memo<EnvironmentManagerProps>(>{t('environments.create')}</Button>+ {/* Last and borderless, as on the subscription accounts page. */}+ <ActionIcon+ loading={refreshing}+ title={t('environments.refresh')}+ onClick={refresh}+ icon={RefreshCwIcon}+ // A row that runs short of width shrinks its children; the icon keeps its square.+ style={{ flex: 'none' }}+ /></Flexbox>);diff --git a/src/features/EnvironmentsAndCreds/PageTabs.tsx b/src/features/EnvironmentsAndCreds/PageTabs.tsxnew file mode 100644index 00000000000..904dddcf283--- /dev/null+++ b/src/features/EnvironmentsAndCreds/PageTabs.tsx@@ -0,0 +1,40 @@+'use client';++import { Tabs } from '@lobehub/ui';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { type PageTab } from './const';++interface PageTabsProps {+ onChange: (tab: PageTab) => void;+ value: PageTab;+}++/**+ * The two tabs of the Environments & Vault page. They sit at the left of the+ * open tab's header row, beside that tab's own filter and create button, so+ * the page has one header row. The tabs fill their parent by default, which+ * would push those actions onto a second line, so they take only their own+ * width.+ */+const PageTabs = memo<PageTabsProps>(({ onChange, value }) => {+ const { t } = useTranslation('setting');++ return (+ <Tabs+ activeKey={value}+ style={{ flex: 'none', width: 'fit-content' }}+ variant={'rounded'}+ items={[+ { key: 'environments', label: t('environmentsAndCreds.tabs.environments') },+ { key: 'vault', label: t('environmentsAndCreds.tabs.vault') },+ ]}+ onChange={(key) => onChange(key as PageTab)}+ />+ );+});++PageTabs.displayName = 'EnvironmentsAndVaultTabs';++export default PageTabs;diff --git a/src/features/EnvironmentsAndCreds/PersonalVault.tsx b/src/features/EnvironmentsAndCreds/PersonalVault.tsxnew file mode 100644index 00000000000..271855d9ea2--- /dev/null+++ b/src/features/EnvironmentsAndCreds/PersonalVault.tsx@@ -0,0 +1,58 @@+'use client';++import { Button, Flexbox, Icon, Tooltip } from '@lobehub/ui';+import { Plus } from 'lucide-react';+import { memo, type ReactNode, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { createCreateCredModal } from '@/features/Settings/creds/features/CreateCredModal';+import CredsList from '@/features/Settings/creds/features/CredsList';+import { personalCredsApi } from '@/features/Settings/creds/features/useCredsApi';+import { usePermission } from '@/hooks/usePermission';++interface PersonalVaultProps {+ /** The page tabs, at the left of the header row. */+ headerLeading: ReactNode;+}++/**+ * The vault tab of the personal Environments & Vault page: every credential+ * here is the caller's own, so there is nothing to filter.+ */+const PersonalVault = memo<PersonalVaultProps>(({ headerLeading }) => {+ const { t } = useTranslation('setting');+ const { allowed: canManageCredentials, reason } = usePermission('manage_provider_key');+ const [refreshKey, setRefreshKey] = useState(0);++ const handleCreate = () => {+ if (!canManageCredentials) return;+ createCreateCredModal({+ credsApi: personalCredsApi,+ onSuccess: () => setRefreshKey((k) => k + 1),+ });+ };++ return (+ <Flexbox gap={16}>+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'} wrap={'wrap'}>+ {headerLeading}+ <Tooltip title={reason}>+ <Button+ disabled={!canManageCredentials}+ icon={<Icon icon={Plus} />}+ style={{ flex: 'none' }}+ type={'primary'}+ onClick={handleCreate}+ >+ {t('creds.create')}+ </Button>+ </Tooltip>+ </Flexbox>+ <CredsList key={refreshKey} />+ </Flexbox>+ );+});++PersonalVault.displayName = 'PersonalVault';++export default PersonalVault;diff --git a/src/routes/(main)/[workspaceSlug]/settings/credential/index.tsx b/src/features/EnvironmentsAndCreds/WorkspaceVault.tsxsimilarity index 70%rename from src/routes/(main)/[workspaceSlug]/settings/credential/index.tsxrename to src/features/EnvironmentsAndCreds/WorkspaceVault.tsxindex 8bfef44fb5d..318395799a6 100644--- a/src/routes/(main)/[workspaceSlug]/settings/credential/index.tsx+++ b/src/features/EnvironmentsAndCreds/WorkspaceVault.tsx@@ -1,10 +1,9 @@'use client';-import { Block, Button, Empty, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import { Block, Button, Empty, Flexbox, Icon, Tooltip } from '@lobehub/ui';import * as stylex from '@stylexjs/stylex';import { Plus } from 'lucide-react';-import { useState } from 'react';+import { memo, type ReactNode, useState } from 'react';import { useTranslation } from 'react-i18next';import { useIsWorkspaceViewer } from '@/business/client/hooks/useIsWorkspaceViewer';@@ -24,7 +23,6 @@ const styles = stylex.create({paddingBlock: '4px',paddingInline: densityTokens['--lobe-density-card-padding'],},- desc: { fontSize: '13px', color: cssVar.colorTextSecondary },});type Visibility = 'private' | 'public';@@ -44,37 +42,45 @@ interface WorkspaceCredsClient {const workspaceClient = lambdaClient.workspaceCreds as unknown as CredsApi['client'] &WorkspaceCredsClient;-const workspaceCredsApi = (createVisibility: Visibility): CredsApi => ({- client: workspaceClient,- createVisibility,- query: lambdaQuery.workspaceCreds as unknown as CredsApi['query'],- setVisibility: (id, visibility) => workspaceClient.setVisibility.mutate({ id, visibility }),-});-/*** A new credential starts private: any non-viewer member may create one, and* nothing is shared until its row's "Publish to Workspace" says so.*/-const credsApi = workspaceCredsApi('private');+const credsApi: CredsApi = {+ client: workspaceClient,+ createVisibility: 'private',+ query: lambdaQuery.workspaceCreds as unknown as CredsApi['query'],+ setVisibility: (id, visibility) => workspaceClient.setVisibility.mutate({ id, visibility }),+};++interface WorkspaceVaultProps {+ /** The page tabs, at the left of the header row. */+ headerLeading: ReactNode;+}/**- * Workspace credential management: one list of every credential the caller- * can use here — the shared ones (the workspace's own and members' personal- * credentials published here) and the caller's private ones, marked with a- * lock. Personal credentials are shared in from the personal settings page- * ("Share to Workspace…"), not listed here wholesale.+ * The vault tab of the workspace Environments & Vault page: every credential+ * the caller can use here — the shared ones (the+ * workspace's own and members' personal credentials published here) and the+ * caller's private ones, marked with a lock. Personal credentials are shared+ * in from the personal settings page ("Share to Workspace…").** When the workspace has no Market organization yet (Community Profile not- * completed), the backend returns NOT_FOUND and the page shows a setup prompt.+ * completed), the backend returns NOT_FOUND and the section shows a setup+ * prompt.+ *+ * Like the other workspace resource lists it shows everything by default; the+ * header filter narrows it to the shared or the caller's private credentials.*/-const WorkspaceCredsSetting = () => {+const WorkspaceVault = memo<WorkspaceVaultProps>(({ headerLeading }) => {const { t } = useTranslation('setting');const { isAuthenticated } = useMarketAuth();const isViewer = useIsWorkspaceViewer();+ const [visibilityFilter, setVisibilityFilter] = useState<VisibilityFilterValue>('all');// Shares its query key with the list inside WorkspaceCredsList, so// `refetch` here refreshes the list.- const { data, error, isLoading, refetch } = credsApi.query.list.useQuery(undefined, {+ const { error, isLoading, refetch } = credsApi.query.list.useQuery(undefined, {enabled: isAuthenticated,// No retry for NOT_FOUND — the org won't materialise on its own.// Cap retries for other errors (500s, network) so failures surface instead of looping.@@ -87,13 +93,8 @@ const WorkspaceCredsSetting = () => {const orgMissing = isAuthenticated && !isLoading && error?.data?.code === 'NOT_FOUND';- const [visibilityFilter, setVisibilityFilter] = useState<VisibilityFilterValue>('all');- const credentials = data?.data ?? [];- const privateCount = credentials.filter((cred) => cred.visibility === 'private').length;-// New credentials are private, which any non-viewer member may create.const canCreate = !isViewer;- const createBlockedReason = isViewer ? t('creds.viewerHint') : '';const handleCreate = () => {if (!canCreate) return;@@ -113,26 +114,16 @@ const WorkspaceCredsSetting = () => {return (<Flexbox gap={16}>- <Flexbox horizontal align={'center'} gap={16} justify={'space-between'}>- <Text className={stylex.props(styles.desc).className}>{t('creds.listDesc')}</Text>+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'} wrap={'wrap'}>+ {headerLeading}{isAuthenticated && !orgMissing && (<Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>- {credentials.length > 0 && (- <VisibilityFilter- value={visibilityFilter}- counts={{- all: credentials.length,- private: privateCount,- workspace: credentials.length - privateCount,- }}- onChange={setVisibilityFilter}- />- )}+ <VisibilityFilter value={visibilityFilter} onChange={setVisibilityFilter} />{// Disabled buttons swallow hover events, so the tooltip needs the// span wrapper to fire (see the usePermission docstring pattern).- createBlockedReason ? (- <Tooltip title={createBlockedReason}>+ isViewer ? (+ <Tooltip title={t('creds.viewerHint')}><span>{createButton}</span></Tooltip>) : (@@ -155,8 +146,8 @@ const WorkspaceCredsSetting = () => {</Block></Flexbox>);-};+});-WorkspaceCredsSetting.displayName = 'WorkspaceCredsSetting';+WorkspaceVault.displayName = 'WorkspaceVault';-export default WorkspaceCredsSetting;+export default WorkspaceVault;diff --git a/src/features/EnvironmentsAndCreds/const.ts b/src/features/EnvironmentsAndCreds/const.tsnew file mode 100644index 00000000000..ab79b69e27a--- /dev/null+++ b/src/features/EnvironmentsAndCreds/const.ts@@ -0,0 +1,12 @@+/** The search param naming the open tab of the Environments & Vault page. */+export const TAB_PARAM = 'tab';++export const PAGE_TABS = ['environments', 'vault'] as const;++export type PageTab = (typeof PAGE_TABS)[number];++/**+ * Opens the vault tab. Old credential links (`/settings/credential`) land on+ * the merged page with it.+ */+export const VAULT_TAB_SEARCH = `?${TAB_PARAM}=vault`;diff --git a/src/features/EnvironmentsAndCreds/usePageTab.test.ts b/src/features/EnvironmentsAndCreds/usePageTab.test.tsnew file mode 100644index 00000000000..ce9b9301668--- /dev/null+++ b/src/features/EnvironmentsAndCreds/usePageTab.test.ts@@ -0,0 +1,42 @@+import { act, renderHook } from '@testing-library/react';+import { createElement, type ReactNode } from 'react';+import { MemoryRouter, useLocation } from 'react-router';+import { describe, expect, it } from 'vitest';++import { VAULT_TAB_SEARCH } from './const';+import { usePageTab } from './usePageTab';++const render = (initialEntry: string) =>+ renderHook(+ () => {+ const [tab, setTab] = usePageTab();+ return { search: useLocation().search, setTab, tab };+ },+ {+ wrapper: ({ children }: { children: ReactNode }) =>+ createElement(MemoryRouter, { initialEntries: [initialEntry] }, children),+ },+ );++describe('usePageTab', () => {+ it('opens environments by default and on unknown values', () => {+ expect(render('/settings/environments').result.current.tab).toBe('environments');+ expect(render('/settings/environments?tab=nope').result.current.tab).toBe('environments');+ });++ it('opens the vault from the link old credential URLs redirect to', () => {+ expect(render(`/settings/environments${VAULT_TAB_SEARCH}`).result.current.tab).toBe('vault');+ });++ it('keeps the tab in the URL and leaves it clean for environments', () => {+ const { result } = render('/settings/environments?keep=1');++ act(() => result.current.setTab('vault'));+ expect(result.current.tab).toBe('vault');+ expect(result.current.search).toBe('?keep=1&tab=vault');++ act(() => result.current.setTab('environments'));+ expect(result.current.tab).toBe('environments');+ expect(result.current.search).toBe('?keep=1');+ });+});diff --git a/src/features/EnvironmentsAndCreds/usePageTab.ts b/src/features/EnvironmentsAndCreds/usePageTab.tsnew file mode 100644index 00000000000..c352ce01e0a--- /dev/null+++ b/src/features/EnvironmentsAndCreds/usePageTab.ts@@ -0,0 +1,30 @@+'use client';++import { useSearchParams } from 'react-router';++import { type PageTab, TAB_PARAM } from './const';++/**+ * The open tab of the Environments & Vault page, kept in the URL so a reload,+ * a shared link or an old credential link opens the same tab. Environments is+ * the default and leaves the URL clean.+ */+export const usePageTab = () => {+ const [searchParams, setSearchParams] = useSearchParams();+ const tab: PageTab = searchParams.get(TAB_PARAM) === 'vault' ? 'vault' : 'environments';++ const setTab = (next: PageTab) => {+ if (next === tab) return;+ setSearchParams(+ (prev) => {+ const params = new URLSearchParams(prev);+ if (next === 'environments') params.delete(TAB_PARAM);+ else params.set(TAB_PARAM, next);+ return params;+ },+ { replace: true },+ );+ };++ return [tab, setTab] as const;+};diff --git a/src/features/Settings/creds/features/EditCredModal/Content.tsx b/src/features/Settings/creds/features/EditCredModal/Content.tsxindex 8314bac139e..558b7784744 100644--- a/src/features/Settings/creds/features/EditCredModal/Content.tsx+++ b/src/features/Settings/creds/features/EditCredModal/Content.tsx@@ -12,9 +12,16 @@ export interface EditCredModalContentProps {cred: UserCredSummary;credsApi: CredsApi;onSuccess?: () => void;+ /** Values cannot be read back (see `isWriteOnlyCredRow`); they can only be replaced. */+ writeOnly?: boolean;}-const EditCredModalContent: FC<EditCredModalContentProps> = ({ cred, credsApi, onSuccess }) => {+const EditCredModalContent: FC<EditCredModalContentProps> = ({+ cred,+ credsApi,+ onSuccess,+ writeOnly,+}) => {const { close } = useModalContext();const isKVType = cred.type === 'kv-env' || cred.type === 'kv-header';@@ -25,7 +32,13 @@ const EditCredModalContent: FC<EditCredModalContentProps> = ({ cred, credsApi, o};return isKVType ? (- <EditKVForm cred={cred} credsApi={credsApi} onCancel={close} onSuccess={handleSuccess} />+ <EditKVForm+ cred={cred}+ credsApi={credsApi}+ writeOnly={writeOnly}+ onCancel={close}+ onSuccess={handleSuccess}+ />) : (<EditMetaForm cred={cred} credsApi={credsApi} onCancel={close} onSuccess={handleSuccess} />);diff --git a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsxindex aa98967a8c9..9190f890592 100644--- a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx+++ b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx@@ -1,7 +1,7 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import { Button, Flexbox, Input, InputPassword, Spin, TextArea } from '@lobehub/ui';+import { Button, Flexbox, Input, InputPassword, Spin, Text, TextArea } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';@@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next';import { usePermission } from '@/hooks/usePermission';import { type CredsApi } from '../useCredsApi';+import { buildKVUpdateInput } from './kvUpdateInput';const styles = stylex.create({footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },@@ -23,6 +24,11 @@ interface EditKVFormProps {credsApi: CredsApi;onCancel: () => void;onSuccess: () => void;+ /**+ * The stored values cannot be read back: the form starts empty, leaving it+ * empty keeps them, and filling it in replaces them all.+ */+ writeOnly?: boolean;}interface FormValues {@@ -31,7 +37,7 @@ interface FormValues {name: string;}-const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }) => {+const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess, writeOnly }) => {const { t } = useTranslation('setting');const { allowed: canManageCredentials } = usePermission('manage_provider_key');const form = useForm<FormValues>({ onSubmit: (values) => handleSubmit(values) });@@ -40,6 +46,16 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }// Fetch decrypted values on mountuseEffect(() => {const fetchDecryptedValues = async () => {+ if (writeOnly) {+ form.setValues({+ description: cred.description,+ kvPairs: [{ key: '', value: '' }],+ name: cred.name,+ });+ setIsLoading(false);+ return;+ }+if (!canManageCredentials) {setIsLoading(false);return;@@ -76,29 +92,13 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }};fetchDecryptedValues();- }, [canManageCredentials, cred.id, cred.name, cred.description, credsApi, form]);+ }, [canManageCredentials, cred.id, cred.name, cred.description, credsApi, form, writeOnly]);const updateMutation = useMutation({mutationFn: async (values: FormValues) => {if (!canManageCredentials) return;- const kvPairs = values.kvPairs || [];- const valuesObj = kvPairs.reduce(- (acc, pair) => {- if (pair.key && pair.value) {- acc[pair.key] = pair.value;- }- return acc;- },- {} as Record<string, string>,- );-- await credsApi.client.update.mutate({- description: values.description,- id: cred.id,- name: values.name,- values: valuesObj,- });+ await credsApi.client.update.mutate(buildKVUpdateInput(cred.id, values, writeOnly));},onSuccess: () => {onSuccess();@@ -126,6 +126,11 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }</Form.Field><Form.Field label={t('creds.form.values')}>+ {writeOnly && (+ <Text fontSize={12} style={{ display: 'block', marginBlockEnd: 8 }} type={'secondary'}>+ {t('creds.writeOnly.editHint')}+ </Text>+ )}<Form.List name="kvPairs">{({ fields, add, remove }) => (<Flexbox gap={8}>diff --git a/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.test.ts b/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.test.tsnew file mode 100644index 00000000000..942ca9d351a--- /dev/null+++ b/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it } from 'vitest';++import { buildKVUpdateInput } from './kvUpdateInput';++describe('buildKVUpdateInput', () => {+ it('keeps the stored values of a write-only credential when no pair is entered', () => {+ const input = buildKVUpdateInput(+ 7,+ { kvPairs: [{ key: '', value: '' }], name: 'Team token' },+ true,+ );++ expect(input).toEqual({ description: undefined, id: 7, name: 'Team token' });+ expect(input).not.toHaveProperty('values');+ });++ it('replaces the values of a write-only credential with the pairs entered', () => {+ const input = buildKVUpdateInput(+ 7,+ {+ kvPairs: [+ { key: 'TEAM_TOKEN', value: 'new-value' },+ { key: 'EMPTY', value: '' },+ ],+ name: 'Team token',+ },+ true,+ );++ expect(input.values).toEqual({ TEAM_TOKEN: 'new-value' });+ });++ it('always sends the values of a readable credential', () => {+ expect(buildKVUpdateInput(7, { kvPairs: [], name: 'Mine' }).values).toEqual({});+ });+});diff --git a/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.ts b/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.tsnew file mode 100644index 00000000000..b2a799841f8--- /dev/null+++ b/src/features/Settings/creds/features/EditCredModal/kvUpdateInput.ts@@ -0,0 +1,29 @@+interface KVFormValues {+ description?: string;+ kvPairs?: Array<{ key: string; value: string }>;+ name: string;+}++/**+ * The `update` request for a key-value credential edited in the form.+ *+ * Pairs missing a key or a value are dropped. For a write-only credential the+ * form starts empty, so entering no pair means "keep the stored values": the+ * request then carries no `values` at all, since an empty object would wipe+ * them. Entering any pair replaces the whole set.+ */+export const buildKVUpdateInput = (id: number, values: KVFormValues, writeOnly?: boolean) => {+ const pairs = Object.fromEntries(+ (values.kvPairs ?? [])+ .filter((pair) => pair.key && pair.value)+ .map((pair) => [pair.key, pair.value]),+ );+ const keepValues = writeOnly && Object.keys(pairs).length === 0;++ return {+ description: values.description,+ id,+ name: values.name,+ ...(keepValues ? {} : { values: pairs }),+ };+};diff --git a/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx b/src/features/Settings/creds/features/WorkspaceCredsList.test.tsxindex 3efca5942ba..fd30b3d07ea 100644--- a/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx+++ b/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx@@ -63,4 +63,27 @@ describe('WorkspaceCredsList', () => {expect(within(mine).getByTestId('private-lock')).toBeInTheDocument();expect(screen.getAllByTestId('private-lock')).toHaveLength(1);});++ it('marks only workspace credentials shared with everyone as write-only', () => {+ render(+ <WorkspaceCredsList+ credsApi={credsApiWith([+ cred({ id: 1, key: 'TEAM_TOKEN', name: 'Team token', visibility: 'public' }),+ cred({ id: 2, key: 'MY_TOKEN', name: 'My token', visibility: 'private' }),+ cred({+ id: 3,+ key: 'SHARED_IN',+ name: 'Shared in',+ ownerAccountId: 1,+ ownerType: 'user',+ visibility: 'public',+ }),+ ])}+ />,+ );++ // Only "Team token": the private one stays readable by its creator, and a+ // personal credential shared in stays readable by its owner.+ expect(screen.getAllByText('creds.writeOnly.tag')).toHaveLength(1);+ });});diff --git a/src/features/Settings/creds/features/WorkspaceCredsList.tsx b/src/features/Settings/creds/features/WorkspaceCredsList.tsxindex b5d3ab3d1bd..67af8740c59 100644--- a/src/features/Settings/creds/features/WorkspaceCredsList.tsx+++ b/src/features/Settings/creds/features/WorkspaceCredsList.tsx@@ -1,7 +1,7 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import { confirmModal, Empty, Flexbox, Icon, Tag, toast } from '@lobehub/ui';+import { confirmModal, Empty, Flexbox, Icon, Tag, toast, Tooltip } from '@lobehub/ui';import { EyeOffIcon, GlobeIcon, Link2Off } from 'lucide-react';import { type FC } from 'react';import { useTranslation } from 'react-i18next';@@ -15,7 +15,7 @@ import { usePermission } from '@/hooks/usePermission';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';import { lambdaClient } from '@/libs/trpc/client';-import { isOwnCredRow, workspaceCredRowAccess } from './credAccess';+import { isOwnCredRow, isWriteOnlyCredRow, workspaceCredRowAccess } from './credAccess';import { credErrorKey } from './credError';import CredItem from './CredItem';import { createEditCredModal } from './EditCredModal';@@ -122,6 +122,7 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({)}{visibleCredentials.map((cred) => {const access = workspaceCredRowAccess(cred, { isAdmin, myAccountId });+ const writeOnly = isWriteOnlyCredRow(cred);const extraMenuItems = [...(access.publish? [@@ -164,19 +165,35 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({key={cred.id}titleSuffix={cred.visibility === 'private' && <PrivateLockIcon />}tags={- cred.ownerType === 'user' && (+ cred.ownerType === 'user' ? (<Tag>{isOwnCredRow(cred, myAccountId)? t('creds.owner.fromPersonal'): t('creds.owner.sharedBy', { name: cred.ownerDisplayName })}</Tag>+ ) : (+ writeOnly && (+ <Tooltip title={t('creds.writeOnly.tooltip')}>+ <Tag>{t('creds.writeOnly.tag')}</Tag>+ </Tooltip>+ ))}onDelete={access.manage ? handleDelete : undefined}- onView={access.manage ? (cred) => createViewCredModal({ cred, credsApi }) : undefined}onEdit={access.manage- ? (cred) => createEditCredModal({ cred, credsApi, onSuccess: () => refetch() })+ ? (cred) =>+ createEditCredModal({+ cred,+ credsApi,+ onSuccess: () => refetch(),+ writeOnly,+ })+ : undefined+ }+ onView={+ access.manage && !writeOnly+ ? (cred) => createViewCredModal({ cred, credsApi }): undefined}/>diff --git a/src/features/Settings/creds/features/credAccess.test.ts b/src/features/Settings/creds/features/credAccess.test.tsindex a0b900ef1e0..8110a78d059 100644--- a/src/features/Settings/creds/features/credAccess.test.ts+++ b/src/features/Settings/creds/features/credAccess.test.ts@@ -1,7 +1,7 @@import { type UserCredSummary } from '@lobechat/types';import { describe, expect, it } from 'vitest';-import { isOwnCredRow, workspaceCredRowAccess } from './credAccess';+import { isOwnCredRow, isWriteOnlyCredRow, workspaceCredRowAccess } from './credAccess';const ME = 42;const OTHER = 99;@@ -131,3 +131,13 @@ describe('workspaceCredRowAccess', () => {});});});++describe('isWriteOnlyCredRow', () => {+ it('is true only for a workspace credential shared with every member', () => {+ expect(isWriteOnlyCredRow(row({ ownerType: 'organization', visibility: 'public' }))).toBe(true);+ expect(isWriteOnlyCredRow(row({ ownerType: 'organization', visibility: 'private' }))).toBe(+ false,+ );+ expect(isWriteOnlyCredRow(row({ ownerType: 'user', visibility: 'public' }))).toBe(false);+ });+});diff --git a/src/features/Settings/creds/features/credAccess.ts b/src/features/Settings/creds/features/credAccess.tsindex 38f0840a87d..321ca3d180c 100644--- a/src/features/Settings/creds/features/credAccess.ts+++ b/src/features/Settings/creds/features/credAccess.ts@@ -42,6 +42,17 @@ const NONE: CredRowAccess = { makePrivate: false, manage: false, publish: false,export const isOwnCredRow = (cred: CredRow, myAccountId: number | undefined): boolean =>cred.ownerType === 'user' && myAccountId !== undefined && cred.ownerAccountId === myAccountId;+/**+ * A workspace credential shared with every member is write-only in settings:+ * whoever may manage it can replace its values but not read them back here.+ * The server's settings endpoint refuses to decrypt one (`workspaceCreds.get`);+ * this only decides what the UI offers. Runs still resolve the value at use+ * time. Personal credentials shared in stay readable by their owner, on the+ * personal page.+ */+export const isWriteOnlyCredRow = (cred: Pick<CredRow, 'ownerType' | 'visibility'>): boolean =>+ cred.ownerType !== 'user' && cred.visibility === 'public';+export const workspaceCredRowAccess = (cred: CredRow, viewer: CredRowViewer): CredRowAccess => {const isPublic = cred.visibility === 'public';diff --git a/src/features/Settings/environments/index.tsx b/src/features/Settings/environments/index.tsxindex a5434c0e5e8..569e1ffd748 100644--- a/src/features/Settings/environments/index.tsx+++ b/src/features/Settings/environments/index.tsx@@ -7,10 +7,15 @@ import { useNavigate, useParams } from 'react-router';import { MAX_WIDTH } from '@/const/layoutTokens';import EnvironmentManager from '@/features/EnvironmentManager';import EnvironmentDetailPage from '@/features/EnvironmentManager/EnvironmentDetailPage';+import PageTabs from '@/features/EnvironmentsAndCreds/PageTabs';+import PersonalVault from '@/features/EnvironmentsAndCreds/PersonalVault';+import { usePageTab } from '@/features/EnvironmentsAndCreds/usePageTab';/**- * `/settings/environments` lists them; `/settings/environments/:sub` is one- * environment's page. The list's Refresh and New actions live in the manager.+ * Environments & Vault, personal: `/settings/environments` has two tabs, the+ * caller's environments and their personal vault (`?tab=vault`) — the+ * definitions a run starts from and the secrets it reads, in one place.+ * `/settings/environments/:sub` is one environment's page.** No gate: an environment is a definition, and writing one down needs no* drive. Only initializing a folder from it does, and that is asked where it@@ -20,17 +25,28 @@ const Page = memo(() => {const { sub: environmentId } = useParams<{ sub?: string }>();// Personal-only route: plain `navigate` keeps it out of any active workspace.const navigate = useNavigate();+ const [tab, setTab] = usePageTab();- return (- <Flexbox style={{ maxWidth: MAX_WIDTH, width: '100%' }}>- {environmentId ? (+ if (environmentId)+ return (+ <Flexbox style={{ maxWidth: MAX_WIDTH, width: '100%' }}><EnvironmentDetailPageenvironmentId={environmentId}key={environmentId}onBack={() => navigate('/settings/environments')}/>+ </Flexbox>+ );++ const tabs = <PageTabs value={tab} onChange={setTab} />;++ return (+ <Flexbox style={{ maxWidth: MAX_WIDTH, width: '100%' }}>+ {tab === 'vault' ? (+ <PersonalVault headerLeading={tabs} />) : (<EnvironmentManager+ headerLeading={tabs}onOpenEnvironment={(id) => navigate(`/settings/environments/${encodeURIComponent(id)}`)}/>)}diff --git a/src/features/Settings/features/tabTitles.ts b/src/features/Settings/features/tabTitles.tsindex 2254512fb50..a1cbc5bf859 100644--- a/src/features/Settings/features/tabTitles.ts+++ b/src/features/Settings/features/tabTitles.ts@@ -20,7 +20,7 @@ export const SETTINGS_TAB_TITLE_KEYS: Partial<Record<SettingsTabs, TitleKey>> =[SettingsTabs.Creds]: ['setting', 'tab.creds'],[SettingsTabs.Credits]: ['subscription', 'tab.credits'],[SettingsTabs.Devices]: ['setting', 'devices.title'],- [SettingsTabs.Environments]: ['setting', 'tab.environments'],+ [SettingsTabs.Environments]: ['setting', 'tab.environmentsAndCreds'],[SettingsTabs.SubscriptionAccounts]: ['setting', 'tab.subscriptionAccounts'],[SettingsTabs.Hotkey]: ['setting', 'tab.hotkey'],[SettingsTabs.Integrations]: ['setting', 'tab.integrations'],diff --git a/src/features/Settings/hooks/useCategory.test.tsx b/src/features/Settings/hooks/useCategory.test.tsxindex 5b39ae5dd4d..ffd50495d44 100644--- a/src/features/Settings/hooks/useCategory.test.tsx+++ b/src/features/Settings/hooks/useCategory.test.tsx@@ -95,8 +95,9 @@ describe('settings useCategory', () => {// environment definitions.const keys = groupKeys(SettingsGroupKey.Resource);expect(keys).toContain(SettingsTabs.Environments);- // Credentials sit right below Environments, the runs that read them.- expect(keys?.indexOf(SettingsTabs.Creds)).toBe(keys!.indexOf(SettingsTabs.Environments) + 1);+ // Credentials share the Environments page: one entry for what a run starts+ // from and the secrets it reads.+ expect(keys).not.toContain(SettingsTabs.Creds);expect(keys).not.toContain('drive');});diff --git a/src/features/Settings/hooks/useCategory.tsx b/src/features/Settings/hooks/useCategory.tsxindex 8e23b29985a..c022d4a122d 100644--- a/src/features/Settings/hooks/useCategory.tsx+++ b/src/features/Settings/hooks/useCategory.tsx@@ -19,7 +19,6 @@ import {Info,KeyboardIcon,KeyIcon,- KeyRound,Map,MessageCircleIcon,MonitorSmartphoneIcon,@@ -245,19 +244,13 @@ export const useCategory = () => {key: SettingsTabs.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.+ // Environments & Vault, always there: what a run starts from and+ // the secrets it reads, in one place. An environment is a definition,+ // written down before anything runs it, so it needs no drive.{icon: ContainerIcon,key: SettingsTabs.Environments,- label: t('tab.environments'),- },- // Secrets the agents' runs read at execution time, next to the- // environments that consume them.- {- icon: KeyRound,- key: SettingsTabs.Creds,- label: t('tab.creds'),+ label: t('tab.environmentsAndCreds'),},isDesktop && {icon: EthernetPort,diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.tsindex 96246873810..57c72c99cc0 100644--- a/src/features/SettingsSearch/items.ts+++ b/src/features/SettingsSearch/items.ts@@ -98,6 +98,9 @@ export const TAB_SEARCH_EN_KEYWORDS: Partial<Record<string, string[]>> = {[SettingsTabs.Environments]: ['sandbox','environments',+ 'credentials',+ 'secrets',+ 'vault','instances','setup script','repository',diff --git a/src/features/SubscriptionAccounts/index.tsx b/src/features/SubscriptionAccounts/index.tsxindex c8e3539d7cc..af4a71c7113 100644--- a/src/features/SubscriptionAccounts/index.tsx+++ b/src/features/SubscriptionAccounts/index.tsx@@ -68,7 +68,8 @@ const SubscriptionAccounts = () => {matchesKeyword(a, keyword),);const openAccount = accounts.find((a) => a.id === openId);- const inRotation = accounts.filter((a) => a.enabled !== false).length;+ // The summary counts what the filters leave, so it moves with them.+ const inRotation = visible.filter((a) => a.enabled !== false).length;// The meters read each account's own readings, which the list sync does not// touch: refreshing re-reads them too, or a newer sample would never show.@@ -137,7 +138,7 @@ const SubscriptionAccounts = () => {const summary = (<Text fontSize={13} type={'secondary'}>{accounts.length > 0 &&- t('subscriptionAccounts.summary', { count: accounts.length, inRotation })}+ t('subscriptionAccounts.summary', { count: visible.length, inRotation })}</Text>);@@ -161,15 +162,7 @@ const SubscriptionAccounts = () => {onChange={(e) => setKeyword(e.target.value)}/>{showVisibilityFilter && (- <VisibilityFilter- value={visibilityFilter}- counts={{- all: accounts.length,- private: accounts.filter(isPrivateAccount).length,- workspace: accounts.filter((a) => !isPrivateAccount(a)).length,- }}- onChange={setVisibilityFilter}- />+ <VisibilityFilter value={visibilityFilter} onChange={setVisibilityFilter} />)}<Selectstyle={{ minWidth: 168 }}@@ -177,11 +170,11 @@ const SubscriptionAccounts = () => {variant={'filled'}options={[{- label: `${t('subscriptionAccounts.filter.allProviders')} · ${accounts.length}`,+ label: t('subscriptionAccounts.filter.allProviders'),value: ALL,},...present.map((p) => ({- label: `${PROVIDER_NAME[p]} · ${accounts.filter((a) => a.provider === p).length}`,+ label: PROVIDER_NAME[p],value: p,})),]}@@ -190,10 +183,12 @@ const SubscriptionAccounts = () => {</>)}<ActionIcon- icon={RefreshCwIcon}loading={isValidating || refreshing}title={t('subscriptionAccounts.refresh')}onClick={() => void refresh()}+ icon={RefreshCwIcon}+ // A row that runs short of width shrinks its children; the icon keeps its square.+ style={{ flex: 'none' }}/></Flexbox></Flexbox>diff --git a/src/features/WorkspaceSetting/hooks/useCategory.test.tsx b/src/features/WorkspaceSetting/hooks/useCategory.test.tsxindex 24373f3264a..064efbfe5a1 100644--- a/src/features/WorkspaceSetting/hooks/useCategory.test.tsx+++ b/src/features/WorkspaceSetting/hooks/useCategory.test.tsx@@ -111,7 +111,7 @@ describe('workspace settings useCategory', () => {expect(result.current.at(-1)?.key).toBe(WorkspaceSettingsGroupKey.System);});- it('groups devices, subscription accounts, environments and credentials under Runtime', () => {+ it('groups devices, subscription accounts and environments & credentials under Runtime', () => {const { result } = renderHook(() => useWorkspaceSettingCategory(), { wrapper });const keys = result.current.map((group) => group.key);const resourceGroup = result.current.find(@@ -130,8 +130,8 @@ describe('workspace settings useCategory', () => {expect(resourceGroup?.items.map((item) => item.key)).toEqual([WorkspaceSettingsTabs.Devices,WorkspaceSettingsTabs.SubscriptionAccounts,+ // Credentials share the Environments page rather than an entry of their own.WorkspaceSettingsTabs.Environments,- WorkspaceSettingsTabs.Creds,]);expect(generalGroup?.items.map((item) => item.key)).not.toContain(WorkspaceSettingsTabs.Devices,diff --git a/src/features/WorkspaceSetting/hooks/useCategory.tsx b/src/features/WorkspaceSetting/hooks/useCategory.tsxindex 2a46fe16c13..d4d5729f767 100644--- a/src/features/WorkspaceSetting/hooks/useCategory.tsx+++ b/src/features/WorkspaceSetting/hooks/useCategory.tsx@@ -18,7 +18,6 @@ import {Info,KeyboardIcon,KeyIcon,- KeyRound,Map,MessageCircleIcon,MessagesSquareIcon,@@ -289,19 +288,13 @@ export const useWorkspaceSettingCategory = (): WorkspaceSettingCategoryGroup[] =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.+ // Environments & Vault, always there: what a run starts from and+ // the secrets it reads, in one place. An environment is a definition,+ // written down before anything runs it, so it needs no drive.{icon: ContainerIcon,key: WorkspaceSettingsTabs.Environments,- label: t('tab.environments'),- },- // Secrets the agents' runs read at execution time, next to the- // environments that consume them.- {- icon: KeyRound,- key: WorkspaceSettingsTabs.Creds,- label: t('tab.creds'),+ label: t('tab.environmentsAndCreds'),},].filter(Boolean) as WorkspaceSettingCategoryItem[],key: WorkspaceSettingsGroupKey.Resource,diff --git a/src/routes/(main)/[workspaceSlug]/settings/environments/index.tsx b/src/routes/(main)/[workspaceSlug]/settings/environments/index.tsxindex ac0d81e2ef1..31d9959c184 100644--- a/src/routes/(main)/[workspaceSlug]/settings/environments/index.tsx+++ b/src/routes/(main)/[workspaceSlug]/settings/environments/index.tsx@@ -1,28 +1,31 @@'use client';-import { Flexbox, Text } from '@lobehub/ui';+import { Flexbox } from '@lobehub/ui';import { memo } from 'react';-import { useTranslation } from 'react-i18next';import { useParams } from 'react-router';import { MAX_WIDTH } from '@/const/layoutTokens';import EnvironmentManager from '@/features/EnvironmentManager';import EnvironmentDetailPage from '@/features/EnvironmentManager/EnvironmentDetailPage';+import PageTabs from '@/features/EnvironmentsAndCreds/PageTabs';+import { usePageTab } from '@/features/EnvironmentsAndCreds/usePageTab';+import WorkspaceVault from '@/features/EnvironmentsAndCreds/WorkspaceVault';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';/**- * The workspace's environments in one list: what members have published, and- * the caller's own private ones, marked with a lock. Running in a published- * one means running in its instances, which carry whatever a session left in- * them.+ * Environments & Vault, workspace: the environments and the credentials the+ * caller can use here, in two tabs (`?tab=vault` opens the vault). Each lists+ * what members have published together with the caller's own private items,+ * marked with a lock; each tab's header filter narrows it to everything, the+ * shared ones or the caller's private ones.*- * A new environment starts private, so creating one cannot quietly publish- * it; its row menu publishes it.+ * New items start private, so creating one cannot quietly publish it; its row+ * menu publishes it.*/const WorkspaceEnvironmentsSetting = memo(() => {- const { t } = useTranslation('setting');const { sub: environmentId } = useParams<{ sub?: string }>();const navigate = useWorkspaceAwareNavigate();+ const [tab, setTab] = usePageTab();if (environmentId)return (@@ -35,17 +38,19 @@ const WorkspaceEnvironmentsSetting = memo(() => {</Flexbox>);+ const tabs = <PageTabs value={tab} onChange={setTab} />;+return (<Flexbox style={{ maxWidth: MAX_WIDTH, width: '100%' }}>- <EnvironmentManager- createVisibility={'private'}- headerLeading={- <Text fontSize={13} style={{ flex: 1, minWidth: 0 }} type={'secondary'}>- {t('environments.workspaceListDesc')}- </Text>- }- onOpenEnvironment={(id) => navigate(`/settings/environments/${encodeURIComponent(id)}`)}- />+ {tab === 'vault' ? (+ <WorkspaceVault headerLeading={tabs} />+ ) : (+ <EnvironmentManager+ createVisibility={'private'}+ headerLeading={tabs}+ onOpenEnvironment={(id) => navigate(`/settings/environments/${encodeURIComponent(id)}`)}+ />+ )}</Flexbox>);});diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsxindex 0bb93a18694..7426fcb2dc4 100644--- a/src/spa/router/desktopRouter.shared.tsx+++ b/src/spa/router/desktopRouter.shared.tsx@@ -18,6 +18,7 @@ import ProviderSettingsSkeleton, {ProviderDetailSkeleton,} from '@/components/Skeleton/Settings/Provider';import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';+import { VAULT_TAB_SEARCH } from '@/features/EnvironmentsAndCreds/const';import { pageRouteMeta } from '@/features/Pages/routeMeta';import ResourceCategorySkeleton from '@/features/ResourceHome/Skeleton';import {@@ -389,8 +390,14 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): Rhandle: { meta: settingsRouteMeta, settingsTab: SettingsTabs.Memory },path: 'memory',},+ // The personal vault is a tab of the Environments & Vault page; old+ // links open that tab.{- element: redirectElement('/settings/credential'),+ element: redirectElement(`/settings/environments${VAULT_TAB_SEARCH}`),+ path: 'credential',+ },+ {+ element: redirectElement(`/settings/environments${VAULT_TAB_SEARCH}`),path: 'creds',},// Skills and connectors moved to the Marketplace. Static routes keep thediff --git a/src/spa/router/mobileRouter.config.tsx b/src/spa/router/mobileRouter.config.tsxindex 09a09a4232e..e31a87296cd 100644--- a/src/spa/router/mobileRouter.config.tsx+++ b/src/spa/router/mobileRouter.config.tsx@@ -50,9 +50,10 @@ const settingsTabSubElement = dynamicElement();// Skills and connectors moved to the Marketplace; their old tabs are redirects.+// Credentials keep their own mobile page: mobile has no environments page to+// share, while desktop redirects `/settings/credential` to it.const TABS_WITHOUT_SETTINGS_PAGE = new Set<string>([SettingsTabs.Connector,- SettingsTabs.Creds,SettingsTabs.Provider,SettingsTabs.Skill,]);diff --git a/src/spa/router/workspaceSettingsRoutes.tsx b/src/spa/router/workspaceSettingsRoutes.tsxindex 7726819a0a1..10a8c6b14f8 100644--- a/src/spa/router/workspaceSettingsRoutes.tsx+++ b/src/spa/router/workspaceSettingsRoutes.tsx@@ -4,6 +4,7 @@ import { createSettingsSectionsSkeleton } from '@/components/Skeleton/Settings/Simport { WORKSPACE_SETTINGS_SECTION_SHAPES } from '@/components/Skeleton/Settings/sectionShapes';import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';import DevicesPageSkeleton from '@/features/DeviceManager/Skeleton';+import { VAULT_TAB_SEARCH } from '@/features/EnvironmentsAndCreds/const';import { createWorkspaceSettingsRouteMeta } from '@/features/WorkspaceSetting/routeMeta';import { LegacySandboxStorageRedirect } from '@/spa/router/sandboxStorageRedirect';import { WorkspaceSettingsTabs } from '@/types/workspaceSettings';@@ -205,22 +206,15 @@ export const workspaceSettingsContentRoute: RouteObject = {},path: 'service-model',},+ // Credentials are the vault tab of the Environments & Vault page; old+ // links open that tab.{- element: dynamicElement(- () => import('@/routes/(main)/[workspaceSlug]/settings/credential'),- 'Desktop > Workspace > Settings > Credential',- ),- handle: {- meta: createWorkspaceSettingsRouteMeta(- WorkspaceSettingsTabs.Creds,- createSurfaceSkeleton('form'),- ),- },+ element: redirectElement(`../environments${VAULT_TAB_SEARCH}`),path: 'credential',},// Legacy `/:slug/settings/creds` URLs — kept for deep-links.{- element: redirectElement('../credential'),+ element: redirectElement(`../environments${VAULT_TAB_SEARCH}`),path: 'creds',},{