fix(meshcore): keep focus on the CLI command line after sending (#3752)#3761
Conversation
The command input is disabled while a command is in flight, which drops keyboard focus and doesn't restore it when the input re-enables — so an operator had to click back into the field before every command. Capture the input ref and refocus it once the send completes (guarded by a flag so it doesn't grab focus on mount or unrelated transitions). Routed through runAndLog, so it covers the form Send, quick-action buttons, and the danger-confirm path, for both the Remote and Local MeshCore consoles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJPe6J5vKrcbwzt6vCdtrt
|
Claude finished @Yeraze's task —— View job PR Review: fix(meshcore): keep focus on the CLI command line after sendingTasks:
SummaryThis is a clean, well-scoped fix. The approach is idiomatic React and the implementation is correct. Here's a detailed breakdown: Code Quality
One minor observation: The Test Coverage
Coverage gaps (optional, non-blocking):
PerformanceNo concerns. Using SecurityNo concerns. VerdictLGTM. The fix is minimal, correct, and well-tested for the primary regression path. The edge case around |
Summary
Fixes #3752. In the MeshCore Remote Administration console, sending a command moved keyboard focus off the "Type a command…" input, forcing the operator to click back into the field before every command (and risking an accidental navigation that drops the admin session).
Cause: the command input is
disabledwhile a command is in flight, which blurs it; focus wasn't restored when the input re-enabled.Fix: capture the input via a ref and refocus it once the send completes. A small flag set at the start of
runAndLog(and cleared in the effect) ensures we only refocus after an actual send — not on mount or on unrelatedsending/disabledtransitions.Because the change lives in the shared
CliConsoleBodyprimitive and routes through the singlerunAndLogchoke point, it covers:for both the Remote and Local MeshCore consoles.
Tests
CliConsoleBody.test.tsx— after a command is sent, asserts focus returns to the input and the field is cleared, ready for the next command.Closes #3752
🤖 Generated with Claude Code