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

feat(roster): drag-to-reorder agents in the AgentStrip

Vyapak Goyal5a5614c76476
diff --git a/src/renderer/src/components/AgentStrip.tsx b/src/renderer/src/components/AgentStrip.tsx
index a68a0f45..5664b393 100644
--- a/src/renderer/src/components/AgentStrip.tsx
+++ b/src/renderer/src/components/AgentStrip.tsx
@@ -18,8 +18,13 @@ export function AgentStrip({ config }: AgentStripProps) {
const select = useStore(s => s.select);
const setAddAgentOpen = useStore(s => s.setAddAgentOpen);
const openTaskDetail = useStore(s => s.openTaskDetail);
+ const reorderAgents = useStore(s => s.reorderAgents);
const [restoring, setRestoring] = useState(false);
const [restoreNote, setRestoreNote] = useState<string | null>(null);
+ // Drag-to-reorder the roster: dragId = the card being dragged, overId = the card
+ // currently hovered as a drop target (drives the insertion-line cue).
+ const [dragId, setDragId] = useState<string | null>(null);
+ const [overId, setOverId] = useState<string | null>(null);
// Each worker's actively-DOING ledger tasks, polled from hive/tasks.json —
// rendered as a sticky note on the avatar card (click → task detail).
const [doingByAgent, setDoingByAgent] = useState<Record<string, string[]>>({});
@@ -176,26 +181,58 @@ export function AgentStrip({ config }: AgentStripProps) {
alignItems: 'center'
}}>
{agents.map(a => (
- <AgentCard
+ // Draggable wrapper: reorder the roster by dragging one card onto another.
+ // Native HTML5 DnD (no dep). A plain click still selects — a drag only
+ // starts on movement — so AgentCard's onClick is unaffected.
+ <div
key={a.id}
- name={a.name}
- character={a.character}
- accent={a.accent}
- status={a.status}
- project={a.project}
- action={a.action}
- progress={a.progress}
- contextTokens={a.contextTokens}
- contextLimit={a.contextLimit}
- selected={a.id === selectedId}
- isGod={a.isGod}
- onClick={() => select(a.id)}
- doingCount={doingByAgent[a.id]?.length ?? 0}
- onTaskNoteClick={() => {
- const first = doingByAgent[a.id]?.[0];
- if (first) openTaskDetail(first);
+ draggable
+ onDragStart={(e) => { setDragId(a.id); e.dataTransfer.effectAllowed = 'move'; }}
+ onDragOver={(e) => {
+ if (!dragId || dragId === a.id) return;
+ e.preventDefault();
+ e.dataTransfer.dropEffect = 'move';
+ if (overId !== a.id) setOverId(a.id);
}}
- />
+ onDragLeave={() => { if (overId === a.id) setOverId(null); }}
+ onDrop={(e) => {
+ e.preventDefault();
+ if (dragId && dragId !== a.id) reorderAgents(dragId, a.id);
+ setDragId(null);
+ setOverId(null);
+ }}
+ onDragEnd={() => { setDragId(null); setOverId(null); }}
+ style={{
+ flexShrink: 0,
+ cursor: 'grab',
+ opacity: dragId === a.id ? 0.4 : 1,
+ // Insertion-line cue on the hovered drop target.
+ boxShadow: overId === a.id && dragId && dragId !== a.id
+ ? 'inset 3px 0 0 0 var(--cth-ink-900)'
+ : 'none',
+ transition: 'opacity 120ms ease'
+ }}
+ >
+ <AgentCard
+ name={a.name}
+ character={a.character}
+ accent={a.accent}
+ status={a.status}
+ project={a.project}
+ action={a.action}
+ progress={a.progress}
+ contextTokens={a.contextTokens}
+ contextLimit={a.contextLimit}
+ selected={a.id === selectedId}
+ isGod={a.isGod}
+ onClick={() => select(a.id)}
+ doingCount={doingByAgent[a.id]?.length ?? 0}
+ onTaskNoteClick={() => {
+ const first = doingByAgent[a.id]?.[0];
+ if (first) openTaskDetail(first);
+ }}
+ />
+ </div>
))}
{restorableAgents.length > 0 && (
<span
diff --git a/src/renderer/src/store/store.ts b/src/renderer/src/store/store.ts
index 4c0f26c9..418287ae 100644
--- a/src/renderer/src/store/store.ts
+++ b/src/renderer/src/store/store.ts
@@ -154,6 +154,7 @@ interface State {
removeArchivedAgent: (id: string) => void;
/** Drop one agent from the restorable list (it was respawned or dismissed). */
removeRestorableAgent: (id: string) => void;
+ reorderAgents: (fromId: string, toId: string) => void; // move agent fromId into toId's slot (AgentStrip drag-reorder) and persist the new order
/** One-shot request to open a Command-Center tab (e.g. clicking the office
* task board → 'tasks'). `seq` makes repeated identical requests distinct. */
ccTabRequest: { tab: string; seq: number } | null;
@@ -462,6 +463,20 @@ export const useStore = create<State>((set) => ({
persistRestorable(restorableAgents);
return { restorableAgents };
}),
+ reorderAgents: (fromId, toId) =>
+ set((s) => {
+ if (fromId === toId) return s;
+ const from = s.agents.findIndex((a) => a.id === fromId);
+ const to = s.agents.findIndex((a) => a.id === toId);
+ if (from === -1 || to === -1) return s;
+ const agents = [...s.agents];
+ const [moved] = agents.splice(from, 1);
+ agents.splice(to, 0, moved);
+ // Persist the new roster order so it survives a reload (same slim key the
+ // rest of the roster uses). selectedId is unchanged by a reorder.
+ persistAgents(agents, s.selectedId);
+ return { agents };
+ }),
taskDetailId: null,
openTaskDetail: (id) => set({ taskDetailId: id }),
closeTaskDetail: () => set({ taskDetailId: null }),