Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(web-studio): improve experience search, platform icons, and ACL UI (#5356)

yufeng2562688c050e
diff --git a/web-studio/src/components/resource-permissions.test.tsx b/web-studio/src/components/resource-permissions.test.tsx
index f1fcd217d..c70d35563 100644
--- a/web-studio/src/components/resource-permissions.test.tsx
+++ b/web-studio/src/components/resource-permissions.test.tsx
@@ -87,7 +87,10 @@ beforeEach(() => {
acl_mode: 'inherit',
direct_entries: [{ principal: 'user:bob', level: 'read' }],
inherited_entries: [{ principal: 'group:engineering', level: 'write' }],
- effective_entries: [],
+ effective_entries: [
+ { principal: 'user:bob', level: 'read' },
+ { principal: 'group:engineering', level: 'write' },
+ ],
}
mocks.get.mockImplementation(async () => report)
mocks.change.mockImplementation(async (_uri, change) => {
@@ -97,6 +100,10 @@ beforeEach(() => {
? { acl_mode: change.mode }
: { direct_entries: [] }),
}
+ report.effective_entries =
+ report.acl_mode === 'restricted'
+ ? report.direct_entries
+ : [...report.direct_entries, ...report.inherited_entries]
return report
})
mocks.users.mockResolvedValue({ users: [{ userId: 'bob' }], total: 1 })
@@ -137,6 +144,9 @@ it('keeps the no-admin recovery link inside the Studio base path', async () => {
it('shows current access and source of each grant without explanatory panels', async () => {
mount()
await screen.findByText('bob')
+ expect(screen.getByText('acl.grantSubjectColumn')).toBeTruthy()
+ expect(screen.getByText('acl.grantLevelColumn')).toBeTruthy()
+ expect(screen.getByText('acl.grantSourceColumn')).toBeTruthy()
expect(screen.getByText(/acl.subjects.user/)).toBeTruthy()
expect(screen.getByText('acl.levels.read')).toBeTruthy()
expect(screen.getByText('acl.peopleWithAccess')).toBeTruthy()
@@ -144,24 +154,62 @@ it('shows current access and source of each grant without explanatory panels', a
expect(screen.getByText(/acl.inheritedSource/)).toBeTruthy()
expect(screen.queryByText('acl.page.grantScope')).toBeNull()
})
-it('shows default sharing as the effective access when no ACL is configured', async () => {
+it('shows the ancestor directory when an inherited grant can be traced', async () => {
+ mocks.get.mockImplementation(async (target: string) =>
+ target === 'viking://resources'
+ ? {
+ uri: target,
+ acl_mode: 'inherit',
+ direct_entries: [{ principal: 'group:engineering', level: 'write' }],
+ inherited_entries: [],
+ effective_entries: [],
+ }
+ : report,
+ )
+ mount()
+ expect(await screen.findByText('resources')).toBeTruthy()
+ expect(screen.getByText('acl.accountAdministrators')).toBeTruthy()
+ expect(screen.getByText('acl.administratorSource')).toBeTruthy()
+})
+it('shows one effective grant with both sources when a principal is also granted directly', async () => {
+ report = {
+ ...report,
+ direct_entries: [{ principal: 'group:engineering', level: 'read' }],
+ effective_entries: [{ principal: 'group:engineering', level: 'write' }],
+ }
+ mount()
+ const row = (await screen.findByText('engineering')).closest('tr')!
+ expect(screen.getAllByText('engineering')).toHaveLength(1)
+ expect(within(row).getByText('acl.directAndInheritedSource')).toBeTruthy()
+ expect(within(row).getByText('acl.effectiveLevel')).toBeTruthy()
+ expect(within(row).getByText('acl.levels.read')).toBeTruthy()
+ expect(
+ within(row).getByRole('button', { name: 'acl.removeFor' }),
+ ).toBeTruthy()
+})
+it('allows adding direct grants while inheritance is enabled by default', async () => {
report = {
...report,
acl_mode: 'none',
direct_entries: [],
inherited_entries: [],
+ effective_entries: [],
}
mount()
await screen.findByText('acl.everyone')
expect(screen.getByText('acl.defaultRule')).toBeTruthy()
expect(screen.queryByText('acl.onlyAdmins')).toBeNull()
- expect(screen.queryByRole('button', { name: 'acl.addGrant' })).toBeNull()
- expect(screen.getByRole('button', { name: 'acl.limitAccess' })).toBeTruthy()
+ expect(screen.getByRole('button', { name: 'acl.addGrant' })).toBeTruthy()
+ expect(
+ screen
+ .getByRole('switch', { name: 'acl.inheritParent' })
+ .getAttribute('aria-checked'),
+ ).toBe('true')
})
it('confirms direct removal and preserves inherited permissions in the display', async () => {
const { user } = mount()
await screen.findByText('bob')
- await user.click(screen.getByRole('button', { name: 'acl.remove' }))
+ await user.click(screen.getByRole('button', { name: 'acl.removeFor' }))
expect(mocks.change).not.toHaveBeenCalled()
await user.click(
within(screen.getByRole('alertdialog')).getByRole('button', {
@@ -176,27 +224,77 @@ it('confirms direct removal and preserves inherited permissions in the display',
)
expect(screen.getByText('engineering')).toBeTruthy()
})
-it('keeps restricted grants without showing the parent-inheritance control', async () => {
- report = { ...report, acl_mode: 'restricted' }
+it('keeps restricted grants and shows inheritance disabled', async () => {
+ report = {
+ ...report,
+ acl_mode: 'restricted',
+ effective_entries: report.direct_entries,
+ }
mount()
await screen.findByText('bob')
- expect(screen.queryByText(/acl.parentGrantsLabel/)).toBeNull()
- expect(screen.queryByRole('button', { name: 'acl.includeParent' })).toBeNull()
- expect(screen.queryByRole('button', { name: 'acl.excludeParent' })).toBeNull()
+ expect(
+ screen
+ .getByRole('switch', { name: 'acl.inheritParent' })
+ .getAttribute('aria-checked'),
+ ).toBe('false')
expect(screen.queryByText('engineering')).toBeNull()
})
+it('explains inheritance and changes only the ACL mode, preserving direct grants', async () => {
+ const { user } = mount()
+ await screen.findByText('bob')
+ await user.click(screen.getByRole('button', { name: 'acl.inheritHelpLabel' }))
+ expect(screen.getByText('acl.inheritHelp')).toBeTruthy()
+ const toggle = screen.getByRole('switch', { name: 'acl.inheritParent' })
+ await user.click(toggle)
+ expect(screen.getByText('acl.restrictWarning')).toBeTruthy()
+ await user.click(
+ within(screen.getByRole('alertdialog')).getByRole('button', {
+ name: 'acl.confirm',
+ }),
+ )
+ await waitFor(() =>
+ expect(mocks.change).toHaveBeenCalledWith(uri, {
+ kind: 'mode',
+ mode: 'restricted',
+ }),
+ )
+ expect(screen.getByText('bob')).toBeTruthy()
+ expect(screen.queryByText('engineering')).toBeNull()
+ await user.click(toggle)
+ expect(screen.getByText('acl.restoreWarning')).toBeTruthy()
+ await user.click(
+ within(screen.getByRole('alertdialog')).getByRole('button', {
+ name: 'acl.confirm',
+ }),
+ )
+ await waitFor(() =>
+ expect(mocks.change).toHaveBeenCalledWith(uri, {
+ kind: 'mode',
+ mode: 'inherit',
+ }),
+ )
+ expect(screen.getByText('engineering')).toBeTruthy()
+ expect(screen.getByText('bob')).toBeTruthy()
+})
it('does not permit editing when account ACL is disabled', async () => {
mocks.enabled = false
mount()
await screen.findByText('bob')
expect(
- screen.getByRole('button', { name: 'acl.remove' }).hasAttribute('disabled'),
+ screen
+ .getByRole('button', { name: 'acl.removeFor' })
+ .hasAttribute('disabled'),
).toBe(true)
expect(
screen
.getByRole('button', { name: 'acl.addGrant' })
.hasAttribute('disabled'),
).toBe(true)
+ expect(
+ screen
+ .getByRole('switch', { name: 'acl.inheritParent' })
+ .hasAttribute('data-disabled'),
+ ).toBe(true)
expect(mocks.users).not.toHaveBeenCalled()
})
it('shows a local request error and retries without affecting the resource page', async () => {
diff --git a/web-studio/src/components/resource-permissions.tsx b/web-studio/src/components/resource-permissions.tsx
index ed20bffd5..402214aa6 100644
--- a/web-studio/src/components/resource-permissions.tsx
+++ b/web-studio/src/components/resource-permissions.tsx
@@ -1,5 +1,17 @@
import { useState } from 'react'
-import { ArrowLeftIcon, CheckIcon, PlusIcon, SearchIcon } from 'lucide-react'
+import {
+ ArrowLeftIcon,
+ CheckIcon,
+ CircleHelpIcon,
+ Globe2Icon,
+ LockKeyholeIcon,
+ PlusIcon,
+ SearchIcon,
+ ShieldCheckIcon,
+ Trash2Icon,
+ UserRoundIcon,
+ UsersRoundIcon,
+} from 'lucide-react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
@@ -7,7 +19,12 @@ import { useAclManagement } from '#/hooks/use-acl-management'
import { ResourceAclIdentityRecovery } from './resource-acl-identity-recovery'
import { isOvClientError } from '#/lib/ov-client'
import { Button } from '#/components/ui/button'
-import { Badge } from '#/components/ui/badge'
+import { Switch } from '#/components/ui/switch'
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from '#/components/ui/popover'
import { Input } from '#/components/ui/input'
import { Field, FieldGroup, FieldLabel } from '#/components/ui/field'
import {
@@ -30,7 +47,13 @@ import {
AlertDialogAction,
} from '#/components/ui/alert-dialog'
import { isSharedAclTarget } from '#/lib/resource-acl'
-import type { AclChange, AclEntry, AclLevel } from '#/lib/resource-acl'
+import { normalizeFileUri, parentUri } from '#/lib/viking-uri'
+import type {
+ AclChange,
+ AclEntry,
+ AclLevel,
+ AclReport,
+} from '#/lib/resource-acl'
import { fetchAdminGroups, fetchAdminUsersPage } from '#/lib/admin'
import { getErrorMessage } from '#/routes/users/-lib/error'
import { useDebouncedValue } from '#/routes/resources/-hooks/viking-fm'
@@ -52,6 +75,21 @@ export function ResourcePermissionsPanel({ uri }: { uri: string }) {
enabled: state.allowed && isSharedAclTarget(uri),
retry: false,
})
+ const sourceReports = useQuery({
+ queryKey: ['resource-acl-sources', state.aclIdentityScopeKey, uri],
+ queryFn: async () =>
+ Promise.allSettled(
+ aclParentUris(uri).map(async (ancestor) => ({
+ uri: ancestor,
+ report: await state.api.get(ancestor),
+ })),
+ ),
+ enabled:
+ report.isSuccess &&
+ report.data.acl_mode !== 'restricted' &&
+ report.data.inherited_entries.length > 0,
+ retry: false,
+ })
const mutation = useMutation({
mutationFn: async (change: PanelChange) => {
if (change.kind !== 'grantMany') return state.api.change(uri, change)
@@ -89,10 +127,46 @@ export function ResourcePermissionsPanel({ uri }: { uri: string }) {
report.error.code === 'PERMISSION_DENIED')
const restricted = report.data?.acl_mode === 'restricted'
const defaultShared = report.data?.acl_mode === 'none'
- const modeChange = confirm?.kind === 'mode'
+ const directGrants = new Map(
+ report.data?.direct_entries.map((entry) => [entry.principal, entry]) ?? [],
+ )
+ const inheritedGrants = new Map(
+ report.data?.inherited_entries.map((entry) => [entry.principal, entry]) ??
+ [],
+ )
return (
<section className="min-w-0">
<div className="flex flex-col gap-4">
+ <div className="flex items-center justify-end gap-2">
+ <label
+ htmlFor="inherit-parent-grants"
+ className="text-sm font-medium"
+ >
+ {t('acl.inheritParent')}
+ </label>
+ <Popover>
+ <PopoverTrigger
+ aria-label={t('acl.inheritHelpLabel')}
+ className="rounded-md p-1 text-muted-foreground hover:text-foreground"
+ >
+ <CircleHelpIcon className="size-4" />
+ </PopoverTrigger>
+ <PopoverContent className="max-w-80 text-sm">
+ {t('acl.inheritHelp')}
+ </PopoverContent>
+ </Popover>
+ <Switch
+ id="inherit-parent-grants"
+ checked={!restricted}
+ disabled={!writable}
+ onCheckedChange={(inherit) =>
+ setConfirm({
+ kind: 'mode',
+ mode: inherit ? 'inherit' : 'restricted',
+ })
+ }
+ />
+ </div>
{report.isPending ? (
<p role="status">{t('loading')}</p>
) : report.isError && permissionDenied ? (
@@ -142,106 +216,177 @@ export function ResourcePermissionsPanel({ uri }: { uri: string }) {
<h2 className="text-sm font-medium">
{t('acl.peopleWithAccess')}
</h2>
- {!defaultShared && (
- <Button
- size="sm"
- disabled={!writable}
- onClick={() => setGrantOpen(true)}
- >
- <PlusIcon data-icon="inline-start" />
- {t('acl.addGrant')}
- </Button>
- )}
- </div>
- {defaultShared && (
- <div className="flex flex-wrap items-center justify-between gap-3 border-b py-4">
- <div className="min-w-0">
- <p className="text-sm font-medium">{t('acl.everyone')}</p>
- <p className="text-xs text-muted-foreground">
- {t('acl.defaultRule')}
- </p>
- </div>
- <Button
- variant="outline"
- size="sm"
- disabled={!writable}
- onClick={() =>
- setConfirm({ kind: 'mode', mode: 'restricted' })
- }
- >
- {t('acl.limitAccess')}
- </Button>
- </div>
- )}
- {!defaultShared &&
- report.data.direct_entries.length === 0 &&
- (restricted || report.data.inherited_entries.length === 0) && (
- <p className="py-6 text-sm text-muted-foreground">
- {t('acl.onlyAdmins')}
- </p>
- )}
- {report.data.direct_entries.map((entry) => (
- <div
- key={entry.principal}
- className="flex flex-wrap items-center gap-3 border-b py-3 last:border-b-0"
+ <Button
+ size="sm"
+ disabled={!writable}
+ onClick={() => setGrantOpen(true)}
>
- <div className="min-w-0 flex-1">
- <p className="break-all text-sm font-medium">
- {principalLabel(entry.principal, t('acl.everyone'))}
- </p>
- <p className="text-xs text-muted-foreground">
- {t('acl.directSource')} ·{' '}
- {t(`acl.subjects.${principalType(entry.principal)}`)}
- </p>
- </div>
- <LevelSelect
- value={entry.level}
- disabled={!writable}
- label={t('acl.levelFor', { principal: entry.principal })}
- onChange={(level) =>
- mutation.mutate({
- kind: 'grant',
- principal: entry.principal,
- level,
- })
- }
- />
- <Button
- variant="ghost"
- size="sm"
- disabled={!writable}
- onClick={() =>
- setConfirm({
- kind: 'revoke',
- principal: entry.principal,
- })
- }
- >
- {t('acl.remove')}
- </Button>
- </div>
- ))}
- {!restricted &&
- !defaultShared &&
- report.data.inherited_entries.map((entry) => (
- <div
- key={`parent:${entry.principal}`}
- className="flex items-center gap-3 border-b py-3 last:border-b-0"
- >
- <div className="min-w-0 flex-1">
- <p className="break-all text-sm font-medium">
- {principalLabel(entry.principal, t('acl.everyone'))}
- </p>
- <p className="text-xs text-muted-foreground">
- {t('acl.inheritedSource')} ·{' '}
- {t(`acl.subjects.${principalType(entry.principal)}`)}
- </p>
- </div>
- <Badge variant="outline">
- {t(`acl.levels.${entry.level}`)}
- </Badge>
- </div>
- ))}
+ <PlusIcon data-icon="inline-start" />
+ {t('acl.addGrant')}
+ </Button>
+ </div>
+ <div className="overflow-x-auto rounded-md border">
+ <table className="w-full min-w-[600px] table-fixed text-sm">
+ <colgroup>
+ <col className="w-[36%]" />
+ <col className="w-[37%]" />
+ <col className="w-[27%]" />
+ </colgroup>
+ <thead className="bg-muted/20 text-left text-muted-foreground">
+ <tr>
+ <th className="px-4 py-2.5 font-medium">
+ {t('acl.grantSubjectColumn')}
+ </th>
+ <th className="px-4 py-2.5 font-medium">
+ {t('acl.grantLevelColumn')}
+ </th>
+ <th className="px-4 py-2.5 font-medium">
+ {t('acl.grantSourceColumn')}
+ </th>
+ </tr>
+ </thead>
+ <tbody className="divide-y">
+ <tr>
+ <td className="px-4 py-3">
+ <GrantSubject
+ label={t('acl.accountAdministrators')}
+ kind="admin"
+ description={t('acl.administratorRole')}
+ />
+ </td>
+ <td className="px-4 py-3">
+ <span className="inline-flex items-center gap-2">
+ {t('acl.levels.manage')}
+ <LockKeyholeIcon className="size-4 text-muted-foreground" />
+ </span>
+ </td>
+ <td className="px-4 py-3 text-muted-foreground">
+ {t('acl.administratorSource')}
+ </td>
+ </tr>
+ {defaultShared && (
+ <tr>
+ <td className="px-4 py-3">
+ <GrantSubject
+ label={t('acl.everyone')}
+ kind="everyone"
+ description={t('acl.subjects.everyone')}
+ />
+ </td>
+ <td className="px-4 py-3">{t('acl.levels.manage')}</td>
+ <td className="px-4 py-3 text-muted-foreground">
+ {t('acl.defaultRule')}
+ </td>
+ </tr>
+ )}
+ {report.data.effective_entries.map((entry) => {
+ const direct = directGrants.get(entry.principal)
+ const inherited = restricted
+ ? undefined
+ : inheritedGrants.get(entry.principal)
+ const source = inherited
+ ? findGrantSource(inherited, sourceReports.data)
+ : null
+ return (
+ <tr key={entry.principal}>
+ <td className="px-4 py-3">
+ <GrantSubject
+ label={principalLabel(
+ entry.principal,
+ t('acl.everyone'),
+ )}
+ kind={principalType(entry.principal)}
+ description={t(
+ `acl.subjects.${principalType(entry.principal)}`,
+ )}
+ />
+ </td>
+ <td className="px-4 py-3 align-middle">
+ <div className="space-y-2">
+ {(!direct || direct.level !== entry.level) && (
+ <span className="inline-flex items-center gap-2 whitespace-nowrap">
+ {direct
+ ? t('acl.effectiveLevel', {
+ level: t(`acl.levels.${entry.level}`),
+ })
+ : t(`acl.levels.${entry.level}`)}
+ {!direct && (
+ <LockKeyholeIcon className="size-4 text-muted-foreground" />
+ )}
+ </span>
+ )}
+ {direct && (
+ <div className="space-y-1">
+ {direct.level !== entry.level && (
+ <span className="block text-xs text-muted-foreground">
+ {t('acl.directSource')}
+ </span>
+ )}
+ <div className="flex items-center gap-1">
+ <LevelSelect
+ value={direct.level}
+ disabled={!writable}
+ label={t('acl.levelFor', {
+ principal: entry.principal,
+ })}
+ onChange={(level) =>
+ mutation.mutate({
+ kind: 'grant',
+ principal: entry.principal,
+ level,
+ })
+ }
+ />
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ disabled={!writable}
+ aria-label={t('acl.removeFor', {
+ principal: entry.principal,
+ })}
+ onClick={() =>
+ setConfirm({
+ kind: 'revoke',
+ principal: entry.principal,
+ })
+ }
+ >
+ <Trash2Icon />
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </td>
+ <td className="px-4 py-3 text-muted-foreground">
+ <span
+ className="block truncate"
+ title={
+ direct && inherited
+ ? t('acl.directAndInheritedSource')
+ : direct
+ ? t('acl.directSource')
+ : t('acl.inheritedSource')
+ }
+ >
+ {direct && inherited
+ ? t('acl.directAndInheritedSource')
+ : direct
+ ? t('acl.directSource')
+ : t('acl.inheritedSource')}
+ </span>
+ {source && (
+ <span className="block truncate" title={source}>
+ {source}
+ </span>
+ )}
+ </td>
+ </tr>
+ )
+ })}
+ </tbody>
+ </table>
+ </div>
</section>
</div>
)}
@@ -255,12 +400,26 @@ export function ResourcePermissionsPanel({ uri }: { uri: string }) {
<AlertDialogContent onKeyDown={(event) => event.stopPropagation()}>
<AlertDialogHeader>
<AlertDialogTitle>
- {t(modeChange ? 'acl.limitTitle' : 'acl.remove')}
+ {t(
+ confirm?.kind === 'mode'
+ ? confirm.mode === 'restricted'
+ ? 'acl.restrictTitle'
+ : 'acl.restoreTitle'
+ : 'acl.remove',
+ )}
</AlertDialogTitle>
<AlertDialogDescription>
- {t(modeChange ? 'acl.limitWarning' : 'acl.removeWarning', {
- principal: confirm?.kind === 'revoke' ? confirm.principal : '',
- })}
+ {t(
+ confirm?.kind === 'mode'
+ ? confirm.mode === 'restricted'
+ ? 'acl.restrictWarning'
+ : 'acl.restoreWarning'
+ : 'acl.removeWarning',
+ {
+ principal:
+ confirm?.kind === 'revoke' ? confirm.principal : '',
+ },
+ )}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
@@ -288,6 +447,68 @@ function principalLabel(principal: string, everyone: string) {
? everyone
: principal.replace(/^(user|group):/, '')
}
+function aclParentUris(uri: string): string[] {
+ const parents: string[] = []
+ let current = normalizeFileUri(parentUri(uri))
+ while (current.startsWith('viking://resources')) {
+ parents.push(current)
+ if (current === 'viking://resources') break
+ current = normalizeFileUri(parentUri(current))
+ }
+ return parents
+}
+function findGrantSource(
+ entry: AclEntry,
+ reports?: PromiseSettledResult<{ uri: string; report: AclReport }>[],
+): string | null {
+ for (const result of reports ?? []) {
+ if (result.status === 'rejected') break
+ const { uri, report } = result.value
+ if (
+ report.direct_entries.some(
+ (grant) =>
+ grant.principal === entry.principal && grant.level === entry.level,
+ )
+ ) {
+ return uri.replace('viking://resources', 'resources')
+ }
+ if (report.acl_mode === 'restricted') break
+ }
+ return null
+}
+function GrantSubject({
+ label,
+ description,
+ kind,
+}: {
+ label: string
+ description: string
+ kind: 'user' | 'group' | 'everyone' | 'admin'
+}) {
+ const Icon =
+ kind === 'group'
+ ? UsersRoundIcon
+ : kind === 'everyone'
+ ? Globe2Icon
+ : kind === 'admin'
+ ? ShieldCheckIcon
+ : UserRoundIcon
+ return (
+ <div className="flex min-w-0 items-center gap-3">
+ <span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
+ <Icon className="size-4" />
+ </span>
+ <span className="min-w-0">
+ <span className="block truncate font-medium" title={label}>
+ {label}
+ </span>
+ <span className="block text-xs text-muted-foreground">
+ {description}
+ </span>
+ </span>
+ </div>
+ )
+}
function principalType(principal: string) {
return principal === 'user:*'
? 'everyone'
diff --git a/web-studio/src/i18n/locales/en/workspace.ts b/web-studio/src/i18n/locales/en/workspace.ts
index 168da7c37..9eb30451d 100644
--- a/web-studio/src/i18n/locales/en/workspace.ts
+++ b/web-studio/src/i18n/locales/en/workspace.ts
@@ -210,6 +210,7 @@ const workspace = {
},
agentExperiencePage: {
pageCount: '{{count}} experiences on this page',
+ searchCount: '{{count}} search results shown',
setup: {
expand: 'Expand steps',
collapse: 'Collapse',
@@ -230,11 +231,10 @@ const workspace = {
description:
'Track experiences distilled from committed sessions, along with the trajectories and outcomes produced after they are applied.',
refresh: 'Refresh',
- searchPlaceholder: 'Search this page by name or URI',
+ searchPlaceholder: 'Search experiences',
searchClear: 'Clear',
- searchNoResults: 'No matching experiences on this page',
- searchNoResultsDescription:
- 'Clear the search or switch pages to continue browsing.',
+ searchNoResults: 'No matching experiences',
+ searchNoResultsDescription: 'Clear the search to continue browsing.',
loading: 'Loading experiences...',
loadFailed: 'Could not load experiences',
networkError:
@@ -843,14 +843,27 @@ const workspace = {
includeParent: 'Include parent grants',
excludeParent: 'Exclude parent grants',
limitAccess: 'Restrict access',
+ inheritParent: 'Inherit parent grants',
+ inheritHelpLabel: 'About inheriting parent grants',
+ inheritHelp:
+ 'When enabled, parent grants and grants added here both apply. When disabled, only grants added here apply. Switching does not delete direct grants. Descendants inherit this directory’s effective permissions by default.',
limitTitle: 'Restrict access to this directory?',
limitWarning:
'This directory will stop inheriting parent grants. Existing direct grants, including Everyone grants, remain active. Review these grants after switching. Account administrators retain access.',
peopleWithAccess: 'People and groups with access',
+ grantSubjectColumn: 'User / group',
+ grantLevelColumn: 'Permission',
+ effectiveLevel: 'Effective: {{level}}',
+ grantSourceColumn: 'Source',
+ accountAdministrators: 'Account administrators',
+ administratorRole: 'System role',
+ administratorSource: 'Account administrator access',
+ removeFor: 'Remove direct grant for {{principal}}',
defaultRule: 'Inherits parent permissions by default',
onlyAdmins: 'No grants yet; account administrators can still access',
- directSource: 'Granted here',
- inheritedSource: 'From parent',
+ directSource: 'Direct grant',
+ inheritedSource: 'Inherited grant',
+ directAndInheritedSource: 'Inherited + direct grant',
adminCredentialIdentity:
'Permission management uses the account administrator credential for {{account}}. Resource browsing still uses the current user.',
identity:
diff --git a/web-studio/src/i18n/locales/zh-CN/workspace.ts b/web-studio/src/i18n/locales/zh-CN/workspace.ts
index 094d71afc..343e2c3cb 100644
--- a/web-studio/src/i18n/locales/zh-CN/workspace.ts
+++ b/web-studio/src/i18n/locales/zh-CN/workspace.ts
@@ -209,6 +209,7 @@ const workspace = {
},
agentExperiencePage: {
pageCount: '本页 {{count}} 条经验',
+ searchCount: '显示 {{count}} 条搜索结果',
setup: {
expand: '展开步骤',
collapse: '收起',
@@ -228,10 +229,10 @@ const workspace = {
description:
'跟踪从会话提交中沉淀的经验资产,以及经验被应用后的执行轨迹与结果分布。',
refresh: '刷新',
- searchPlaceholder: '搜索当前页的经验名称或 URI',
+ searchPlaceholder: '搜索经验',
searchClear: '清除',
- searchNoResults: '当前页没有匹配的经验',
- searchNoResultsDescription: '可清除搜索条件,或切换页面继续查看。',
+ searchNoResults: '没有匹配的经验',
+ searchNoResultsDescription: '可清除搜索条件后重试。',
loading: '正在加载经验列表...',
loadFailed: '经验列表加载失败',
networkError: '无法连接 OpenViking 服务,请检查服务地址和连接状态。',
@@ -808,14 +809,27 @@ const workspace = {
includeParent: '使用上级授权',
excludeParent: '排除上级授权',
limitAccess: '限制访问',
+ inheritParent: '继承上级授权',
+ inheritHelpLabel: '了解继承上级授权',
+ inheritHelp:
+ '开启后,上级目录的授权与本目录直接授权共同生效;关闭后,仅本目录直接授权生效。切换不会删除本目录授权,下级目录默认继续继承此目录的有效权限。',
limitTitle: '限制这个目录的访问?',
limitWarning:
'此目录将停止继承上级授权。已有的直接授权(包括所有人授权)仍然生效,请在切换后检查这些授权。账号管理员仍可访问。',
peopleWithAccess: '有权限的用户和用户组',
+ grantSubjectColumn: '用户 / 用户组',
+ grantLevelColumn: '权限',
+ effectiveLevel: '生效权限:{{level}}',
+ grantSourceColumn: '来源',
+ accountAdministrators: '账号管理员',
+ administratorRole: '系统角色',
+ administratorSource: '账号管理员权限',
+ removeFor: '移除 {{principal}} 的直接授权',
defaultRule: '默认继承上级权限',
onlyAdmins: '暂无授权对象,仅账号管理员可访问',
- directSource: '本目录授权',
- inheritedSource: '上级目录授权',
+ directSource: '直接授权',
+ inheritedSource: '来自继承',
+ directAndInheritedSource: '继承 + 直接授权',
adminCredentialIdentity:
'权限管理使用 {{account}} 的账号管理员凭证;资源浏览仍使用当前用户。',
identity: '资源操作使用当前数据身份:{{account}} / {{user}}。',
diff --git a/web-studio/src/routes/agent-experience/-lib/api.test.ts b/web-studio/src/routes/agent-experience/-lib/api.test.ts
index 42565f090..53295cc56 100644
--- a/web-studio/src/routes/agent-experience/-lib/api.test.ts
+++ b/web-studio/src/routes/agent-experience/-lib/api.test.ts
@@ -3,12 +3,17 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
fetchAgentEvolutionStatus,
fetchExperiences,
+ searchExperiences,
setAgentEvolutionEnabled,
} from './api'
-const { get, patch } = vi.hoisted(() => ({ get: vi.fn(), patch: vi.fn() }))
+const { get, patch, post } = vi.hoisted(() => ({
+ get: vi.fn(),
+ patch: vi.fn(),
+ post: vi.fn(),
+}))
vi.mock('#/lib/ov-client', () => ({
- ovClient: { client: { get, patch } },
+ ovClient: { client: { get, patch, post } },
getOvResult: (result: unknown) => result,
isOvClientError: () => false,
}))
@@ -81,6 +86,43 @@ describe('experience listing server pagination', () => {
})
})
+describe('experience search', () => {
+ beforeEach(() => post.mockReset())
+
+ it('searches the experience directory with find and returns direct files without pagination', async () => {
+ post.mockResolvedValue({
+ memories: [
+ { uri: `${experiencesUri}/matching.md` },
+ { uri: `${experiencesUri}/nested/other.md` },
+ { uri: 'viking://user/other/memories/experiences/leak.md' },
+ ],
+ })
+ const signal = new AbortController().signal
+ const result = await searchExperiences({
+ experiencesUri,
+ keyword: 'matching',
+ signal,
+ })
+ expect(post).toHaveBeenCalledWith({
+ url: '/api/v1/search/find',
+ body: {
+ query: 'matching',
+ target_uri: experiencesUri,
+ context_type: 'memory',
+ level: 2,
+ limit: 100,
+ },
+ signal,
+ })
+ expect(result).toEqual({
+ items: [file('matching.md')],
+ hasMore: false,
+ page: 1,
+ pageSize: 1,
+ })
+ })
+})
+
describe('account-scoped evolution settings', () => {
beforeEach(() => {
get.mockReset()
diff --git a/web-studio/src/routes/agent-experience/-lib/api.ts b/web-studio/src/routes/agent-experience/-lib/api.ts
index ef976ffda..408a70a13 100644
--- a/web-studio/src/routes/agent-experience/-lib/api.ts
+++ b/web-studio/src/routes/agent-experience/-lib/api.ts
@@ -54,6 +54,49 @@ export async function fetchExperiences(options: {
}
}
+/** Search indexed experience files in this user's experience directory. */
+export async function searchExperiences(options: {
+ experiencesUri: string
+ keyword: string
+ signal?: AbortSignal
+}): Promise<ExperiencePage> {
+ const { experiencesUri, keyword, signal } = options
+ const result = await getOvResult<unknown>(
+ ovClient.client.post({
+ body: {
+ query: keyword,
+ target_uri: experiencesUri,
+ context_type: 'memory',
+ level: 2,
+ limit: 100,
+ },
+ signal,
+ url: '/api/v1/search/find',
+ }),
+ )
+ const memories =
+ result && typeof result === 'object' && 'memories' in result
+ ? (result as { memories?: unknown }).memories
+ : undefined
+ const prefix = `${experiencesUri.replace(/\/$/, '')}/`
+ const items = Array.isArray(memories)
+ ? memories.flatMap((match) => {
+ if (
+ !match ||
+ typeof match !== 'object' ||
+ typeof match.uri !== 'string'
+ )
+ return []
+ const uri = match.uri as string
+ const name = uri.startsWith(prefix) ? uri.slice(prefix.length) : ''
+ return name && !name.includes('/') && name.endsWith('.md')
+ ? [{ name, uri }]
+ : []
+ })
+ : []
+ return { items, hasMore: false, page: 1, pageSize: items.length }
+}
+
export async function fetchContent(
uri: string,
signal?: AbortSignal,
diff --git a/web-studio/src/routes/agent-experience/index.tsx b/web-studio/src/routes/agent-experience/index.tsx
index d7d241c1f..e317143fe 100644
--- a/web-studio/src/routes/agent-experience/index.tsx
+++ b/web-studio/src/routes/agent-experience/index.tsx
@@ -45,7 +45,7 @@ import { cn } from '#/lib/utils'
import { ExperienceSetupGuide } from './-components/experience-setup-guide'
import { ExperiencePreviewSheet } from './-components/experience-preview-sheet'
-import { fetchExperiences } from './-lib/api'
+import { fetchExperiences, searchExperiences } from './-lib/api'
import {
buildExperiencesUri,
formatTimestamp,
@@ -205,39 +205,39 @@ function AgentExperienceRoute() {
const { t, i18n } = useTranslation('agentExperiencePage')
const { connection, identityScopeKey } = useAppConnection()
const [keyword, setKeyword] = React.useState('')
+ const [searchKeyword, setSearchKeyword] = React.useState('')
const [page, setPage] = React.useState(1)
const [pageSize, setPageSize] = React.useState(10)
const [previewExperience, setPreviewExperience] =
React.useState<ExperienceFileItem | null>(null)
const experiencesUri = buildExperiencesUri(connection.userId)
+ React.useEffect(() => {
+ const timeout = window.setTimeout(() => {
+ setSearchKeyword(keyword.trim())
+ setPage(1)
+ }, 300)
+ return () => window.clearTimeout(timeout)
+ }, [keyword])
const experiencesQuery = useQuery({
queryFn: ({ signal }) =>
- fetchExperiences({
- experiencesUri,
- page,
- pageSize,
- signal,
- }),
+ searchKeyword
+ ? searchExperiences({ experiencesUri, keyword: searchKeyword, signal })
+ : fetchExperiences({ experiencesUri, page, pageSize, signal }),
queryKey: [
'agent-experience-list',
identityScopeKey,
experiencesUri,
page,
pageSize,
+ searchKeyword,
],
staleTime: 30_000,
})
const pageItems = experiencesQuery.data?.items ?? []
const hasMore = experiencesQuery.data?.hasMore ?? false
- const normalizedKeyword = keyword.trim().toLocaleLowerCase()
- const experiences = pageItems.filter(
- (item) =>
- !normalizedKeyword ||
- item.name.toLocaleLowerCase().includes(normalizedKeyword) ||
- item.uri.toLocaleLowerCase().includes(normalizedKeyword),
- )
+ const experiences = pageItems
// Snapshot "updated since last visit" badges when the list settles, then
// mark the whole list as seen. Comparing against the pre-visit snapshot
@@ -310,6 +310,38 @@ function AgentExperienceRoute() {
<ExperienceSetupGuide />
+ <div className="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-border/70 px-4 py-3">
+ <div className="relative w-full sm:max-w-md">
+ <SearchIcon className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
+ <Input
+ aria-label={t('searchPlaceholder')}
+ autoComplete="off"
+ className="h-9 bg-transparent pr-9 pl-8 shadow-none dark:bg-transparent"
+ name="agent-experience-search"
+ placeholder={t('searchPlaceholder')}
+ value={keyword}
+ onChange={(event) => setKeyword(event.target.value)}
+ />
+ {keyword ? (
+ <button
+ type="button"
+ aria-label={t('searchClear')}
+ className="absolute top-1/2 right-2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ onClick={() => setKeyword('')}
+ >
+ <XIcon className="size-3.5" />
+ </button>
+ ) : null}
+ </div>
+ {experiencesQuery.isSuccess && (
+ <span className="text-xs tabular-nums text-muted-foreground">
+ {t(searchKeyword ? 'searchCount' : 'pageCount', {
+ count: experiences.length,
+ })}
+ </span>
+ )}
+ </div>
+
{experiencesQuery.isLoading ? (
<Card className="min-h-56 items-center justify-center">
<div className="flex items-center gap-2 text-sm text-muted-foreground">
@@ -355,10 +387,7 @@ function AgentExperienceRoute() {
)}
</div>
</Card>
- ) : pageItems.length === 0 &&
- page === 1 &&
- !hasMore &&
- !keyword.trim() ? (
+ ) : pageItems.length === 0 && page === 1 && !hasMore && !searchKeyword ? (
<Card className="min-h-56 items-center justify-center px-6 text-center">
<div className="flex size-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
<BrainCircuitIcon className="size-5" />
@@ -388,38 +417,6 @@ function AgentExperienceRoute() {
size="sm"
className="rounded-xl bg-background shadow-none ring-border/70 data-[size=sm]:gap-0 data-[size=sm]:py-0"
>
- <div className="flex flex-wrap items-center justify-between gap-3 border-b border-border/60 px-4 py-3">
- <div className="relative w-full sm:max-w-md">
- <SearchIcon className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
- <Input
- aria-label={t('searchPlaceholder')}
- autoComplete="off"
- className="h-9 bg-transparent pr-9 pl-8 shadow-none dark:bg-transparent"
- name="agent-experience-search"
- placeholder={t('searchPlaceholder')}
- value={keyword}
- onChange={(event) => {
- setKeyword(event.target.value)
- }}
- />
- {keyword ? (
- <button
- type="button"
- aria-label={t('searchClear')}
- className="absolute top-1/2 right-2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
- onClick={() => {
- setKeyword('')
- }}
- >
- <XIcon className="size-3.5" />
- </button>
- ) : null}
- </div>
- <span className="text-xs tabular-nums text-muted-foreground">
- {t('pageCount', { count: experiences.length })}
- </span>
- </div>
-
{experiences.length === 0 ? (
<div className="grid min-h-40 place-items-center px-6 py-8 text-center">
<div className="grid max-w-md gap-1">
@@ -436,9 +433,11 @@ function AgentExperienceRoute() {
<TableHead className="h-10 pl-4 text-xs font-normal text-muted-foreground">
{t('columnFile')}
</TableHead>
- <TableHead className="hidden h-10 w-44 sm:table-cell text-xs font-normal text-muted-foreground">
- {t('columnUpdated')}
- </TableHead>
+ {!searchKeyword && (
+ <TableHead className="hidden h-10 w-44 sm:table-cell text-xs font-normal text-muted-foreground">
+ {t('columnUpdated')}
+ </TableHead>
+ )}
<TableHead className="h-10 w-28 pr-4 text-right text-xs font-normal text-muted-foreground">
{t('columnActions')}
</TableHead>
@@ -475,7 +474,7 @@ function AgentExperienceRoute() {
}}
>
<HighlightedText
- keyword={normalizedKeyword}
+ keyword={searchKeyword}
text={experience.name}
/>
</button>
@@ -488,16 +487,16 @@ function AgentExperienceRoute() {
</Badge>
) : null}
</div>
- {normalizedKeyword &&
+ {searchKeyword &&
!experience.name
.toLocaleLowerCase()
- .includes(normalizedKeyword) ? (
+ .includes(searchKeyword.toLocaleLowerCase()) ? (
<span
className="truncate font-mono text-[11px] text-muted-foreground"
title={experience.uri}
>
<HighlightedText
- keyword={normalizedKeyword}
+ keyword={searchKeyword}
text={experience.uri}
/>
</span>
@@ -505,9 +504,11 @@ function AgentExperienceRoute() {
</div>
</div>
</TableCell>
- <TableCell className="hidden w-44 text-xs tabular-nums text-muted-foreground sm:table-cell">
- {updated ?? '-'}
- </TableCell>
+ {!searchKeyword && (
+ <TableCell className="hidden w-44 text-xs tabular-nums text-muted-foreground sm:table-cell">
+ {updated ?? '-'}
+ </TableCell>
+ )}
<TableCell
className="w-28 pr-4 text-right"
onClick={(event) => event.stopPropagation()}
@@ -537,17 +538,19 @@ function AgentExperienceRoute() {
</TableBody>
</Table>
)}
- <ExperiencePagination
- page={page}
- hasMore={hasMore}
- disabled={experiencesQuery.isFetching}
- pageSize={pageSize}
- onPageChange={setPage}
- onPageSizeChange={(nextPageSize) => {
- setPageSize(nextPageSize)
- setPage(1)
- }}
- />
+ {!searchKeyword && (
+ <ExperiencePagination
+ page={page}
+ hasMore={hasMore}
+ disabled={experiencesQuery.isFetching}
+ pageSize={pageSize}
+ onPageChange={setPage}
+ onPageSizeChange={(nextPageSize) => {
+ setPageSize(nextPageSize)
+ setPage(1)
+ }}
+ />
+ )}
</Card>
)}
diff --git a/web-studio/src/routes/permissions/-components/permissions-page.tsx b/web-studio/src/routes/permissions/-components/permissions-page.tsx
index 5bfe71d57..d66b907ea 100644
--- a/web-studio/src/routes/permissions/-components/permissions-page.tsx
+++ b/web-studio/src/routes/permissions/-components/permissions-page.tsx
@@ -1,33 +1,16 @@
-import { useEffect, useState } from 'react'
+import { useState } from 'react'
import {
ArrowLeftIcon,
ChevronRightIcon,
FolderIcon,
- Globe2Icon,
RotateCwIcon,
- UserRoundIcon,
- UsersRoundIcon,
} from 'lucide-react'
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
-import { toast } from 'sonner'
import { AccountAclSettings } from '#/components/account-acl-settings'
import { ResourcePermissionsPanel } from '#/components/resource-permissions'
import { ResourceAclIdentityRecovery } from '#/components/resource-acl-identity-recovery'
-import { Badge } from '#/components/ui/badge'
import { Button } from '#/components/ui/button'
-import { Switch } from '#/components/ui/switch'
-import { Alert, AlertTitle, AlertDescription } from '#/components/ui/alert'
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
-} from '#/components/ui/alert-dialog'
import {
Sheet,
SheetContent,
@@ -100,18 +83,6 @@ function DirectoryPermissions() {
enabled: state.allowed,
retry: false,
})
- const parentReport = useQuery({
- queryKey: ['resource-acl', state.aclIdentityScopeKey, currentUri],
- queryFn: () => state.api.get(currentUri),
- enabled: state.allowed && currentUri !== root,
- retry: false,
- })
- const parentControlled =
- currentUri !== root &&
- parentReport.isSuccess &&
- parentReport.data.acl_mode !== 'none'
- const parentKnown =
- currentUri === root || (parentReport.isSuccess && !parentReport.isFetching)
const pathParts = currentUri.slice(root.length).split('/').filter(Boolean)
const breadcrumbs = [
{ label: 'resources', uri: root },
@@ -177,32 +148,12 @@ function DirectoryPermissions() {
<RotateCwIcon />
</Button>
</div>
- {currentUri !== root && parentReport.isError && (
- <Alert variant="destructive">
- <AlertTitle>{t('acl.page.parentAclFailed')}</AlertTitle>
- <AlertDescription>
- <p>{getErrorMessage(parentReport.error)}</p>
- <Button
- variant="outline"
- onClick={() => void parentReport.refetch()}
- >
- {t('actions.refresh')}
- </Button>
- </AlertDescription>
- </Alert>
- )}
<div className="rounded-lg border">
- <Table className="min-w-[900px] table-fixed">
+ <Table className="table-fixed">
<TableHeader>
<TableRow>
- <TableHead className="w-[24%] pl-4">
- {t('acl.page.nameColumn')}
- </TableHead>
- <TableHead>{t('acl.page.granteesColumn')}</TableHead>
+ <TableHead className="pl-4">{t('acl.page.nameColumn')}</TableHead>
<TableHead className="w-44">{t('acl.page.ruleColumn')}</TableHead>
- <TableHead className="w-28 text-center">
- {t('acl.limitAccess')}
- </TableHead>
<TableHead className="w-28 pr-4 text-right">
{t('acl.page.actionsColumn')}
</TableHead>
@@ -212,7 +163,7 @@ function DirectoryPermissions() {
{directories.isPending ? (
<TableRow>
<TableCell
- colSpan={5}
+ colSpan={3}
className="py-10 text-center text-muted-foreground"
>
{t('loading')}
@@ -220,7 +171,7 @@ function DirectoryPermissions() {
</TableRow>
) : directories.isError ? (
<TableRow>
- <TableCell colSpan={5} className="py-8 text-center">
+ <TableCell colSpan={3} className="py-8 text-center">
{isOvClientError(directories.error) &&
(directories.error.statusCode === 403 ||
directories.error.code === 'PERMISSION_DENIED') ? (
@@ -251,7 +202,7 @@ function DirectoryPermissions() {
) : directories.data.length === 0 ? (
<TableRow>
<TableCell
- colSpan={5}
+ colSpan={3}
className="py-10 text-center text-muted-foreground"
>
{t('acl.page.emptyDirectory')}
@@ -267,8 +218,6 @@ function DirectoryPermissions() {
state.settings.isSuccess &&
!state.settings.isFetching
}
- parentControlled={parentControlled}
- parentKnown={parentKnown}
onOpen={() => setCurrentUri(entry.uri)}
onEdit={() => setEditingUri(entry.uri)}
/>
@@ -281,7 +230,7 @@ function DirectoryPermissions() {
open={Boolean(editingUri)}
onOpenChange={(open) => !open && setEditingUri('')}
>
- <SheetContent className="gap-0 data-[side=right]:sm:max-w-2xl">
+ <SheetContent className="gap-0 data-[side=right]:sm:max-w-3xl">
<SheetHeader className="border-b px-6 py-5">
<SheetTitle className="pr-10 text-lg">
{t('acl.page.editDirectory', {
@@ -306,215 +255,57 @@ function DirectoryPermissions() {
function DirectoryRow({
entry,
accountEnabled,
- parentControlled,
- parentKnown,
onOpen,
onEdit,
}: {
entry: VikingFsEntry
accountEnabled: boolean
- parentControlled: boolean
- parentKnown: boolean
onOpen: () => void
onEdit: () => void
}) {
const state = useAclManagement(false)
const { t } = useTranslation('settings')
- const client = useQueryClient()
- const [next, setNext] = useState<boolean | null>(null)
- useEffect(() => {
- if (!accountEnabled) setNext(null)
- }, [accountEnabled])
const uri = entry.uri
- const key = ['resource-acl', state.aclIdentityScopeKey, uri]
const report = useQuery({
- queryKey: key,
+ queryKey: ['resource-acl', state.aclIdentityScopeKey, uri],
queryFn: () => state.api.get(uri),
enabled: state.allowed,
retry: false,
})
const name = entry.name
- const hasAcl = report.isSuccess && report.data.acl_mode !== 'none'
- const restricted = report.isSuccess && report.data.acl_mode === 'restricted'
- const grants =
- report.data?.direct_entries.map((grant) => {
- if (grant.principal === 'user:*') {
- return {
- principal: grant.principal,
- label: t('acl.subjects.everyoneShort'),
- level: grant.level,
- type: 'everyone',
- }
- }
- const type = grant.principal.startsWith('group:') ? 'group' : 'user'
- return {
- principal: grant.principal,
- label: grant.principal.slice(grant.principal.indexOf(':') + 1),
- level: grant.level,
- type,
- }
- }) || []
- const grantNames = grants.map(
- ({ label, level, type }) =>
- `${type === 'everyone' ? t('acl.everyone') : `${t(`acl.subjects.${type}`)} · ${label}`}: ${t(`acl.levels.${level}`)}`,
- )
- const writable =
- accountEnabled && report.isSuccess && !report.isFetching && parentKnown
- // The drawer contains identity recovery when this row's ACL report is denied.
- const canOpenEditor =
- report.isError || (writable && (hasAcl || parentControlled))
- const update = useMutation({
- mutationFn: (limit: boolean) =>
- state.api.change(
- uri,
- limit
- ? { kind: 'mode', mode: 'restricted' }
- : parentControlled
- ? { kind: 'mode', mode: 'inherit' }
- : { kind: 'reset' },
- ),
- onSuccess: async (updated) => {
- client.setQueryData(key, updated)
- setNext(null)
- toast.success(t('acl.saved'))
- await client.invalidateQueries()
- },
- onError: (error) =>
- toast.error(t('acl.failed'), { description: getErrorMessage(error) }),
- })
return (
- <>
- <TableRow>
- <TableCell className="pl-4">
- <button
- type="button"
- className="flex max-w-full items-center gap-2 text-left font-medium hover:underline"
- onClick={onOpen}
- >
- <FolderIcon className="size-4 shrink-0 text-muted-foreground" />
- <span className="truncate" title={name}>
- {name}
- </span>
- </button>
- </TableCell>
- <TableCell
- className="min-w-0 overflow-hidden"
- title={grantNames.join(', ')}
+ <TableRow>
+ <TableCell className="pl-4">
+ <button
+ type="button"
+ className="flex max-w-full items-center gap-2 text-left font-medium hover:underline"
+ onClick={onOpen}
>
- {report.isSuccess ? (
- grants.length > 0 ? (
- <div className="flex min-w-0 items-center gap-1.5 overflow-hidden">
- {grants.slice(0, 3).map((grant) => (
- <Badge
- key={grant.principal}
- variant="secondary"
- className="max-w-44 min-w-0 gap-1 text-muted-foreground"
- title={`${grant.label}: ${t(`acl.levels.${grant.level}`)}`}
- >
- {grant.type === 'group' ? (
- <UsersRoundIcon className="shrink-0" />
- ) : grant.type === 'everyone' ? (
- <Globe2Icon className="shrink-0" />
- ) : (
- <UserRoundIcon className="shrink-0" />
- )}
- <span className="truncate">{grant.label}</span>
- <span aria-hidden="true">:</span>
- <span className="shrink-0 text-foreground">
- {t(`acl.levels.${grant.level}`)}
- </span>
- </Badge>
- ))}
- {grants.length > 3 && (
- <Badge variant="outline" className="text-muted-foreground">
- +{grants.length - 3}
- </Badge>
- )}
- </div>
- ) : (
- <span className="text-muted-foreground">
- {t('acl.page.noGrantees')}
- </span>
- )
- ) : (
- '—'
- )}
- </TableCell>
- <TableCell>
- <span className="text-muted-foreground">
- {report.isPending
- ? t('loading')
- : report.isError
- ? t('acl.page.unreadable')
- : t(`acl.modes.${report.data.acl_mode}`)}
+ <FolderIcon className="size-4 shrink-0 text-muted-foreground" />
+ <span className="truncate" title={name}>
+ {name}
</span>
- </TableCell>
- <TableCell className="text-center">
- {report.isSuccess ? (
- <Switch
- checked={restricted}
- disabled={!writable || update.isPending}
- aria-label={t('acl.page.limitFor', { directory: name })}
- onCheckedChange={setNext}
- />
- ) : (
- <span className="text-muted-foreground">—</span>
- )}
- </TableCell>
- <TableCell className="pr-4 text-right">
- <Button
- variant="ghost"
- size="sm"
- disabled={!canOpenEditor || update.isPending}
- onClick={onEdit}
- >
- {t('acl.page.manageAction')}
- </Button>
- </TableCell>
- </TableRow>
- <AlertDialog
- open={next !== null}
- onOpenChange={(open) => {
- if (!open && !update.isPending) setNext(null)
- }}
- >
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {t(
- next
- ? 'acl.limitTitle'
- : parentControlled
- ? 'acl.page.restoreInheritanceTitle'
- : 'acl.page.disableLimitTitle',
- )}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {t(
- next
- ? 'acl.limitWarning'
- : parentControlled
- ? 'acl.page.restoreInheritanceWarning'
- : 'acl.page.disableLimitWarning',
- )}
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel disabled={update.isPending}>
- {t('actions.cancel')}
- </AlertDialogCancel>
- <AlertDialogAction
- disabled={!writable || update.isPending}
- onClick={(event) => {
- event.preventDefault()
- if (writable && next !== null) update.mutate(next)
- }}
- >
- {update.isPending ? t('loading') : t('acl.confirm')}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- </>
+ </button>
+ </TableCell>
+ <TableCell>
+ <span className="text-muted-foreground">
+ {report.isPending
+ ? t('loading')
+ : report.isError
+ ? t('acl.page.unreadable')
+ : t(`acl.modes.${report.data.acl_mode}`)}
+ </span>
+ </TableCell>
+ <TableCell className="pr-4 text-right">
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={!accountEnabled}
+ onClick={onEdit}
+ >
+ {t('acl.page.manageAction')}
+ </Button>
+ </TableCell>
+ </TableRow>
)
}
diff --git a/web-studio/src/routes/permissions/route.test.tsx b/web-studio/src/routes/permissions/route.test.tsx
index e10d87664..dd52a3cf3 100644
--- a/web-studio/src/routes/permissions/route.test.tsx
+++ b/web-studio/src/routes/permissions/route.test.tsx
@@ -17,31 +17,18 @@ const mocks = vi.hoisted(() => ({
accountId: 'acme',
allowed: true,
enabled: true,
- settingsFetching: false,
modes: {} as Record<string, 'none' | 'inherit' | 'restricted'>,
list: vi.fn(),
- change: vi.fn(),
- get: vi.fn(async (uri: string) => ({
- uri,
- acl_mode: mocks.modes[uri] ?? 'inherit',
- direct_entries: [{ principal: 'user:alice', level: 'read' }],
- inherited_entries: [],
- effective_entries: [],
- })),
+ get: vi.fn(),
}))
vi.mock('#/hooks/use-acl-management', () => ({
useAclManagement: () => ({
allowed: mocks.allowed,
- settings: {
- data: mocks.enabled,
- isSuccess: true,
- isFetching: mocks.settingsFetching,
- },
+ settings: { data: mocks.enabled, isSuccess: true, isFetching: false },
settingsKey: ['account-acl', mocks.accountId],
connection: { baseUrl: 'http://localhost', accountId: mocks.accountId },
- identityScopeKey: mocks.accountId,
aclIdentityScopeKey: mocks.accountId,
- api: { get: mocks.get, listDirectory: mocks.list, change: mocks.change },
+ api: { get: mocks.get, listDirectory: mocks.list },
}),
}))
vi.mock('#/components/account-acl-settings', () => ({
@@ -60,27 +47,20 @@ vi.mock('#/components/resource-acl-identity-recovery', () => ({
vi.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key }),
}))
-vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }))
beforeEach(() => {
mocks.allowed = true
mocks.enabled = true
- mocks.settingsFetching = false
mocks.accountId = 'acme'
mocks.modes = {}
- mocks.list.mockReset()
mocks.get.mockReset()
mocks.get.mockImplementation(async (uri: string) => ({
uri,
acl_mode: mocks.modes[uri] ?? 'inherit',
direct_entries: [{ principal: 'user:alice', level: 'read' }],
- inherited_entries: [],
+ inherited_entries: [{ principal: 'user:bob', level: 'write' }],
effective_entries: [],
}))
- mocks.change.mockReset()
- mocks.change.mockImplementation(async (uri, change) => {
- mocks.modes[uri] = change.kind === 'reset' ? 'inherit' : change.mode
- return mocks.get(uri)
- })
+ mocks.list.mockReset()
mocks.list.mockImplementation(async (uri: string) => ({
entries:
uri === root
@@ -91,6 +71,7 @@ beforeEach(() => {
}))
})
afterEach(cleanup)
+
function mount() {
const client = new QueryClient({
defaultOptions: { queries: { retry: false } },
@@ -101,246 +82,78 @@ function mount() {
</QueryClientProvider>
)
const view = render(element())
- return {
- ...view,
- user: userEvent.setup(),
- refresh: () => view.rerender(element()),
- }
+ return { user: userEvent.setup(), refresh: () => view.rerender(element()) }
}
-it('shows parent ACL errors and restores child controls after retry', async () => {
- const getReport = mocks.get.getMockImplementation()!
- let parentFails = true
- mocks.get.mockImplementation(async (uri) => {
- if (uri === `${root}im/` && parentFails) {
- throw new Error('Parent ACL request timed out')
- }
- return getReport(uri)
- })
- const { user } = mount()
- await user.click(await screen.findByRole('button', { name: 'im' }))
- const row = (await screen.findByRole('button', { name: 'feishu' })).closest(
- 'tr',
- )!
- const alert = await screen.findByRole('alert')
- expect(within(alert).getByText('acl.page.parentAclFailed')).toBeTruthy()
- expect(within(alert).getByText('Parent ACL request timed out')).toBeTruthy()
- const toggle = await within(row).findByRole('switch')
- const manager = within(row).getByRole('button', {
- name: 'acl.page.manageAction',
- })
- expect(toggle.hasAttribute('data-disabled')).toBe(true)
- expect(manager.hasAttribute('disabled')).toBe(true)
- parentFails = false
- await user.click(
- within(alert).getByRole('button', { name: 'actions.refresh' }),
- )
- await waitFor(() => expect(screen.queryByRole('alert')).toBeNull())
- expect(toggle.hasAttribute('data-disabled')).toBe(false)
- expect(manager.hasAttribute('disabled')).toBe(false)
-})
-
-it('discards an open confirmation when account ACL is disabled', async () => {
- const { user, refresh } = mount()
- const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
- await user.click(await within(row).findByRole('switch'))
- expect(screen.getByRole('alertdialog')).toBeTruthy()
- mocks.enabled = false
- refresh()
- await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull())
- expect(within(row).getByRole('switch').hasAttribute('data-disabled')).toBe(
- true,
- )
- expect(mocks.change).not.toHaveBeenCalled()
- mocks.enabled = true
- refresh()
- expect(screen.queryByRole('alertdialog')).toBeNull()
-})
-it('blocks directory changes while account settings are refreshing', async () => {
- const { user, refresh } = mount()
- const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
- const toggle = await within(row).findByRole('switch')
- mocks.settingsFetching = true
- refresh()
- expect(toggle.hasAttribute('data-disabled')).toBe(true)
- await user.click(toggle)
- expect(screen.queryByRole('alertdialog')).toBeNull()
- expect(mocks.change).not.toHaveBeenCalled()
- mocks.settingsFetching = false
- refresh()
- expect(toggle.hasAttribute('data-disabled')).toBe(false)
-})
-
-it('browses resources one directory at a time and edits permissions separately', async () => {
- const { user } = mount()
- expect(await screen.findByRole('button', { name: 'im' })).toBeTruthy()
- expect(screen.getByRole('button', { name: 'volcengine' })).toBeTruthy()
- expect(
- screen.queryByRole('button', { name: 'acl.page.addDirectory' }),
- ).toBeNull()
- await waitFor(() =>
- expect(
- screen.getAllByRole('button', { name: 'acl.page.manageAction' }),
- ).toHaveLength(2),
- )
-
- await user.click(screen.getByRole('button', { name: 'im' }))
- expect(await screen.findByRole('button', { name: 'feishu' })).toBeTruthy()
- expect(screen.queryByRole('button', { name: 'volcengine' })).toBeNull()
- await user.click(
- screen.getByRole('button', { name: 'acl.page.manageAction' }),
- )
- expect(
- within(screen.getByRole('dialog')).getByTestId('editor').textContent,
- ).toBe(`${root}im/feishu/`)
- await user.keyboard('{Escape}')
- await user.click(screen.getByRole('button', { name: 'acl.page.back' }))
- expect(await screen.findByRole('button', { name: 'volcengine' })).toBeTruthy()
-})
-it('shows recipient and permission level in a wider summary column', async () => {
- mocks.get.mockImplementation(async (uri: string) => ({
- uri,
- acl_mode: 'restricted',
- direct_entries: [
- { principal: 'group:fe-dev', level: 'read' },
- { principal: 'user:anonymous', level: 'write' },
- { principal: 'user:alice', level: 'manage' },
- { principal: 'user:bob', level: 'read' },
- ],
- inherited_entries: [],
- effective_entries: [],
- }))
+it('keeps grants and inheritance switches out of the directory list', async () => {
mount()
const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
- await waitFor(() => expect(within(row).getByText('+1')).toBeTruthy())
- expect(within(row).getByText('fe-dev')).toBeTruthy()
- expect(within(row).getByText('anonymous')).toBeTruthy()
- expect(within(row).getByText('alice')).toBeTruthy()
- expect(within(row).getByText('acl.levels.read')).toBeTruthy()
- expect(within(row).getByText('acl.levels.write')).toBeTruthy()
- expect(within(row).getByText('acl.levels.manage')).toBeTruthy()
+ expect(within(row).queryByRole('switch')).toBeNull()
+ expect(within(row).queryByText('alice')).toBeNull()
expect(within(row).queryByText('bob')).toBeNull()
- expect(within(row).getByText('+1').closest('td')?.getAttribute('title')).toBe(
- 'acl.subjects.group · fe-dev: acl.levels.read, acl.subjects.user · anonymous: acl.levels.write, acl.subjects.user · alice: acl.levels.manage, acl.subjects.user · bob: acl.levels.read',
+ expect(screen.queryByText('acl.page.granteesColumn')).toBeNull()
+ await waitFor(() =>
+ expect(within(row).getByText('acl.modes.inherit')).toBeTruthy(),
)
})
-it('enables permission management only after restricted access is switched on', async () => {
+
+it('allows management in every inheritance mode and browses directories', async () => {
mocks.modes[`${root}im/`] = 'none'
const { user } = mount()
const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
const manager = within(row).getByRole('button', {
name: 'acl.page.manageAction',
})
- expect(manager.hasAttribute('disabled')).toBe(true)
- await user.click(await within(row).findByRole('switch'))
- expect(mocks.change).not.toHaveBeenCalled()
+ expect(manager.hasAttribute('disabled')).toBe(false)
+ await user.click(manager)
+ expect(
+ within(screen.getByRole('dialog')).getByTestId('editor').textContent,
+ ).toBe(`${root}im/`)
+ await user.keyboard('{Escape}')
+ await user.click(within(row).getByRole('button', { name: 'im' }))
+ const child = (await screen.findByRole('button', { name: 'feishu' })).closest(
+ 'tr',
+ )!
await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
+ within(child).getByRole('button', { name: 'acl.page.manageAction' }),
)
- await waitFor(() =>
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/`, {
- kind: 'mode',
- mode: 'restricted',
+ expect(
+ within(screen.getByRole('dialog')).getByTestId('editor').textContent,
+ ).toBe(`${root}im/feishu/`)
+})
+
+it('opens management even when the row ACL report is denied', async () => {
+ mocks.get.mockRejectedValueOnce(
+ new OvClientError({
+ code: 'PERMISSION_DENIED',
+ message: 'Denied',
+ statusCode: 403,
}),
)
- await waitFor(() => expect(manager.hasAttribute('disabled')).toBe(false))
-})
-it('toggles a root child restriction independently of inherited grants', async () => {
- mocks.get.mockImplementation(async (uri: string) => {
- const mode = mocks.modes[uri] ?? 'inherit'
- const inherited = [{ principal: 'user:*', level: 'manage' }]
- return {
- uri,
- acl_mode: mode,
- direct_entries: [],
- inherited_entries: inherited,
- effective_entries: mode === 'restricted' ? [] : inherited,
- }
- })
const { user } = mount()
const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
- const toggle = await within(row).findByRole('switch')
- expect(toggle.getAttribute('aria-checked')).toBe('false')
- await user.click(toggle)
- await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
- )
- await waitFor(() => expect(toggle.getAttribute('aria-checked')).toBe('true'))
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/`, {
- kind: 'mode',
- mode: 'restricted',
- })
- await user.click(toggle)
- expect(screen.getByText('acl.page.disableLimitWarning')).toBeTruthy()
await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
+ within(row).getByRole('button', { name: 'acl.page.manageAction' }),
)
- await waitFor(() =>
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/`, { kind: 'reset' }),
- )
- await waitFor(() => expect(toggle.getAttribute('aria-checked')).toBe('false'))
- expect(within(row).getByText('acl.modes.inherit')).toBeTruthy()
+ expect(within(screen.getByRole('dialog')).getByTestId('editor')).toBeTruthy()
})
-it('lets a child stop and restore inheritance without clearing its grants', async () => {
- const { user } = mount()
+
+it('refreshes ACL reports without a local directory cache', async () => {
+ const { user, refresh } = mount()
await user.click(await screen.findByRole('button', { name: 'im' }))
- const row = (await screen.findByRole('button', { name: 'feishu' })).closest(
- 'tr',
- )!
- await waitFor(() => expect(within(row).getByRole('switch')).toBeTruthy())
- expect(within(row).getByText('acl.modes.inherit')).toBeTruthy()
- await user.click(within(row).getByRole('switch'))
- await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
- )
- await waitFor(() =>
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/feishu/`, {
- kind: 'mode',
- mode: 'restricted',
- }),
- )
- await user.click(within(row).getByRole('switch'))
- expect(
- within(screen.getByRole('alertdialog')).getByText(
- 'acl.page.restoreInheritanceWarning',
- ),
- ).toBeTruthy()
- await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
- )
+ await screen.findByRole('button', { name: 'feishu' })
+ mocks.get.mockClear()
+ await user.click(screen.getByRole('button', { name: 'actions.refresh' }))
await waitFor(() =>
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/feishu/`, {
- kind: 'mode',
- mode: 'inherit',
- }),
+ expect(mocks.get).toHaveBeenCalledWith(`${root}im/feishu/`),
)
- expect(
- within(row)
- .getByRole('button', { name: 'acl.page.manageAction' })
- .hasAttribute('disabled'),
- ).toBe(false)
-})
-it('loads the tree from the server for each account, without a browser-maintained directory list', async () => {
- const view = mount()
- await screen.findByRole('button', { name: 'im' })
- await view.user.click(screen.getByRole('button', { name: 'im' }))
- await screen.findByRole('button', { name: 'feishu' })
mocks.accountId = 'other'
- view.refresh()
+ refresh()
expect(await screen.findByRole('button', { name: 'volcengine' })).toBeTruthy()
expect(mocks.list).toHaveBeenCalledWith(root)
})
-it('shows a directory listing error with a retry action', async () => {
+
+it('shows directory errors and offers retry or identity recovery', async () => {
mocks.list.mockRejectedValueOnce(new Error('Network unavailable'))
const { user } = mount()
expect(await screen.findByText('Network unavailable')).toBeTruthy()
@@ -348,8 +161,7 @@ it('shows a directory listing error with a retry action', async () => {
screen.getAllByRole('button', { name: 'actions.refresh' })[1],
)
expect(await screen.findByRole('button', { name: 'im' })).toBeTruthy()
-})
-it('offers identity recovery when listing directories is denied', async () => {
+ cleanup()
mocks.list.mockRejectedValueOnce(
new OvClientError({
code: 'PERMISSION_DENIED',
@@ -360,65 +172,3 @@ it('offers identity recovery when listing directories is denied', async () => {
mount()
expect(await screen.findByTestId('identity-recovery')).toBeTruthy()
})
-it('opens the permission drawer when a row ACL report is denied', async () => {
- mocks.get.mockRejectedValueOnce(
- new OvClientError({
- code: 'PERMISSION_DENIED',
- message: 'Denied',
- statusCode: 403,
- }),
- )
- const { user } = mount()
- const row = (await screen.findByRole('button', { name: 'im' })).closest('tr')!
- const manager = within(row).getByRole('button', {
- name: 'acl.page.manageAction',
- })
- await waitFor(() => expect(manager.hasAttribute('disabled')).toBe(false))
- await user.click(manager)
- expect(within(screen.getByRole('dialog')).getByTestId('editor')).toBeTruthy()
-})
-it('keeps advanced account settings in the header and shows inline controls when disabled', () => {
- const { refresh } = mount()
- expect(screen.queryByTestId('account-settings')).toBeNull()
- expect(screen.getByTestId('advanced-settings')).toBeTruthy()
- mocks.enabled = false
- refresh()
- expect(screen.getByTestId('account-settings')).toBeTruthy()
- expect(screen.queryByTestId('advanced-settings')).toBeNull()
-})
-
-it('refreshes parent and child ACL reports even when directory entries are unchanged', async () => {
- const { user } = mount()
- await user.click(await screen.findByRole('button', { name: 'im' }))
- await screen.findByRole('button', { name: 'feishu' })
- await waitFor(() =>
- expect(screen.getByRole('switch').hasAttribute('disabled')).toBe(false),
- )
- mocks.get.mockClear()
- mocks.modes[`${root}im/`] = 'none'
- mocks.get.mockImplementation(async (uri: string) => ({
- uri,
- acl_mode: mocks.modes[uri] ?? 'restricted',
- direct_entries: [{ principal: 'user:bob', level: 'manage' }],
- inherited_entries: [],
- effective_entries: [],
- }))
- await user.click(screen.getByRole('button', { name: 'actions.refresh' }))
- await waitFor(() => {
- expect(mocks.get).toHaveBeenCalledWith(`${root}im/`)
- expect(mocks.get).toHaveBeenCalledWith(`${root}im/feishu/`)
- expect(screen.getByText('bob')).toBeTruthy()
- expect(screen.getByText('acl.modes.restricted')).toBeTruthy()
- })
- await user.click(screen.getByRole('switch'))
- await user.click(
- within(screen.getByRole('alertdialog')).getByRole('button', {
- name: 'acl.confirm',
- }),
- )
- await waitFor(() =>
- expect(mocks.change).toHaveBeenCalledWith(`${root}im/feishu/`, {
- kind: 'reset',
- }),
- )
-})
diff --git a/web-studio/src/routes/vikingbot/-components/brand-icons/dingtalk.svg b/web-studio/src/routes/vikingbot/-components/brand-icons/dingtalk.svg
new file mode 100644
index 000000000..ffb462392
--- /dev/null
+++ b/web-studio/src/routes/vikingbot/-components/brand-icons/dingtalk.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 1024 1024"><path fill="currentColor" d="M573.7 252.5C422.5 197.4 201.3 96.7 201.3 96.7c-15.7-4.1-17.9 11.1-17.9 11.1c-5 61.1 33.6 160.5 53.6 182.8c19.9 22.3 319.1 113.7 319.1 113.7S326 357.9 270.5 341.9c-55.6-16-37.9 17.8-37.9 17.8c11.4 61.7 64.9 131.8 107.2 138.4c42.2 6.6 220.1 4 220.1 4s-35.5 4.1-93.2 11.9c-42.7 5.8-97 12.5-111.1 17.8c-33.1 12.5 24 62.6 24 62.6c84.7 76.8 129.7 50.5 129.7 50.5c33.3-10.7 61.4-18.5 85.2-24.2L565 743.1h84.6L603 928l205.3-271.9H700.8l22.3-38.7c.3.5.4.8.4.8S799.8 496.1 829 433.8l.6-1h-.1c5-10.8 8.6-19.7 10-25.8c17-71.3-114.5-99.4-265.8-154.5"/></svg>
\ No newline at end of file
diff --git a/web-studio/src/routes/vikingbot/-components/brand-icons/discord.svg b/web-studio/src/routes/vikingbot/-components/brand-icons/discord.svg
new file mode 100644
index 000000000..9d7796b8a
--- /dev/null
+++ b/web-studio/src/routes/vikingbot/-components/brand-icons/discord.svg
@@ -0,0 +1 @@
+<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Discord</title><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg>
\ No newline at end of file
diff --git a/web-studio/src/routes/vikingbot/-components/brand-icons/feishu.svg b/web-studio/src/routes/vikingbot/-components/brand-icons/feishu.svg
new file mode 100644
index 000000000..11418d391
--- /dev/null
+++ b/web-studio/src/routes/vikingbot/-components/brand-icons/feishu.svg
@@ -0,0 +1 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.13732 3.80654C8.76716 5.98777 11.0232 8.49408 12.7428 11.4327L14.4397 9.75535C15.2458 8.96545 16.2113 8.34129 17.258 7.93496C16.7802 6.31936 16.0033 4.98005 14.9403 3.65376C14.8135 3.49449 14.6185 3.40346 14.4137 3.40346L6.28362 3.40021C6.06906 3.40021 5.9748 3.67001 6.13732 3.80654Z" fill="black"/><path d="M20.5703 14.1922L20.58 14.1793L20.6155 14.1146C20.6026 14.1372 20.5864 14.1631 20.5703 14.1922Z" fill="black"/><path d="M11.0361 14.5567C12.2714 15.0833 13.3766 15.5287 14.6899 15.883C17.0207 16.5136 19.2311 15.5709 20.3234 13.4872L21.6432 10.8541C21.939 10.2105 22.3128 9.6156 22.7647 9.07273C21.9715 8.78016 21.3149 8.63064 20.4534 8.63064C18.5518 8.63064 16.7606 9.36205 15.4018 10.6948L13.3831 12.6875C12.6647 13.3929 11.878 14.0203 11.0361 14.5567Z" fill="black"/><path d="M20.7945 13.7752L20.8039 13.7566L20.8101 13.7473C20.8039 13.7535 20.8007 13.7659 20.7945 13.7752Z" fill="black"/><path d="M1.62519 9.74885C1.47889 9.60906 1.23511 9.70983 1.23511 9.91463L1.23834 17.8724C1.23834 18.1 1.34887 18.3112 1.53416 18.4348C3.66663 19.8521 6.15343 20.5998 8.72151 20.5998C11.166 20.5998 13.5488 19.9171 15.6098 18.6266C16.3867 18.139 16.9979 17.7099 17.6512 17.0792C16.6013 17.388 15.4472 17.4075 14.2835 17.0922C9.37815 15.7594 5.20097 13.2044 1.62519 9.74885Z" fill="black"/></svg>
\ No newline at end of file
diff --git a/web-studio/src/routes/vikingbot/-components/brand-icons/slack.svg b/web-studio/src/routes/vikingbot/-components/brand-icons/slack.svg
new file mode 100644
index 000000000..d254d8665
--- /dev/null
+++ b/web-studio/src/routes/vikingbot/-components/brand-icons/slack.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M5.042 15.165a2.53 2.53 0 0 1-2.52 2.523A2.53 2.53 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52a2.527 2.527 0 0 1 2.521 2.52v6.313A2.53 2.53 0 0 1 8.834 24a2.53 2.53 0 0 1-2.521-2.522zM8.834 5.042a2.53 2.53 0 0 1-2.521-2.52A2.53 2.53 0 0 1 8.834 0a2.53 2.53 0 0 1 2.521 2.522v2.52zm0 1.271a2.53 2.53 0 0 1 2.521 2.521a2.53 2.53 0 0 1-2.521 2.521H2.522A2.53 2.53 0 0 1 0 8.834a2.53 2.53 0 0 1 2.522-2.521zm10.122 2.521a2.53 2.53 0 0 1 2.522-2.521A2.53 2.53 0 0 1 24 8.834a2.53 2.53 0 0 1-2.522 2.521h-2.522zm-1.268 0a2.53 2.53 0 0 1-2.523 2.521a2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.53 2.53 0 0 1 2.523 2.522zm-2.523 10.122a2.53 2.53 0 0 1 2.523 2.522A2.53 2.53 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522zm0-1.268a2.527 2.527 0 0 1-2.52-2.523a2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.53 2.53 0 0 1-2.522 2.523z"/></svg>
\ No newline at end of file
diff --git a/web-studio/src/routes/vikingbot/-components/brand-icons/telegram.svg b/web-studio/src/routes/vikingbot/-components/brand-icons/telegram.svg
new file mode 100644
index 000000000..c46b0ed70
--- /dev/null
+++ b/web-studio/src/routes/vikingbot/-components/brand-icons/telegram.svg
@@ -0,0 +1 @@
+<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Telegram</title><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>
\ No newline at end of file
diff --git a/web-studio/src/routes/vikingbot/-components/platform-icon.tsx b/web-studio/src/routes/vikingbot/-components/platform-icon.tsx
index dd01c45e1..b5495fa00 100644
--- a/web-studio/src/routes/vikingbot/-components/platform-icon.tsx
+++ b/web-studio/src/routes/vikingbot/-components/platform-icon.tsx
@@ -1,29 +1,30 @@
-import {
- FeatherIcon,
- Gamepad2Icon,
- HashIcon,
- SendIcon,
- ZapIcon,
-} from 'lucide-react'
-import type { LucideIcon } from 'lucide-react'
+import discordIcon from './brand-icons/discord.svg?url'
+import dingtalkIcon from './brand-icons/dingtalk.svg?url'
+import feishuIcon from './brand-icons/feishu.svg?url'
+import slackIcon from './brand-icons/slack.svg?url'
+import telegramIcon from './brand-icons/telegram.svg?url'
-const icons: Record<string, LucideIcon | undefined> = {
- feishu: FeatherIcon,
- slack: HashIcon,
- dingtalk: ZapIcon,
- discord: Gamepad2Icon,
- telegram: SendIcon,
+// Feishu: Semi Icons (MIT); DingTalk: Ant Design Icons (MIT);
+// Slack, Discord, Telegram: Simple Icons (CC0).
+const icons: Record<string, string> = {
+ feishu: feishuIcon,
+ slack: slackIcon,
+ dingtalk: dingtalkIcon,
+ discord: discordIcon,
+ telegram: telegramIcon,
}
export function PlatformIcon({ platform }: { platform: string }) {
- const Icon = icons[platform.toLowerCase()]
- if (!Icon) return null
+ const icon = icons[platform.toLowerCase()]
+ if (!icon) return null
+ const mask = `url("${icon}") center / contain no-repeat`
+
return (
<span
className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted/50 text-muted-foreground"
aria-hidden="true"
>
- <Icon className="size-5" />
+ <span className="size-5 bg-current" style={{ mask, WebkitMask: mask }} />
</span>
)
}