Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Sort conversation list dynamically by latest message updatedAt
claw2774816c8b6f3
diff --git a/src/main/features/chats.ts b/src/main/features/chats.tsindex f27a342f..4bc3e12b 100644--- a/src/main/features/chats.ts+++ b/src/main/features/chats.ts@@ -56,6 +56,9 @@ export interface Conversation {* the index. */processing?: boolean;processing_since?: string | null;+ /** Derived: max(<cid>.jsonl mtime, updated_at). Drives sidebar+ * last-activity ordering; never persisted. */+ last_active_at?: string;}/** Persisted record on `<cid>.jsonl`. Aliased for legacy callers; the new@@ -93,6 +96,7 @@ export async function listConversations(userId: string): Promise<Conversation[]>// this window (Cmd+R right after stop) and we say processing=false,// it stops polling and never picks up the late abort message — user// sees only their own msg, "everything I watched stream is gone".+ const dir = ensureUserDir(userId);const out: Conversation[] = [];for (const c of items) {let processing = false;@@ -103,14 +107,23 @@ export async function listConversations(userId: string): Promise<Conversation[]>processing = s.status === 'running' || busBusy;since = processing ? s.last_active_at : null;} catch { /* missing state file = idle */ }- out.push({ ...c, processing, processing_since: since });+ // Last-activity timestamp for sidebar ordering. <cid>.jsonl mtime is+ // touched whenever the bus appends a message; falls back to the+ // index's updated_at / created_at when the file isn't there yet.+ let lastActiveAt = c.updated_at || c.created_at || '';+ try {+ const mtime = fs.statSync(path.join(dir, `${c.conversation_id}.jsonl`)).mtime.toISOString();+ if (mtime > lastActiveAt) lastActiveAt = mtime;+ } catch { /* missing jsonl — keep updated_at */ }+ out.push({ ...c, processing, processing_since: since, last_active_at: lastActiveAt });}+ out.sort((a, b) => (b.last_active_at || '').localeCompare(a.last_active_at || ''));return out;}export async function saveConversations(userId: string, items: Conversation[]): Promise<void> {const cleaned = items.map((c) => {- const { processing, processing_since, ...rest } = c;+ const { processing, processing_since, last_active_at, ...rest } = c;return rest;});await writeJson(path.join(ensureUserDir(userId), CONVERSATION_INDEX_NAME), cleaned);diff --git a/src/renderer/modules/conversation.js b/src/renderer/modules/conversation.jsindex 61de6c72..75b07a16 100644--- a/src/renderer/modules/conversation.js+++ b/src/renderer/modules/conversation.js@@ -1073,6 +1073,20 @@ async function loadConversations() {}}+// Move a conversation to the top of the sidebar list and re-render.+// Called whenever a non-internal message lands on a cid so the list stays+// ordered by last activity (matches backend listConversations sort, which+// reads <cid>.jsonl mtime on the next full reload).+function _bumpConvToTop(cid) {+ if (!cid || !Array.isArray(conversations) || !conversations.length) return;+ const idx = conversations.findIndex((c) => c && c.conversation_id === cid);+ if (idx <= 0) return;+ const [c] = conversations.splice(idx, 1);+ c.last_active_at = new Date().toISOString();+ conversations.unshift(c);+ renderConversationList();+}+function renderConversationList() {const container = document.getElementById('conversation-list');if (!conversations.length) {@@ -1667,6 +1681,16 @@ async function handleNewChatSubmit() {input.value = '';autoGrow(input, 260);+ // Also clear the conversation-view input. setView with skipLoad:true+ // bypasses _restoreDraft, so without this the new conv would inherit+ // whatever draft text the previously-active conversation left behind in+ // #chat-input — and the next keystroke would save that stale text under+ // the new cid's draft key.+ const chatInput = document.getElementById('chat-input');+ if (chatInput) {+ chatInput.value = '';+ autoGrow(chatInput, 200);+ }setView('conversation', convId, { skipLoad: true });// Carry the new-chat recipient pick into the new conv's per-cid state so// the chip stays "@<agent>" instead of snapping back to commander.@@ -2860,6 +2884,14 @@ function _finalizeActorPlaceholder(ph, gm, cid, archive) {// { type: 'aborted', cid }function _handleGroupBusEvent(cid, streamingMsg, evData, { archive = false } = {}) {if (!evData || typeof evData !== 'object') return;+ // Bump the conv to the top of the sidebar list whenever a user-visible+ // message lands — applies to both currently-viewed and background convs,+ // so the sidebar stays ordered by last activity in real time. Skip+ // internal commander→agent dispatch records (they're not visible in the+ // user's view; visible end-of-turn replies will bump shortly after).+ if (evData.type === 'message' && evData.msg && !evData.msg.dispatch) {+ _bumpConvToTop(cid);+ }// Cross-cid leakage guard: per-cid controllers stay alive when the user// navigates away mid-stream (a legit pattern — let the conv finish in// the background, sidebar badge tracks completion). But all cids share