|
|
@@ -25,6 +25,7 @@ import { workspaceAvatarMembers, workspaceAvatarState, workspaceConversationItem
|
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
import { useThemeStore } from '@/stores/theme'
|
|
|
import { apiRequest } from '@/api/client'
|
|
|
+import { updateProfileIdentity, type ProfileIdentityInput } from '@/api/profiles'
|
|
|
import type { JsonValue } from '@shared/types'
|
|
|
import type {
|
|
|
WorkspaceAgent as Agent,
|
|
|
@@ -55,6 +56,9 @@ const text = ref(''),
|
|
|
files = ref<WorkspaceFile[]>([]),
|
|
|
mentions = ref<string[]>([]),
|
|
|
older = ref(true)
|
|
|
+const identityBusy = ref(false),
|
|
|
+ identityError = ref(''),
|
|
|
+ identityResetVersion = ref(0)
|
|
|
const searchItems = computed<SidebarItem[]>(() => [false, true].map(archived => {
|
|
|
const items = conversations.value.filter(c => c.archived === archived).map(c => workspaceConversationItem(c, agents.value))
|
|
|
return { id: archived ? 'archived' : 'unarchived', title: archived ? '已归档' : '未归档', children: items, emptyText: archived ? '没有已归档聊天' : '没有未归档聊天' }
|
|
|
@@ -158,6 +162,22 @@ const selected = computed(() => (typeof route.params.id === 'string' ? route.par
|
|
|
const members = computed(() => agents.value.filter((a) => active.value?.memberIds.includes(a.id)))
|
|
|
const isAgentDialog = computed(() => dialog.value === 'agent' || dialog.value === 'editAgent')
|
|
|
const body = (v: unknown) => v as JsonValue
|
|
|
+async function saveProfileIdentity(input: ProfileIdentityInput) {
|
|
|
+ const profile = auth.activeProfile
|
|
|
+ if (!profile) return
|
|
|
+ identityBusy.value = true
|
|
|
+ identityError.value = ''
|
|
|
+ try {
|
|
|
+ await updateProfileIdentity(profile, input)
|
|
|
+ await auth.refreshProfiles()
|
|
|
+ await auth.refreshProfileAvatars()
|
|
|
+ identityResetVersion.value += 1
|
|
|
+ } catch (cause) {
|
|
|
+ identityError.value = cause instanceof Error ? cause.message : '保存 Agent 身份失败'
|
|
|
+ } finally {
|
|
|
+ identityBusy.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
async function refresh() {
|
|
|
const [a, c] = await Promise.all([
|
|
|
apiRequest<{ agents: Agent[] }>('/api/app/agents'),
|
|
|
@@ -482,6 +502,7 @@ function rendered(m: Message) {
|
|
|
|
|
|
watch(selected, () => void load())
|
|
|
onMounted(async () => {
|
|
|
+ void auth.refreshProfileAvatars().catch(() => undefined)
|
|
|
try {
|
|
|
await apiRequest('/api/app/capabilities')
|
|
|
await refresh()
|
|
|
@@ -507,12 +528,16 @@ onBeforeUnmount(() => {
|
|
|
:upstream-error="auth.upstreamError"
|
|
|
:theme="theme.resolvedTheme"
|
|
|
:theme-preference="theme.theme"
|
|
|
+ :identity-busy="identityBusy"
|
|
|
+ :identity-error="identityError"
|
|
|
+ :identity-reset-version="identityResetVersion"
|
|
|
sidebar-title="聊天"
|
|
|
sidebar-context-title="聊天列表"
|
|
|
@logout="auth.logout"
|
|
|
@select-profile="auth.selectProfile"
|
|
|
@toggle-theme="theme.toggle"
|
|
|
@set-theme="theme.setTheme"
|
|
|
+ @save-identity="saveProfileIdentity"
|
|
|
@create-agent="openDialog('agent')"
|
|
|
@create-group="openDialog('group')"
|
|
|
>
|