feat: add Failed status support for Auto Master#1063
Conversation
- Add 'failed' status to AutoMasterStatus enum for cases where Auto Master exits without configuring the device (e.g., found another Master on network) - When Auto Master status is 'Failed', continue normal PnP flow instead of redirecting to login page, since password is still 'admin' Ref: LinksysWRT#383 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Summary by QodoSupport Auto Master "Failed" status and continue PnP flow
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
Code Review —
|
- Add failed to pollAutoMasterStatus() condition to stop polling - Add failed status handling in pnp_setup_view's polling loop - Use flag to skip timeout handling when Auto Master failed This fixes the issue where users would be stuck on the waiting screen for ~5 minutes when Auto Master reports Failed status. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AustinChangLinksys
left a comment
There was a problem hiding this comment.
🤖 Automated Review — Round 1 · 4b7a7d0..a86ba0b (full)
Verdict: 💬 Self-review (comment only) — Austin's own PR; automated flow never self-approves. Review findings below are for reference and blind-spot catching only.
| Conf. | Where | Issue (one-liner) | |
|---|---|---|---|
| High | auto_master_status.dart:36 |
[both reviewers] GetAutoMasterStatusResponse doc comment missing "Failed" from wire format |
|
| Med | pnp_setup_view.dart:675,723,771 |
After failed break, _setupStep stays waitingAutoMaster until line 771 save setState — brief visual gap |
|
| High | pnp_admin_view.dart:570–573 |
Comment "Auto Master completed successfully" misleadingly covers idle case too |
|
| High | pnp_admin_view_test.dart / pnp_setup_view_test.dart |
Zero test coverage for AutoMasterStatus.failed polling path in either view |
|
| Med | pnp_setup_view.dart:723–753 |
if (autoMasterFailed) true branch is no-op log; intentional fall-through to save is implicit and fragile |
|
| 💡 | High | pnp_admin_view.dart:621 |
Pre-existing unsafe as cast in _retryAutoMasterCheck (test: guard makes it safe, but fragile pattern; not new in this PR) |
| 💡 | High | pnp_setup_view.dart:681 |
autoMasterFailed boolean for loop-break control; admin_view.dart's return pattern is cleaner |
| 💡 | High | pnp_setup_view.dart:722–765 |
autoMasterFailed path falls through to idle→complete edge-case check unnecessarily (harmless but latent) |
| 💡 | Med | pnp_provider.dart:782–790 |
Non-success JNAP results (error/timeout) collapse to null with no log differentiation — harder to triage |
| 💡 | Med | pnp_admin_view.dart:12, pnp_setup_view.dart:9 |
View layers import core/jnap/models directly (pre-existing pattern, extended by this PR) |
Confidence: High = code-verified · Med = located + reasoned, not fully confirmed · Low = speculative, please double-check.
Items marked [both reviewers] were independently flagged by two agents → higher confidence.
⚠️ Warning Details
1. Stale Response format doc comment — High confidence [both reviewers]
- Location:
lib/core/jnap/models/auto_master_status.dart:36 - Evidence:
/// Response format: { "autoMasterStatus": "Idle" | "Running" | "Complete" }
class GetAutoMasterStatusResponse extends Equatable {"Failed" was added to the enum and fromValue/toValue, but the class-level doc comment still shows only 3 values. Any consumer reading this comment will have an incomplete API contract.
- Fix: Update to
"Idle" | "Running" | "Complete" | "Failed"
2. _setupStep stays waitingAutoMaster during brief async window after failed — Med confidence [single, Reviewer A]
- Location:
lib/page/instant_setup/pnp_setup_view.dart:675, 716–723, 771 - Evidence: Line 675 sets
_setupStep = waitingAutoMaster. Whenfailedis received at lines 714–717 (autoMasterFailed = true; break;), theif (autoMasterFailed)block at line 723 only logs._setupStepis NOT reset until line 771 (_setupStep = saving). During any async work between lines 723 and 771, the UI remains onPnpAutoMasterWaitingView(lines 244–246 widget switch). Not a permanent hang (setState at 771 corrects it), but the user sees the Auto Master waiting spinner during the save phase. - Fix: Add
setState(() { _setupStep = _PnpSetupStep.config; });insideif (autoMasterFailed)at line 723, or add a comment explaining the intentional fall-through.
3. Misleading comment on idle/complete terminal block — High confidence [single, Reviewer B]
- Location:
lib/page/instant_setup/pnp_admin_view.dart:570–573 - Evidence:
if (pollStatus == AutoMasterStatus.complete ||
pollStatus == AutoMasterStatus.idle) {
// Auto Master completed successfully, password may have changed
setState(() { _isWaitingForAutoMaster = false; });
throw ExceptionInterruptAndExit(route: RouteNamed.localLoginPassword);
}idle means Auto Master is not running, not that it completed successfully. This comment misrepresents the semantics of the idle case.
- Fix:
// Auto Master either completed (password changed) or was idle (never ran); redirect to login.
4. No test coverage for AutoMasterStatus.failed polling path — High confidence [single, Reviewer B]
- Location:
test/page/instant_setup/localizations/pnp_admin_view_test.dart,pnp_setup_view_test.dart - Evidence:
grep -rn "AutoMasterStatus.failed" test/→ zero results. Existing tests coverrunning,idle,complete, and null-3-times connection error. Thefailedpath produces a different observable outcome (continue PnP vs. redirect to login) — safety-critical distinction, untested. - Fix: Add tests mocking
pollAutoMasterStatus()emittingAutoMasterStatus.failed, asserting no navigation to login and normal flow continues; one test per affected view.
5. Implicit fall-through from autoMasterFailed to save logic — Med confidence [single, Reviewer B]
- Location:
lib/page/instant_setup/pnp_setup_view.dart:723–753 - Evidence:
if (autoMasterFailed) {
logger.d('[PnP]: Auto Master failed, skipping timeout handling');
// no return, no setState — intentional fall-through to save
} else {
// timeout reconnection logic
}
// falls through to save logic at line 771The true branch is a no-op log followed by silent fall-through. A future developer inserting return here would break the save flow without a compile error.
- Fix: Add comment
// intentional fall-through: proceed to save on failed status, or negate:if (!autoMasterFailed) { /* timeout logic */ }.
✅ What looks good
auto_master_status.dart: enum correctly addsfailedwith matchingtoValue()/fromValue()entries; exhaustive switch patterns maintained.pnp_provider.dart:773:conditioninscheduledCommandcorrectly includes|| status == AutoMasterStatus.failed— polling terminates onFailedas intended. (Reviewer B initially considered this a Critical gap; re-reading head code confirms the fix is present and correct.)pnp_admin_view.dart:579–588:failedpath correctly sets_isWaitingForAutoMaster = falseandreturns — consistent with the admin view's exception-based flow structure.pnp_setup_view.dart:failedcorrectly breaks polling, skips timeout reconnection logic, and proceeds to save — preserving the existing recovery strategy without triggering false connection error UI.- Enum doc comment on line 4 corrected from
"idle: Auto Master is not running or failed"to the cleaner"idle: Auto Master is not running".
Cross-reviewed by two independent agents (security+correctness / architecture+maintainability). Automated — please sanity-check before merge.
Re-review — Critical fixed ✅Verified 1. Provider condition — 2. setup_view second defense — handled more carefully than admin_view, and correctly so: setup_view can't just Remaining follow-ups (non-blocking)
Critical resolved — approving. |
HankYuLinksys
left a comment
There was a problem hiding this comment.
Critical from the earlier review is correctly fixed in a86ba0b8 — pollAutoMasterStatus condition now terminates on failed, and setup_view's second defense uses a break + flag to skip timeout handling and fall through to the save flow (no more ~5-min stall). LGTM 🚀 FW-compat (old Idle) and a Failed test remain good follow-ups.
Summary
failedstatus toAutoMasterStatusenum to support FW's new statusFailed, continue normal PnP flow instead of redirecting to login page, since password is stilladminBackground
FW team added a new
Failedstatus forGetAutoMasterStatusJNAP (LinksysWRT#383). This status indicates Auto Master exited without configuring the device (e.g., found another Master on network). In this case, the admin password remainsadmin, so the app should continue the normal PnP flow.Changes
lib/core/jnap/models/auto_master_status.dart: Addfailedenum valuelib/page/instant_setup/pnp_admin_view.dart: HandleFailedstatus in polling loopBehavior
CompleteIdleFailedadminTest plan
FailedstatusFailedRef: LinksysWRT#383
🤖 Generated with Claude Code