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

Merge #190: allow agent names to be edited after spin-up

Chaitanya Giri77f0de9b9d9e
diff --cc src/preload/index.ts
index a3c3622c,a3364320..5bbd0376
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@@ -730,9 -727,9 +730,12 @@@ const api =
// ─── Hive (multi-agent coordination) ─────────────────────────────────────
hiveRegistry: (): Promise<HiveRegistry> => ipcRenderer.invoke('hive:registry'),
+ /** Persist a hire/job role to hive registry.json + identity.md (no respawn). */
+ hivePatchAgentRole: (id: string, role: string): Promise<{ ok: boolean; error?: string }> =>
+ ipcRenderer.invoke('hive:patchAgentRole', id, role),
+ /** Rename an agent's display name. Its id, hive directory, and PTY are unchanged. */
+ hiveRenameAgent: (id: string, name: string): Promise<{ ok: boolean; name?: string; error?: string }> =>
+ ipcRenderer.invoke('hive:renameAgent', id, name),
hiveBoard: (): Promise<string> => ipcRenderer.invoke('hive:board'),
hiveTasks: (): Promise<unknown> => ipcRenderer.invoke('hive:tasks'),
hiveLog: (n?: number): Promise<unknown[]> => ipcRenderer.invoke('hive:log', n ?? 200),
diff --cc src/renderer/src/components/AgentDetailPanel.tsx
index a150f9d6,27288d69..af2ca0d4
--- a/src/renderer/src/components/AgentDetailPanel.tsx
+++ b/src/renderer/src/components/AgentDetailPanel.tsx
@@@ -12,9 -12,9 +12,10 @@@ import { SidebarTabs } from './SidebarT
import { ThreadsPanel } from './ThreadsPanel';
import { ToolWaterfall } from './ToolWaterfall';
import { AgentControlStrip } from './AgentControlStrip';
+import { EditAgentModal } from './EditAgentModal';
import { GitTab } from './GitTab';
import { Icon } from './Icon';
+ import { AgentNameEditor } from './AgentNameEditor';
import { useStore, type Agent } from '@/store/store';
import { usePtyParser } from '@/hooks/usePtyParser';
@@@ -25,9 -25,9 +26,10 @@@ export interface AgentDetailPanelProps
export function AgentDetailPanel({ agent }: AgentDetailPanelProps) {
const [openTerminalState, setOpenTerminalState] = useState<'idle' | 'opening' | 'ok' | 'error'>('idle');
const [openTerminalError, setOpenTerminalError] = useState<string | undefined>();
+ const [editOpen, setEditOpen] = useState(false);
const archiveAgent = useStore(s => s.archiveAgent);
const updateAgent = useStore(s => s.updateAgent);
+ const renameAgent = useStore(s => s.renameAgent);
const setFullscreen = useStore(s => s.setFullscreen);
const fullscreenAgentId = useStore(s => s.fullscreenAgentId);
const sidebarTab = useStore(s => s.sidebarTab);
diff --cc src/renderer/src/store/store.ts
index 6138ee0b,e94a18c6..0eb9bf60
--- a/src/renderer/src/store/store.ts
+++ b/src/renderer/src/store/store.ts
@@@ -194,9 -184,9 +194,12 @@@ interface State
setGodStatus: (status: GodStatus) => void;
select: (id: string) => void;
updateAgent: (id: string, patch: Partial<Agent>) => void;
+ /** Copy durable hive roles onto roster descriptions (and the reverse is a
+ * no-op when the roster already has a real job string). */
+ syncDescriptionsFromRoles: (roles: Record<string, string>) => void;
+ /** Persist a display-name change to both the hive registry and renderer roster.
+ * The agent id and all id-derived paths remain unchanged. */
+ renameAgent: (id: string, name: string) => Promise<{ ok: boolean; error?: string }>;
setAgentNote: (id: string, note: string) => void;
pushFeed: (id: string, line: string) => void;
addAgent: (agent: Agent) => void;
@@@ -627,29 -615,28 +630,51 @@@ export const useStore = create<State>((
if (touchesDurableAgentField(patch)) persistAgents(agents, s.selectedId);
return { agents };
}),
+ syncDescriptionsFromRoles: (roles) =>
+ set((s) => {
+ const apply = (list: Agent[]): Agent[] => {
+ let changed = false;
+ const next = list.map((a) => {
+ const description = preferredAgentRole(a.description, roles[a.id], !!a.isGod);
+ if (description === a.description) return a;
+ changed = true;
+ return { ...a, description };
+ });
+ return changed ? next : list;
+ };
+ const agents = apply(s.agents);
+ const archivedAgents = apply(s.archivedAgents);
+ const restorableAgents = apply(s.restorableAgents);
+ if (agents === s.agents && archivedAgents === s.archivedAgents && restorableAgents === s.restorableAgents) {
+ return s;
+ }
+ persistAgents(agents, s.selectedId);
+ if (archivedAgents !== s.archivedAgents) persistArchived(archivedAgents);
+ if (restorableAgents !== s.restorableAgents) persistRestorable(restorableAgents);
+ return { agents, archivedAgents, restorableAgents };
+ }),
+ renameAgent: async (id, name) => {
+ try {
+ const result = await window.cth.hiveRenameAgent(id, name);
+ if (!result.ok || !result.name) return { ok: false, error: result.error ?? 'Could not rename agent' };
+ const nextName = result.name;
+
+ set((s) => {
+ const rename = (agents: Agent[]): Agent[] =>
+ agents.map((agent) => agent.id === id ? { ...agent, name: nextName } : agent);
+ const agents = rename(s.agents);
+ const archivedAgents = rename(s.archivedAgents);
+ const restorableAgents = rename(s.restorableAgents);
+ persistAgents(agents, s.selectedId);
+ persistArchived(archivedAgents);
+ persistRestorable(restorableAgents);
+ return { agents, archivedAgents, restorableAgents };
+ });
+ return { ok: true };
+ } catch (error) {
+ return { ok: false, error: error instanceof Error ? error.message : 'Could not rename agent' };
+ }
+ },
setAgentNote: (id, note) =>
set((s) => {
const agents = s.agents.map((a) => a.id === id ? { ...a, note } : a);
diff --cc test/hive-roster-injection.test.cjs
index 2fbd2812,72f38c38..a6292083
--- a/test/hive-roster-injection.test.cjs
+++ b/test/hive-roster-injection.test.cjs
@@@ -83,29 -83,30 +83,53 @@@ test('the roster line carries the whol
assert.ok(line.length < 1200, `too long for a 3-agent floor: ${line.length} chars`);
});
+test('each agent line carries its live context-window occupancy (ctx NN%)', async (t) => {
+ const { hive, fire } = await floor(t);
+ snapshot(hive);
+
+ // No Status tick yet — a bare direct call (no callback) must not add ctx.
+ assert.ok(!hive.rosterContext().includes('ctx '), 'no occupancy when no statusLine tick has fired');
+
+ // Seed live context-window accounting through the statusLine shim path.
+ // god-1: 62% of a 200k window; jim-1: 99% (near-full, the routing signal).
+ await fire('god-1', 'Status', { context_window: { total_input_tokens: 124000, context_window_size: 200000 } });
+ await fire('jim-1', 'Status', { context_window: { total_input_tokens: 99000, context_window_size: 100000 } });
+
+ // Read the roster the way god actually receives it: injected on a prompt,
+ // which is where HookServer layers the LIVE occupancy onto the disk snapshot.
+ const line = context(await fire('god-1', 'UserPromptSubmit'));
+ assert.ok(line.includes('LIVE ROSTER'), 'roster injected on prompt');
+ assert.match(line, /god-1[^;]*ctx 62%/, 'god line shows its own occupancy');
+ assert.match(line, /jim-1[^;]*ctx 99%/, 'a near-full agent is flagged to god');
+ // pam-1 never fired a Status tick — its line must NOT get ctx.
+ assert.match(line, /pam-1[^;]*\(agent, no activity yet\)/, 'no ctx for an agent with no Status data');
+ assert.ok(!line.includes('\n'), 'still a single compact line');
+});
+
+ test('renaming changes only the display name and reaches god immediately', async (t) => {
+ const { home, hive } = await floor(t);
+ snapshot(hive);
+ const agentDir = path.join(home, 'hive', 'agents', 'jim-1');
+ const before = hive.registry().agents['jim-1'];
+
+ const result = hive.renameAgent('jim-1', ' Kevin ');
+
+ assert.deepEqual(result, { ok: true, name: 'Kevin' });
+ assert.deepEqual(hive.registry().agents['jim-1'], { ...before, name: 'Kevin' },
+ 'registry metadata must be unchanged apart from the display name');
+ assert.equal(fs.existsSync(agentDir), true, 'the id-derived agent directory must not move');
+ assert.match(hive.rosterContext(), /jim-1 "Kevin"/);
+ assert.doesNotMatch(hive.rosterContext(), /jim-1 "Jim"/);
+ });
+
+ test('rename rejects empty and unknown agents without changing the registry', async (t) => {
+ const { hive } = await floor(t);
+
+ assert.equal(hive.renameAgent('jim-1', ' ').ok, false);
+ assert.equal(hive.renameAgent('missing', 'Kevin').ok, false);
+ assert.equal(hive.registry().agents['jim-1'].name, 'Jim');
+ });
+
test('god gets the roster on SessionStart and on every prompt — nobody else does', async (t) => {
const { hive, fire } = await floor(t);
snapshot(hive);