Skip to content

fix: Windows ARM64 version#29

Merged
Jason2866 merged 14 commits into
mainfrom
win_bullshit
Apr 16, 2026
Merged

fix: Windows ARM64 version#29
Jason2866 merged 14 commits into
mainfrom
win_bullshit

Conversation

@Jason2866
Copy link
Copy Markdown
Owner

@Jason2866 Jason2866 commented Apr 15, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed port opening failures on Windows ARM64 systems that prevented serial connection establishment.
  • Improvements

    • Improved error handling and logging for serial connections, with enhanced output channel reporting and better error message communication to help users troubleshoot issues effectively.
  • Chores

    • Version bump to 0.20.1.
    • Removed outdated ESP8266 keyword reference.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@Jason2866 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85dcad93-3f2b-4504-bcee-4e1aaf7aa038

📥 Commits

Reviewing files that changed from the base of the PR and between f5dab6b and 92a9225.

📒 Files selected for processing (1)
  • src/serialPortManager.ts
📝 Walkthrough

Walkthrough

This PR bumps the extension version to 0.20.1 and adds comprehensive serial communication logging. It introduces OutputChannel support to SerialPortManager, enhances error handling with improved event propagation, adds connection/error logging to WebviewPanel, and updates package.json with a patched serialport bindings fork to fix Windows ARM64 issues.

Changes

Cohort / File(s) Summary
Package Configuration
package.json, CHANGELOG.md
Version bumped to 0.20.1, dependency override added for @serialport/bindings-cpp to use patched fork for Windows ARM64 support, and changelog entries documented for 0.20.1 and 0.20.0.
Serial Port Manager Enhancement
src/serialPortManager.ts
Constructor now accepts optional OutputChannel for logging. Enhanced connect() with detailed logging and hupcl: false option. Improved error/close handlers with explicit state updates. Data event listener now attached after port.open() succeeds. Disconnect now explicitly updates connection state on close failure.
Logging & Integration
src/webviewPanel.ts, src/extension.ts
WebviewPanel wired to log serial errors and connection state changes. Extension activation now passes outputChannel to SerialPortManager constructor, enabling shared logging infrastructure.
Type Safety Improvements
src/crashDecoder.ts
Enhanced type safety by replacing unknown/any casts with proper DecodeParams and TrbrTarget types, improving type checking in decoder parameter construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Whiskers twitch with logging cheer,
Serial secrets crystal clear,
ARM64 dreams now come alive,
Error handlers help logs thrive! 📻✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: Windows ARM64 version' directly matches the main change documented in the PR—a fix for Windows ARM64 where the port could not be opened by switching to a patched serialport/bindings-cpp fork.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch win_bullshit

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
fork-template/README.md (1)

52-58: Version in example doesn't match actual usage.

The example shows ^13.0.0, but the actual package.json in the repository root uses ^13.0.2. Update this example to match for consistency:

 {
   "overrides": {
-    "@serialport/bindings-cpp": "npm:`@jason2866/serialport-bindings-cpp`@^13.0.0"
+    "@serialport/bindings-cpp": "npm:`@jason2866/serialport-bindings-cpp`@^13.0.2"
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fork-template/README.md` around lines 52 - 58, The version shown in the
README JSON example is inconsistent with package.json: update the override value
for "@serialport/bindings-cpp" from "^13.0.0" to "^13.0.2" in the README's JSON
example so it matches the repository's actual dependency version; locate the
JSON code block in README.md that contains "overrides" and change the version
string accordingly.
package.json (1)

203-205: Update documentation example to match the override version.

The forked package exists and version 13.0.2 is available on npm. However, there's a documentation inconsistency:

  • The override uses ^13.0.2
  • The example in fork-template/README.md shows ^13.0.0

Update the README example to reference ^13.0.2 for consistency with the actual version pinned in package.json.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 203 - 205, Update the example in
fork-template/README.md so the documented override version matches package.json:
change the referenced override for `@serialport/bindings-cpp` from ^13.0.0 to
^13.0.2 to reflect the actual pinned override ("@serialport/bindings-cpp":
"npm:`@jason2866/serialport-bindings-cpp`@^13.0.2") and keep docs consistent with
package.json.
src/webviewPanel.ts (1)

74-79: Also surface serial errors in the monitor UI, not only output channel.

Right now errors are appended to the output channel only. Posting a webview error message here would keep user-visible feedback consistent with other failure paths.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/webviewPanel.ts` around lines 74 - 79, The serial error handler currently
only writes to the output channel via this.log.appendLine inside the
this.serialManager.onError callback; update that handler to also send an error
notification to the monitor webview so the UI shows the failure. Locate the
onError subscription (this.serialManager.onError) and add a webview message post
(e.g., this.panel.webview.postMessage or this.webview.postMessage depending on
the class field used) sending a payload like { type: 'error', message:
err.message } alongside the existing this.log.appendLine call so both the output
channel and the webview receive the error.
src/serialPortManager.ts (1)

113-127: Prefer extension output-channel logging over raw console.log in connect path.

These logs bypass the extension’s existing output-channel trail and can become noisy in production. Consider routing through a shared logger/output channel (or a debug flag) for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/serialPortManager.ts` around lines 113 - 127, The connect() method
currently uses raw console.log calls (e.g., inside connect(), around
this._isConnected, this._selectedPath, this._baudRate and when no port is
selected) which bypass the extension’s output channel; replace those console.log
calls with the shared extension logger/output-channel API (or gate them behind a
debug flag) so logs flow through the extension’s output trail — update messages
in connect(), the selected-port branch (where selectPort() is called), and
before/after await this.disconnect() to call the shared logger (preserving the
same content) and ensure any async/error paths still return the same boolean
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/serialPortManager.ts`:
- Around line 151-157: The 'close' handler currently always calls
this._onConnectionChange.fire(false), causing duplicate disconnect events
because disconnect() also emits false; modify the close handler to only fire the
connection change when the connection state actually transitions (e.g., check
this._isConnected or a similar flag before calling
this._onConnectionChange.fire(false)), or remove the emission from the 'close'
handler and let disconnect() be the single place that emits; update the logic
around this.port.on('close', ...) and the disconnect() method to ensure
_onConnectionChange.fire(false) is emitted exactly once per disconnect and that
this._isConnected is set consistently.

---

Nitpick comments:
In `@fork-template/README.md`:
- Around line 52-58: The version shown in the README JSON example is
inconsistent with package.json: update the override value for
"@serialport/bindings-cpp" from "^13.0.0" to "^13.0.2" in the README's JSON
example so it matches the repository's actual dependency version; locate the
JSON code block in README.md that contains "overrides" and change the version
string accordingly.

In `@package.json`:
- Around line 203-205: Update the example in fork-template/README.md so the
documented override version matches package.json: change the referenced override
for `@serialport/bindings-cpp` from ^13.0.0 to ^13.0.2 to reflect the actual
pinned override ("@serialport/bindings-cpp":
"npm:`@jason2866/serialport-bindings-cpp`@^13.0.2") and keep docs consistent with
package.json.

In `@src/serialPortManager.ts`:
- Around line 113-127: The connect() method currently uses raw console.log calls
(e.g., inside connect(), around this._isConnected, this._selectedPath,
this._baudRate and when no port is selected) which bypass the extension’s output
channel; replace those console.log calls with the shared extension
logger/output-channel API (or gate them behind a debug flag) so logs flow
through the extension’s output trail — update messages in connect(), the
selected-port branch (where selectPort() is called), and before/after await
this.disconnect() to call the shared logger (preserving the same content) and
ensure any async/error paths still return the same boolean behavior.

In `@src/webviewPanel.ts`:
- Around line 74-79: The serial error handler currently only writes to the
output channel via this.log.appendLine inside the this.serialManager.onError
callback; update that handler to also send an error notification to the monitor
webview so the UI shows the failure. Locate the onError subscription
(this.serialManager.onError) and add a webview message post (e.g.,
this.panel.webview.postMessage or this.webview.postMessage depending on the
class field used) sending a payload like { type: 'error', message: err.message }
alongside the existing this.log.appendLine call so both the output channel and
the webview receive the error.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03a598bc-fa27-41c0-9a78-b7d9ba1a2ca6

📥 Commits

Reviewing files that changed from the base of the PR and between 069d242 and 25fa507.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .vscodeignore
  • fork-template/.github/workflows/prebuild.yml
  • fork-template/README.md
  • package.json
  • src/serialPortManager.ts
  • src/webviewPanel.ts

Comment thread src/serialPortManager.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/serialPortManager.ts (1)

153-160: ⚠️ Potential issue | 🟡 Minor

Clear this.port in the close handler to avoid stale closed handles.

On Line 153, the close path updates _isConnected but keeps this.port non-null. For unexpected closes (e.g., device removal), this leaves stale state until a later reconnect.

♻️ Proposed fix
       this.port.on('close', (disconnectError?: Error | null) => {
         if (disconnectError) {
           this._onError.fire(disconnectError);
         }
-        if (this._isConnected) {
-          this._isConnected = false;
-          this._onConnectionChange.fire(false);
-        }
+        const wasConnected = this._isConnected;
+        this._isConnected = false;
+        this.port = null;
+        if (wasConnected) {
+          this._onConnectionChange.fire(false);
+        }
       });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/serialPortManager.ts` around lines 153 - 160, The close handler currently
sets _isConnected and fires _onConnectionChange/_onError but leaves this.port
referencing the closed SerialPort; modify the close callback on this.port to
clear the stale handle (set this.port = null) and remove/cleanup any listeners
so the manager no longer holds a closed port reference. Ensure you do this
inside the existing this.port.on('close', ...) block alongside setting
this._isConnected = false and firing _onConnectionChange, referencing this.port,
_isConnected, _onConnectionChange, and _onError.
🧹 Nitpick comments (1)
src/serialPortManager.ts (1)

33-35: Track OutputChannel ownership for proper disposal.

If no channel is injected (Line 35), this class creates one but never disposes it in dispose().

♻️ Proposed refactor
 export class SerialPortManager extends vscode.Disposable {
   private port: SerialPort | null = null;
@@
   private readonly log: vscode.OutputChannel;
+  private readonly ownsLog: boolean;
@@
   constructor(outputChannel?: vscode.OutputChannel) {
     super(() => this.dispose());
-    this.log = outputChannel || vscode.window.createOutputChannel('ESP Decoder');
+    this.ownsLog = !outputChannel;
+    this.log = outputChannel || vscode.window.createOutputChannel('ESP Decoder');
@@
   dispose(): void {
@@
     this._onData.dispose();
     this._onError.dispose();
     this._onConnectionChange.dispose();
+    if (this.ownsLog) {
+      this.log.dispose();
+    }
   }
 }

Also applies to: 272-279

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/serialPortManager.ts` around lines 33 - 35, The class creates an
OutputChannel in the constructor when none is injected but never disposes it;
add an ownership flag (e.g., createdOutputChannel or ownsOutputChannel) set true
when you call vscode.window.createOutputChannel in the constructor(s) and false
when an external channel is provided, then update the dispose() method to call
this.log.dispose() only when that flag is true; apply the same change to the
other constructor/creation site referenced around the 272-279 block so only
internally-created channels are disposed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/serialPortManager.ts`:
- Around line 153-160: The close handler currently sets _isConnected and fires
_onConnectionChange/_onError but leaves this.port referencing the closed
SerialPort; modify the close callback on this.port to clear the stale handle
(set this.port = null) and remove/cleanup any listeners so the manager no longer
holds a closed port reference. Ensure you do this inside the existing
this.port.on('close', ...) block alongside setting this._isConnected = false and
firing _onConnectionChange, referencing this.port, _isConnected,
_onConnectionChange, and _onError.

---

Nitpick comments:
In `@src/serialPortManager.ts`:
- Around line 33-35: The class creates an OutputChannel in the constructor when
none is injected but never disposes it; add an ownership flag (e.g.,
createdOutputChannel or ownsOutputChannel) set true when you call
vscode.window.createOutputChannel in the constructor(s) and false when an
external channel is provided, then update the dispose() method to call
this.log.dispose() only when that flag is true; apply the same change to the
other constructor/creation site referenced around the 272-279 block so only
internally-created channels are disposed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10267b32-c6b3-4c84-8635-d38489adc56d

📥 Commits

Reviewing files that changed from the base of the PR and between 25fa507 and 7d7bdfe.

📒 Files selected for processing (3)
  • src/extension.ts
  • src/serialPortManager.ts
  • src/webviewPanel.ts

@Jason2866
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/serialPortManager.ts`:
- Around line 196-203: The current close callback clears this.port and emits a
disconnected state even when this.port.close reports an error; instead, only
clear this.port and update this._isConnected / call
this._onConnectionChange.fire(false) when err is falsy so the existing 'close'
event handler remains the sole place that cleans up on an actual close; leave
the port reference intact and do not change connection state on error
(optionally log or propagate the err) in the this.port.close callback.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd8514cf-bca6-4a4e-a506-277b13c8414f

📥 Commits

Reviewing files that changed from the base of the PR and between 069d242 and f5dab6b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • CHANGELOG.md
  • package.json
  • src/crashDecoder.ts
  • src/extension.ts
  • src/serialPortManager.ts
  • src/webviewPanel.ts

Comment thread src/serialPortManager.ts Outdated
Remove redundant assignment of port to null on close.
@Jason2866 Jason2866 merged commit 3774a19 into main Apr 16, 2026
3 checks passed
Jason2866 added a commit that referenced this pull request Apr 16, 2026
fix: Windows ARM64 version (#29)
@Jason2866 Jason2866 deleted the win_bullshit branch April 16, 2026 11:50
@coderabbitai coderabbitai Bot mentioned this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant