Make every identity editable: agent and operator names plus avatars
- Migration 049: avatar_emoji/avatar_color on agents and employees - updateAgent accepts a new name (mention-name validated) and avatar; new updateEmployeeProfile renames the operator and sets their avatar - Avatars are emoji-on-color tiles (renderer CSP blocks remote images); an AvatarDirectoryContext built from the snapshot lets the shared Avatar component honor custom looks at every call site - chat rows, conversation list, org chart, office card, sidebar - without threading props through pages - Team edit dialog gains Name + avatar editor (CEO included); the sidebar foot opens an Edit-profile dialog for the operator - e2e: rename an agent to a new mention handle with an emoji avatar, edit the operator profile, both verified in the live shell
This commit is contained in:
1 parent
86aa6fdb29
commit
e55b8b85b0
20 files changed
+377
-31
No files matched your search
@@ -24,7 +24,7 @@ describe("domain services", () => {
|
||||
const connection = createConnection();
|
||||
|
||||
const rows = connection.db.prepare("select version from schema_migrations order by version asc").all() as Array<{ version: number }>;
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]);
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ function agent(id: string, department: string): AgentRecord {
|
||||
id, orgId: "org", name: id, role: "engineer", department,
|
||||
modelProviderId: null, modelId: null, budgetCents: 0, managerAgentId: null,
|
||||
title: id, roleLevel: "ic", modelStrategy: "single", workspaceId: null,
|
||||
heartbeatEnabled: false, heartbeatIntervalSec: 0, lifecycle: "active", createdAt: "2026-01-01",
|
||||
heartbeatEnabled: false, heartbeatIntervalSec: 0, lifecycle: "active",
|
||||
avatarEmoji: null, avatarColor: null, createdAt: "2026-01-01",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { OrganizationService } from "../../src/main/services/organization-service";
|
||||
|
||||
function harness(): { connection: DatabaseConnection; organization: OrganizationService; orgId: string; agentId: string; employeeId: string } {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-profile-${randomUUID()}.db`));
|
||||
const organization = new OrganizationService(connection.db);
|
||||
let orgId = "";
|
||||
let agentId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({ organizationName: "OrbitOps", employeeName: "Yang", mission: "m", goal: "g" });
|
||||
agentId = organization.createAgent({
|
||||
orgId, name: "CEO", role: "CEO", department: "Executive",
|
||||
modelProviderId: null, modelId: null, budgetCents: 25000, managerAgentId: null, roleLevel: "c_suite",
|
||||
});
|
||||
});
|
||||
const employeeId = (connection.db.prepare("select id from employees where org_id = ?").get(orgId) as { id: string }).id;
|
||||
return { connection, organization, orgId, agentId, employeeId };
|
||||
}
|
||||
|
||||
describe("identity editing", () => {
|
||||
test("renames an agent (the CEO included) and stores its avatar", () => {
|
||||
const h = harness();
|
||||
h.connection.transaction(() => h.organization.updateAgent({
|
||||
orgId: h.orgId,
|
||||
agentId: h.agentId,
|
||||
name: "Nova Chen",
|
||||
role: "CEO",
|
||||
title: "Chief Executive Officer",
|
||||
roleLevel: "c_suite",
|
||||
department: "Executive",
|
||||
budgetCents: 25000,
|
||||
modelProviderId: null,
|
||||
modelId: null,
|
||||
avatarEmoji: "🚀",
|
||||
avatarColor: "#26B69A",
|
||||
}));
|
||||
const row = h.connection.db.prepare("select name, avatar_emoji, avatar_color from agents where id = ?").get(h.agentId) as
|
||||
{ name: string; avatar_emoji: string; avatar_color: string };
|
||||
expect(row).toEqual({ name: "Nova Chen", avatar_emoji: "🚀", avatar_color: "#26b69a" });
|
||||
|
||||
// Clearing the avatar returns the tile to the hashed palette.
|
||||
h.connection.transaction(() => h.organization.updateAgent({
|
||||
orgId: h.orgId,
|
||||
agentId: h.agentId,
|
||||
role: "CEO",
|
||||
title: "Chief Executive Officer",
|
||||
roleLevel: "c_suite",
|
||||
department: "Executive",
|
||||
budgetCents: 25000,
|
||||
modelProviderId: null,
|
||||
modelId: null,
|
||||
avatarEmoji: "",
|
||||
avatarColor: "",
|
||||
}));
|
||||
const cleared = h.connection.db.prepare("select name, avatar_emoji, avatar_color from agents where id = ?").get(h.agentId) as
|
||||
{ name: string; avatar_emoji: string | null; avatar_color: string | null };
|
||||
expect(cleared).toEqual({ name: "Nova Chen", avatar_emoji: null, avatar_color: null });
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("rejects blank names and malformed avatar colors", () => {
|
||||
const h = harness();
|
||||
const base = {
|
||||
orgId: h.orgId,
|
||||
agentId: h.agentId,
|
||||
role: "CEO",
|
||||
title: "Chief Executive Officer",
|
||||
roleLevel: "c_suite",
|
||||
department: "Executive",
|
||||
budgetCents: 25000,
|
||||
modelProviderId: null,
|
||||
modelId: null,
|
||||
};
|
||||
expect(() => h.organization.updateAgent({ ...base, name: " " })).toThrow("Agent name is required.");
|
||||
expect(() => h.organization.updateAgent({ ...base, avatarColor: "red" })).toThrow("Avatar color must be a #rrggbb hex value.");
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("updates the operator's display name and avatar", () => {
|
||||
const h = harness();
|
||||
h.connection.transaction(() => h.organization.updateEmployeeProfile({
|
||||
orgId: h.orgId,
|
||||
employeeId: h.employeeId,
|
||||
displayName: "Yang Zhang",
|
||||
avatarEmoji: "🎯",
|
||||
avatarColor: "#5e6ad2",
|
||||
}));
|
||||
const row = h.connection.db.prepare("select display_name, avatar_emoji, avatar_color from employees where id = ?").get(h.employeeId) as
|
||||
{ display_name: string; avatar_emoji: string; avatar_color: string };
|
||||
expect(row).toEqual({ display_name: "Yang Zhang", avatar_emoji: "🎯", avatar_color: "#5e6ad2" });
|
||||
expect(() => h.organization.updateEmployeeProfile({ orgId: h.orgId, employeeId: h.employeeId, displayName: " " }))
|
||||
.toThrow("Display name is required.");
|
||||
h.connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user