♻️ (device-management-kit) [NO-ISSUE]: Use WaitForAppAndVersionDeviceAction in GetDeviceStatusDeviceAction#1540
Open
benruseau wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors GetDeviceStatusDeviceAction to delegate “get app + version (including unlock handling)” to the existing WaitForAppAndVersionDeviceAction, reducing duplicated state-machine logic and adjusting tests accordingly.
Changes:
- Replaced the inlined app/version + unlock flow in
GetDeviceStatusDeviceActionwith an invokedWaitForAppAndVersionchild machine. - Simplified
GetDeviceStatuserror typing to reuseWaitForAppAndVersionDAErrorand updated step constants. - Reworked the
GetDeviceStatusDeviceActiontest suite and added a reusablesetupWaitForAppAndVersionMockhelper.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/device-management-kit/src/api/device-action/os/GetDeviceStatus/types.ts | Updates steps and error unions to align with WaitForAppAndVersion. |
| packages/device-management-kit/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts | Refactors the state machine to invoke WaitForAppAndVersion as a child action. |
| packages/device-management-kit/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts | Updates expectations and mocking strategy to match the refactor. |
| packages/device-management-kit/src/api/device-action/test-utils/setupTestMachine.ts | Adds setupWaitForAppAndVersionMock helper for tests. |
| .changeset/spicy-snails-eat.md | Patch changeset documenting the refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9ecd7a0 to
9d5b303
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


📝 Description
This PR refactors
GetDeviceStatusDeviceActionto reuse the existingWaitForAppAndVersionDeviceActioninstead of duplicating its logic (see merged PR).Previously,
GetDeviceStatusDeviceActionimplemented its own app/version retrieval and device-unlock handling: agetAppAndVersioncommand call, awaitForDeviceUnlockobservable that polled every second with a timeout, and a dedicatedUserActionUnlockDevicestate with all the related error/locked-state handling (5515locked device,6e00CLA not supported, etc.).All of that logic now lives in
WaitForAppAndVersionDeviceAction, so this DA simply invokes it as a child state machine, forwarding theunlockTimeoutinput and propagating therequiredUserInteractionviaonSnapshot. The result is handled with a cleanLeft/RightcaseOf, delegating locked-device and old-firmware edge cases to the shared action.This removes ~270 lines of duplicated state-machine logic and centralizes the "wait for app and version (handling unlock)" behavior in a single place.
Key changes:
getAppAndVersionactor andwaitForDeviceUnlockobservable with a singlewaitForAppAndVersionchild machine.UserActionUnlockDevicestate, thelockedinternal state, theisDeviceLockedguard, and the unlock-related actions/errors.AppAndVersionCheck→WaitForAppAndVersionandApplicationAvailableResultCheck→WaitForAppAndVersionResultCheck.GetDeviceStatusDAErrorto reuseWaitForAppAndVersionDAError(droppingDeviceLockedError,UnknownDAError, and the raw command error).WAIT_FOR_APP_AND_VERSIONadded,UNLOCK_DEVICEremoved).setupWaitForAppAndVersionMocktest helper and reworked the test suite accordingly.❓ Context
JIRA or GitHub link: NO-ISSUE
Feature: Internal refactor of
GetDeviceStatusDeviceActionto delegate app/version + unlock handling toWaitForAppAndVersionDeviceAction, reducing duplication.✅ Checklist
Pull Requests must pass CI checks and undergo code review. Set the PR as Draft if it is not yet ready for review.
GetDeviceStatusDeviceActionnow depends onWaitForAppAndVersionDeviceAction; QA should verify the full GetDeviceStatus flow on dashboard (BOLOS) and inside apps.6e00) and locked (5515) edge cases still behave as before.🧐 Checklist for the PR Reviewers