Skip to content

Commit 89b9919

Browse files
committed
hub/reducers: Also match legacy flags against USB actions.
We were already doing something similar for USB firmware revision, but this was missed for software revision.
1 parent f3dc7b5 commit 89b9919

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/pybricks-blocks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 430147fd5757c39a47455ca5e8ea2cf0c97ac2b1

src/hub/reducers.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2025 The Pybricks Authors
2+
// Copyright (c) 2020-2026 The Pybricks Authors
33

44
import { Reducer, combineReducers } from 'redux';
55
import * as semver from 'semver';
@@ -31,6 +31,7 @@ import {
3131
usbDidDisconnectPybricks,
3232
usbDidReceiveDeviceName,
3333
usbDidReceiveFirmwareRevision,
34+
usbDidReceiveSoftwareRevision,
3435
usbDisconnectPybricks,
3536
} from '../usb/actions';
3637
import { pythonVersionToSemver } from '../utils/version';
@@ -361,7 +362,10 @@ const useLegacyDownload: Reducer<boolean> = (state = false, action) => {
361362
* When true, use NUS for stdio instead of Pybricks control characteristic.
362363
*/
363364
const useLegacyStdio: Reducer<boolean> = (state = false, action) => {
364-
if (bleDIServiceDidReceiveSoftwareRevision.matches(action)) {
365+
if (
366+
bleDIServiceDidReceiveSoftwareRevision.matches(action) ||
367+
usbDidReceiveSoftwareRevision.matches(action)
368+
) {
365369
// Behavior changed starting with Pybricks Profile v1.3.0.
366370
return !semver.satisfies(action.version, '^1.3.0');
367371
}
@@ -373,7 +377,10 @@ const useLegacyStdio: Reducer<boolean> = (state = false, action) => {
373377
* When true, use Legacy StartUserProgram.
374378
*/
375379
const useLegacyStartUserProgram: Reducer<boolean> = (state = false, action) => {
376-
if (bleDIServiceDidReceiveSoftwareRevision.matches(action)) {
380+
if (
381+
bleDIServiceDidReceiveSoftwareRevision.matches(action) ||
382+
usbDidReceiveSoftwareRevision.matches(action)
383+
) {
377384
// Behavior changed starting with Pybricks Profile v1.4.0.
378385
return !semver.satisfies(action.version, '^1.4.0');
379386
}
@@ -385,7 +392,10 @@ const useLegacyStartUserProgram: Reducer<boolean> = (state = false, action) => {
385392
* When true, use the legacy `__main__` module name instead of the actual file name.
386393
*/
387394
const useLegacyMainModule: Reducer<boolean> = (state = false, action) => {
388-
if (bleDIServiceDidReceiveSoftwareRevision.matches(action)) {
395+
if (
396+
bleDIServiceDidReceiveSoftwareRevision.matches(action) ||
397+
usbDidReceiveSoftwareRevision.matches(action)
398+
) {
389399
// Behavior changed starting with Pybricks Profile v1.5.0.
390400
return !semver.satisfies(action.version, '^1.5.0');
391401
}

0 commit comments

Comments
 (0)