Skip to content

Fix device configuration streaming and Settings lifecycle - #1325

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

Fix device configuration streaming and Settings lifecycle#1325
RCGV1 wants to merge 3 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/out-of-order configuration completion messages from incorrectly marking setup as complete.
    • Ensured settings resets reliably discard drafts and queued administrative changes.
    • Applied the correct LoRa serialHalOnly default when omitted.
    • Ignored protobuf metadata differences so edits aren’t flagged as modified unnecessarily.
  • Tests
    • Added/expanded coverage for config 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: 8fbd1739-45df-4d7c-aba8-99f284a2ae63

📥 Commits

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

📒 Files selected for processing (6)
  • apps/web/src/core/hooks/useWaitForConfig.test.tsx
  • apps/web/src/core/hooks/useWaitForConfig.ts
  • packages/sdk/src/core/client/MeshClient.progress.test.ts
  • packages/sdk/src/core/client/MeshClient.ts
  • packages/sdk/src/core/queue/Queue.test.ts
  • packages/sdk/src/core/queue/Queue.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/src/core/hooks/useWaitForConfig.ts
  • packages/sdk/src/core/queue/Queue.ts
  • packages/sdk/src/core/client/MeshClient.ts

📝 Walkthrough

Walkthrough

The changes add LoRa configuration defaults, make configuration waiting resolve from device-store updates, remount settings forms after resets, improve editor dirty-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.

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

Poem

A rabbit hops through settings bright,
Defaults fill each field just right.
Two nonce gates swing open wide,
Old drafts vanish, queues subside.
“Config complete!” we cheer tonight.

🚥 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 Concise and specific; it reflects the main changes to configuration streaming and Settings behavior.
Description check ✅ Passed It covers the problem, changes, impact, and validation, though the headings don't exactly match 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 💡
  • Fix failing CI checks

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
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