Repository navigation
Model management fixes - #570
Open
harishthakur52 wants to merge 8 commits into
Open
harishthakur52 wants to merge 8 commits into
harishthakur52 wants to merge 8 commits into
Conversation
…fix/model-management-sync
thias15
reviewed
Dec 6, 2026
thias15
left a comment
Collaborator
There was a problem hiding this comment.
Nice cleanup. Updating only the changed model and never writing over an unreadable list should fix the lost models. Two things:
- An empty list counts as unreadable. On Android
writeModelChangesanddeleteModelEverywherestop when the parsed list is empty, so a shared list that really is[]can never be written again. Could a parse error return null and be checked separately from an empty list? - Models added while signed out: after sign-in, user-added models are uploaded to the shared list. If such a model only has a local file path, other devices get an entry they can't download. Is the model file uploaded somewhere I missed? If not, it may be better to skip those entries or upload the file first.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved synchronization races can lose updates or resurrect deleted models, while model validation and inference gaps still permit crashes.
20 open issues
Use conflict-checked in-place writes for config.json · New Validate driving model control-output shape · New Track pending changes instead of replaying all local models · New Serialize local updates and retry Drive write conflicts · New Record signed-out deletions so sync cannot restore entries · New Clean up local state independently of fragment lifecycle · New Reject invalid paths and input dimensions before use · New Require the supported two-value driving model output · New Reconcile remote deletions before replaying local models · New Prevent lost updates with conflict-checked Drive writes · New Persist signed-out deletions for replay after sign-in · New Reject duplicate names and abort failed file renames · New Guard camera inference when model loading fails · New Validate inputSize dimensions when decoding model entries · New Reject driving models without two control outputs · New Distinguish an empty model list from a parse failure · New Upload model bytes before publishing their Drive links · New Allow additions when the shared model list is empty · New Give each overlapping import its own temporary file · New Upload model files and save portable download links · New
What changed in this PR
This PR updates model management across the robot apps and web playground to improve Drive synchronization, model compatibility checks, and deletion.
Changes:
- Merges model-specific changes into Drive configuration and normalizes legacy type names.
- Derives model settings from
.tflitefiles and adds safer detector error handling. - Adds permanent-delete actions and localized messages.
| File | Description |
|---|---|
| robot/ios/OpenBot/OpenBot/zh-Hans.lproj/Localizable.strings | Adds Chinese model messages. |
| robot/ios/OpenBot/OpenBot/Utils/Toast.swift | Adds an alert helper. |
| robot/ios/OpenBot/OpenBot/Utils/Strings.swift | Exposes new localized messages. |
| robot/ios/OpenBot/OpenBot/Utils/Constants.swift | Normalizes shared model names. |
| robot/ios/OpenBot/OpenBot/Utils/Common.swift | Adds resilient loading and lookup helpers. |
| robot/ios/OpenBot/OpenBot/tflite/Model.swift | Adds entry decoding and file inspection. |
| robot/ios/OpenBot/OpenBot/tflite/DetectorFloatYoloV5.swift | Makes model parsing throwable. |
| robot/ios/OpenBot/OpenBot/tflite/DetectorFloatYoloV4.swift | Checks detector outputs. |
| robot/ios/OpenBot/OpenBot/tflite/DetectorDefault.swift | Checks detector output compatibility. |
| robot/ios/OpenBot/OpenBot/tflite/Detector.swift | Propagates parsing errors. |
| robot/ios/OpenBot/OpenBot/ko.lproj/Localizable.strings | Adds Korean model messages. |
| robot/ios/OpenBot/OpenBot/hi.lproj/Localizable.strings | Adds Hindi model messages. |
| robot/ios/OpenBot/OpenBot/fr.lproj/Localizable.strings | Adds French model messages. |
| robot/ios/OpenBot/OpenBot/es.lproj/Localizable.strings | Adds Spanish model messages. |
| robot/ios/OpenBot/OpenBot/en.lproj/Localizable.strings | Adds English model messages. |
| robot/ios/OpenBot/OpenBot/de.lproj/Localizable.strings | Adds German model messages. |
| robot/ios/OpenBot/OpenBot/Controllers/runRobot/RunRobot.swift | Avoids forced detector creation. |
| robot/ios/OpenBot/OpenBot/Controllers/ObjectTracking/ObjectTrackingFragment.swift | Reports detector compatibility errors. |
| robot/ios/OpenBot/OpenBot/Controllers/ModelManagement/PopupWindowView.swift | Uses inspected settings when saving. |
| robot/ios/OpenBot/OpenBot/Controllers/ModelManagement/ModelManagementTable.swift | Validates downloads and adds deletion. |
| robot/ios/OpenBot/OpenBot/Controllers/ModelManagement/BottomSheet.swift | Checks temporary imports before saving. |
| robot/ios/OpenBot/OpenBot/Authentication/Authentication.swift | Adds per-model Drive updates and deletion. |
| robot/android/app/src/test/java/org/openbot/app/robot/tflite/ModelFileCheckTest.java | Tests model classification rules. |
| robot/android/app/src/main/res/values/strings.xml | Adds default model messages. |
| robot/android/app/src/main/res/values-zh/strings.xml | Adds Chinese model messages. |
| robot/android/app/src/main/res/values-ko/strings.xml | Adds Korean model messages. |
| robot/android/app/src/main/res/values-hi/strings.xml | Adds Hindi model messages. |
| robot/android/app/src/main/res/values-fr/strings.xml | Adds French model messages. |
| robot/android/app/src/main/res/values-es/strings.xml | Adds Spanish model messages. |
| robot/android/app/src/main/res/values-de/strings.xml | Adds German model messages. |
| robot/android/app/src/main/java/org/openbot/app/robot/utils/FileUtils.java | Filters entries and restores download links. |
| robot/android/app/src/main/java/org/openbot/app/robot/tflite/Network.java | Adds local filename fallback. |
| robot/android/app/src/main/java/org/openbot/app/robot/tflite/ModelFileCheck.java | Inspects model tensor metadata. |
| robot/android/app/src/main/java/org/openbot/app/robot/tflite/Model.java | Adds legacy aliases and validation. |
| robot/android/app/src/main/java/org/openbot/app/robot/tflite/Detector.java | Guards missing model classes. |
| robot/android/app/src/main/java/org/openbot/app/robot/objectNav/ObjectNavFragment.java | Makes model filtering null-safe. |
| robot/android/app/src/main/java/org/openbot/app/robot/modelManagement/ModelManagementFragment.java | Validates imports and adds permanent deletion. |
| robot/android/app/src/main/java/org/openbot/app/robot/modelManagement/ModelAdapter.java | Handles long-press deletion. |
| robot/android/app/src/main/java/org/openbot/app/robot/modelManagement/EditModelDialogFragment.java | Restricts settings to inspected values. |
| robot/android/app/src/main/java/org/openbot/app/robot/googleServices/GoogleServices.java | Merges Drive changes and handles deletion. |
| robot/android/app/src/main/java/org/openbot/app/robot/autopilot/AutopilotFragment.java | Makes model filtering null-safe. |
| open-code/src/utils/tfliteModel.js | Reads and classifies model tensors. |
| open-code/src/utils/constants.js | Removes manual model-type options. |
| open-code/src/utils/color.js | Adds validation-error color. |
| open-code/src/services/workspace.js | Preserves configuration on read failures. |
| open-code/src/services/googleDrive.js | Locates and reads shared configuration. |
| open-code/src/pages/playground/index.js | Refreshes configuration on entry. |
| open-code/src/components/inputComponent/simpleInputComponent.js | Displays file-derived model settings. |
| open-code/src/components/inputComponent/inputComponent.module.css | Styles disabled inputs. |
| open-code/src/components/bottomBar/modelUploadingComponent.js | Validates uploads and refreshes shared metadata. |
| open-code/src/components/blockly/blocks/customblocks.js | Accepts both navigation type names. |
Review effort: Balanced
Comment on lines
157
to
158
| configData.push(newModelData) | ||
| await uploadToGoogleDrive(JSON.stringify(configData), Constants.json).then(async () => { |
| const settings = (type, classes) => ({type, classes, width: image.shape[2], height: image.shape[1]}); | ||
|
|
||
| // Driving models take the camera image plus a command (1 value) or a goal (3 values). | ||
| if (inputs.length === 2 && outputs.length === 1) { |
Comment on lines
+551
to
+555
| if (model.pathType == Model.PATH_TYPE.FILE | ||
| || FileUtils.isUserModel(mActivity, model)) models.add(model); | ||
| } | ||
| try { | ||
| if (!models.isEmpty()) writeModelChanges(driveService, models, false); |
Comment on lines
+581
to
+584
| for (Model model : models) applyModelChange(gson, modelList, model, removed); | ||
| String modelListContent = gson.toJson(FileUtils.removeInvalidModels(modelList)); | ||
|
|
||
| if (configFileId != null) updateModelListFile(modelListContent, configFileId); |
Comment on lines
+494
to
+496
| if (!googleServices.isSignedIn()) { | ||
| deleteModelFromPhone(mItem); | ||
| return; |
| if (configFileId != null) { | ||
| modelList = parseModelList(gson, readFile(driveService, configFileId)); | ||
| // Never write over a list that couldn't be read. | ||
| if (modelList.isEmpty()) throw new IOException("Shared model list is unreadable"); |
| Gson gson = new Gson(); | ||
| String json = gson.toJson(masterList); | ||
| System.out.println("filenameId:::" + masterList.indexOf(item1)); | ||
| googleServices.uploadModelChange(item1, false); |
Comment on lines
+550
to
+552
| guard !driveModels.isEmpty else { | ||
| print("Drive config.json is unreadable, not updating it") | ||
| return |
| } catch { | ||
| print(error.localizedDescription) | ||
| // Check a temporary copy; the model is added to the app only on Done. | ||
| let checkURL = FileManager.default.temporaryDirectory.appendingPathComponent("model_check.tflite") |
| } | ||
| } else { | ||
| } | ||
| Authentication.googleAuthentication.updateModelListFile(models: allModels.filter { $0.name == model.name }, removedNames: isRenamed ? [originalName] : []) |
This branch has not been deployed
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.


Problem
Model sync between the apps and Google Drive was causing a lot of issues:
#Fixes