Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: ignore stale Brain capture completions (#5427)

[._.]/ Adam Eivy5b63934214fc
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index 2a78fdc8a3..41f4f2f50e 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -382,7 +382,7 @@ export default function CmdKSearch() {
} else if (e.key === 'Escape') {
e.preventDefault();
e.stopPropagation();
- setCaptureMode(false);
+ resetCapture();
}
return;
}
diff --git a/client/src/components/CmdKSearch.test.jsx b/client/src/components/CmdKSearch.test.jsx
index fcb955e13a..a6e3a7657e 100644
--- a/client/src/components/CmdKSearch.test.jsx
+++ b/client/src/components/CmdKSearch.test.jsx
@@ -219,6 +219,25 @@ describe('CmdKSearch inline Brain capture', () => {
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
});
+ it('ignores a pending capture result after Escape returns to search', async () => {
+ let resolveCapture;
+ runPaletteAction.mockImplementation(() => new Promise((resolve) => { resolveCapture = resolve; }));
+ await renderBrainCapturePalette();
+ fireEvent.click(await screen.findByRole('option', { name: /Capture to Brain/ }));
+ const captureInput = screen.getByRole('textbox', { name: 'Capture to Brain' });
+ fireEvent.change(captureInput, { target: { value: 'Pending thought' } });
+ fireEvent.keyDown(captureInput, { key: 'Enter' });
+
+ fireEvent.keyDown(captureInput, { key: 'Escape' });
+ const searchInput = screen.getByRole('textbox', { name: 'Command palette' });
+ fireEvent.change(searchInput, { target: { value: 'keep searching' } });
+ await act(async () => { resolveCapture({ ok: true, result: { summary: 'Captured.' } }); });
+
+ expect(screen.getByRole('dialog', { name: 'Command palette' })).toBeInTheDocument();
+ expect(searchInput).toHaveValue('keep searching');
+ expect(toast.success).not.toHaveBeenCalled();
+ });
+
it('resets capture state when dismissed through the backdrop', async () => {
const dialog = await renderBrainCapturePalette();
fireEvent.click(await screen.findByRole('option', { name: /Capture to Brain/ }));