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: retain focus during pending Brain capture (#5427)

[._.]/ Adam Eivy304456b8264a
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index 21c09abb79..2a78fdc8a3 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -305,6 +305,7 @@ export default function CmdKSearch() {
if (!text || captureSubmittingRef.current) return;
captureSubmittingRef.current = true;
+ inputRef.current?.focus();
setCaptureSubmitting(true);
const attempt = ++captureAttemptRef.current;
const res = await runPaletteAction('brain_capture', { text }).then(
diff --git a/client/src/components/CmdKSearch.test.jsx b/client/src/components/CmdKSearch.test.jsx
index dc3b792b76..fcb955e13a 100644
--- a/client/src/components/CmdKSearch.test.jsx
+++ b/client/src/components/CmdKSearch.test.jsx
@@ -163,6 +163,23 @@ describe('CmdKSearch inline Brain capture', () => {
await act(async () => { resolveCapture({ ok: true, result: { summary: 'Captured.' } }); });
});
+ it('keeps focus inside the dialog during a pending mouse submission', async () => {
+ let resolveCapture;
+ runPaletteAction.mockImplementation(() => new Promise((resolve) => { resolveCapture = resolve; }));
+ await renderBrainCapturePalette();
+ fireEvent.click(await screen.findByRole('option', { name: /Capture to Brain/ }));
+ const input = screen.getByRole('textbox', { name: 'Capture to Brain' });
+ fireEvent.change(input, { target: { value: 'Mouse thought' } });
+ const button = screen.getByRole('button', { name: 'Capture thought' });
+ button.focus();
+
+ fireEvent.click(button);
+
+ expect(input).toHaveFocus();
+ expect(input).toHaveAttribute('readonly');
+ await act(async () => { resolveCapture({ ok: true, result: { summary: 'Captured.' } }); });
+ });
+
it('keeps the full draft open after a failed request without a second error toast', async () => {
runPaletteAction.mockRejectedValue(new Error('Capture failed'));
await renderBrainCapturePalette();