
























@@ -53,17 +53,25 @@ import {
5353tabFromPath,
5454type Tab,
5555} from "./navigation.ts";
56-import { saveSettings, type UiSettings } from "./storage.ts";
56+import {
57+saveLocalUserIdentity,
58+saveSettings,
59+type LocalUserIdentity,
60+type UiSettings,
61+} from "./storage.ts";
5762import { normalizeOptionalString } from "./string-coerce.ts";
5863import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition.ts";
5964import { resolveTheme, type ResolvedTheme, type ThemeMode, type ThemeName } from "./theme.ts";
6065import type { AgentsListResult, AttentionItem } from "./types.ts";
66+import { normalizeLocalUserIdentity } from "./user-identity.ts";
6167import { resetChatViewState } from "./views/chat.ts";
62686369export { setLastActiveSessionKey } from "./app-last-active-session.ts";
64706571type SettingsHost = {
6672settings: UiSettings;
73+userName?: string | null;
74+userAvatar?: string | null;
6775password?: string;
6876theme: ThemeName;
6977themeMode: ThemeMode;
@@ -93,6 +101,11 @@ type SettingsHost = {
93101dreamDiaryContent: string | null;
94102};
95103104+type LocalUserIdentityHost = {
105+userName?: string | null;
106+userAvatar?: string | null;
107+};
108+96109type SettingsAppHost = SettingsHost &
97110AgentFilesState &
98111AgentIdentityState &
@@ -137,6 +150,20 @@ export function applySettings(host: SettingsHost, next: UiSettings) {
137150host.applySessionKey = host.settings.lastActiveSessionKey;
138151}
139152153+export function applyLocalUserIdentity(
154+host: LocalUserIdentityHost,
155+next: Partial<LocalUserIdentity>,
156+) {
157+const normalized = normalizeLocalUserIdentity({
158+name: host.userName,
159+avatar: host.userAvatar,
160+ ...next,
161+});
162+host.userName = normalized.name;
163+host.userAvatar = normalized.avatar;
164+saveLocalUserIdentity(normalized);
165+}
166+140167function applySessionSelection(host: SettingsHost, session: string) {
141168host.sessionKey = session;
142169applySettings(host, {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。