fix: never greet the user by the assistant's default name (UF-055)
Home and the sidebar read the user's name from the identity row, which the sidecar fills with the assistant's identity named Waggle. Both now use the profile name, with the identity name as a fallback that skips the default.
This commit is contained in:
@@ -24,6 +24,7 @@ import RouteTransition from './RouteTransition';
|
||||
import Sidebar, { type SidebarNavItem } from './Sidebar';
|
||||
import AppErrorBoundary from './ErrorBoundary';
|
||||
import { adapter } from '@/lib/adapter';
|
||||
import { pickUserName } from '@/lib/user-name';
|
||||
import { stashDeepLink } from '@/lib/app-deeplink';
|
||||
import { writeLoginBriefingDismissed, writeLoginBriefingLastDismissedAt, readLoginBriefingDismissed, readSkipBriefingParam } from '@/lib/login-briefing';
|
||||
import { prefetchBriefing, computeAwayDays, BRIEFING_ABSENCE_DAYS } from '@/lib/briefing-source';
|
||||
@@ -198,10 +199,17 @@ const ShellLayout = () => {
|
||||
const [userName, setUserName] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
// The user's name comes from their profile; the identity row is a fallback
|
||||
// that may hold the assistant's default name (UF-055). Neither set: the row
|
||||
// degrades to "Account".
|
||||
const loadIdentity = () => {
|
||||
adapter.getIdentity()
|
||||
.then(r => { if (!cancelled) setUserName(r.name ?? null); })
|
||||
.catch(() => { /* identity is optional — the row degrades to "Account" */ });
|
||||
const read = <T,>(fn: () => Promise<T>) => Promise.resolve().then(fn).catch(() => null);
|
||||
void Promise.all([read(() => adapter.getProfile()), read(() => adapter.getIdentity())])
|
||||
.then(([profile, identity]) => {
|
||||
if (cancelled) return;
|
||||
const profileName = typeof profile?.name === 'string' ? profile.name : null;
|
||||
setUserName(pickUserName(profileName, identity?.name));
|
||||
});
|
||||
};
|
||||
loadIdentity();
|
||||
window.addEventListener('waggle:connect-settled', loadIdentity);
|
||||
|
||||
Reference in New Issue
Block a user