Add remote controls input modal#130
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR adds a remote keyboard/gamepad control modal with platform-specific actions and screenshot capture, implements CoreAPI methods for keyboard/gamepad input and screenshot retrieval with connection checks and runtime validation, exposes a remoteInput feature gate, integrates the modal into ScanControls/Index, and adds styles, translations, and tests. ChangesRemote Keyboard Feature
Sequence DiagramsequenceDiagram
participant User
participant Modal as RemoteKeyboardModal
participant API as CoreAPI
participant Store as Zustand Store
User->>Modal: click remote/keyboard mode
Modal->>Modal: toggle mode
alt Remote mode
User->>Modal: click directional/action button
Modal->>Store: read connected status
alt connected
Modal->>API: inputKeyboard({key macro})
API-->>Modal: success
else disconnected
Modal->>Modal: show error toast
end
else Keyboard mode
User->>Modal: press key/macro/layout-switch
Modal->>Modal: compute key macro
alt layout-switch key
Modal->>Modal: change keyboard layout
else regular key
Modal->>API: inputKeyboard({key})
end
end
User->>Modal: click screenshot
Modal->>API: screenshot()
API-->>Modal: {path, data, size}
Modal->>Modal: display image + download link
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/components/wui/Segmented.tsx (1)
58-58: ⚡ Quick winUse
classnamesfor the conditional label class.Please switch this ternary class assignment to
classNames(...)for guideline consistency.Suggested patch
- <label className={labelHidden ? "sr-only" : "mb-1 block"}>{label}</label> + <label + className={classNames({ + "sr-only": labelHidden, + "mb-1 block": !labelHidden, + })} + > + {label} + </label>As per coding guidelines, "Use classnames for conditional Tailwind classes in components".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/wui/Segmented.tsx` at line 58, Replace the ternary class assignment on the label element in the Segmented component with the classnames helper: import classNames from "classnames" at the top of src/components/wui/Segmented.tsx and change the label's className to use classNames({ "sr-only": labelHidden }, "mb-1 block") (or equivalent ordering) so the conditional "sr-only" is applied when labelHidden is true and "mb-1 block" remains otherwise; update any existing imports to avoid duplicates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/__tests__/unit/components/home/ScanControls.test.tsx`:
- Around line 74-95: The test relies on store-driven feature availability
(useStatusStore) and can inherit state from other tests; reset the status store
state before this test by calling useStatusStore.setState({...}) in a beforeEach
(or at the start of this test's Arrange) to set the required default flags so
the remote keyboard feature is deterministic; update the test file to call
useStatusStore.setState with the appropriate baseline state prior to rendering
<ScanControls ... onRemoteKeyboard={onRemoteKeyboard}>.
In `@src/__tests__/unit/components/RemoteKeyboardModal.test.tsx`:
- Around line 51-54: The test setup's beforeEach currently calls
vi.clearAllMocks() and sets useStatusStore state but doesn't reset CoreAPI;
modify the beforeEach block in RemoteKeyboardModal.test.tsx to call
CoreAPI.reset() (ensure CoreAPI is exported from the module mock and included in
the test mock setup) so tests are isolated—keep the existing vi.clearAllMocks()
and useStatusStore.setState({ connected: true, corePlatform: null }) and add
CoreAPI.reset() alongside them.
In `@src/components/RemoteKeyboardModal.tsx`:
- Around line 233-237: The catch handlers in RemoteKeyboardModal (the .catch(()
=> { ... }) blocks around the remote keyboard send logic) currently only set UI
state and toast errors; update both catch blocks (the one at 233-237 and the one
at 267-271) to accept the error parameter (e.g., err), call
logger.error(message, err, { category: "remoteKeyboard", action: "send",
severity: "error" }) before calling setError(message) and toast.error(message),
and keep existing UI behaviors intact; ensure the logger import/instance used
matches the component (logger) and that the message variable is reused for the
log call.
---
Nitpick comments:
In `@src/components/wui/Segmented.tsx`:
- Line 58: Replace the ternary class assignment on the label element in the
Segmented component with the classnames helper: import classNames from
"classnames" at the top of src/components/wui/Segmented.tsx and change the
label's className to use classNames({ "sr-only": labelHidden }, "mb-1 block")
(or equivalent ordering) so the conditional "sr-only" is applied when
labelHidden is true and "mb-1 block" remains otherwise; update any existing
imports to avoid duplicates.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 03720cf6-04ba-4634-9592-c0b968f45bcd
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
package.jsonsrc/__tests__/unit/components/RemoteKeyboardModal.test.tsxsrc/__tests__/unit/components/home/ScanControls.test.tsxsrc/__tests__/unit/lib/coreApi.test.tssrc/components/RemoteKeyboardModal.tsxsrc/components/home/ScanControls.tsxsrc/components/wui/Segmented.tsxsrc/index.csssrc/lib/coreApi.tssrc/lib/featureGates.tssrc/lib/models.tssrc/routes/-pages/Index.tsxsrc/translations/en-US.json
…into feature/remote-controls-inputs
Summary
Verification
Summary by CodeRabbit
New Features
Tests
Documentation
Chores