Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(conversations): add thread pinning and unread indicators

Steven Enamakel2cadbe3f3c9f
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index ca26fe78ac..4afef7de3f 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -107,6 +107,8 @@ import {
} from './aui/ReasoningEffortPicker';
import { useChatSurfaceRegistration } from './hooks/useChatSurfaceRegistration';
import { ThreadList } from './threadList/ThreadList';
+import { useThreadPins } from './threadList/useThreadPins';
+import { useUnreadThreads } from './threadList/useUnreadThreads';
const CHAT_MODEL_HINT = 'hint:chat';
const debug = debugFactory('conversations');
@@ -1562,6 +1564,12 @@ const Conversations = ({
},
[pendingSendingThreadIds, activeThreadIds, inferenceTurnLifecycleByThread]
);
+ const runningThreadIds = useMemo(
+ () => threads.filter(thread => isThreadRunning(thread.id)).map(thread => thread.id),
+ [threads, isThreadRunning]
+ );
+ const unreadThreadIds = useUnreadThreads(runningThreadIds, selectedThreadId ?? null);
+ const { isPinned: isThreadPinnedNow, togglePin: toggleThreadPin } = useThreadPins();
// Thread list (left pane). Rendered through `TwoPanelLayout` below in page
// mode; the embedded `variant="sidebar"` mode shows no thread list at all.
@@ -1579,6 +1587,9 @@ const Conversations = ({
}}
resolveTitle={resolveThreadDisplayTitle}
isThreadRunning={isThreadRunning}
+ unreadThreadIds={unreadThreadIds}
+ isPinned={isThreadPinnedNow}
+ onTogglePin={toggleThreadPin}
onRequestDelete={thread =>
setDeleteModal({
isOpen: true,
diff --git a/app/src/features/conversations/threadList/useThreadPins.ts b/app/src/features/conversations/threadList/useThreadPins.ts
new file mode 100644
index 0000000000..8e1088abe5
--- /dev/null
+++ b/app/src/features/conversations/threadList/useThreadPins.ts
@@ -0,0 +1,60 @@
+import debugFactory from 'debug';
+import { useCallback, useState } from 'react';
+
+import { threadApi } from '../../../services/api/threadApi';
+import { useAppDispatch } from '../../../store/hooks';
+import { loadThreads } from '../../../store/threadSlice';
+import type { Thread } from '../../../types/thread';
+import { isThreadPinned, labelsWithPin } from './groupThreads';
+
+const debug = debugFactory('conversations:pins');
+
+/**
+ * Pin / unpin a thread through the core's label store.
+ *
+ * The pin is the reserved `pinned` label, written with
+ * `openhuman.threads_update_labels` so it persists with the thread. The row
+ * moves immediately via a local override, held until the thread list reload
+ * carries the persisted labels; a failed write drops the override, so the row
+ * snaps back to what the core actually stored.
+ */
+export function useThreadPins(): {
+ isPinned: (thread: Thread) => boolean;
+ togglePin: (thread: Thread, pinned: boolean) => void;
+} {
+ const dispatch = useAppDispatch();
+ const [overrides, setOverrides] = useState<ReadonlyMap<string, boolean>>(() => new Map());
+
+ const isPinned = useCallback(
+ (thread: Thread) => overrides.get(thread.id) ?? isThreadPinned(thread),
+ [overrides]
+ );
+
+ const togglePin = useCallback(
+ (thread: Thread, pinned: boolean) => {
+ setOverrides(prev => new Map(prev).set(thread.id, pinned));
+ const clearOverride = () =>
+ setOverrides(prev => {
+ if (!prev.has(thread.id)) return prev;
+ const next = new Map(prev);
+ next.delete(thread.id);
+ return next;
+ });
+ debug('toggle pin thread=%s pinned=%s', thread.id, pinned);
+ void threadApi
+ .updateLabels(thread.id, labelsWithPin(thread.labels, pinned))
+ .then(() => dispatch(loadThreads()).unwrap())
+ .catch((error: unknown) => {
+ debug(
+ 'pin update failed thread=%s: %s',
+ thread.id,
+ error instanceof Error ? error.message : String(error)
+ );
+ })
+ .finally(clearOverride);
+ },
+ [dispatch]
+ );
+
+ return { isPinned, togglePin };
+}