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): arm the watchdog for a prefill turn with no iteration yet
M3gA-Mindc711011e058e
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsxindex 4a9dec063c..85a6ade8fd 100644--- a/app/src/features/conversations/Conversations.tsx+++ b/app/src/features/conversations/Conversations.tsx@@ -908,8 +908,25 @@ const Conversations = ({// A local send already armed one. Never replace it: re-arming here would// hand the turn a fresh 120s every time this effect re-ran.if (sendingTimeoutsRef.current.has(selectedThreadId)) return;- if (!inferenceStatusByThread[selectedThreadId]) return;- if (inferenceTurnLifecycleByThread[selectedThreadId] === 'interrupted') return;+ const lifecycle = inferenceTurnLifecycleByThread[selectedThreadId];+ if (lifecycle === 'interrupted') return;+ // `inferenceStatusByThread` alone is not a complete in-flight test. The+ // hydration reducer only writes it when `iteration > 0 && maxIterations > 0`+ // and deletes it otherwise, so a snapshot that is genuinely running but has+ // not reported its first iteration yet — initial prefill — hydrates with no+ // status entry at all. Keying solely on it would leave exactly that turn+ // without a watchdog, which is the case this effect exists to cover.+ //+ // The lifecycle is written for every non-`completed` snapshot regardless of+ // iteration, so it still identifies a prefill turn. `completed` is not a+ // member of `InferenceTurnLifecycle` (the reducer deletes the key rather+ // than storing a terminal value), so a settled turn leaves both undefined+ // and is correctly skipped.+ const inFlight =+ Boolean(inferenceStatusByThread[selectedThreadId]) ||+ lifecycle === 'started' ||+ lifecycle === 'streaming';+ if (!inFlight) return;debug(`inherited in-flight turn on ${selectedThreadId} — arming silence timer`);armSilenceTimer(selectedThreadId);// `armSilenceTimer` reads only refs and `dispatch`, so it is stable enoughdiff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsxindex 9bea508571..efc5fad494 100644--- a/app/src/pages/__tests__/Conversations.render.test.tsx+++ b/app/src/pages/__tests__/Conversations.render.test.tsx@@ -1551,6 +1551,44 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {}});+ it('arms the silence timer for a prefill turn that has no iteration yet', async () => {+ // The hydration reducer writes `inferenceStatusByThread` only when+ // `iteration > 0 && maxIterations > 0` and deletes it otherwise, so a turn+ // that is genuinely running but has not reported its first iteration —+ // initial prefill — hydrates with no status entry. Keying the arming+ // decision on that entry alone left exactly this turn unwatched. The+ // lifecycle is written regardless of iteration, so it still identifies it.+ vi.useFakeTimers({ shouldAdvanceTime: true });+ vi.mocked(threadApi.getTurnState).mockResolvedValue({+ ...inFlightSnapshot('started'),+ iteration: 0,+ maxIterations: 0,+ });+ try {+ const { store } = await renderSelectedConversation();++ // Precondition that makes this test meaningful: hydration produced a live+ // lifecycle but NO status entry. If this ever flips, the test is no+ // longer covering the prefill gap it was written for.+ await waitFor(() => {+ expect(+ store?.getState().chatRuntime.inferenceTurnLifecycleByThread['send-thread']+ ).toBe('started');+ });+ expect(store?.getState().chatRuntime.inferenceStatusByThread['send-thread']).toBeUndefined();++ await act(async () => {+ await vi.advanceTimersByTimeAsync(120_000);+ });++ const banner = await screen.findByTestId('chat-send-error');+ expect(banner).toHaveAttribute('data-chat-send-error-code', 'safety_timeout');+ } finally {+ vi.mocked(threadApi.getTurnState).mockResolvedValue(null);+ vi.useRealTimers();+ }+ });+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