Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a4114d8
docs: draft design for session unread dots and notifications
LittleSound Oct 14, 2026
d270134
docs: choose the needs-you inbox for unread sessions
LittleSound Oct 16, 2026
c54cc9a
docs: add implementation plan for session unread notifications
LittleSound Oct 16, 2026
afe3dce
feat(db): add session attention and read cursors
LittleSound Oct 16, 2026
e4ff35c
feat(chat): record session attention and publish it per user
LittleSound Oct 16, 2026
5579f63
feat(runtime): observe runs entering waiting_decision
LittleSound Oct 16, 2026
7dd9b3b
feat(agent): mark session attention when runs finish or wait
LittleSound Oct 16, 2026
b5c9bab
feat(api): expose unread sessions, mark-read and attention stream
LittleSound Oct 16, 2026
31f6067
feat(web): track unread sessions across bots
LittleSound Oct 16, 2026
5b53513
chore(db): renumber the session attention migration after main
LittleSound Oct 20, 2026
8e8bacc
fix(api): recheck bot access for every attention frame
LittleSound Oct 20, 2026
18cbd47
feat(web): mark the viewed session as read
LittleSound Oct 20, 2026
ab85809
feat(web): show unread dots and the needs-you inbox
LittleSound Oct 20, 2026
cdfe71c
feat: raise browser and desktop notifications for attention
LittleSound Oct 20, 2026
0cd6136
fix(web): stop KeepAlive-cached panes from reading sessions
LittleSound Oct 20, 2026
91f0ada
feat(web): raise the needs-you inbox into an animated card
LittleSound Oct 20, 2026
daa1ad6
chore(db): renumber the session attention migration to 0170
LittleSound Oct 27, 2026
690ef25
fix(web): play attention arrival motion only for live arrivals
LittleSound Oct 29, 2026
ada4968
fix(web): expand the needs-you list at collapse speed
LittleSound Oct 29, 2026
8847e3c
feat: let users mark sessions unread
LittleSound Oct 29, 2026
a50bcbf
feat(web): fold the needs-you card, clear it with undo, mark sessions…
LittleSound Oct 29, 2026
3031542
fix(web): open session selection below the needs-you card
LittleSound Oct 29, 2026
9ca5889
fix(api): answer a read without through as a field error
LittleSound Oct 29, 2026
5d69ff0
feat(web): rank attention colors by urgency
LittleSound Oct 29, 2026
42f3bcd
chore: sync session attention with main and merged UI tones
chen-ran Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions apps/desktop/src/main/attention-notifications.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { describe, expect, it, vi } from 'vitest'
import { createAttentionNotifications } from './attention-notifications'

const payload = {
botId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
sessionId: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
attentionAt: '2026-10-20T08:00:00Z',
title: 'Atlas · Refactor',
body: 'Reply ready',
}

describe('desktop attention notifications', () => {
it('deduplicates renderers, replaces a session notification and navigates on click', () => {
const clicks: Array<() => void> = []
const close = vi.fn()
const show = vi.fn((_p, onClick: () => void) => { clicks.push(onClick); return close })
const navigate = vi.fn()
const notifications = createAttentionNotifications({ show, navigate })
notifications.notify(payload)
notifications.notify(payload)
expect(show).toHaveBeenCalledTimes(1)
clicks[0]?.()
expect(navigate).toHaveBeenCalledWith(`/bot/${payload.botId}?session=${payload.sessionId}`)
notifications.notify({ ...payload, attentionAt: '2026-10-20T08:01:00Z' })
expect(close).toHaveBeenCalledTimes(1)
expect(show).toHaveBeenCalledTimes(2)
notifications.clear()
expect(close).toHaveBeenCalledTimes(2)
})

it('rejects invalid IPC input and stale events', () => {
const show = vi.fn(() => vi.fn())
const notifications = createAttentionNotifications({ show, navigate: vi.fn() })
for (const invalid of [null, {}, { ...payload, botId: '//evil.test' }, { ...payload, attentionAt: 'bad' }, { ...payload, title: 'x'.repeat(1000) }]) {
notifications.notify(invalid)
}
expect(show).not.toHaveBeenCalled()
notifications.notify(payload)
notifications.notify({ ...payload, attentionAt: '2026-10-19T08:00:00Z' })
expect(show).toHaveBeenCalledTimes(1)
})
})
49 changes: 49 additions & 0 deletions apps/desktop/src/main/attention-notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { AttentionNotification } from '../shared/attention'

const uuid = /^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i

function parseNotification(value: unknown): AttentionNotification | null {
if (!value || typeof value !== 'object') return null
const data = value as Record<string, unknown>
if (typeof data.botId !== 'string' || !uuid.test(data.botId)
|| typeof data.sessionId !== 'string' || !uuid.test(data.sessionId)
|| typeof data.attentionAt !== 'string' || !Number.isFinite(Date.parse(data.attentionAt))
|| typeof data.title !== 'string' || data.title.length > 256
|| typeof data.body !== 'string' || data.body.length > 1024) return null
return data as unknown as AttentionNotification
}

/** The main process owns deduplication across windows; no renderer-provided URL is trusted. */
export function createAttentionNotifications(deps: {
show(payload: AttentionNotification, onClick: () => void): (() => void) | null
navigate(path: string): void
}) {
const latest = new Map<string, { at: number, close: () => void }>()

function notify(raw: unknown) {
const payload = parseNotification(raw)
if (!payload) return
const at = Date.parse(payload.attentionAt)
const previous = latest.get(payload.sessionId)
if (previous && previous.at >= at) return
const close = deps.show(payload, () => deps.navigate(`/bot/${payload.botId}?session=${payload.sessionId}`))
if (!close) return
previous?.close()
latest.delete(payload.sessionId)
latest.set(payload.sessionId, { at, close })
if (latest.size > 1000) {
const oldest = latest.keys().next().value
if (oldest) {
latest.get(oldest)?.close()
latest.delete(oldest)
}
}
}

function clear() {
for (const entry of latest.values()) entry.close()
latest.clear()
}

return { notify, clear }
}
27 changes: 27 additions & 0 deletions apps/desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { loadRemoteIcon } from './remote-icon'
import {
app,
Menu,
Notification,
shell,
BrowserWindow,
ipcMain,
Expand All @@ -23,6 +24,7 @@ import { acceleratorForCommand, appKeyboardCommands, type AppKeyboardCommand } f
import { attachMenuShortcutOwnership } from './menu-shortcuts'
import { dispatchFocusedWindowCommand } from './window-commands'
import { dispatchRendererNavigate } from './window-navigation'
import { createAttentionNotifications } from './attention-notifications'
import { attachDevelopmentWindowShortcuts } from './window-shortcuts'
import { macWindowChromeOptions } from './window-chrome'
import { maybeSelfInstallMacOS } from './self-install'
Expand Down Expand Up @@ -72,6 +74,22 @@ type TraySettingsItem = {
}

let chatWindow: BrowserWindow | null = null
const attentionNotifications = createAttentionNotifications({
show(payload, onClick) {
if (!Notification.isSupported()) return null
const notification = new Notification({ title: payload.title, body: payload.body })
notification.on('click', onClick)
notification.show()
return () => notification.close()
},
navigate(path) {
if (!chatWindow || chatWindow.isDestroyed()) chatWindow = createChatWindow()
if (chatWindow.isMinimized()) chatWindow.restore()
chatWindow.show()
chatWindow.focus()
dispatchRendererNavigate(chatWindow, path)
},
})
let menuShortcuts: ReturnType<typeof attachMenuShortcutOwnership> | null = null
let appTray: Tray | null = null
let trayUpdateVersion: string | null = null
Expand Down Expand Up @@ -791,6 +809,15 @@ app.whenReady().then(async () => {
assertTrustedRenderer(event)
return openExternalUrl(rawURL)
})
ipcMain.handle('desktop:notify', (event, payload: unknown) => {
assertTrustedRenderer(event)
attentionNotifications.notify(payload)
})
ipcMain.handle('desktop:set-badge-count', (event, count: unknown) => {
assertTrustedRenderer(event)
if (typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0) return
app.setBadgeCount(count)
})
ipcMain.handle('desktop:set-tray-bots', (event, payload: unknown) => {
assertTrustedRenderer(event)
trayBots = normalizeTrayBots(payload)
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import type { ServerConnectResult, ServerConnectionResult } from '../shared/server-connection'
import type { DesktopRuntimeConfig, DesktopRuntimeState } from '../shared/remote-runtime'
import type { DesktopUpdateInfo, DesktopUpdateState } from '../shared/updates'
import type { AttentionNotification } from '../shared/attention'

// Renderer query-cache invalidation payload. Mirrors the subset of
// Pinia Colada's `UseQueryEntryFilter` that survives structured-clone
Expand All @@ -27,6 +28,8 @@ export interface RendererInvalidatePayload {
// node-privileged main process.
const api = {
desktop: {
notify: (payload: AttentionNotification): Promise<void> => ipcRenderer.invoke('desktop:notify', payload),
setBadgeCount: (count: number): Promise<void> => ipcRenderer.invoke('desktop:set-badge-count', count),
loadRemoteIcon: (url: string): Promise<string> => ipcRenderer.invoke('desktop:load-remote-icon', url),
getServerStatus: (): Promise<{
baseUrl: string
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/src/shared/attention.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface AttentionNotification {
botId: string
sessionId: string
attentionAt: string
title: string
body: string
}
40 changes: 40 additions & 0 deletions apps/web/src/components/sidebar/attention-dot.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<span
ref="dot"
data-slot="attention-dot"
:data-kind="kind"
:data-cutout="cutout || undefined"
class="relative inline-block size-2 shrink-0 rounded-full"
aria-hidden="true"
/>
</template>

<script setup lang="ts">
import { onMounted, useTemplateRef, watch } from 'vue'
import type { AttentionKind } from '@/composables/api/attention-api'
import { useUnreadStore } from '@/store/unread'
import { popDot } from '@/utils/attention-motion'

/**
* The one unread mark for sessions, the inbox and the bot switcher. It pops only when
* the attention it shows (`sessionId` + `attentionAt`) just arrived live, so mounting it
* later (expanding a list, reloading, switching bots) stays still. `cutout` rings the dot
* in the sidebar surface for avatar corners.
*/
const props = defineProps<{
kind: AttentionKind
sessionId?: string
attentionAt?: string
cutout?: boolean
}>()

const unread = useUnreadStore()
const dot = useTemplateRef('dot')

function popIfFresh() {
if (dot.value && props.sessionId && props.attentionAt && unread.isFresh(props.sessionId, props.attentionAt)) popDot(dot.value)
}

onMounted(popIfFresh)
watch(() => props.attentionAt, popIfFresh)
</script>
57 changes: 44 additions & 13 deletions apps/web/src/components/sidebar/bot-switcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,34 @@
: 'max-w-full gap-2 rounded-md px-1.5'"
:aria-label="t('sidebar.switchBot')"
>
<Avatar
class="shrink-0 ring-1 ring-[color-mix(in_oklab,var(--foreground)_10%,transparent)]"
:class="fullWidth ? 'size-[22px]' : 'size-5'"
>
<AvatarImage
v-if="currentBot?.avatar_url"
:src="currentBot.avatar_url"
:alt="currentLabel"
/>
<AvatarFallback class="text-[9px]">
{{ avatarFallback }}
</AvatarFallback>
</Avatar>
<span class="relative shrink-0">
<Avatar
class="shrink-0 ring-1 ring-[color-mix(in_oklab,var(--foreground)_10%,transparent)]"
:class="fullWidth ? 'size-[22px]' : 'size-5'"
>
<AvatarImage
v-if="currentBot?.avatar_url"
:src="currentBot.avatar_url"
:alt="currentLabel"
/>
<AvatarFallback class="text-[9px]">
{{ avatarFallback }}
</AvatarFallback>
</Avatar>
<span
v-if="otherBotKind"
class="absolute -right-0.5 -top-0.5 flex"
role="img"
:aria-label="t('notifications.otherBots')"
>
<AttentionDot
:kind="otherBotKind"
:session-id="otherBotNewest?.sessionId"
:attention-at="otherBotNewest?.attentionAt"
cutout
/>
</span>
</span>
<span
class="min-w-0 truncate text-[13px] font-[550] tracking-[0.015em] text-foreground dark:text-[color:oklch(0.97_0_0)]"
:class="fullWidth && 'flex-1 text-left'"
Expand Down Expand Up @@ -107,6 +122,11 @@
v-if="bot.id === currentBotId"
class="size-3.5 shrink-0 text-muted-foreground"
/>
<BadgeCount
v-if="bot.id && unread.countByBot[bot.id]"
:count="unread.countByBot[bot.id] ?? 0"
:variant="botCountVariant(bot.id)"
/>
</div>
</div>

Expand Down Expand Up @@ -163,9 +183,13 @@ import {
DropdownMenuLabel,
DropdownMenuSeparator,
Spinner,
BadgeCount,
} from '@felinic/ui'
import { Check, ChevronsUpDown, GripVertical, Plus, Settings2 } from 'lucide-vue-next'
import { useChatStore } from '@/store/chat-list'
import { useUnreadStore } from '@/store/unread'
import { attentionBadgeVariant, mostUrgentKind } from '@/utils/session-attention'
import AttentionDot from './attention-dot.vue'
import { firstAvatarCharacter } from '@/composables/useAvatarInitials'
import { usePinnedBots } from '@/composables/usePinnedBots'
import { usePendingBotsRefresh } from '@/composables/usePendingBotsRefresh'
Expand All @@ -175,6 +199,13 @@ const router = useRouter()
const { t } = useI18n()
const chatStore = useChatStore()
const { currentBotId } = storeToRefs(chatStore)
const unread = useUnreadStore()
/** The dot for other bots speaks for their most urgent unread; the newest arrival drives the pop. */
const otherBotEntries = computed(() => unread.inbox.filter(entry => entry.botId !== currentBotId.value))
const otherBotKind = computed(() => mostUrgentKind(otherBotEntries.value.map(entry => entry.kind)))
/** Per-bot count tone in the menu, by that bot's most urgent unread. */
const botCountVariant = (botId: string) => attentionBadgeVariant(unread.inbox.filter(entry => entry.botId === botId).map(entry => entry.kind))
const otherBotNewest = computed(() => otherBotEntries.value[0])
const { sortBots } = usePinnedBots()

// Full-width shape for web / Windows (no traffic lights); mac desktop passes
Expand Down
Loading
Loading