Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: 稳定运行中任务的优先级排序
Dashaf35139f9c35
diff --git a/apps/desktop/src/renderer/__tests__/mainListModel.test.ts b/apps/desktop/src/renderer/__tests__/mainListModel.test.tsindex 543d851a73..0a3fd405d8 100644--- a/apps/desktop/src/renderer/__tests__/mainListModel.test.ts+++ b/apps/desktop/src/renderer/__tests__/mainListModel.test.ts@@ -414,6 +414,112 @@ describe('buildMainListEntries — 排序口径', () => {expect(labels(entries)).toEqual(['s:just-sent', 's:running-older', 's:idle-newer']);});+ it('keeps running tasks in recency order when one also has stale unread attention', () => {+ const newer = session({ updatedAt: '2026-08-12T12:00:00Z', title: 'newer-running' });+ const older = session({ updatedAt: '2026-08-12T11:00:00Z', title: 'older-running' });+ const hold = {+ heldPriorityRanks: new Map<string, number>(),+ recentlyViewedAtMs: new Map<string, number>(),+ };+ const withStaleUnread = {+ runningSessionIds: new Set([newer.id, older.id]),+ attentionSessionIds: new Set([older.id]),+ waitingSessionIds: new Set<string>(),+ };++ expect(sessionPriorityRank(older, withStaleUnread)).toBe(LIVE_TASK_PRIORITY.running);+ holdViewedPriorityRank(hold, older.id, withStaleUnread);+ const runningOnly = {+ ...withStaleUnread,+ attentionSessionIds: new Set<string>(),+ };+ advanceViewedPriorityHold(hold, older.id, runningOnly, 1_000);+ expect(hold.heldPriorityRanks.get(older.id)).toBe(LIVE_TASK_PRIORITY.running);++ const beforeSwitch = buildMainListEntries({+ projects: [],+ dialogues: [older, newer],+ groupBy: 'project',+ groupDialogue: false,+ sortBy: 'priority',+ manualProjectOrder: [],+ priorityContext: { ...runningOnly, heldPriorityRanks: hold.heldPriorityRanks },+ });+ expect(labels(beforeSwitch)).toEqual(['s:newer-running', 's:older-running']);++ advanceViewedPriorityHold(hold, newer.id, runningOnly, 2_000);+ const afterSwitch = buildMainListEntries({+ projects: [],+ dialogues: [older, newer],+ groupBy: 'project',+ groupDialogue: false,+ sortBy: 'priority',+ manualProjectOrder: [],+ priorityContext: { ...runningOnly, heldPriorityRanks: hold.heldPriorityRanks },+ });+ expect(labels(afterSwitch)).toEqual(labels(beforeSwitch));+ expect(hold.recentlyViewedAtMs.has(older.id)).toBe(false);+ });++ it('does not restore an old unread hold after the viewed run finishes', () => {+ const viewed = session({ updatedAt: '2026-08-12T12:00:00Z', title: 'viewed' });+ const hold = {+ heldPriorityRanks: new Map<string, number>(),+ recentlyViewedAtMs: new Map<string, number>(),+ };+ holdViewedPriorityRank(hold, viewed.id, {+ runningSessionIds: new Set<string>(),+ attentionSessionIds: new Set([viewed.id]),+ waitingSessionIds: new Set<string>(),+ });+ const running = {+ runningSessionIds: new Set([viewed.id]),+ attentionSessionIds: new Set<string>(),+ waitingSessionIds: new Set<string>(),+ };+ advanceViewedPriorityHold(hold, viewed.id, running, 1_000);+ expect(hold.heldPriorityRanks.get(viewed.id)).toBe(LIVE_TASK_PRIORITY.running);++ const finished = {+ ...running,+ runningSessionIds: new Set<string>(),+ heldPriorityRanks: hold.heldPriorityRanks,+ };+ expect(sessionPriorityRank(viewed, finished)).toBe(LIVE_TASK_PRIORITY.running);++ advanceViewedPriorityHold(hold, undefined, finished, 2_000);+ expect(hold.recentlyViewedAtMs.has(viewed.id)).toBe(false);+ expect(sessionPriorityRank(viewed, finished)).toBe(LIVE_TASK_PRIORITY.rest);+ });++ it('still promotes a viewed running task to waiting and releases it when running resumes', () => {+ const viewed = session({ updatedAt: '2026-08-12T12:00:00Z', title: 'viewed' });+ const hold = {+ heldPriorityRanks: new Map<string, number>(),+ recentlyViewedAtMs: new Map<string, number>(),+ };+ const running = {+ runningSessionIds: new Set([viewed.id]),+ attentionSessionIds: new Set<string>(),+ waitingSessionIds: new Set<string>(),+ };+ holdViewedPriorityRank(hold, viewed.id, running);++ const waiting = {+ ...running,+ attentionSessionIds: new Set([viewed.id]),+ waitingSessionIds: new Set([viewed.id]),+ };+ advanceViewedPriorityHold(hold, viewed.id, waiting, 1_000);+ expect(hold.heldPriorityRanks.get(viewed.id)).toBe(LIVE_TASK_PRIORITY.waiting);+ expect(+ sessionPriorityRank(viewed, { ...waiting, heldPriorityRanks: hold.heldPriorityRanks }),+ ).toBe(LIVE_TASK_PRIORITY.waiting);++ advanceViewedPriorityHold(hold, viewed.id, running, 2_000);+ expect(hold.heldPriorityRanks.get(viewed.id)).toBe(LIVE_TASK_PRIORITY.running);+ });+it('keeps the open unread task in place, then parks it at the top of the rest tier after leave', () => {const unread = session({ updatedAt: '2026-07-01T00:00:00Z', title: 'just-read' });const olderRest = session({ updatedAt: '2026-08-12T00:00:00Z', title: 'older-rest' });diff --git a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.tsindex a4a3790426..b933e67823 100644--- a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts@@ -20,6 +20,9 @@ const storeMock = vi.hoisted(() => ({terminalErrorSessions: new Set<string>(),sideTaskStopSessions: new Set<string>(),}));+const startingMock = vi.hoisted(() => ({+ sessionIds: new Set<string>(),+}));vi.mock('@/lib/makerChatStore', () => ({makerChatStore: {@@ -43,6 +46,10 @@ vi.mock('@/lib/sessionAttentionStore', () => ({useSessionAttentionSnapshot: () => new Set<string>(),}));+vi.mock('@/lib/sessionStartingStore', () => ({+ getStartingSessionIds: () => startingMock.sessionIds,+}));+function status(isRunning: boolean, hasError = false, sideTask?: boolean): SessionStatusInfo {return {isRunning,@@ -68,6 +75,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {storeMock.listeners.clear();storeMock.terminalErrorSessions.clear();storeMock.sideTaskStopSessions.clear();+ startingMock.sessionIds.clear();resetSilencedSessionDoneStoreForTests();vi.clearAllMocks();vi.restoreAllMocks();@@ -292,6 +300,62 @@ describe('useSessionRunningStatus silenced completion handling', () => {vi.useRealTimers();});+ it('does not restore done attention when the session becomes active during debounce', async () => {+ vi.useFakeTimers();+ const onSessionDone = vi.fn();+ const initialProps: { activeSessionId: string | undefined } = {+ activeSessionId: undefined,+ };+ const { rerender } = renderHook(+ ({ activeSessionId }: { activeSessionId: string | undefined }) =>+ useSessionRunningStatus(activeSessionId, { onSessionDone }),+ { initialProps },+ );++ await emitSnapshot(new Map([['session-active', status(true)]]));+ await emitSnapshot(new Map([['session-active', status(false)]]));+ rerender({ activeSessionId: 'session-active' });+ await act(async () => {+ await vi.advanceTimersByTimeAsync(500);+ });++ expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-active', 'done');+ expect(onSessionDone).toHaveBeenCalledWith('session-active');+ });++ it('does not restore done attention if a new run is visible when debounce expires', async () => {+ vi.useFakeTimers();+ const onSessionDone = vi.fn();+ renderHook(() => useSessionRunningStatus(undefined, { onSessionDone }));++ await emitSnapshot(new Map([['session-running', status(true)]]));+ await emitSnapshot(new Map([['session-running', status(false)]]));+ // 模拟 running snapshot 已更新、订阅 effect 尚未消费的同帧竞态。+ storeMock.snapshot = new Map([['session-running', status(true)]]);+ await act(async () => {+ await vi.advanceTimersByTimeAsync(500);+ });++ expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-running', 'done');+ expect(onSessionDone).toHaveBeenCalledWith('session-running');+ });++ it('does not restore done attention while the next turn is starting', async () => {+ vi.useFakeTimers();+ const onSessionDone = vi.fn();+ renderHook(() => useSessionRunningStatus(undefined, { onSessionDone }));++ await emitSnapshot(new Map([['session-starting', status(true)]]));+ await emitSnapshot(new Map([['session-starting', status(false)]]));+ startingMock.sessionIds.add('session-starting');+ await act(async () => {+ await vi.advanceTimersByTimeAsync(500);+ });++ expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-starting', 'done');+ expect(onSessionDone).toHaveBeenCalledWith('session-starting');+ });+it('coalesces multiple queue-drain transitions into a single final notification', async () => {// 排队 3 条消息:A → done → B → done → C → done。前两次 done 都在 debounce// 窗口内被下一次 turn 起始取消,只有 C 结束(队列空)最终 fire 一次通知。diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts b/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.tsindex 88831a28d7..51f4cebb26 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts@@ -106,10 +106,17 @@ export function sessionNaturalPriorityRank(return naturalPriorityRankForId(session.id, ctx);}+function viewedPriorityRank(natural: number, held: number | undefined): number {+ // 当前轮已经运行时,释放上一轮 unread / waiting 的 hold。否则看的过程中跑完后,+ // 旧 hold 会再次把任务抬回高档位,直到点击离开才突然重排。+ if (natural === LIVE_TASK_PRIORITY.running) return natural;+ return held === undefined ? natural : Math.min(natural, held);+}+export function sessionPriorityRank(session: Session, ctx: MainListPriorityContext): number {const natural = sessionNaturalPriorityRank(session, ctx);const held = ctx.heldPriorityRanks?.get(session.id);- return held === undefined ? natural : Math.min(natural, held);+ return viewedPriorityRank(natural, held);}export interface ViewedPriorityHoldState {@@ -141,10 +148,7 @@ export function advanceViewedPriorityHold(if (viewedSessionId) {const natural = naturalPriorityRankForId(viewedSessionId, ctx);const held = state.heldPriorityRanks.get(viewedSessionId);- state.heldPriorityRanks.set(- viewedSessionId,- held === undefined ? natural : Math.min(held, natural),- );+ state.heldPriorityRanks.set(viewedSessionId, viewedPriorityRank(natural, held));}state.prevViewedId = viewedSessionId;return state;@@ -164,7 +168,7 @@ export function holdViewedPriorityRank(): void {const natural = naturalPriorityRankForId(sessionId, ctx);const held = state.heldPriorityRanks.get(sessionId);- state.heldPriorityRanks.set(sessionId, held === undefined ? natural : Math.min(held, natural));+ state.heldPriorityRanks.set(sessionId, viewedPriorityRank(natural, held));}export function sessionPriorityRecencyMs(session: Session, ctx: MainListPriorityContext): number {diff --git a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.tsindex 54cc1ee2b0..f73d0f9059 100644--- a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts+++ b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts@@ -53,6 +53,7 @@ import {isSessionTerminalNotificationOwnedByScheduler,isSessionDoneSilenced,} from '@/lib/silencedSessionDoneStore';+import { getStartingSessionIds } from '@/lib/sessionStartingStore';// Codex maker 化后, codex session 也走 makerChatStore;// 不再需要双 store 合并 —— 直接订阅 makerChatStore 即可。@@ -110,6 +111,8 @@ export function useSessionRunningStatus(const onSessionDoneRef = useRef(options?.onSessionDone);const onSessionErrorRef = useRef(options?.onSessionError);const onSessionNeedsReplyRef = useRef(options?.onSessionNeedsReply);+ const activeSessionIdRef = useRef(activeSessionId);+ activeSessionIdRef.current = activeSessionId;useEffect(() => {onSessionDoneRef.current = options?.onSessionDone;onSessionErrorRef.current = options?.onSessionError;@@ -201,8 +204,6 @@ export function useSessionRunningStatus(// 抑制 callback,侧栏 / Dock attention 仍按普通 done/error 逻辑保留。const notificationOwnedByScheduler =isSessionTerminalNotificationOwnedByScheduler(sessionId);- const isActive = sessionId === activeSessionId;-// error 立刻处理:队列会被 abort,不存在"下一条自动接着跑"的场景;红角标 +// 系统通知(onSessionError,由 renderer 侧 gate focus)都马上触发,不走// debounce。出错永不静默:失败的后台 turn 不能伪装成正常完成或悄无声息消失。@@ -235,13 +236,16 @@ export function useSessionRunningStatus(// section 3 在 section 2 之后跑、awaiting 天然覆盖 done;debounce 把 done 推迟到// section 3 之后,必须显式让 awaiting 优先。done 系统通知仍照常发(与原行为一致)。const cur = makerChatStore.getRunningSnapshot().get(sessionId);+ const isActive = sessionId === activeSessionIdRef.current;+ const isRunning = cur?.isRunning === true;+ const isStarting = getStartingSessionIds().has(sessionId);const stillPending =!!cur &&(cur.hasPendingAskUser ||cur.hasPendingPermission ||cur.hasPendingPlanReview ||cur.hasPendingPluginSetup);- if (!isActive && !stillPending) {+ if (!isActive && !isRunning && !isStarting && !stillPending) {addSessionAttention(sessionId, 'done');}if (!notificationOwnedByScheduler) onSessionDoneRef.current?.(sessionId);diff --git a/apps/desktop/src/shared/__tests__/liveTaskPriority.test.ts b/apps/desktop/src/shared/__tests__/liveTaskPriority.test.tsindex bee1e40c78..6b2d49737b 100644--- a/apps/desktop/src/shared/__tests__/liveTaskPriority.test.ts+++ b/apps/desktop/src/shared/__tests__/liveTaskPriority.test.ts@@ -8,6 +8,9 @@ describe('liveTaskPriorityRank', () => {LIVE_TASK_PRIORITY.waiting,);expect(liveTaskPriorityRank({ waiting: false, unread: true, running: true })).toBe(+ LIVE_TASK_PRIORITY.running,+ );+ expect(liveTaskPriorityRank({ waiting: false, unread: true, running: false })).toBe(LIVE_TASK_PRIORITY.unread,);expect(liveTaskPriorityRank({ waiting: false, unread: false, running: true })).toBe(diff --git a/apps/mobile/src/__tests__/homeListPriority.test.ts b/apps/mobile/src/__tests__/homeListPriority.test.tsindex 2c292a5b87..cd49ef2020 100644--- a/apps/mobile/src/__tests__/homeListPriority.test.ts+++ b/apps/mobile/src/__tests__/homeListPriority.test.ts@@ -89,6 +89,56 @@ describe('homeListPriority hold', () => {.toBe(LIVE_TASK_PRIORITY.waiting);expect(naturalPriorityRankForId('ask-1', cleared)).toBe(LIVE_TASK_PRIORITY.rest);});++ it('releases an old unread hold when the viewed task starts running', () => {+ const state = createViewedPriorityHoldState();+ const unread = {+ runningSessionIds: new Set<string>(),+ unreadSessionIds: new Set(['task-1']),+ waitingSessionIds: new Set<string>(),+ };+ holdViewedPriorityRank(state, 'task-1', unread);++ const running = {+ runningSessionIds: new Set(['task-1']),+ unreadSessionIds: new Set<string>(),+ waitingSessionIds: new Set<string>(),+ };+ advanceViewedPriorityHold(state, 'task-1', running, 10);+ expect(state.heldPriorityRanks.get('task-1')).toBe(LIVE_TASK_PRIORITY.running);+ expect(sessionPriorityRank('task-1', { ...running, heldPriorityRanks: state.heldPriorityRanks }))+ .toBe(LIVE_TASK_PRIORITY.running);++ const finished = {+ ...running,+ runningSessionIds: new Set<string>(),+ heldPriorityRanks: state.heldPriorityRanks,+ };+ expect(sessionPriorityRank('task-1', finished)).toBe(LIVE_TASK_PRIORITY.running);++ advanceViewedPriorityHold(state, undefined, finished, 20);+ expect(state.recentlyViewedAtMs.has('task-1')).toBe(false);+ });++ it('still promotes a viewed running task to waiting, then releases waiting when running resumes', () => {+ const state = createViewedPriorityHoldState();+ const running = {+ runningSessionIds: new Set(['task-1']),+ unreadSessionIds: new Set<string>(),+ waitingSessionIds: new Set<string>(),+ };+ holdViewedPriorityRank(state, 'task-1', running);++ const waiting = {+ ...running,+ waitingSessionIds: new Set(['task-1']),+ };+ advanceViewedPriorityHold(state, 'task-1', waiting, 10);+ expect(state.heldPriorityRanks.get('task-1')).toBe(LIVE_TASK_PRIORITY.waiting);++ advanceViewedPriorityHold(state, 'task-1', running, 20);+ expect(state.heldPriorityRanks.get('task-1')).toBe(LIVE_TASK_PRIORITY.running);+ });});describe('collectHomePriorityContext', () => {@@ -110,7 +160,7 @@ describe('collectHomePriorityContext', () => {expect(naturalPriorityRankForId('idle', ctx)).toBe(LIVE_TASK_PRIORITY.rest);});- it('ranks an unread + running task as unread, not running', () => {+ it('ranks an unread + running task as running for its current turn', () => {const hold = createViewedPriorityHoldState();// 定时任务同时「完成未读」(scheduleInfo.unreadCount>0) 又「下一轮运行中」。const ctx = collectHomePriorityContext(@@ -122,7 +172,7 @@ describe('collectHomePriorityContext', () => {// 独立收集:该任务同时进 unread 与 running 集合。expect(ctx.unreadSessionIds.has('both')).toBe(true);expect(ctx.runningSessionIds.has('both')).toBe(true);- // 尺子 waiting > unread > running:落 unread 档而非 running 档。- expect(naturalPriorityRankForId('both', ctx)).toBe(LIVE_TASK_PRIORITY.unread);+ // 当前轮 running 压过上一轮 done 未读;纯完成未读仍在纯 running 前面。+ expect(naturalPriorityRankForId('both', ctx)).toBe(LIVE_TASK_PRIORITY.running);});});diff --git a/apps/mobile/src/session/homeListPriority.ts b/apps/mobile/src/session/homeListPriority.tsindex aab4312a43..98d6b3221f 100644--- a/apps/mobile/src/session/homeListPriority.ts+++ b/apps/mobile/src/session/homeListPriority.ts@@ -50,10 +50,17 @@ export function naturalPriorityRankForId(});}+function viewedPriorityRank(natural: number, held: number | undefined): number {+ // 当前轮已经运行时,释放上一轮 unread / waiting 的 hold。否则看的过程中跑完后,+ // 旧 hold 会再次把任务抬回高档位,直到点击离开才突然重排。+ if (natural === LIVE_TASK_PRIORITY.running) return natural;+ return held === undefined ? natural : Math.min(natural, held);+}+export function sessionPriorityRank(sessionId: string, ctx: HomeListPriorityContext): number {const natural = naturalPriorityRankForId(sessionId, ctx);const held = ctx.heldPriorityRanks?.get(sessionId);- return held === undefined ? natural : Math.min(natural, held);+ return viewedPriorityRank(natural, held);}/**@@ -75,10 +82,7 @@ export function advanceViewedPriorityHold(if (viewedSessionId) {const natural = naturalPriorityRankForId(viewedSessionId, ctx);const held = state.heldPriorityRanks.get(viewedSessionId);- state.heldPriorityRanks.set(- viewedSessionId,- held === undefined ? natural : Math.min(held, natural),- );+ state.heldPriorityRanks.set(viewedSessionId, viewedPriorityRank(natural, held));}state.prevViewedId = viewedSessionId;return state;@@ -95,7 +99,7 @@ export function holdViewedPriorityRank(): void {const natural = naturalPriorityRankForId(sessionId, ctx);const held = state.heldPriorityRanks.get(sessionId);- state.heldPriorityRanks.set(sessionId, held === undefined ? natural : Math.min(held, natural));+ state.heldPriorityRanks.set(sessionId, viewedPriorityRank(natural, held));}export function sessionPriorityRecencyMs(@@ -124,9 +128,9 @@ export function collectHomePriorityContext(for (const item of items) {// 各信号独立收集,不从互斥的 resolveMobileSessionRightStatus 反推:定时任务同时// 「完成未读」又「下一轮运行中」时,右侧展示状态会先返回 running 把 unread 吞掉,导致- // 排序落到 running 档而非「完成未读 > 运行中」。这里对齐桌面(attentionSessionIds /- // runningSessionIds 各自独立集合),让同一会话可同时进 unread 与 running,由- // liveTaskPriorityRank 的尺子(waiting > unread > running)裁决档位。+ // 排序丢失上一轮完成未读。这里对齐桌面(attentionSessionIds / runningSessionIds+ // 各自独立集合),让同一会话可同时进 unread 与 running,由共享尺子裁决:+ // 当前轮 running 压过旧 done 未读,但纯完成未读仍排在纯 running 前面。const liveAttention = item.liveActivity?.attention === true;const livePhase = item.liveActivity?.phase;const isError = liveAttention && livePhase === 'error';diff --git a/packages/maker-shared/src/__tests__/liveTaskPriority.test.ts b/packages/maker-shared/src/__tests__/liveTaskPriority.test.tsindex bee1e40c78..6b2d49737b 100644--- a/packages/maker-shared/src/__tests__/liveTaskPriority.test.ts+++ b/packages/maker-shared/src/__tests__/liveTaskPriority.test.ts@@ -8,6 +8,9 @@ describe('liveTaskPriorityRank', () => {LIVE_TASK_PRIORITY.waiting,);expect(liveTaskPriorityRank({ waiting: false, unread: true, running: true })).toBe(+ LIVE_TASK_PRIORITY.running,+ );+ expect(liveTaskPriorityRank({ waiting: false, unread: true, running: false })).toBe(LIVE_TASK_PRIORITY.unread,);expect(liveTaskPriorityRank({ waiting: false, unread: false, running: true })).toBe(diff --git a/packages/maker-shared/src/liveTaskPriority.ts b/packages/maker-shared/src/liveTaskPriority.tsindex f76eda535e..29fa2a7531 100644--- a/packages/maker-shared/src/liveTaskPriority.ts+++ b/packages/maker-shared/src/liveTaskPriority.ts@@ -2,6 +2,8 @@* 侧栏 / 首页「按优先级」与灵动岛活任务共用的档位。** waiting(等你处理,含出错) > unread(完成未读) > running > rest。+ * 同一任务同时有旧完成未读和当前轮 running 时按 running:当前轮状态优先,+ * 避免任务视觉上已经运行中、排序却仍占着上一轮 unread 档。* 数字越小越靠前,对齐 Codex 侧栏(waiting:0 / unread:1 / active:2 / idle:3)。** 灵动岛不展示 rest;它自己的短暂置顶 / 展开钉住顺序叠在这把尺子外面。@@ -24,7 +26,7 @@ export interface LiveTaskPrioritySignals {export function liveTaskPriorityRank(signals: LiveTaskPrioritySignals): LiveTaskPriorityRank {if (signals.waiting) return LIVE_TASK_PRIORITY.waiting;- if (signals.unread) return LIVE_TASK_PRIORITY.unread;+ if (signals.unread && !signals.running) return LIVE_TASK_PRIORITY.unread;if (signals.running) return LIVE_TASK_PRIORITY.running;return LIVE_TASK_PRIORITY.rest;}