Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix: god's renamed identity no longer reverts to "Michael" on respawn

savvask46737e5208da
diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.ts
index 5e10fbca..b0d6fe77 100644
--- a/src/renderer/src/hooks/useHive.ts
+++ b/src/renderer/src/hooks/useHive.ts
@@ -19,6 +19,7 @@ import type { AgentProvider } from '../../../shared/agentProvider';
import { bridgeOf, providerPreset } from '../../../shared/agentProvider';
import { isDurableRole, preferredAgentRole, roleForHiveSpawn } from '../../../shared/agentRole';
import { inboxNudgeText } from '../../../shared/hiveNudge';
+import { resolveGodName } from '../../../shared/godIdentity';
import { acquireTerminal, resetTerminal, isTerminalAutomationSafe } from '@/components/terminalPool';
import { canDeliverToAgent, deliverWithAcknowledgement, checkPrecondition } from './queueDelivery';
import { OFFICE_CAST, DEFAULT_CHARACTER } from '@/scene/office/cast';
@@ -379,6 +380,13 @@ export function useHive(config: HarnessConfig | null): void {
godSpawning.current = true;
useStore.getState().removeAgent(GOD_ID); // clear any stale restored entry
+ // A prior rename (Edit Agent panel → renameAgent() → hive.ts's renameAgent())
+ // persists straight into registry.json, so read it back here rather than
+ // hardcoding DEFAULT_GOD_NAME below — otherwise a custom name reverts on
+ // every respawn even though the registry still has it right.
+ const reg = await window.cth.hiveRegistry().catch(() => null);
+ const godName = resolveGodName(reg?.agents?.[GOD_ID]?.name);
+
const godProvider = config.godProvider ?? 'claude';
const godModel = config.godModel;
const command = buildSpawnCommand(config, godModel, godProvider);
@@ -397,13 +405,13 @@ export function useHive(config: HarnessConfig | null): void {
// fresh session. Without this the most important context on the floor —
// the orchestrator's — was lost on every restart.
resume: true,
- hive: { id: GOD_ID, name: 'Michael', provider: godProvider, cwd: config.harnessHome!, isGod: true, role: 'orchestrator (god)' }
+ hive: { id: GOD_ID, name: godName, provider: godProvider, cwd: config.harnessHome!, isGod: true, role: 'orchestrator (god)' }
});
if (cancelled) { godSpawning.current = false; return; }
if (!res.ok) { godSpawning.current = false; useStore.getState().setGodStatus('failed'); return; }
const god: Agent = {
id: GOD_ID,
- name: 'Michael',
+ name: godName,
character: 'michael',
accent: 'lemon',
description: 'god — runs the floor, triages requests, escalates only critical calls to you',
@@ -437,7 +445,7 @@ export function useHive(config: HarnessConfig | null): void {
bootGraceUntil.current[GOD_ID] = Date.now() + BOOT_GRACE_MS;
void (async () => {
try {
- const remoteCommand = remoteControlCommandForProvider(godProvider, 'Michael');
+ const remoteCommand = remoteControlCommandForProvider(godProvider, godName);
if (remoteCommand) {
// settleMs pauses the chain ~1.5s after /remote-control before the
// orientation prompt (fresh spawns only) is submitted next.
diff --git a/src/shared/godIdentity.ts b/src/shared/godIdentity.ts
new file mode 100644
index 00000000..a077a0f5
--- /dev/null
+++ b/src/shared/godIdentity.ts
@@ -0,0 +1,20 @@
+/** God's identity before anyone has customized it — the app's own default,
+ * not a magic string sprinkled at every spawn call site. */
+export const DEFAULT_GOD_NAME = 'Michael';
+
+/**
+ * Resolve god's display name for a (re)spawn.
+ *
+ * `renameAgent()` (`store.ts`) persists a rename straight into `registry.json`
+ * via `hive.ts`'s `renameAgent()` — but the god-spawn effect used to rebuild
+ * god's agent object from scratch with `name: DEFAULT_GOD_NAME` hardcoded in
+ * three places, so a custom name reverted to "Michael" on every app restart
+ * even though the registry still had it right. Reading the persisted name
+ * back here (instead of hardcoding the default) is what keeps a rename from
+ * reverting. Falls back to the default only when nothing has been persisted
+ * yet — a fresh hive, or a registry not yet written this run.
+ */
+export function resolveGodName(persistedName: string | undefined | null): string {
+ const trimmed = persistedName?.trim();
+ return trimmed ? trimmed : DEFAULT_GOD_NAME;
+}
diff --git a/test/god-identity.test.cjs b/test/god-identity.test.cjs
new file mode 100644
index 00000000..f6865232
--- /dev/null
+++ b/test/god-identity.test.cjs
@@ -0,0 +1,19 @@
+'use strict';
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const loadTs = require('./load-ts.cjs');
+
+const { DEFAULT_GOD_NAME, resolveGodName } = loadTs('src/shared/godIdentity.ts');
+
+test('a persisted rename wins over the default', () => {
+ assert.equal(resolveGodName('Savvas'), 'Savvas');
+ assert.equal(resolveGodName(' Savvas '), 'Savvas'); // trimmed, like renameAgent() trims on write
+});
+
+test('nothing persisted yet falls back to the default', () => {
+ assert.equal(resolveGodName(undefined), DEFAULT_GOD_NAME);
+ assert.equal(resolveGodName(null), DEFAULT_GOD_NAME);
+ assert.equal(resolveGodName(''), DEFAULT_GOD_NAME);
+ assert.equal(resolveGodName(' '), DEFAULT_GOD_NAME); // whitespace-only is not a real name
+});