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

@@ -26,6 +26,7 @@
import type { FastifyPluginAsync } from 'fastify';
import { IdentityLayer } from '@waggle/core';
import { DEFAULT_AGENT_NAME } from '@waggle/agent';
import { PERSONAL_SCOPE } from '@waggle/memory-contract';
import { memoryStatus } from '../memory-status.js';
import { buildWorkspaceState } from '../workspace-state.js';
@@ -35,6 +36,7 @@ import {
type CronScheduleLike,
} from './workspace-context.js';
import { getAuditDb } from './events.js';
import { loadProfile } from './profile.js';
import { createLogger } from '../logger.js';
const log = createLogger('home');
@@ -256,16 +258,27 @@ export const homeRoutes: FastifyPluginAsync = async (server) => {
server.get('/api/home/briefing', async () => {
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;
try {
const layer = new IdentityLayer(server.waggleDb);
if (layer.exists()) {
const name = layer.get().name?.trim();
if (name) userName = name;
const dataDir = server.localConfig?.dataDir;
if (dataDir) {
const profileName = loadProfile(dataDir).name?.trim();
if (profileName) userName = profileName;
}
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();