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(memory): also drop a poll asked while the start was in flight
M3gA-Mind7bc62b2707da
diff --git a/app/src/components/memory/MemoryImportBanner.test.tsx b/app/src/components/memory/MemoryImportBanner.test.tsxindex e5c4ff14fb..d8e1f2a058 100644--- a/app/src/components/memory/MemoryImportBanner.test.tsx+++ b/app/src/components/memory/MemoryImportBanner.test.tsx@@ -460,6 +460,43 @@ describe('MemoryImportBanner', () => {expect(screen.queryByTestId('memory-migration-offer')).not.toBeInTheDocument();});+ it('drops a poll asked while the start was in flight', async () => {+ hoisted.mScan.mockResolvedValue({ needed: true, shared: false });+ vi.useFakeTimers({ shouldAdvanceTime: true });+ renderWithProviders(<MemoryImportBanner engineLabel="TinyHumans" />);+ expect(await screen.findByTestId('memory-migration-offer')).toBeInTheDocument();++ // The start is slow to answer.+ let answerStart: (value: unknown) => void = () => {};+ hoisted.mStart.mockReturnValueOnce(+ new Promise(resolve => {+ answerStart = resolve;+ })+ );+ fireEvent.click(screen.getByTestId('memory-migration-start'));+ // Meanwhile a poll reads the state from before the move began.+ let answerPoll: (value: unknown) => void = () => {};+ hoisted.mStatus.mockReturnValueOnce(+ new Promise(resolve => {+ answerPoll = resolve;+ })+ );+ await act(async () => {+ await vi.advanceTimersByTimeAsync(MIGRATION_IDLE_POLL_MS + 10);+ });+ await act(async () => {+ answerStart(moving(4));+ });+ expect(await screen.findByTestId('memory-migration-running')).toHaveTextContent('4');++ // That poll answers last; it must not bring the offer back.+ await act(async () => {+ answerPoll(MOVE_IDLE);+ });+ expect(screen.getByTestId('memory-migration-running')).toBeInTheDocument();+ expect(screen.queryByTestId('memory-migration-offer')).not.toBeInTheDocument();+ });+it('drops a poll that fails after the user started the move', async () => {hoisted.mScan.mockResolvedValue({ needed: true, shared: false });vi.useFakeTimers({ shouldAdvanceTime: true });diff --git a/app/src/components/memory/MemoryImportBanner.tsx b/app/src/components/memory/MemoryImportBanner.tsxindex 58ee96e5d0..65abfbad1f 100644--- a/app/src/components/memory/MemoryImportBanner.tsx+++ b/app/src/components/memory/MemoryImportBanner.tsx@@ -219,7 +219,11 @@ export default function MemoryImportBanner({ engineLabel }: MemoryImportBannerPrsetError(null);mStatusGen.current += 1;try {- const next = await memoryMigrationStart(takeover);+ // Bumped again when the start answers: a poll asked while it was in+ // flight may have read the state from before the move began.+ const next = await memoryMigrationStart(takeover).finally(() => {+ mStatusGen.current += 1;+ });mlog('start: takeover=%s phase=%s running=%s', takeover, next.state.phase, next.running);setMStatus(next);} catch (err) {@@ -239,7 +243,11 @@ export default function MemoryImportBanner({ engineLabel }: MemoryImportBannerPrmStatusGen.current += 1;try {await memoryMigrationRetry();- setMStatus(await memoryMigrationStart(false));+ setMStatus(+ await memoryMigrationStart(false).finally(() => {+ mStatusGen.current += 1;+ })+ );} catch (err) {mlog('retry failed: %o', err);setError(memoryErrorMessage(err, t));