Skip to content

Fix device configuration streaming and Settings lifecycle - #1325

Open
RCGV1 wants to merge 6 commits into
meshtastic:mainfrom
RCGV1:agent/fix-config-streaming
Open

Fix device configuration streaming and Settings lifecycle#1325
RCGV1 wants to merge 6 commits into
meshtastic:mainfrom
RCGV1:agent/fix-config-streaming

Conversation

@RCGV1

@RCGV1 RCGV1 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Send heartbeat and configuration control packets without waiting for routing acknowledgements that firmware does not emit.
  • Track configuration-only and node-only nonces independently and ignore stale completion packets.
  • Make Settings suspend until the requested configuration actually arrives instead of hanging forever.
  • Normalize the legacy serialHalOnly form value, correctly reset controlled forms, and ignore protobuf metadata when calculating dirty state.

Root cause

The web client treated local configuration requests like acknowledged mesh packets and used one completion path for multiple streaming modes. Settings also suspended on a promise that could never resolve. Separately, form values omitted by older firmware and protobuf metadata caused invalid boolean and false-dirty states.

Impact

HTTP and serial clients can complete configuration streaming consistently, Settings loads after the requested section arrives, and Serial HAL Only behaves as a boolean with a clean edit/reset lifecycle.

Validation

  • NODE_OPTIONS=--no-experimental-webstorage pnpm vitest run: 70 files, 393 tests passed.
  • pnpm --filter meshtastic-web build: passed.
  • pnpm lint: passed with existing warnings.
  • git diff --check: passed.
  • GitHub E2E (real device): passed in 2m8s.
  • Physical T-Beam S3 over the web HTTP transport: configuration completed, 8 channels and 199+ nodes streamed, and the LoRa Settings form rendered.
  • Live Settings cycle: Serial HAL Only changed false → true → Reset → false; Save returned disabled, dirty state cleared, and no boolean validation error appeared. No configuration was written to the device.

Notes

  • Vercel preview requires Meshtastic team authorization for fork deployments.

Summary by CodeRabbit

  • Bug Fixes
    • Improved device configuration synchronization with a reliable, staged handshake.
    • Prevented stale or out-of-order completion messages from incorrectly marking setup as complete.
    • Ensured settings resets discard drafts and queued administrative changes.
    • Applied the correct LoRa serialHalOnly default when omitted.
    • Ignored protobuf metadata differences when detecting edits.
  • Tests
    • Expanded coverage for configuration waiting, handshake progress, reset behavior, LoRa defaults, and queue cancellation.

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

@RCGV1 is attempting to deploy a commit to the Meshtastic Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6247b76-ec6d-4b24-903f-4999470003d8

📥 Commits

Reviewing files that changed from the base of the PR and between 28a7466 and 15b8a6f.

📒 Files selected for processing (2)
  • .github/workflows/e2e.yml
  • tsconfig.json

📝 Walkthrough

Walkthrough

The changes add LoRa configuration defaults, resolve configuration waits from device-store updates, remount settings forms after resets, improve editor state handling, and replace the SDK configuration handshake with a nonce-validated two-stage flow using unacknowledged packet sends.

Changes

Web configuration behavior

Layer / File(s) Summary
LoRa default normalization
apps/web/src/validation/config/lora.ts, apps/web/src/validation/config/lora.test.ts, apps/web/src/components/PageComponents/Settings/LoRa.tsx
Adds withLoRaDefaults and applies serialHalOnly: false when LoRa form values omit the field.
Resolvable configuration suspense
apps/web/src/core/hooks/useWaitForConfig.ts, apps/web/src/core/hooks/useWaitForConfig.test.tsx
Subscribes to the device store, resolves pending waits when requested configuration appears, and reuses pending subscriptions.
Settings and editor reset state
apps/web/src/pages/Settings/index.tsx, packages/sdk/src/features/config/domain/ConfigEditor.ts, packages/sdk/src/features/config/ConfigEditor.test.ts
Remounts the active settings form after editor resets, clears queued admin messages and dirty flags, and ignores protobuf $typeName metadata during equality checks.

SDK configuration handshake

Layer / File(s) Summary
Unacknowledged packet transport
packages/sdk/src/core/queue/Queue.ts, packages/sdk/src/core/queue/Queue.test.ts, packages/sdk/src/core/client/MeshClient.ts
Adds unacknowledged queue transmission, cancellation handling, and uses it for heartbeat and handshake packets.
Nonce-driven handshake state machine
packages/sdk/src/core/client/MeshClient.ts
Implements config and nodes handshake stages, validates completion nonces, and resets handshake state on completion.
Completion packet delegation and validation
packages/sdk/src/core/packet-codec/decodePacket.ts, packages/sdk/src/core/client/MeshClient.progress.test.ts
Delegates completion packets to MeshClient.handleConfigComplete and tests staged progress, stale nonces, callbacks, and configure resets.

Build configuration triggering

Layer / File(s) Summary
TypeScript and E2E workflow configuration
tsconfig.json, .github/workflows/e2e.yml
Removes two TypeScript project references and runs E2E workflow checks when tsconfig.json changes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MeshClient
  participant Queue
  participant Firmware
  MeshClient->>Queue: Send heartbeat and config-stage request
  Queue->>Firmware: Transmit without routing acknowledgement
  Firmware-->>MeshClient: Return config completion nonce
  MeshClient->>Queue: Send nodes-stage request
  Queue->>Firmware: Transmit without routing acknowledgement
  Firmware-->>MeshClient: Return nodes completion nonce
  MeshClient->>MeshClient: Dispatch completion and mark configured
Loading

Suggested reviewers: thebentern

Poem

A rabbit checks each setting field,
While nonce stages move through the shield.
Old drafts reset, queues clear away,
Config waits resolve today.
“Complete!” the burrow sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary changes to device configuration streaming and Settings lifecycle.
Description check ✅ Passed The description clearly explains the problem, changes, impact, and extensive validation results, despite using headings different from the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

@RCGV1
RCGV1 marked this pull request as ready for review July 22, 2026 16:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@apps/web/src/core/hooks/useWaitForConfig.ts`:
- Around line 24-42: Update the suspended waiter in useWaitForConfig so each
store subscription is disposed when the waiting component unmounts or the
suspended render is abandoned, while still resolving and unsubscribing when
hasRequestedConfig returns true. Ensure repeated pending renders do not leave
accumulated listeners on useDeviceStore.

In `@packages/sdk/src/core/client/MeshClient.progress.test.ts`:
- Around line 113-120: Update the test around client.configure and the
config-complete responses to await completion through handleConfigComplete or
the completed collection instead of using the fixed 20 ms timeout. Ensure both
config-complete packets are processed before asserting sent,
progress.value.phase, and completed, while preserving the expected ignored-nonce
results.

In `@packages/sdk/src/core/client/MeshClient.ts`:
- Around line 158-164: Update the connect() documentation and completion
behavior to reflect that it resolves after configure() writes only the config
request; the nodes-only request is sent later by handleConfigComplete(). Remove
the inaccurate “both requests” contract while preserving the existing
DeviceConnecting status update and configure() flow.

In `@packages/sdk/src/core/queue/Queue.ts`:
- Around line 113-120: Update the wait loop in the queue send flow around
queuedItem and processQueue so it also detects when complete() has cleared the
queued control packet. Reject the pending configure() or heartbeat() operation
when the detached item is removed, instead of continuing to poll queuedItem.sent
forever; preserve the existing success path and cleanup for packets that are
sent normally.
🪄 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 Plus

Run ID: 540b024a-e082-4e7e-8717-aac204e75997

📥 Commits

Reviewing files that changed from the base of the PR and between d707bb1 and d329c18.

📒 Files selected for processing (12)
  • apps/web/src/components/PageComponents/Settings/LoRa.tsx
  • apps/web/src/core/hooks/useWaitForConfig.test.tsx
  • apps/web/src/core/hooks/useWaitForConfig.ts
  • apps/web/src/pages/Settings/index.tsx
  • apps/web/src/validation/config/lora.test.ts
  • apps/web/src/validation/config/lora.ts
  • packages/sdk/src/core/client/MeshClient.progress.test.ts
  • packages/sdk/src/core/client/MeshClient.ts
  • packages/sdk/src/core/packet-codec/decodePacket.ts
  • packages/sdk/src/core/queue/Queue.ts
  • packages/sdk/src/features/config/ConfigEditor.test.ts
  • packages/sdk/src/features/config/domain/ConfigEditor.ts

Comment thread apps/web/src/core/hooks/useWaitForConfig.ts Outdated
Comment thread packages/sdk/src/core/client/MeshClient.progress.test.ts
Comment thread packages/sdk/src/core/client/MeshClient.ts Outdated
Comment thread packages/sdk/src/core/queue/Queue.ts
@danditomaso

Copy link
Copy Markdown
Collaborator

Looks like e2e tests are failing, did you need to me to look at and fix the issues?

@RCGV1

RCGV1 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Fixed the E2E startup failure by removing invalid root TypeScript project references that Playwright validates when loading its config. Also added the root tsconfig to the E2E workflow path filters so future changes to it run the suite.\n\nValidated locally with Playwright test discovery (all 4 E2E tests), formatting, lint, and diff checks. The new E2E and PR CI runs are queued for the latest commit.\n\nThe Vercel check still requires Meshtastic-team authorization for this fork deployment; the PR will also need the required maintainer approval.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web-test Ready Ready Preview Aug 12, 2026 11:08pm

Request Review

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