Skip to content

The agent that grows with you

style: eslint --fix on salvaged unread-dot files

Teknium0ceb739abc84
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index 3f3ae0be472..657d682a74a 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -71,6 +71,7 @@ import {
toggleSidebarMessagingOpen,
unpinSession
} from '@/store/layout'
+import { notifyError } from '@/store/notifications'
import {
$newChatProfile,
$profileColors,
@@ -125,7 +126,6 @@ import { $sessionDotStateById, sessionStatusBucket } from '@/store/session-dot-s
import { $focusedStoredSessionId, $workingSessionIds, type SplitDir } from '@/store/session-states'
import { ackAllSessionsRead } from '@/store/session-unread'
import { markSessionUnread } from '@/store/session-unread-remote'
-import { notifyError } from '@/store/notifications'
import { $archivedSessions, loadArchivedSessions } from '@/store/sidebar-archive'
import { $sidebarSessionRankIds } from '@/store/sidebar-sort'
@@ -374,6 +374,7 @@ export function ChatSidebar({
const profiles = useStore($profiles)
const profileColors = useStore($profileColors)
const profileScope = useStore($profileScope)
+
// Toggle the persisted read-state watermark from a row menu. The row's own
// `unread` prop mirrors what the dot paints; flip it and let the backend
// become the truth (optimistic update + rollback in markSessionUnread).
@@ -386,6 +387,7 @@ export function ChatSidebar({
markSessionUnread(storedId, row.unread !== true).catch(err => notifyError(err, s.row.unreadFailed))
}
+
// Only surface the profile switcher when more than one profile exists, so
// single-profile users see the unchanged sidebar.
const multiProfile = profiles.length > 1
diff --git a/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx b/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
index b2f1392a8dc..2550800e724 100644
--- a/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-actions-menu.tsx
@@ -50,9 +50,9 @@ import {
sessionPinId,
setSessions
} from '@/store/session'
-import { ackStoredSessionId } from '@/store/session-unread'
import { $sessionColorOverrides, setSessionColorOverride } from '@/store/session-color'
import { $sessionTiles } from '@/store/session-states'
+import { ackStoredSessionId } from '@/store/session-unread'
import { canOpenSessionInTerminal, canOpenSessionWindow, openSessionInTerminal } from '@/store/windows'
import type { SessionTitleResponse } from '../../types'
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.tsx b/apps/desktop/src/app/chat/sidebar/session-row.tsx
index 4b75bd39dea..07d13c686b9 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.tsx
@@ -337,10 +337,10 @@ function SidebarSessionRowImpl({
onPin={onPin}
onToggleUnread={onToggleUnread}
pinned={isPinned}
- unread={unread}
profile={session.profile}
sessionId={session.id}
title={title}
+ unread={unread}
>
<SidebarRowShell
actions={card ? undefined : actionsNode}
diff --git a/apps/desktop/src/store/session-dot-state.ts b/apps/desktop/src/store/session-dot-state.ts
index 39e4971c7d5..f6f30169ff4 100644
--- a/apps/desktop/src/store/session-dot-state.ts
+++ b/apps/desktop/src/store/session-dot-state.ts
@@ -138,18 +138,23 @@ export const $sessionDotStateById = computed(
// our own writes is fenced out by the write guard: keep OUR value until a
// page confirms it or the guard expires.
const persistedUnread: string[] = []
+
for (const s of sessions) {
const entry = unreadWriteGuard.get(s.id)
+
if (entry && Date.now() - entry.at < UNREAD_WRITE_GUARD_MS) {
if (entry.value) {
persistedUnread.push(s.id)
}
+
continue
}
+
if (s.unread === true) {
persistedUnread.push(s.id)
}
}
+
claim(persistedUnread, 'unread')
claim(background, 'background')
diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.ts
index de350e747b4..108b8d761e8 100644
--- a/apps/desktop/src/store/session-states.ts
+++ b/apps/desktop/src/store/session-states.ts
@@ -38,7 +38,6 @@ import {
$lastReadAtBySessionId,
$selectedStoredSessionId,
$sessions,
- $unreadFinishedSessionIds,
clearReadBaseline,
lineageAliases,
markSessionRead,
diff --git a/apps/desktop/src/store/session-unread-remote.test.ts b/apps/desktop/src/store/session-unread-remote.test.ts
index 645e57d6406..1cbc967baae 100644
--- a/apps/desktop/src/store/session-unread-remote.test.ts
+++ b/apps/desktop/src/store/session-unread-remote.test.ts
@@ -12,7 +12,7 @@ vi.mock('@/hermes', () => ({
setSessionUnreadRemote: (id: string, unread: boolean, profile?: null | string) => patch(id, unread, profile)
}))
-import { $sessions, setSessions } from '@/store/session'
+import { $sessions } from '@/store/session'
import { $unreadWriteGuard, clearUnreadOnOpen, markSessionUnread, watchUnreadWriteGuard } from './session-unread-remote'
diff --git a/apps/desktop/src/store/session-unread-remote.ts b/apps/desktop/src/store/session-unread-remote.ts
index e90d3a2c9ee..6200b8b6c9f 100644
--- a/apps/desktop/src/store/session-unread-remote.ts
+++ b/apps/desktop/src/store/session-unread-remote.ts
@@ -39,6 +39,7 @@ function rowFor(storedId: string) {
* brand-new chat with no persisted row yet — there is nothing to flag). */
export async function markSessionUnread(storedId: string, unread: boolean): Promise<void> {
const row = rowFor(storedId)
+
if (!row) {
return
}
@@ -65,9 +66,11 @@ export async function markSessionUnread(storedId: string, unread: boolean): Prom
* Best-effort: a failed PATCH is healed by the next honest refresh. */
export async function clearUnreadOnOpen(storedId: string): Promise<void> {
const row = rowFor(storedId)
+
if (!row || row.unread !== true) {
return
}
+
try {
await markSessionUnread(storedId, false)
} catch {
@@ -84,6 +87,7 @@ export function watchUnreadWriteGuard(): void {
for (const [id, entry] of guard) {
const row = rows.find(r => r.id === id)
+
if (row && row.unread === entry.value) {
guard.delete(id)
changed = true