Skip to content

fix(scripting): derive run device order from the device list instead of storing it - #1170

Merged
JamieRuderman merged 3 commits into
mainfrom
fix/scripting-run-device-order
Aug 3, 2026
Merged

fix(scripting): derive run device order from the device list instead of storing it#1170
JamieRuderman merged 3 commits into
mainfrom
fix/scripting-run-device-order

Conversation

@JamieRuderman

Copy link
Copy Markdown
Member

Follow-up to #1167, addressing the Codex review finding on #1169.

#1167 ordered ui.selected by device-list position at selection time and stored that order. Codex correctly flagged that the order goes stale: changing the sort in FilterDrawer calls devices.set({ sort }) + fetchList(), which reorders the list without any selection click, so sortSelectedIds never re-runs. The run form then displays — and submits — the old order.

List position is mutable, so any stored copy of it can drift. The same applies to filtering, searching, and paging, not just sorting. Deriving the order at the point of display removes the whole class of staleness.

Changes

  • ScriptRunPage.resolvedDevices now orders by device-list index. It's already a useMemo over devices, so it recomputes when the list reorders — no extra work, and it covers SELECTED and CUSTOM alike.
  • handleRun/handlePrepare submit resolvedDevices.map(d => d.id), so what's displayed is what's sent. CUSTOM runs are now ordered too, where before only SELECTED was touched.
  • sortSelectedIds is deleted from helpers/selectionRange.ts and useSelect no longer calls it, so ui.selected goes back to plain click order.

Net effect: 14 insertions, 18 deletions — this removes more than it adds.

Notes

Testing

tsc --noEmit passes. Not exercised in the running app. The case worth clicking through is the one Codex described: select several devices, change the device list sort, then open the run form and confirm the chips follow the new sort.

@aws-amplify-us-west-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1170.d20k671nqqv4kl.amplifyapp.com

@JamieRuderman
JamieRuderman merged commit 55d243c into main Aug 3, 2026
8 checks passed
@JamieRuderman
JamieRuderman deleted the fix/scripting-run-device-order branch August 3, 2026 20:31
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