The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): clear silence timers when Conversations unmounts
M3gA-Mind3147faa4d39a
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsxindex b717ac87db..4a9dec063c 100644--- a/app/src/features/conversations/Conversations.tsx+++ b/app/src/features/conversations/Conversations.tsx@@ -858,6 +858,25 @@ const Conversations = ({sendingTimeoutsRef.current.set(threadId, timeout);};+ // Drop every silence timer this component owns when it unmounts.+ //+ // The timer's callback is not inert after teardown: it dispatches+ // `clearRuntimeForThread` and `clearThreadInferenceActive`, which mutate+ // shared store state that outlives this component. Left armed, a timer from+ // a thread the user has navigated away from can wipe the runtime of a turn+ // that is still legitimately in flight, up to 120s later.+ //+ // Deliberately `[]` — unmount only. Keying this on `selectedThreadId` would+ // clear the timer every time the user switched threads, which is exactly the+ // watchdog this PR exists to arm.+ useEffect(() => {+ const timers = sendingTimeoutsRef.current;+ return () => {+ for (const timeout of timers.values()) clearTimeout(timeout);+ timers.clear();+ };+ }, []);+// A turn this client did not start still needs the 120s watchdog.//// `armSilenceTimer` is only called on the local send path, so a client thatdiff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsxindex 36d7235640..9bea508571 100644--- a/app/src/pages/__tests__/Conversations.render.test.tsx+++ b/app/src/pages/__tests__/Conversations.render.test.tsx@@ -8,7 +8,7 @@* previously-blocked lines that are now always rendered.*/import { combineReducers, configureStore } from '@reduxjs/toolkit';-import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';import { Provider } from 'react-redux';import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';import { beforeEach, describe, expect, it, vi } from 'vitest';@@ -1551,6 +1551,37 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {}});+ it('does not fire an armed silence timer after the page unmounts', async () => {+ // The timer's callback outlives this component: it dispatches+ // `clearRuntimeForThread` / `clearThreadInferenceActive` into the shared+ // store. Left armed past teardown it would wipe the runtime of a turn that+ // is still in flight, up to 120s after the user navigated away.+ vi.useFakeTimers({ shouldAdvanceTime: true });+ vi.mocked(threadApi.getTurnState).mockResolvedValue(inFlightSnapshot());+ try {+ const { store } = await renderSelectedConversation();++ // Prove a timer was actually armed, so this cannot pass by unmounting a+ // page that never had one.+ await waitFor(() => {+ expect(store?.getState().chatRuntime.inferenceStatusByThread['send-thread']).toBeDefined();+ });++ await act(async () => {+ cleanup();+ });+ await act(async () => {+ await vi.advanceTimersByTimeAsync(120_000);+ });++ // Still present: the cleanup cleared the timer, so nothing dispatched.+ expect(store?.getState().chatRuntime.inferenceStatusByThread['send-thread']).toBeDefined();+ } finally {+ vi.mocked(threadApi.getTurnState).mockResolvedValue(null);+ vi.useRealTimers();+ }+ });+it('rearms the silence timer on sub-agent tool-timeline updates', async () => {// Regression: when a delegated sub-agent (`Research`, `Tools Agent`,// …) is running, the parent thread's `inferenceStatusByThread` and