Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat(app): desktop notifications for finished, failed and approval-needed runs (#9703)
Akarshan Biswas49a84bdeaebd
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 70e581c9e..cdf72d68e 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -75,6 +75,7 @@ dependencies = ["tauri-plugin-llamacpp","tauri-plugin-log","tauri-plugin-mlx",+ "tauri-plugin-notification","tauri-plugin-opener","tauri-plugin-os","tauri-plugin-rag",@@ -4322,6 +4323,20 @@ version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"+[[package]]+name = "mac-notification-sys"+version = "0.6.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fd604973958ddcc11b561193c0fb96ba146506ef2f231ef2e7c35fd2cbc9beca"+dependencies = [+ "cc",+ "log",+ "objc2",+ "objc2-foundation",+ "time",+ "uuid",+]+[[package]]name = "mac_address"version = "1.1.8"@@ -4629,6 +4644,20 @@ dependencies = ["memchr",]+[[package]]+name = "notify-rust"+version = "4.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4587364a9a0074333429b3df75a30a205340c56a536ca3eb6ca0e59b87bbf8af"+dependencies = [+ "futures-lite",+ "log",+ "mac-notification-sys",+ "serde",+ "tauri-winrt-notification",+ "zbus 5.17.0",+]+[[package]]name = "ntapi"version = "0.4.3"@@ -8194,6 +8223,26 @@ dependencies = ["tokio",]+[[package]]+name = "tauri-plugin-notification"+version = "2.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "14a226bfb8189ec4ab2c1936e66330ad06c44d9f6c54a674338208491dee177f"+dependencies = [+ "log",+ "notify-rust",+ "rand 0.10.2",+ "serde",+ "serde_json",+ "serde_repr",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.18",+ "time",+ "url",+ "zbus 5.17.0",+]+[[package]]name = "tauri-plugin-opener"version = "2.5.4"@@ -8506,6 +8555,17 @@ dependencies = ["toml 1.1.3+spec-1.1.0",]+[[package]]+name = "tauri-winrt-notification"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f37a6c354fd28fc9e322ed9bd47e3959576dad28c9d58ea1cf888cce1c7ccb36"+dependencies = [+ "thiserror 2.0.18",+ "windows 0.62.2",+ "windows-version",+]+[[package]]name = "tempfile"version = "3.27.0"diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 1e8482caa..8c81395ee 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -72,6 +72,7 @@ tauri-app = ["dep:tauri-plugin-llamacpp","dep:tauri-plugin-log","dep:tauri-plugin-opener",+ "dep:tauri-plugin-notification","dep:tauri-plugin-os","dep:tauri-plugin-rag","dep:tauri-plugin-shell",@@ -200,6 +201,7 @@ tauri-plugin-http = { version = "2", optional = true, default-features = false,] }tauri-plugin-log = { version = "2.0.0-rc", optional = true }tauri-plugin-opener = { version = "2.2.7", optional = true }+tauri-plugin-notification = { version = "2.8.1", optional = true }tauri-plugin-os = { version = "2.2.1", optional = true }tauri-plugin-shell = { version = "2.2.0", optional = true }tauri-plugin-store = { version = "2", optional = true }diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex 272d22c04..0eb404728 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -19,6 +19,7 @@"core:window:allow-set-focus","os:default","opener:default",+ "notification:default","log:default","core:webview:allow-create-webview-window","opener:allow-open-url",diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 74f5a4f04..84d979a7e 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -446,6 +446,7 @@ pub fn run() {.plugin(core::navigation::init()).plugin(tauri_plugin_os::init()).plugin(tauri_plugin_opener::init())+ .plugin(tauri_plugin_notification::init()).plugin(tauri_plugin_http::init()).plugin(tauri_plugin_store::Builder::new().build()).plugin(tauri_plugin_shell::init())diff --git a/web-app/package.json b/web-app/package.jsonindex 1727b3516..10e5c40fd 100644--- a/web-app/package.json+++ b/web-app/package.json@@ -58,6 +58,7 @@"@tauri-apps/plugin-deep-link": "2.4.3","@tauri-apps/plugin-http": "2.5.9","@tauri-apps/plugin-log": "^2.6.0",+ "@tauri-apps/plugin-notification": "2.8.1","@tauri-apps/plugin-opener": "2.5.2","@tauri-apps/plugin-os": "2.2.1","@tauri-apps/plugin-store": "^2.4.2",@@ -114,12 +115,12 @@"@testing-library/react": "16.3.0","@testing-library/user-event": "14.6.1","@types/culori": "2.1.1",+ "@types/hast": "^3.0.4","@types/istanbul-lib-report": "3.0.3","@types/istanbul-reports": "3.0.4","@types/lodash.clonedeep": "4.5.9","@types/lodash.debounce": "4.0.9","@types/matter-js": "^0",- "@types/hast": "^3.0.4","@types/mdast": "^4.0.4","@types/node": "22.14.1","@types/react": "19.1.2",diff --git a/web-app/src/containers/CoworkPage.tsx b/web-app/src/containers/CoworkPage.tsxindex d23200089..7f2266884 100644--- a/web-app/src/containers/CoworkPage.tsx+++ b/web-app/src/containers/CoworkPage.tsx@@ -1,4 +1,5 @@/* eslint-disable @typescript-eslint/no-explicit-any */+import { notifyRun } from '@/lib/runNotifications'import { useNavigate } from '@tanstack/react-router'import ChatInput from '@/containers/ChatInput'import HeaderPage from '@/containers/HeaderPage'@@ -1127,6 +1128,16 @@ export function CoworkPage() {errorText: thrown?.errorText ?? outcome?.errorText,})+ const queuedNext = useMessageQueue.getState().getQueue(sid).length > 0+ if (stop && !(stop === 'done' && queuedNext)) {+ void notifyRun({+ kind:+ stop === 'aborted' ? 'cancel' : stop === 'error' ? 'error' : 'finish',+ threadId: sid,+ eventId: handle.runId,+ })+ }+// Message queue (ChatInput enqueues while chatStatus is 'streaming',// scoped to this session): a clean finish sends the next queued message;// an error discards the queue, mirroring the chat route — errors mean thediff --git a/web-app/src/hooks/useInterfaceSettings.ts b/web-app/src/hooks/useInterfaceSettings.tsindex cb02b4ac4..758728360 100644--- a/web-app/src/hooks/useInterfaceSettings.ts+++ b/web-app/src/hooks/useInterfaceSettings.ts@@ -128,7 +128,24 @@ const stepMessageZoom = (current: number, direction: 1 | -1): number => {)}+export type RunNotificationSettings = {+ enabled: boolean+ onFinish: boolean+ onError: boolean+ onApproval: boolean+ onCancel: boolean+}++const defaultRunNotifications: RunNotificationSettings = {+ enabled: true,+ onFinish: true,+ onError: true,+ onApproval: true,+ onCancel: false,+}+interface InterfaceSettingsState {+ runNotifications: RunNotificationSettingsfontSize: FontSizemessageZoom: numberaccentColor: AccentColorValue@@ -147,6 +164,7 @@ interface InterfaceSettingsState {setColoredUserBubble: (colored: boolean) => voidsetRenderHtmlArtifacts: (render: boolean) => voidsetAutoGenerateTitle: (auto: boolean) => void+ setRunNotifications: (patch: Partial<RunNotificationSettings>) => voidresetInterface: () => void}@@ -163,6 +181,7 @@ type InterfaceSettingsPersistedSlice = Omit<| 'setColoredUserBubble'| 'setRenderHtmlArtifacts'| 'setAutoGenerateTitle'+ | 'setRunNotifications'>export const fontSizeOptions = [@@ -185,6 +204,7 @@ const createDefaultInterfaceValues = (): InterfaceSettingsPersistedSlice => {coloredUserBubble: true,renderHtmlArtifacts: false,autoGenerateTitle: true,+ runNotifications: { ...defaultRunNotifications },}}@@ -225,6 +245,7 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(coloredUserBubble: true,renderHtmlArtifacts: false,autoGenerateTitle: true,+ runNotifications: { ...defaultRunNotifications },})},@@ -274,6 +295,12 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(setAutoGenerateTitle: (auto) => {set({ autoGenerateTitle: auto })},++ setRunNotifications: (patch) => {+ set((state) => ({+ runNotifications: { ...state.runNotifications, ...patch },+ }))+ },}},{@@ -289,6 +316,7 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(coloredUserBubble: state.coloredUserBubble,renderHtmlArtifacts: state.renderHtmlArtifacts,autoGenerateTitle: state.autoGenerateTitle,+ runNotifications: state.runNotifications,}),// Apply settings when hydrating from storageonRehydrateStorage: () => (state) => {@@ -324,6 +352,11 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(state.showTokenSpeed = true}+ state.runNotifications = {+ ...defaultRunNotifications,+ ...state.runNotifications,+ }+if (typeof state.coloredUserBubble !== 'boolean') {state.coloredUserBubble = true}diff --git a/web-app/src/hooks/useToolApprovalRequests.ts b/web-app/src/hooks/useToolApprovalRequests.tsindex 944689647..627854142 100644--- a/web-app/src/hooks/useToolApprovalRequests.ts+++ b/web-app/src/hooks/useToolApprovalRequests.ts@@ -1,4 +1,5 @@import { create } from 'zustand'+import { notifyRun } from '@/lib/runNotifications'import {consentAnswer,consentCancelThread,@@ -95,6 +96,11 @@ export const useToolApprovalRequests = create<ToolApprovalRequestsState>()(// A second ask for an id whose prompt is open is denied: replacing the// prompt would strand the first call's answer.if (get().pending[toolCallId]) return false+ void notifyRun({+ kind: 'approval',+ threadId,+ eventId: toolCallId,+ })return new Promise<boolean>((resolve) => {set((s) => ({pending: {diff --git a/web-app/src/lib/__tests__/runNotifications.test.ts b/web-app/src/lib/__tests__/runNotifications.test.tsnew file mode 100644index 000000000..535b055be--- /dev/null+++ b/web-app/src/lib/__tests__/runNotifications.test.ts@@ -0,0 +1,49 @@+import { describe, it, expect } from 'vitest'+import {+ kindIsEnabled,+ shouldNotify,+ threadIsOnScreen,+} from '../runNotifications'++const all = {+ enabled: true,+ onFinish: true,+ onError: true,+ onApproval: true,+ onCancel: false,+}++describe('kindIsEnabled', () => {+ it('skips user cancellations unless opted in', () => {+ expect(kindIsEnabled(all, 'cancel')).toBe(false)+ expect(kindIsEnabled({ ...all, onCancel: true }, 'cancel')).toBe(true)+ })++ it('is off for every kind when the master switch is off', () => {+ const off = { ...all, enabled: false }+ expect(kindIsEnabled(off, 'finish')).toBe(false)+ expect(kindIsEnabled(off, 'approval')).toBe(false)+ })++ it('honours each per-event toggle', () => {+ expect(kindIsEnabled({ ...all, onError: false }, 'error')).toBe(false)+ expect(kindIsEnabled({ ...all, onError: false }, 'finish')).toBe(true)+ })+})++describe('threadIsOnScreen', () => {+ it('needs both focus and the matching thread route', () => {+ expect(threadIsOnScreen('t1', true, '/threads/t1')).toBe(true)+ expect(threadIsOnScreen('t1', false, '/threads/t1')).toBe(false)+ expect(threadIsOnScreen('t1', true, '/threads/t2')).toBe(false)+ expect(threadIsOnScreen('t1', true, '/settings')).toBe(false)+ })+})++describe('shouldNotify', () => {+ const input = { kind: 'finish', threadId: 't1', eventId: 'm1' } as const+ it('stays quiet while the conversation is visible', () => {+ expect(shouldNotify(all, input, true)).toBe(false)+ expect(shouldNotify(all, input, false)).toBe(true)+ })+})diff --git a/web-app/src/lib/runNotifications.ts b/web-app/src/lib/runNotifications.tsnew file mode 100644index 000000000..4e5da06ca--- /dev/null+++ b/web-app/src/lib/runNotifications.ts@@ -0,0 +1,105 @@+import { i18n } from '@/i18n/react-i18next-compat'+import {+ useInterfaceSettings,+ type RunNotificationSettings,+} from '@/hooks/useInterfaceSettings'+import { isPlatformTauri } from '@/lib/platform/utils'+import { useThreads } from '@/hooks/useThreads'+import { useCoworkSessions } from '@/hooks/useCoworkSessions'++export type RunNotificationKind = 'finish' | 'error' | 'approval' | 'cancel'++export type RunNotificationInput = {+ kind: RunNotificationKind+ threadId: string+ /** Distinguishes repeated events for one thread (message or tool call id). */+ eventId: string+}++const SETTING_FOR_KIND: Record<+ RunNotificationKind,+ keyof Omit<RunNotificationSettings, 'enabled'>+> = {+ finish: 'onFinish',+ error: 'onError',+ approval: 'onApproval',+ cancel: 'onCancel',+}++const MAX_REMEMBERED = 200+const sent = new Set<string>()++export const kindIsEnabled = (+ settings: RunNotificationSettings,+ kind: RunNotificationKind+): boolean => settings.enabled && settings[SETTING_FOR_KIND[kind]]++export const threadIsOnScreen = (+ threadId: string,+ windowFocused: boolean,+ pathname: string+): boolean =>+ windowFocused && pathname.split('/').filter(Boolean).pop() === threadId++export const shouldNotify = (+ settings: RunNotificationSettings,+ input: RunNotificationInput,+ onScreen: boolean+): boolean => kindIsEnabled(settings, input.kind) && !onScreen++const rememberOnce = (key: string): boolean => {+ if (sent.has(key)) return false+ sent.add(key)+ if (sent.size > MAX_REMEMBERED) {+ sent.delete(sent.values().next().value as string)+ }+ return true+}++export const resetRunNotificationsForTest = () => sent.clear()++const titleOf = (threadId: string): string | undefined =>+ useThreads.getState().threads[threadId]?.title ||+ useCoworkSessions.getState().sessions.find((s) => s.id === threadId)?.title++async function windowIsFocused(): Promise<boolean> {+ const { getCurrentWindow } = await import('@tauri-apps/api/window')+ const win = getCurrentWindow()+ const [focused, minimized] = await Promise.all([+ win.isFocused(),+ win.isMinimized(),+ ])+ return focused && !minimized+}++export async function notifyRun(input: RunNotificationInput): Promise<void> {+ if (!isPlatformTauri()) return+ const settings = useInterfaceSettings.getState().runNotifications+ if (!kindIsEnabled(settings, input.kind)) return+ try {+ const onScreen = threadIsOnScreen(+ input.threadId,+ await windowIsFocused(),+ window.location.pathname+ )+ if (!shouldNotify(settings, input, onScreen)) return+ if (!rememberOnce(`${input.kind}:${input.threadId}:${input.eventId}`)) {+ return+ }+ const { isPermissionGranted, requestPermission, sendNotification } =+ await import('@tauri-apps/plugin-notification')+ if (+ !(await isPermissionGranted()) &&+ (await requestPermission()) !== 'granted'+ ) {+ return+ }+ const name = titleOf(input.threadId)?.trim() || i18n.t('common:untitledThread')+ sendNotification({+ title: i18n.t(`common:runNotification.${input.kind}.title`),+ body: i18n.t(`common:runNotification.${input.kind}.body`, { name }),+ })+ } catch (error) {+ console.error('Run notification failed:', error)+ }+}diff --git a/web-app/src/locales/__tests__/localeKeys.test.ts b/web-app/src/locales/__tests__/localeKeys.test.tsindex f7b98e882..6a4f0cbb8 100644--- a/web-app/src/locales/__tests__/localeKeys.test.ts+++ b/web-app/src/locales/__tests__/localeKeys.test.ts@@ -65,6 +65,15 @@ const DYNAMIC_KEYS: Record<string, string[]> = {'coworkEmpty.folder.first','coworkEmpty.folder.second','coworkEmpty.folder.third',+ // runNotifications composes the key from the event kind.+ 'runNotification.finish.title',+ 'runNotification.finish.body',+ 'runNotification.error.title',+ 'runNotification.error.body',+ 'runNotification.approval.title',+ 'runNotification.approval.body',+ 'runNotification.cancel.title',+ 'runNotification.cancel.body',],// The settings page labels each host extension by its lifecycle state.extensions: [diff --git a/web-app/src/locales/en/common.json b/web-app/src/locales/en/common.jsonindex ef6b47b74..91c384331 100644--- a/web-app/src/locales/en/common.json+++ b/web-app/src/locales/en/common.json@@ -946,5 +946,24 @@"description": "Jan keeps this conversation and continues it as a Cowork task. A task can run tools, write files and run commands in its own workspace without asking for each step. You cannot switch it back to a chat.","descriptionFolder": "Jan keeps this conversation and continues it as a Cowork task. A task can edit files and run commands in {{folder}} without asking for each change. You cannot switch it back to a chat.","confirm": "Continue as task"+ },+ "untitledThread": "your conversation",+ "runNotification": {+ "finish": {+ "title": "Jan finished the task",+ "body": "{{name}} is ready."+ },+ "error": {+ "title": "Jan task failed",+ "body": "{{name}} stopped with an error."+ },+ "approval": {+ "title": "Jan needs your approval",+ "body": "{{name}} is waiting for you to approve a tool call."+ },+ "cancel": {+ "title": "Jan task cancelled",+ "body": "{{name}} was cancelled."+ }}}diff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.jsonindex 264421e60..6c3812458 100644--- a/web-app/src/locales/en/settings.json+++ b/web-app/src/locales/en/settings.json@@ -127,7 +127,13 @@"resetCodeBlockStyle": "Reset Code Block Style","resetCodeBlockStyleDesc": "Reset code block style to default.","resetCodeBlockSuccess": "Code block style reset successfully",- "resetCodeBlockSuccessDesc": "Code block style has been restored to default."+ "resetCodeBlockSuccessDesc": "Code block style has been restored to default.",+ "runNotifications": "Desktop notifications",+ "runNotificationsDesc": "Notify you when Jan is in the background or the conversation is not open.",+ "runNotificationsFinish": "Task finished",+ "runNotificationsError": "Task failed",+ "runNotificationsApproval": "Approval needed",+ "runNotificationsCancel": "Task cancelled"},"hardware": {"os": "Operating System",diff --git a/web-app/src/routes/settings/__tests__/interface.test.tsx b/web-app/src/routes/settings/__tests__/interface.test.tsxindex 387547b31..5cb027553 100644--- a/web-app/src/routes/settings/__tests__/interface.test.tsx+++ b/web-app/src/routes/settings/__tests__/interface.test.tsx@@ -52,6 +52,8 @@ vi.mock('@/hooks/useTheme', () => ({ useTheme: () => ({ activeTheme: theme.activvi.mock('@/hooks/useInterfaceSettings', () => ({useInterfaceSettings: () => ({resetInterface: vi.fn(),+ runNotifications: { enabled: false },+ setRunNotifications: vi.fn(),}),}))diff --git a/web-app/src/routes/settings/interface.tsx b/web-app/src/routes/settings/interface.tsxindex 46b189c68..410e87975 100644--- a/web-app/src/routes/settings/interface.tsx+++ b/web-app/src/routes/settings/interface.tsx@@ -31,6 +31,8 @@ function InterfaceSettings() {setRenderHtmlArtifacts,autoGenerateTitle,setAutoGenerateTitle,+ runNotifications,+ setRunNotifications,} = useInterfaceSettings()const { activeTheme } = useTheme()@@ -121,6 +123,70 @@ function InterfaceSettings() {/>}/>+ <CardItem+ title={t('settings:interface.runNotifications')}+ description={t('settings:interface.runNotificationsDesc')}+ actions={+ <Switch+ checked={runNotifications.enabled}+ onCheckedChange={(enabled) =>+ setRunNotifications({ enabled })+ }+ />+ }+ />+ {runNotifications.enabled && (+ <CardItem+ title={t('settings:interface.runNotificationsFinish')}+ actions={+ <Switch+ checked={runNotifications.onFinish}+ onCheckedChange={(onFinish) =>+ setRunNotifications({ onFinish })+ }+ />+ }+ />+ )}+ {runNotifications.enabled && (+ <CardItem+ title={t('settings:interface.runNotificationsError')}+ actions={+ <Switch+ checked={runNotifications.onError}+ onCheckedChange={(onError) =>+ setRunNotifications({ onError })+ }+ />+ }+ />+ )}+ {runNotifications.enabled && (+ <CardItem+ title={t('settings:interface.runNotificationsApproval')}+ actions={+ <Switch+ checked={runNotifications.onApproval}+ onCheckedChange={(onApproval) =>+ setRunNotifications({ onApproval })+ }+ />+ }+ />+ )}+ {runNotifications.enabled && (+ <CardItem+ title={t('settings:interface.runNotificationsCancel')}+ actions={+ <Switch+ checked={runNotifications.onCancel}+ onCheckedChange={(onCancel) =>+ setRunNotifications({ onCancel })+ }+ />+ }+ />+ )}<CardItemtitle={t('settings:interface.resetToDefault')}description={t('settings:interface.resetToDefaultDesc')}diff --git a/web-app/src/routes/threads/$threadId.tsx b/web-app/src/routes/threads/$threadId.tsxindex 5bd61b296..6d3fe04f6 100644--- a/web-app/src/routes/threads/$threadId.tsx+++ b/web-app/src/routes/threads/$threadId.tsx@@ -1,3 +1,4 @@+import { notifyRun } from '@/lib/runNotifications'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import type { CSSProperties } from 'react'import {@@ -758,6 +759,7 @@ function ThreadDetail() {// Context limit hit: send partial content as prefill so the model continues// from where it stopped. The stream wrapper injects it as the first text-delta// of the new message, so the user sees the partial text immediately.+ let hitContextLimit = falseif (!isAbort && finishReason === 'length') {const providerState = turnModelOf(threadId)const isContextLimit = isContextLimitStop({@@ -771,6 +773,7 @@ function ThreadDetail() {launchedCtxLen: launchedCtxLens.get(threadId),})+ hitContextLimit = isContextLimitif (isContextLimit) {// Stash the partial so the manual "Increase Context Size" button can// resume from here. Surface the standard banner with the manual@@ -792,6 +795,20 @@ function ThreadDetail() {// as stopped so the "Continue" button can resume it.}+ const failed =+ isError ||+ hitContextLimit ||+ isEmptyReply({ message, isAbort, isError, finishReason })+ const queuedNext =+ !isAbort && !failed && useMessageQueue.getState().getQueue(threadId).length > 0+ if (finishReason !== 'tool-calls' && !queuedNext) {+ void notifyRun({+ kind: isAbort ? 'cancel' : failed ? 'error' : 'finish',+ threadId,+ eventId: finishedMessage.id,+ })+ }+if (!isAbort && message.parts.length) clearPendingContinue(threadId)// Nothing would be persisted for an empty reply, so without this thediff --git a/web-app/src/routes/threads/__tests__/$threadId.test.tsx b/web-app/src/routes/threads/__tests__/$threadId.test.tsxindex ffbd65d84..61aec4fe6 100644--- a/web-app/src/routes/threads/__tests__/$threadId.test.tsx+++ b/web-app/src/routes/threads/__tests__/$threadId.test.tsx@@ -149,7 +149,9 @@ const h = vi.hoisted(() => {const messageQueueState: any = {dequeue: vi.fn(() => null),clearQueue: vi.fn(),+ getQueue: vi.fn((): unknown[] => []),}+ const notifyRunMock = vi.fn()const useMessageQueueMock: any = (_selector: any) => undefineduseMessageQueueMock.getState = () => messageQueueState@@ -187,6 +189,8 @@ const h = vi.hoisted(() => {useAgentModeMock,messageQueueState,useMessageQueueMock,+ messageQueueState,+ notifyRunMock,}})@@ -474,6 +478,7 @@ vi.mock('@/hooks/useToolApprovalRequests', () => ({useToolApprovalRequests: h.useToolApprovalRequestsMock,}))vi.mock('@/hooks/useAgentMode', () => ({ useAgentMode: h.useAgentModeMock }))+vi.mock('@/lib/runNotifications', () => ({ notifyRun: h.notifyRunMock }))vi.mock('@/stores/message-queue-store', () => ({ useMessageQueue: h.useMessageQueueMock }))vi.mock('@/hooks/useAutoScroll', () => ({@@ -1091,6 +1096,39 @@ describe('ThreadDetail route', () => {expect(screen.queryByText('Increase Context Size')).toBeNull()})+ it('notifies a failure, not a finish, for a context-limit stop', () => {+ h.modelProviderState.selectedProvider = 'llamacpp'+ renderComponent()+ act(() => {+ finishAtLength()+ })+ expect(h.notifyRunMock).toHaveBeenCalledWith(+ expect.objectContaining({ kind: 'error', threadId: 'thread-1' })+ )+ })++ it('notifies a finish for a truncated cloud reply', () => {+ h.modelProviderState.selectedProvider = 'anthropic'+ renderComponent()+ act(() => {+ finishAtLength()+ })+ expect(h.notifyRunMock).toHaveBeenCalledWith(+ expect.objectContaining({ kind: 'finish' })+ )+ })++ it('does not notify a finish while a queued message will run next', () => {+ h.modelProviderState.selectedProvider = 'anthropic'+ h.messageQueueState.getQueue.mockReturnValue([{ text: 'next' }])+ renderComponent()+ act(() => {+ finishAtLength()+ })+ expect(h.notifyRunMock).not.toHaveBeenCalled()+ h.messageQueueState.getQueue.mockReturnValue([])+ })+// A reply that fills a local model's context was generated; dropping it left// the user with only their own message and a banner.it('keeps the partial reply of a local model near ctx_len, with the banner', () => {diff --git a/yarn.lock b/yarn.lockindex 29589fcae..a90b43047 100644--- a/yarn.lock+++ b/yarn.lock@@ -1970,6 +1970,7 @@ __metadata:"@tauri-apps/plugin-deep-link": "npm:2.4.3""@tauri-apps/plugin-http": "npm:2.5.9""@tauri-apps/plugin-log": "npm:^2.6.0"+ "@tauri-apps/plugin-notification": "npm:2.8.1""@tauri-apps/plugin-opener": "npm:2.5.2""@tauri-apps/plugin-os": "npm:2.2.1""@tauri-apps/plugin-store": "npm:^2.4.2"@@ -4759,6 +4760,13 @@ __metadata:languageName: nodelinkType: hard+"@tauri-apps/api@npm:^2.12.0":+ version: 2.12.5+ resolution: "@tauri-apps/api@npm:2.12.5"+ checksum: 10c0/fa35056017c27d1812b246590f09a81b0dde097aa4062c5978f44bcce82363e9e4b7b35c18524d29d96ab63f87a77504d1ef1b851ed7ffd3241bfff27686c1c7+ languageName: node+ linkType: hard+"@tauri-apps/cli-darwin-arm64@npm:2.8.4":version: 2.8.4resolution: "@tauri-apps/cli-darwin-arm64@npm:2.8.4"@@ -4907,6 +4915,15 @@ __metadata:languageName: nodelinkType: hard+"@tauri-apps/plugin-notification@npm:2.8.1":+ version: 2.8.1+ resolution: "@tauri-apps/plugin-notification@npm:2.8.1"+ dependencies:+ "@tauri-apps/api": "npm:^2.12.0"+ checksum: 10c0/33fbc6917b51f4ee97186c2b70a9505e88b7abf85e847fcb1d59f461f642812f31db4871332da9b3f8b2213f363691a04da153e1891a9ff30dbf14ef7cb5f0d4+ languageName: node+ linkType: hard+"@tauri-apps/plugin-opener@npm:2.5.2":version: 2.5.2resolution: "@tauri-apps/plugin-opener@npm:2.5.2"