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:
shumeiko.it
2026-10-27 14:24:35 +01:00
parent c2998f1a6b
commit 659c84bee2
8 changed files with 111 additions and 13 deletions

View File

@@ -24,6 +24,7 @@ import RouteTransition from './RouteTransition';
import Sidebar, { type SidebarNavItem } from './Sidebar'; import Sidebar, { type SidebarNavItem } from './Sidebar';
import AppErrorBoundary from './ErrorBoundary'; import AppErrorBoundary from './ErrorBoundary';
import { adapter } from '@/lib/adapter'; import { adapter } from '@/lib/adapter';
import { pickUserName } from '@/lib/user-name';
import { stashDeepLink } from '@/lib/app-deeplink'; import { stashDeepLink } from '@/lib/app-deeplink';
import { writeLoginBriefingDismissed, writeLoginBriefingLastDismissedAt, readLoginBriefingDismissed, readSkipBriefingParam } from '@/lib/login-briefing'; import { writeLoginBriefingDismissed, writeLoginBriefingLastDismissedAt, readLoginBriefingDismissed, readSkipBriefingParam } from '@/lib/login-briefing';
import { prefetchBriefing, computeAwayDays, BRIEFING_ABSENCE_DAYS } from '@/lib/briefing-source'; import { prefetchBriefing, computeAwayDays, BRIEFING_ABSENCE_DAYS } from '@/lib/briefing-source';
@@ -198,10 +199,17 @@ const ShellLayout = () => {
const [userName, setUserName] = useState<string | null>(null); const [userName, setUserName] = useState<string | null>(null);
useEffect(() => { useEffect(() => {
let cancelled = false; 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 = () => { const loadIdentity = () => {
adapter.getIdentity() const read = <T,>(fn: () => Promise<T>) => Promise.resolve().then(fn).catch(() => null);
.then(r => { if (!cancelled) setUserName(r.name ?? null); }) void Promise.all([read(() => adapter.getProfile()), read(() => adapter.getIdentity())])
.catch(() => { /* identity is optional — the row degrades to "Account" */ }); .then(([profile, identity]) => {
if (cancelled) return;
const profileName = typeof profile?.name === 'string' ? profile.name : null;
setUserName(pickUserName(profileName, identity?.name));
});
}; };
loadIdentity(); loadIdentity();
window.addEventListener('waggle:connect-settled', loadIdentity); window.addEventListener('waggle:connect-settled', loadIdentity);

View File

@@ -0,0 +1,18 @@
import { describe, it, expect } from 'vitest';
import { pickUserName } from './user-name';
describe('pickUserName (UF-055)', () => {
it('prefers the name in the profile', () => {
expect(pickUserName('Ana', 'Waggle')).toBe('Ana');
expect(pickUserName(' Ana ', 'Marko')).toBe('Ana');
});
it('falls back to a real identity name', () => {
expect(pickUserName('', 'Marko')).toBe('Marko');
});
it('never returns the assistant default name as the user', () => {
expect(pickUserName(null, 'Waggle')).toBeNull();
expect(pickUserName(undefined, undefined)).toBeNull();
});
});

View File

@@ -0,0 +1,13 @@
/** The assistant's default identity name (DEFAULT_AGENT_NAME in @waggle/agent). */
export const ASSISTANT_DEFAULT_NAME = 'Waggle';
/**
* The user's display name: the one in their profile, else the identity row's
* name unless that is the assistant's default (UF-055). Null means unknown.
*/
export function pickUserName(profileName?: string | null, identityName?: string | null): string | null {
const fromProfile = profileName?.trim();
if (fromProfile) return fromProfile;
const fromIdentity = identityName?.trim();
return fromIdentity && fromIdentity !== ASSISTANT_DEFAULT_NAME ? fromIdentity : null;
}

View File

@@ -83,6 +83,7 @@ Baseline: commit `b20b138` of `git.os-dev.tech/oleg.m/waggle-os`.
| UF-052 | Home offers the same workspace twice | Fixed | Web UI | | UF-052 | Home offers the same workspace twice | Fixed | Web UI |
| UF-053 | The user's chat bubble is squared on the wrong corner | Fixed | Web UI, chat | | UF-053 | The user's chat bubble is squared on the wrong corner | Fixed | Web UI, chat |
| UF-054 | Settings and the status bar name different default models | Fixed | Web UI, models | | UF-054 | Settings and the status bar name different default models | Fixed | Web UI, models |
| UF-055 | Home greets the user by the assistant's name | Fixed | Sidecar, Web UI |
## Entries ## Entries
@@ -545,3 +546,12 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14.
- Cause: both are true. The primary has no API key, so the server's usable-model check routes new chats to the local model, and the status bar shows that model. Model Pilot only shows the configured primary and never says it cannot answer. - Cause: both are true. The primary has no API key, so the server's usable-model check routes new chats to the local model, and the status bar shows that model. Model Pilot only shows the configured primary and never says it cannot answer.
- What we did: when the primary's provider needs a key the vault lacks, Model Pilot says so under Primary and names the model new chats use until a key is added. Settings reads that model from the server. A test covers the keyless, unknown and keyed cases. - What we did: when the primary's provider needs a key the vault lacks, Model Pilot says so under Primary and names the model new chats use until a key is added. Settings reads that model from the server. A test covers the keyless, unknown and keyed cases.
- Recommendation: apply the same change in the main project. - Recommendation: apply the same change in the main project.
### UF-055. Home greets the user by the assistant's name
- Status: Fixed
- Found: 2026-10-14
- Where: at commit `b20b138`, `packages/server/src/local/routes/home.ts:265` (the greeting name) and `apps/web/src/components/os/AppShell.tsx:206` (the sidebar account row); the default comes from `packages/agent/src/auto-identity.ts`
- Symptom: a user who left their name empty during onboarding sees "Welcome, Waggle" on Home and "Waggle" as the account name in the sidebar.
- Cause: both read the name from the identity row. At startup the sidecar fills that row with the assistant's own identity, named "Waggle", and onboarding only overwrites it when the user types a name.
- What we did: the name comes from profile.json, which the user states. The identity row is a fallback and its default assistant name is ignored, so with no name the greeting has none and the account row reads "Account". The agent package exports the default name as `DEFAULT_AGENT_NAME`. Server and web tests cover a profile name, a real identity name and the default.
- Recommendation: apply the same change in the main project, and keep the assistant's identity apart from the user's.

View File

@@ -7,8 +7,11 @@ export interface IdentityConfig {
capabilities?: string[]; capabilities?: string[];
} }
/** The assistant's own default name. It is not the user's name. */
export const DEFAULT_AGENT_NAME = 'Waggle';
const DEFAULT_IDENTITY: Required<IdentityConfig> = { const DEFAULT_IDENTITY: Required<IdentityConfig> = {
name: 'Waggle', name: DEFAULT_AGENT_NAME,
role: 'AI assistant with persistent memory and web access', role: 'AI assistant with persistent memory and web access',
personality: personality:
'Direct, concise, helpful. Leads with answers, avoids filler. Admits uncertainty rather than guessing.', 'Direct, concise, helpful. Leads with answers, avoids filler. Admits uncertainty rather than guessing.',

View File

@@ -198,7 +198,7 @@ export {
type MessagesCompressionEvent, type MessagesCompressionEvent,
type CompressMessagesResult, type CompressMessagesResult,
} from './long-task/messages-compressor.js'; } from './long-task/messages-compressor.js';
export { ensureIdentity, type IdentityConfig } from './auto-identity.js'; export { ensureIdentity, DEFAULT_AGENT_NAME, type IdentityConfig } from './auto-identity.js';
export { buildSelfAwareness, type AgentCapabilities } from './self-awareness.js'; export { buildSelfAwareness, type AgentCapabilities } from './self-awareness.js';
export { export {
loadSystemPrompt, loadSystemPrompt,

View File

@@ -26,6 +26,7 @@
import type { FastifyPluginAsync } from 'fastify'; import type { FastifyPluginAsync } from 'fastify';
import { IdentityLayer } from '@waggle/core'; import { IdentityLayer } from '@waggle/core';
import { DEFAULT_AGENT_NAME } from '@waggle/agent';
import { PERSONAL_SCOPE } from '@waggle/memory-contract'; import { PERSONAL_SCOPE } from '@waggle/memory-contract';
import { memoryStatus } from '../memory-status.js'; import { memoryStatus } from '../memory-status.js';
import { buildWorkspaceState } from '../workspace-state.js'; import { buildWorkspaceState } from '../workspace-state.js';
@@ -35,6 +36,7 @@ import {
type CronScheduleLike, type CronScheduleLike,
} from './workspace-context.js'; } from './workspace-context.js';
import { getAuditDb } from './events.js'; import { getAuditDb } from './events.js';
import { loadProfile } from './profile.js';
import { createLogger } from '../logger.js'; import { createLogger } from '../logger.js';
const log = createLogger('home'); const log = createLogger('home');
@@ -256,16 +258,27 @@ export const homeRoutes: FastifyPluginAsync = async (server) => {
server.get('/api/home/briefing', async () => { server.get('/api/home/briefing', async () => {
const now = new Date(); const now = new Date();
// ── Greeting + identity name (B8) ───────────────────────────── // ── Greeting + user name (B8) ─────────────────────────────
// The user's name comes from profile.json, which the user states. The
// identity row is only a fallback: it also holds the assistant's identity,
// whose default name is the product's, so a user who skipped their name
// was greeted "Welcome, Waggle" (UF-055).
let userName: string | undefined; let userName: string | undefined;
try { const dataDir = server.localConfig?.dataDir;
const layer = new IdentityLayer(server.waggleDb); if (dataDir) {
if (layer.exists()) { const profileName = loadProfile(dataDir).name?.trim();
const name = layer.get().name?.trim(); if (profileName) userName = profileName;
if (name) userName = name; }
if (!userName) {
try {
const layer = new IdentityLayer(server.waggleDb);
if (layer.exists()) {
const name = layer.get().name?.trim();
if (name && name !== DEFAULT_AGENT_NAME) userName = name;
}
} catch (err) {
log.warn('briefing: identity read failed', (err as Error).message);
} }
} catch (err) {
log.warn('briefing: identity read failed', (err as Error).message);
} }
const ranked = rankPersonalWorkspaces(); const ranked = rankPersonalWorkspaces();

View File

@@ -17,6 +17,9 @@
* emitAuditEvent stays a safe no-op. * emitAuditEvent stays a safe no-op.
*/ */
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import Fastify from 'fastify'; import Fastify from 'fastify';
import { IdentityLayer, WaggleDB } from '@waggle/core'; import { IdentityLayer, WaggleDB } from '@waggle/core';
@@ -193,6 +196,36 @@ describe('GET /api/home/briefing (P2 — J08 needsReviewCount + greeting)', () =
expect(res.json().userName).toBeUndefined(); expect(res.json().userName).toBeUndefined();
expect(res.json().greeting).not.toContain(','); expect(res.json().greeting).not.toContain(',');
}); });
function seedAssistantIdentity() {
new IdentityLayer(server.waggleDb).create({
name: 'Waggle', role: 'AI assistant with persistent memory and web access', department: '',
personality: '', capabilities: '', system_prompt: '',
});
}
it('UF-055: never greets the user by the assistant\'s default name', async () => {
boot();
seedAssistantIdentity();
const res = await server.inject({ method: 'GET', url: '/api/home/briefing' });
expect(res.json().userName).toBeUndefined();
expect(res.json().greeting).not.toContain('Waggle');
});
it('UF-055: greets by the name the user gave in their profile', async () => {
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-home-profile-'));
try {
fs.writeFileSync(path.join(dataDir, 'profile.json'), JSON.stringify({ name: 'Ana' }));
boot();
server.decorate('localConfig', { dataDir } as never);
seedAssistantIdentity();
const res = await server.inject({ method: 'GET', url: '/api/home/briefing' });
expect(res.json().userName).toBe('Ana');
expect(res.json().greeting).toContain(', Ana');
} finally {
fs.rmSync(dataDir, { recursive: true, force: true });
}
});
}); });
describe('upNext schedule aggregation (global jobs dedup + future-only)', () => { describe('upNext schedule aggregation (global jobs dedup + future-only)', () => {