Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/buddy/electron/main/config/LexoraConfigStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ const desktopConfigSchema = z.object({
device_name: '',
avatar: '',
}),
agent_profile: z.object({
name: z.string().max(30).default(''),
avatar: z.string().max(DESKTOP_PROFILE_AVATAR_MAX_DATA_URL_LENGTH).default(''),
sync_with_user_profile: z.boolean().default(false),
}).passthrough().default({
name: '',
avatar: '',
sync_with_user_profile: false,
}),
developer_tools_enabled: z.boolean().default(false),
language: z.enum(['zh-CN', 'en-US']).default('zh-CN'),
launch_at_login: z.boolean().default(false),
Expand All @@ -86,6 +95,7 @@ const desktopConfigSchema = z.object({
task_sidebar_pinned_items: [],
task_sidebar: { collapsed: false, collapsed_sections: [], collapsed_spaces: [] },
profile: { user_name: '', device_name: '', avatar: '' },
agent_profile: { name: '', avatar: '', sync_with_user_profile: false },
developer_tools_enabled: false,
language: 'zh-CN',
launch_at_login: false,
Expand Down Expand Up @@ -312,6 +322,11 @@ function decodeConfig(value: unknown): LexoraConfig {
deviceName: config.desktop.profile.device_name,
avatar: config.desktop.profile.avatar,
},
agentProfile: {
name: config.desktop.agent_profile.name,
avatar: config.desktop.agent_profile.avatar,
syncWithUserProfile: config.desktop.agent_profile.sync_with_user_profile,
},
developerToolsEnabled: config.desktop.developer_tools_enabled,
language: config.desktop.language,
launchAtLogin: config.desktop.launch_at_login,
Expand Down Expand Up @@ -363,6 +378,11 @@ function encodeConfig(config: LexoraConfig) {
device_name: config.desktop.profile.deviceName,
avatar: config.desktop.profile.avatar,
},
agent_profile: {
name: config.desktop.agentProfile.name,
avatar: config.desktop.agentProfile.avatar,
sync_with_user_profile: config.desktop.agentProfile.syncWithUserProfile,
},
developer_tools_enabled: config.desktop.developerToolsEnabled,
language: config.desktop.language,
launch_at_login: config.desktop.launchAtLogin,
Expand Down Expand Up @@ -405,6 +425,10 @@ function mergeConfig(current: LexoraConfig, patch: LexoraConfigPatch): LexoraCon
...current.desktop.profile,
...patch.desktop?.profile,
},
agentProfile: {
...current.desktop.agentProfile,
...patch.desktop?.agentProfile,
},
},
pet: {
...current.pet,
Expand Down Expand Up @@ -433,6 +457,10 @@ function mergeConfigFile(file: unknown, config: LexoraConfig): Record<string, un
...asRecord(desktop.profile),
...asRecord(encoded.desktop.profile),
},
agent_profile: {
...asRecord(desktop.agent_profile),
...asRecord(encoded.desktop.agent_profile),
},
}
delete nextDesktop.chat_sidebar_section_order
delete nextDesktop.chat_sidebar_pinned_items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ describe('lexoraConfigStore', () => {
deviceName: '',
userName: '',
},
agentProfile: {
avatar: '',
name: '',
syncWithUserProfile: false,
},
sidebarCollapsed: false,
theme: 'dark',
})
Expand Down
10 changes: 9 additions & 1 deletion apps/buddy/electron/shared/desktopApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export interface DesktopUserProfileConfig {
avatar: string
}

export interface DesktopAgentProfileConfig {
name: string
avatar: string
syncWithUserProfile: boolean
}

export interface DesktopAppInfo {
runtimeProfile: BuddyRuntimeProfile
isPackaged: boolean
Expand Down Expand Up @@ -181,6 +187,7 @@ export interface LexoraConfig {
updateNotificationsEnabled: boolean
notifyWhenFocused: boolean
profile: DesktopUserProfileConfig
agentProfile: DesktopAgentProfileConfig
pluginAuthor: string
sidebarCollapsed: boolean
theme: 'system' | 'light' | 'dark'
Expand All @@ -196,10 +203,11 @@ export interface LexoraConfigPatch {
runtime?: Partial<LexoraConfig['runtime']>
browser?: Partial<LexoraConfig['browser']>
proxy?: LexoraConfig['proxy']
desktop?: Partial<Omit<LexoraConfig['desktop'], 'chat' | 'taskSidebar' | 'profile'>> & {
desktop?: Partial<Omit<LexoraConfig['desktop'], 'agentProfile' | 'chat' | 'taskSidebar' | 'profile'>> & {
chat?: Partial<DesktopChatPreferences>
taskSidebar?: Partial<DesktopTaskSidebarPreferences>
profile?: Partial<DesktopUserProfileConfig>
agentProfile?: Partial<DesktopAgentProfileConfig>
}
pet?: Partial<LexoraConfig['pet']>
}
Expand Down
7 changes: 7 additions & 0 deletions apps/buddy/electron/shared/desktopApiSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const desktopUserProfilePatchSchema = z.object({
avatar: z.string().max(DESKTOP_PROFILE_AVATAR_MAX_DATA_URL_LENGTH).optional(),
}).strict()

const desktopAgentProfilePatchSchema = z.object({
name: z.string().max(30).optional(),
avatar: z.string().max(DESKTOP_PROFILE_AVATAR_MAX_DATA_URL_LENGTH).optional(),
syncWithUserProfile: z.boolean().optional(),
}).strict()

export const feedbackIssueInputSchema = z.object({
feedback: z.string().max(4_000),
}).strict()
Expand Down Expand Up @@ -75,6 +81,7 @@ export const lexoraConfigPatchSchema: z.ZodType<LexoraConfigPatch> = z.object({
taskSidebarPinnedItems: taskSidebarPinnedItemsSchema.optional(),
taskSidebar: taskSidebarPreferencesSchema.optional(),
profile: desktopUserProfilePatchSchema.optional(),
agentProfile: desktopAgentProfilePatchSchema.optional(),
developerToolsEnabled: z.boolean().optional(),
pluginAuthor: extensionAuthorSchema.optional(),
language: z.enum(['zh-CN', 'en-US']).optional(),
Expand Down
31 changes: 31 additions & 0 deletions apps/buddy/src/app/bootstrap/DesktopAppProvider.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import type { DesktopAgentProfileConfig, DesktopUserProfileConfig } from '@buddy-electron/shared/desktopApi'
import type { DesktopShellBindings } from '../shell/desktopShellBindings'
import type { DesktopBrowserGuestSurfaceHost } from '@/platform/browser/browserGuestSurface'
import { DEFAULT_DESKTOP_CHAT_PREFERENCES } from '@buddy-electron/shared/desktopApi'
Expand All @@ -9,7 +10,8 @@
import { useProvideAutomationContext } from '@/modules/automations'
import { useExtensionState, useExtensionUiContributions, useExtensionViews, useProvideExtensionContext } from '@/modules/extensions'
import { DesktopExtensionControl, DesktopExtensionFrameHost, DesktopExtensionMenu, DesktopExtensionOverlays, DesktopExtensionReviewHost, DesktopExtensionSlot } from '@/modules/extensions/ui'
import { usePluginSettings, useProvideSettingsContext, useSettingsRegistry } from '@/modules/settings'

Check failure on line 13 in apps/buddy/src/app/bootstrap/DesktopAppProvider.vue

View workflow job for this annotation

GitHub Actions / Workspace checks

'@/modules/settings' imported multiple times
import { resolveUserProfile } from '@/modules/settings'

Check failure on line 14 in apps/buddy/src/app/bootstrap/DesktopAppProvider.vue

View workflow job for this annotation

GitHub Actions / Workspace checks

'@/modules/settings' imported multiple times
import { useProvideSkillsContext } from '@/modules/skills'
import { useProvideTaskEnvironment, useTaskIndex, useTaskResourcePanel } from '@/modules/tasks'
import { useProvideDesktopUpdates } from '@/modules/updates'
Expand Down Expand Up @@ -207,6 +209,32 @@
const browserGuests = useBrowserGuestHost(browserGuestHost)
onScopeDispose(workbench.controller.subscribe(() => void nextTick(() => browserGuests.layout?.())))
const toggleAppSidebar = () => void shell.setAppSidebarCollapsed(!shell.appSidebarCollapsed.value)
const profileConfig = computed(() => stores.applicationSettings.config.value?.desktop.profile ?? { avatar: '', deviceName: '', userName: '' })
const agentProfileConfig = computed(() => stores.applicationSettings.config.value?.desktop.agentProfile ?? { avatar: '', name: '', syncWithUserProfile: false })
const agentIdentity = computed(() => {
const profile = agentProfileConfig.value
if (!profile.syncWithUserProfile)
return { avatar: profile.avatar, avatarColor: null, initials: null, name: profile.name }
const resolved = resolveUserProfile(stores.applicationSettings.config.value?.desktop.profile, shell.appInfo.value)
return {
avatar: resolved.avatarUrl ?? '',
avatarColor: resolved.avatarUrl ? null : resolved.avatarColor,
initials: resolved.avatarUrl ? null : resolved.initials,
name: resolved.userName,
}
})
async function updateProfile(patch: Partial<DesktopUserProfileConfig>) {
const saved = await stores.applicationSettings.updateSettings({ desktop: { profile: patch } })
if (saved)
message.success(translateBuddy(stores.applicationSettings.language.value, 'desktop.account.saveSuccess'))
return saved
}
async function updateAgentProfile(patch: Partial<DesktopAgentProfileConfig>) {
const saved = await stores.applicationSettings.updateSettings({ desktop: { agentProfile: patch } })
if (saved)
message.success(translateBuddy(stores.applicationSettings.language.value, 'desktop.agent.saveSuccess'))
return saved
}

const shellBindings: DesktopShellBindings = {
pages,
Expand Down Expand Up @@ -240,6 +268,7 @@
chat: computed(() => stores.applicationSettings.config.value?.desktop.chat ?? DEFAULT_DESKTOP_CHAT_PREFERENCES),
language: stores.applicationSettings.language,
appSidebarCollapsed: shell.appSidebarCollapsed,
agentIdentity,
})
useProvideTaskEnvironment({
resources,
Expand All @@ -257,6 +286,8 @@
appInfo: shell.appInfo,
dataSettings: capabilities.dataSettings,
platformCapabilities: shell.platformCapabilities,
profile: { config: profileConfig, update: updateProfile },
agentProfile: { config: agentProfileConfig, update: updateAgentProfile },
providerSettings: stores.modelProviders,
ready,
webSettings: capabilities.webSettings,
Expand Down
14 changes: 14 additions & 0 deletions apps/buddy/src/i18n/locales/en-US/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export default {
'desktop.about.node': 'Node.js: {version}',
'desktop.about.title': 'About Lexora Buddy',
'desktop.about.version': 'Version: {version}',
'desktop.agent.avatarInvalidType': 'Please select an image file.',
'desktop.agent.avatarReadFailed': 'Failed to read image.',
'desktop.agent.avatarTooLarge': 'Image file must be under 2MB.',
'desktop.agent.changeAvatar': 'Change avatar',
'desktop.agent.name': 'Name',
'desktop.agent.nameHelp': 'Shown above AI replies in chat. Leave empty to use the default name.',
'desktop.agent.namePlaceholder': 'e.g. Lexora Buddy',
'desktop.agent.resetAvatar': 'Reset avatar',
'desktop.agent.saveAction': 'Save',
'desktop.agent.saveFailed': 'Failed to save. Try again.',
'desktop.agent.saveSuccess': 'AI identity updated',
'desktop.agent.sectionTitle': 'AI identity',
'desktop.agent.syncWithProfile': 'Sync with profile avatar and name',
'desktop.agent.syncedFromProfile': 'Using the avatar and name from your profile',
'desktop.command.app.about': 'About Lexora Buddy',
'desktop.command.app.checkUpdates': 'Check for updates…',
'desktop.command.app.quit': 'Quit',
Expand Down
14 changes: 14 additions & 0 deletions apps/buddy/src/i18n/locales/zh-CN/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ export default {
'desktop.about.node': 'Node.js:{version}',
'desktop.about.title': '关于 Lexora Buddy',
'desktop.about.version': '版本:{version}',
'desktop.agent.avatarInvalidType': '请选择图片文件。',
'desktop.agent.avatarReadFailed': '读取图片失败。',
'desktop.agent.avatarTooLarge': '图片大小不能超过 2MB。',
'desktop.agent.changeAvatar': '更换头像',
'desktop.agent.name': '名字',
'desktop.agent.nameHelp': '显示在聊天窗口 AI 回复上方,留空则使用默认名称。',
'desktop.agent.namePlaceholder': '例如:Lexora Buddy',
'desktop.agent.resetAvatar': '恢复默认头像',
'desktop.agent.saveAction': '保存',
'desktop.agent.saveFailed': '保存失败,请重试',
'desktop.agent.saveSuccess': 'AI 身份已更新',
'desktop.agent.sectionTitle': 'AI 身份',
'desktop.agent.syncWithProfile': '同步用户头像与名称',
'desktop.agent.syncedFromProfile': '当前使用个人资料里的头像与名称',
'desktop.command.app.about': '关于 Lexora Buddy',
'desktop.command.app.checkUpdates': '检查更新…',
'desktop.command.app.quit': '退出',
Expand Down
1 change: 1 addition & 0 deletions apps/buddy/src/modules/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export { useSettingsRegistry } from './state/useSettingsRegistry'
export { useUsageStore } from './state/useUsageStore'
export type { WebSettingsCapability } from './state/useWebSettingsCapability'
export { useWebSettingsCapability } from './state/useWebSettingsCapability'
export { resolveUserProfile } from './widgets/account/userProfile'
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script setup lang="ts">
import DesktopSettingsModuleLayout from '@/modules/settings/layouts/DesktopSettingsModuleLayout.vue'
import { computed } from 'vue'

Check failure on line 3 in apps/buddy/src/modules/settings/pages/DesktopAppearanceSettingsView.vue

View workflow job for this annotation

GitHub Actions / Workspace checks

Expected "vue" (value-external) to come before "@/modules/settings/layouts/DesktopSettingsModuleLayout.vue" (value-internal)
import { useSettingsContext } from '@/modules/settings/settingsContext'
import { resolveUserProfile } from '@/modules/settings/widgets/account/userProfile'
import DesktopAgentIdentitySettings from '@/modules/settings/widgets/app/DesktopAgentIdentitySettings.vue'
import DesktopAppearanceSettings from '@/modules/settings/widgets/app/DesktopAppearanceSettings.vue'

const { applicationSettings } = useSettingsContext()
const { agentProfile, appInfo, applicationSettings, profile } = useSettingsContext()
const { config, settingsError, language, updateSettings } = applicationSettings
const agentProfileConfig = computed(() => agentProfile.config.value)
const syncedProfile = computed(() => resolveUserProfile(profile.config.value, appInfo.value))
</script>

<template>
Expand All @@ -15,5 +20,11 @@
:language="language"
:update-settings="updateSettings"
/>
<DesktopAgentIdentitySettings
:language="language"
:profile="agentProfileConfig"
:synced-profile="syncedProfile"
:update-profile="agentProfile.update"
/>
</DesktopSettingsModuleLayout>
</template>
10 changes: 9 additions & 1 deletion apps/buddy/src/modules/settings/settingsContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DesktopAppInfo, DesktopBrowserApi } from '@buddy-electron/shared/desktopApi'
import type { DesktopAgentProfileConfig, DesktopAppInfo, DesktopBrowserApi, DesktopUserProfileConfig } from '@buddy-electron/shared/desktopApi'
import type { BuddyCapabilities } from '@buddy-shared/platform'
import type { Ref } from 'vue'
import type { ApplicationSettings, ShortcutSettings } from './contracts'
Expand All @@ -19,6 +19,14 @@ export interface SettingsContext {
applicationSettings: ApplicationSettings
dataSettings: DesktopDataSettingsCapability
platformCapabilities: Readonly<Ref<BuddyCapabilities | null>>
profile: {
config: Readonly<Ref<DesktopUserProfileConfig>>
update: (patch: Partial<DesktopUserProfileConfig>) => Promise<boolean>
}
agentProfile: {
config: Readonly<Ref<DesktopAgentProfileConfig>>
update: (patch: Partial<DesktopAgentProfileConfig>) => Promise<boolean>
}
providerSettings: ModelProvidersStore
ready: Promise<void>
openTask: (conversationId: string) => Promise<void>
Expand Down
Loading
Loading