Skip to content

Document new TypeScript SDK MachineConnectionEvent values (RECONNECTING, RECONNECTION_FAILED)#4937

Open
shannonbradshaw wants to merge 3 commits intonew-docs-sitefrom
claude/ts-sdk-reconnecting-events
Open

Document new TypeScript SDK MachineConnectionEvent values (RECONNECTING, RECONNECTION_FAILED)#4937
shannonbradshaw wants to merge 3 commits intonew-docs-sitefrom
claude/ts-sdk-reconnecting-events

Conversation

@shannonbradshaw
Copy link
Copy Markdown
Collaborator

Source change

  • APP-15653: Add reconnecting and reconnection failed state viam-typescript-sdk#864 (4a3bfca): The MachineConnectionEvent enum gained two values: RECONNECTING (emitted as soon as the SDK starts retrying after an unintentional drop) and RECONNECTION_FAILED (emitted when retries are exhausted, with error and attempts fields on the payload). DISCONNECTED is now only emitted on intentional close or when noReconnect is set.

Docs changes

  • docs/build-apps/tasks/handle-connection-state.md: added the two new states to the main switch example and the in-browser status example; replaced the "five values" prose with a seven-row table that explains when each value is emitted; rewrote the rebuild-after-reconnect example to trigger on RECONNECTING instead of DISCONNECTED and noted the new event semantics.
  • docs/build-apps/app-tutorials/tutorial-dashboard.md: added RECONNECTING (orange) and RECONNECTION_FAILED (red) cases to the dashboard's watchConnection switch; updated the test description to mention the new "Reconnecting..." indicator.
  • docs/build-apps/concepts/how-apps-connect.md: added a sentence describing the new RECONNECTING and RECONNECTION_FAILED events in the reconnection-narrative section.

How I found these

  • Grep for MachineConnectionEvent, RECONNECTING, RECONNECTION_FAILED, DIALING, DISCONNECTING across the docs repo.
  • Verified the new event semantics in viam-typescript-sdk/src/robot/client.ts's onDisconnect and reconnect handlers and in src/events.ts.

Generated by daily docs change agent

viamrobotics/viam-typescript-sdk#864 added two new MachineConnectionEvent
values: RECONNECTING (emitted as soon as the SDK starts retrying after an
unintentional drop) and RECONNECTION_FAILED (emitted when retries are
exhausted, with error and attempts on the payload). DISCONNECTED is now
only emitted on intentional close or when noReconnect is set.

Update the connection-state how-to, the dashboard tutorial, and the
how-apps-connect concept page to add the two new states, switch the
rebuild-after-reconnect trigger from DISCONNECTED to RECONNECTING, and
note the new payload fields.
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2026

Deploy Preview for viam-docs ready!

Name Link
🔨 Latest commit 9b78e1d
🔍 Latest deploy log https://app.netlify.com/projects/viam-docs/deploys/69df9acac0878a000858b440
😎 Deploy Preview https://deploy-preview-4937--viam-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 40 (🔴 down 5 from production)
Accessibility: 99 (🔴 down 1 from production)
Best Practices: 92 (no change from production)
SEO: 89 (🔴 down 3 from production)
PWA: 60 (🔴 down 10 from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Build Apps documentation to reflect newly added MachineConnectionEvent values in the TypeScript SDK (RECONNECTING, RECONNECTION_FAILED) and the updated semantics for when DISCONNECTED is emitted.

Changes:

  • Expanded MachineConnectionEvent documentation to include the two new events and clarified emission semantics in the main connection-state handling guide.
  • Updated the dashboard tutorial’s watchConnection example and testing narrative to reflect the new reconnection event flow.
  • Added a reconnection narrative note in the connection model concept doc describing the new events and payload fields.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/build-apps/tasks/handle-connection-state.md Adds the two new connection events, replaces outdated “five values” prose with a 7-row table, and updates the rebuild-after-reconnect guidance.
docs/build-apps/app-tutorials/tutorial-dashboard.md Updates the connection-state switch example and test instructions to include RECONNECTING / RECONNECTION_FAILED.
docs/build-apps/concepts/how-apps-connect.md Extends reconnection narrative to mention RECONNECTING and RECONNECTION_FAILED plus payload fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 226 to 231
if (eventType === VIAM.MachineConnectionEvent.RECONNECTING) {
wasReconnecting = true;
}
if (eventType === VIAM.MachineConnectionEvent.CONNECTED && wasDisconnected) {
wasDisconnected = false;
if (eventType === VIAM.MachineConnectionEvent.CONNECTED && wasReconnecting) {
wasReconnecting = false;
await rebuildAfterReconnect();
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

In the rebuild-after-reconnect example, wasReconnecting is set to true on RECONNECTING but is only cleared when a subsequent CONNECTED arrives. If reconnection ultimately fails (or the client is intentionally closed), the flag stays true, so a later fresh connect could incorrectly be treated as a “reconnect” and trigger rebuildAfterReconnect(). Consider clearing the flag on RECONNECTION_FAILED/DISCONNECTED (and/or tracking a reconnect attempt ID) so the example doesn’t misfire after a failed reconnect.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — the flag would misfire on a subsequent fresh connect. Rewrote the example as a switch that clears wasReconnecting on RECONNECTION_FAILED and DISCONNECTED as well, and added a sentence in the surrounding prose explaining why. Fixed in 5e5989d.


Generated by Claude Code

claude and others added 2 commits April 15, 2026 12:59
…CTION_FAILED

The previous rebuild-after-reconnect example set wasReconnecting = true
on RECONNECTING but only cleared it on CONNECTED. If reconnection failed
(or the client was intentionally closed) and the user later started a
fresh connect, its first CONNECTED event would be incorrectly treated
as a reconnect and trigger rebuildAfterReconnect.

Rewrite the example as a switch that clears the flag on both
RECONNECTION_FAILED and DISCONNECTED, and document that rule in the
surrounding prose.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

3 participants