chore: update safe dependencies and fix cross-platform electron-dev script#328
chore: update safe dependencies and fix cross-platform electron-dev script#328AnshuPriya-1 wants to merge 1 commit into
Conversation
WalkthroughReplaces WebSocket signaling with an Express router exposing HTTP signaling and SSE endpoints; removes ydotool and a complex InputHandler class, replacing it with a simpler handleMessage function; and updates package.json scripts and dependencies (adds cross-env, bumps multiple packages). Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant SSEClients as "SSE Clients"
Client->>Server: POST /signal { type, sdp }
Server-->>Client: 200 OK
Client->>Server: GET /signal
Server-->>Client: { offer?, answer? }
Client->>Server: POST /ice { candidate }
Server->>SSEClients: broadcast candidate (SSE)
SSEClients-->>Server: connection close (unregister)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @imxade , Updated safe dependencies and verified that the app works correctly.
|
There was a problem hiding this comment.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
73-76:⚠️ Potential issue | 🟡 MinorStale reference to removed dependency in build config.
The
asarUnpackconfiguration still referencesnode_modules/@nut-tree-fork/**/*, but@nut-tree-fork/nut-jshas been removed from dependencies. This should be cleaned up.🧹 Proposed fix
"asarUnpack": [ - ".output/**/*", - "node_modules/@nut-tree-fork/**/*" + ".output/**/*" ],🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` around lines 73 - 76, The asarUnpack build config in package.json still includes a stale entry "node_modules/@nut-tree-fork/**/*" even though `@nut-tree-fork/nut-js` was removed; open package.json, locate the asarUnpack array (symbol: "asarUnpack") and remove the "node_modules/@nut-tree-fork/**/*" entry (or conditionally filter it out if you keep dynamic entries), then run a quick search for any other references to `@nut-tree-fork` to ensure all stale build/dependency references are cleaned up.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package.json`:
- Around line 25-26: Remove the duplicate "express" and "koffi" dependency
entries so only the intended versions remain (the v5 express entries that match
"@types/express@^5.0.6"); locate the two sets of keys named "express" and
"koffi" in package.json and delete the older/incorrect duplicates (the ones
overriding with "^4.18.2" and "^2.7.0"), leaving a single dependency entry for
each to avoid silent overrides and ensure dependency versions align with
`@types/express`.
In `@src/server/InputHandler.ts`:
- Around line 7-8: Replace the use of the any type in handleMessage by declaring
a concrete interface (e.g., InputMessage) that lists the expected properties
(type: string, x: number, y: number, button?: number | string, delta?: number,
etc. as applicable) and update the function signature to handleMessage(message:
InputMessage); adjust optionality/union types for button and delta to match
actual usage and update any callers if necessary so TypeScript checks the shape
instead of allowing any.
- Around line 1-5: The imports moveMouse, clickMouse, and scrollMouse in
InputHandler.ts reference an empty module (linux-uinput-driver.ts) which will
cause runtime failures—either implement and export these functions from
linux-uinput-driver.ts or point the imports to the correct module that provides
them (ensure exported signatures match usages in InputHandler). Also replace the
any-typed parameter message in the affected function with an explicit type:
define an interface (e.g., InputMessage) that lists expected fields and use that
type for the message parameter so the function signature is strongly typed and
conforms to TypeScript guidelines.
In `@src/server/websocket.ts`:
- Line 1: The current import brings Request and Response into the runtime;
change them to type-only imports so they are erased at runtime. Update the
import statement in websocket.ts to import express normally and import type {
Request, Response } from "express" (or use a single line with "import express,
type { Request, Response } from 'express'") so Request and Response are used
only as type annotations and not bundled into the runtime.
- Around line 48-50: The current iteration uses clients.forEach(...) which
violates the Biome lint rule and prevents early exits; replace the forEach with
a for...of loop over the clients iterable (e.g., for (const client of clients) {
client.write(`data: ${JSON.stringify(candidate)}\n\n`); }) so you can
return/break early if needed and satisfy the lint rule—update the block where
clients and candidate are used in websocket.ts accordingly.
- Around line 31-43: The SSE route handler router.get("/ice", (_req: Request,
res: Response) => { ... }) should explicitly flush headers and send an initial
SSE comment to keep the connection alive and traverse proxies: after setting the
response headers and pushing res into clients, call res.flushHeaders() (or
res.flush if using express/compat) and then write an initial comment line (e.g.,
a colon-prefixed comment) to the stream before returning; keep the existing
close handler that filters the clients array. This ensures headers are sent
immediately and an initial heartbeat is delivered to clients and intermediaries.
- Around line 5-6: Replace the implicit any on the signaling variables by
defining explicit interfaces for the signaling payload and using them for offer
and answer; create interfaces (e.g., OfferSignal and AnswerSignal or a shared
Signal type) that include the expected fields (sdp, type, ICE candidate fields,
and any metadata your signaling layer uses) and update the declarations of offer
and answer to use those types instead of any so the compiler enforces correct
structure when the variables are read/assigned in websocket.ts.
- Line 55: Restore the original named export createWsServer in websocket.ts
(re-export router if you want default) so existing callers still work, or update
vite.config.ts to import the new default router and adjust calls accordingly;
also fix the TypeScript violations by replacing the two implicit any
declarations with explicit types for those variables, change the .forEach usage
around the message/event handling to a for...of loop (or map/for loop) to
satisfy linting, and convert any pure type-only imports to use "import type" to
follow the import-type guideline.
---
Outside diff comments:
In `@package.json`:
- Around line 73-76: The asarUnpack build config in package.json still includes
a stale entry "node_modules/@nut-tree-fork/**/*" even though
`@nut-tree-fork/nut-js` was removed; open package.json, locate the asarUnpack
array (symbol: "asarUnpack") and remove the "node_modules/@nut-tree-fork/**/*"
entry (or conditionally filter it out if you keep dynamic entries), then run a
quick search for any other references to `@nut-tree-fork` to ensure all stale
build/dependency references are cleaned up.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: dc9d47d9-2465-4d2f-ae6d-6ee393a5e2ca
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
REIN_PoC.mdpackage.jsonsrc/server/InputHandler.tssrc/server/linux-uinput-driver.tssrc/server/websocket.tssrc/server/ydotool.ts
💤 Files with no reviewable changes (1)
- src/server/ydotool.ts
| "express": "^5.2.1", | ||
| "koffi": "^2.15.2", |
There was a problem hiding this comment.
Critical: Duplicate JSON keys cause undefined behavior.
Lines 34-35 duplicate the express and koffi keys already defined at lines 25-26. JSON parsers typically keep the last value, so express@^4.18.2 and koffi@^2.7.0 will silently override the intended versions. This conflicts with the @types/express@^5.0.6 types at line 46, which expect Express v5 APIs.
🐛 Proposed fix: Remove duplicate entries
"react-icons": "^5.6.0",
- "winston": "^3.19.0",
- "express": "^4.18.2",
- "koffi": "^2.7.0"
+ "winston": "^3.19.0"
},Also applies to: 34-35
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@package.json` around lines 25 - 26, Remove the duplicate "express" and
"koffi" dependency entries so only the intended versions remain (the v5 express
entries that match "@types/express@^5.0.6"); locate the two sets of keys named
"express" and "koffi" in package.json and delete the older/incorrect duplicates
(the ones overriding with "^4.18.2" and "^2.7.0"), leaving a single dependency
entry for each to avoid silent overrides and ensure dependency versions align
with `@types/express`.
| import { | ||
| moveMouse, | ||
| clickMouse, | ||
| scrollMouse, | ||
| } from "./linux-uinput-driver.ts"; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Verify linux-uinput-driver.ts content and exports
echo "=== File contents ==="
cat src/server/linux-uinput-driver.ts 2>/dev/null || echo "File not found"
echo ""
echo "=== Check for exported functions ==="
rg -n "export.*(moveMouse|clickMouse|scrollMouse)" src/server/Repository: AOSSIE-Org/Rein
Length of output: 118
🏁 Script executed:
#!/bin/bash
# Check file existence and details
echo "=== Checking if file exists ==="
ls -la src/server/linux-uinput-driver.ts 2>&1
echo ""
echo "=== File size and line count ==="
wc -l src/server/linux-uinput-driver.ts 2>&1
echo ""
echo "=== Hex dump to see if there's hidden content ==="
hexdump -C src/server/linux-uinput-driver.ts 2>&1 | head -20
echo ""
echo "=== Check InputHandler.ts for usage context ==="
cat -n src/server/InputHandler.ts 2>&1 | head -30Repository: AOSSIE-Org/Rein
Length of output: 1008
🏁 Script executed:
#!/bin/bash
# Search for these function definitions anywhere in src/server
echo "=== Search for function definitions ==="
rg -n "^\s*(export\s+)?(function|const)\s+(moveMouse|clickMouse|scrollMouse)" src/server/ 2>&1
echo ""
echo "=== List all files in src/server ==="
ls -la src/server/ 2>&1Repository: AOSSIE-Org/Rein
Length of output: 632
Critical: Imports from empty module will fail at runtime, and parameter lacks explicit type.
The file src/server/linux-uinput-driver.ts is empty and exports nothing. The imports of moveMouse, clickMouse, and scrollMouse on lines 1-5 will fail when these functions are invoked at runtime.
Additionally, the message parameter on line 7 uses any type instead of an explicit type as required by the TypeScript guidelines.
🧰 Tools
🪛 GitHub Actions: CI
[error] 1-1: Biome format check failed: File content differs from formatting output.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/InputHandler.ts` around lines 1 - 5, The imports moveMouse,
clickMouse, and scrollMouse in InputHandler.ts reference an empty module
(linux-uinput-driver.ts) which will cause runtime failures—either implement and
export these functions from linux-uinput-driver.ts or point the imports to the
correct module that provides them (ensure exported signatures match usages in
InputHandler). Also replace the any-typed parameter message in the affected
function with an explicit type: define an interface (e.g., InputMessage) that
lists expected fields and use that type for the message parameter so the
function signature is strongly typed and conforms to TypeScript guidelines.
| export function handleMessage(message: any) { | ||
| const { type, x, y, button, delta } = message; |
There was a problem hiding this comment.
Replace any with an explicit type.
Using any violates coding guidelines and disables type checking. Define an interface for the message structure.
🛡️ Proposed fix
+interface InputMessage {
+ type: string;
+ x?: number;
+ y?: number;
+ button?: number;
+ delta?: number;
+}
+
-export function handleMessage(message: any) {
+export function handleMessage(message: InputMessage) {
const { type, x, y, button, delta } = message;As per coding guidelines: "Avoid 'any', use explicit types".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function handleMessage(message: any) { | |
| const { type, x, y, button, delta } = message; | |
| interface InputMessage { | |
| type: string; | |
| x?: number; | |
| y?: number; | |
| button?: number; | |
| delta?: number; | |
| } | |
| export function handleMessage(message: InputMessage) { | |
| const { type, x, y, button, delta } = message; |
🧰 Tools
🪛 GitHub Actions: CI
[error] 7-7: Biome (lint/suspicious/noExplicitAny): Unexpected any. Specify a different type.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/InputHandler.ts` around lines 7 - 8, Replace the use of the any
type in handleMessage by declaring a concrete interface (e.g., InputMessage)
that lists the expected properties (type: string, x: number, y: number, button?:
number | string, delta?: number, etc. as applicable) and update the function
signature to handleMessage(message: InputMessage); adjust optionality/union
types for button and delta to match actual usage and update any callers if
necessary so TypeScript checks the shape instead of allowing any.
| import logger from "../utils/logger" | ||
| import { InputHandler, type InputMessage } from "./InputHandler" | ||
| import { getLocalIp } from "./getLocalIp" | ||
| import express, { Request, Response } from "express"; |
There was a problem hiding this comment.
Use import type for type-only imports.
Request and Response are only used as type annotations. Use import type to avoid including them in the runtime bundle.
♻️ Proposed fix
-import express, { Request, Response } from "express";
+import express from "express";
+import type { Request, Response } from "express";As per coding guidelines: "Prefer 'import type' for type imports".
🧰 Tools
🪛 GitHub Actions: Build Electron
[error] 1-1: Build failed: No matching export in "src/server/websocket.ts" for import "createWsServer" (imported in vite.config.ts).
🪛 GitHub Actions: CI
[error] 1-1: Biome (lint/style/useImportType): Some named imports are only used as types.
[error] 1-1: Biome format check failed: File content differs from formatting output.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/websocket.ts` at line 1, The current import brings Request and
Response into the runtime; change them to type-only imports so they are erased
at runtime. Update the import statement in websocket.ts to import express
normally and import type { Request, Response } from "express" (or use a single
line with "import express, type { Request, Response } from 'express'") so
Request and Response are used only as type annotations and not bundled into the
runtime.
| let offer: any = null; | ||
| let answer: any = null; |
There was a problem hiding this comment.
Replace any with explicit signaling types.
Using any disables type safety. Define interfaces for the signaling data.
🛡️ Proposed fix
+interface SignalData {
+ type: "offer" | "answer";
+ sdp: string;
+}
+
-let offer: any = null;
-let answer: any = null;
+let offer: SignalData | null = null;
+let answer: SignalData | null = null;As per coding guidelines: "Avoid 'any', use explicit types".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let offer: any = null; | |
| let answer: any = null; | |
| interface SignalData { | |
| type: "offer" | "answer"; | |
| sdp: string; | |
| } | |
| let offer: SignalData | null = null; | |
| let answer: SignalData | null = null; |
🧰 Tools
🪛 GitHub Actions: CI
[error] 5-5: Biome (lint/suspicious/noExplicitAny): Unexpected any. Specify a different type.
[error] 6-6: Biome (lint/suspicious/noExplicitAny): Unexpected any. Specify a different type.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/websocket.ts` around lines 5 - 6, Replace the implicit any on the
signaling variables by defining explicit interfaces for the signaling payload
and using them for offer and answer; create interfaces (e.g., OfferSignal and
AnswerSignal or a shared Signal type) that include the expected fields (sdp,
type, ICE candidate fields, and any metadata your signaling layer uses) and
update the declarations of offer and answer to use those types instead of any so
the compiler enforces correct structure when the variables are read/assigned in
websocket.ts.
| router.get("/ice", (_req: Request, res: Response) => { | ||
| res.set({ | ||
| "Content-Type": "text/event-stream", | ||
| "Cache-Control": "no-cache", | ||
| Connection: "keep-alive", | ||
| }); | ||
|
|
||
| if (url.pathname !== "/ws") return | ||
| clients.push(res); | ||
|
|
||
| const token = url.searchParams.get("token") | ||
| const local = isLocalhost(request) | ||
| res.on("close", () => { | ||
| clients = clients.filter((c) => c !== res); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
SSE endpoint lacks flush and initial response.
Some clients require an explicit flush after setting headers, and sending an initial comment helps keep the connection alive through proxies.
✨ Suggested improvement
router.get("/ice", (_req: Request, res: Response) => {
res.set({
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
Connection: "keep-alive",
});
+ res.flushHeaders();
+ res.write(": connected\n\n"); // Keep-alive comment for proxies
clients.push(res);
res.on("close", () => {
clients = clients.filter((c) => c !== res);
});
});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/websocket.ts` around lines 31 - 43, The SSE route handler
router.get("/ice", (_req: Request, res: Response) => { ... }) should explicitly
flush headers and send an initial SSE comment to keep the connection alive and
traverse proxies: after setting the response headers and pushing res into
clients, call res.flushHeaders() (or res.flush if using express/compat) and then
write an initial comment line (e.g., a colon-prefixed comment) to the stream
before returning; keep the existing close handler that filters the clients
array. This ensures headers are sent immediately and an initial heartbeat is
delivered to clients and intermediaries.
| clients.forEach((client) => { | ||
| client.write(`data: ${JSON.stringify(candidate)}\n\n`); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Use for...of instead of forEach.
Per Biome lint rules, prefer for...of for better readability and early-exit capability.
♻️ Proposed fix
- clients.forEach((client) => {
- client.write(`data: ${JSON.stringify(candidate)}\n\n`);
- });
+ for (const client of clients) {
+ client.write(`data: ${JSON.stringify(candidate)}\n\n`);
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| clients.forEach((client) => { | |
| client.write(`data: ${JSON.stringify(candidate)}\n\n`); | |
| }); | |
| for (const client of clients) { | |
| client.write(`data: ${JSON.stringify(candidate)}\n\n`); | |
| } |
🧰 Tools
🪛 GitHub Actions: CI
[error] 48-48: Biome (lint/complexity/noForEach): Prefer for...of instead of forEach.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/websocket.ts` around lines 48 - 50, The current iteration uses
clients.forEach(...) which violates the Biome lint rule and prevents early
exits; replace the forEach with a for...of loop over the clients iterable (e.g.,
for (const client of clients) { client.write(`data:
${JSON.stringify(candidate)}\n\n`); }) so you can return/break early if needed
and satisfy the lint rule—update the block where clients and candidate are used
in websocket.ts accordingly.
| }, | ||
| ) | ||
| } | ||
| export default router; No newline at end of file |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check all usages of createWsServer in the codebase
echo "=== Files importing createWsServer ==="
rg -n "createWsServer" --type ts
echo ""
echo "=== Current websocket.ts exports ==="
rg -n "^export" src/server/websocket.tsRepository: AOSSIE-Org/Rein
Length of output: 344
🏁 Script executed:
#!/bin/bash
# Read the full websocket.ts file to understand the context
wc -l src/server/websocket.ts
echo "---"
cat -n src/server/websocket.tsRepository: AOSSIE-Org/Rein
Length of output: 1668
🏁 Script executed:
#!/bin/bash
# Verify that vite.config.ts will actually fail with current exports
head -35 vite.config.ts | cat -nRepository: AOSSIE-Org/Rein
Length of output: 1324
Critical: Breaking change breaks the build.
Changing from a named export createWsServer to a default export router breaks vite.config.ts, which still imports createWsServer (line 9) and calls it at lines 24 and 29. The import will fail.
Either restore the named export or update vite.config.ts to use the new router-based approach.
Additionally, address the TypeScript violations: any types at lines 5–6, forEach at line 48, and ensure proper import statements follow the import type guideline.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/server/websocket.ts` at line 55, Restore the original named export
createWsServer in websocket.ts (re-export router if you want default) so
existing callers still work, or update vite.config.ts to import the new default
router and adjust calls accordingly; also fix the TypeScript violations by
replacing the two implicit any declarations with explicit types for those
variables, change the .forEach usage around the message/event handling to a
for...of loop (or map/for loop) to satisfy linting, and convert any pure
type-only imports to use "import type" to follow the import-type guideline.
f88c3a8 to
205bf2e
Compare
Addressed Issues:
Fixes #327
Description
Updated dependencies that bring improvements while ensuring no breaking changes.
Updated Dependencies
Vite 8 Evaluation
Attempted upgrading to Vite 8 but found compatibility issues with:
To avoid breaking functionality, Vite remains on v7.
Additional Fix
Fixed electron-dev script for cross-platform compatibility using cross-env
Testing
Verified:
npm run devnpm run buildnpm run electron-devAll working successfully.
Checklist
My PR addresses a single issue, fixes a single bug or makes a single improvement.
My code follows the project's code style and conventions
I have performed a self-review of my own code
My changes generate no new warnings or errors
Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
Summary by CodeRabbit
Chores
Refactor