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: handle superseded thread clears and init dialog states
Steven Enamakel1e7aa0e1f9cc
diff --git a/app/src/store/__tests__/threadSlice.test.ts b/app/src/store/__tests__/threadSlice.test.tsindex 4e92ac25d0..baa65175e6 100644--- a/app/src/store/__tests__/threadSlice.test.ts+++ b/app/src/store/__tests__/threadSlice.test.ts@@ -212,6 +212,22 @@ describe('threadSlice loadThreads thunk', () => {vi.clearAllMocks();});+ it('does not restore threads from a load superseded by clearing all threads', async () => {+ const store = createStore();+ let resolveThreads!: (value: { threads: Thread[]; count: number }) => void;+ mockedThreadApi.getThreads.mockImplementationOnce(+ () => new Promise(resolve => (resolveThreads = resolve))+ );++ const request = store.dispatch(loadThreads());+ store.dispatch(clearAllThreads());+ resolveThreads({ threads: [makeThread({ id: 'stale' })], count: 1 });+ await request;++ expect(store.getState().thread.threads).toEqual([]);+ expect(store.getState().thread.selectedThreadId).toBeNull();+ });+it('sets isLoadingThreads while pending and stores threads on fulfilled', async () => {const store = createStore();const payload = { threads: [makeThread({ id: 'a' })], count: 1 };diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.tsindex 9028fd4fa8..fbd319df9d 100644--- a/app/src/store/threadSlice.ts+++ b/app/src/store/threadSlice.ts@@ -614,9 +614,13 @@ const threadSlice = createSlice({.addCase(loadThreads.fulfilled, (state, action) => {state.isLoadingThreads = false;const liveThreadIds = new Set(action.payload.threads.map(thread => thread.id));+ const currentIntentVersion = state.selectionIntentVersion ?? 0;const selectionWasSuperseded =- state.selectionIntentVersion !==- (action.payload.selectionIntentVersionAtRequest ?? state.selectionIntentVersion);+ currentIntentVersion !==+ (action.payload.selectionIntentVersionAtRequest ?? currentIntentVersion);+ if (selectionWasSuperseded && !state.selectedThreadId && state.threads.length === 0) {+ return;+ }const supersedingThread =selectionWasSuperseded &&state.selectedThreadId &&diff --git a/app/test/playwright/helpers/core-rpc.ts b/app/test/playwright/helpers/core-rpc.tsindex 9a78439bed..b18c84111c 100644--- a/app/test/playwright/helpers/core-rpc.ts+++ b/app/test/playwright/helpers/core-rpc.ts@@ -268,6 +268,7 @@ export async function waitForAppReady(page: Page): Promise<void> {}};const init = await readInitStatus();+ if (init?.overall === 'done' || init?.overall === 'idle') return;if (init?.overall === 'running' || init?.overall === 'failed') {const alreadyDismissed = await page.evaluate(startedAt =>@@ -275,22 +276,41 @@ export async function waitForAppReady(page: Page): Promise<void> {init.started_at);if (alreadyDismissed) return;+ }- const continueButton = page.getByTestId(/harness-init-(?:background|continue-anyway)/);- await expect- .poll(- async () => {- if (await continueButton.isVisible().catch(() => false)) return true;- const current = await readInitStatus();- return current?.overall === 'done' || current?.overall === 'idle' || current === null;- },- { timeout: 10_000 }- )- .toBe(true);- if (await continueButton.isVisible().catch(() => false)) {- await continueButton.click();- await expect(page.getByTestId('harness-init-dialog')).toBeHidden({ timeout: 5_000 });- }+ const dialog = page.getByTestId('harness-init-dialog');+ const backgroundButton = page.getByTestId('harness-init-background');+ const continueButton = page.getByTestId('harness-init-continue-anyway');+ const action: { value: 'background' | 'continue' | 'terminal' } = { value: 'terminal' };+ await expect+ .poll(+ async () => {+ if (await continueButton.isVisible().catch(() => false)) {+ action.value = 'continue';+ return true;+ }+ if (await backgroundButton.isVisible().catch(() => false)) {+ action.value = 'background';+ return true;+ }+ const current = await readInitStatus();+ if (current?.overall === 'done' || current?.overall === 'idle') {+ action.value = 'terminal';+ return true;+ }+ if (current === null && !(await dialog.isVisible().catch(() => false))) {+ action.value = 'terminal';+ return true;+ }+ return false;+ },+ { timeout: 10_000 }+ )+ .toBe(true);+ if (action.value === 'background' || action.value === 'continue') {+ const button = action.value === 'background' ? backgroundButton : continueButton;+ await button.click();+ await expect(dialog).toBeHidden({ timeout: 5_000 });}}