fix: Resolve multiple bugs (#69, #70, #73, #74, #82, #83)#84
Conversation
- Fix usb_serial jcenter() build failure by replacing deprecated repos with mavenCentral() in subproject afterEvaluate (#69) - Fix setup progress bar stalling at 0% during extraction and npm install by using indeterminate animation, show percentage when real progress is available, fix off-by-one in step completion check (#83) - Fix token mismatch by reading actual token from openclaw.json config as source of truth, clear stale token on gateway start, add clearDashboardUrl to state copyWith (#74, #82) - Auto-repair missing bionic-bypass.js after app update instead of forcing full re-setup (#70, #73) Co-Authored-By: Mithun Gowda B <mithungowda.b7411@gmail.com>
Co-Authored-By: Mithun Gowda B <mithungowda.b7411@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughApp version bumped to 1.8.5 and repo metadata changed for Android. Gateway initialization now prefers tokens from Changes
Sequence Diagram(s)sequenceDiagram
participant App as App/UI
participant GatewaySvc as GatewayService
participant FS as FileSystem
participant Prefs as SharedPrefs
participant Native as NativeBridge
App->>GatewaySvc: init()
GatewaySvc->>Prefs: read persisted dashboardUrl
GatewaySvc->>FS: _readTokenFromConfig()
alt token in config
GatewaySvc->>Prefs: write dashboardUrl (http://localhost:18789/#token=...)
GatewaySvc->>App: update state.dashboardUrl (from config)
else no token
GatewaySvc->>App: keep persisted dashboardUrl
end
App->>Native: isBootstrapComplete()
alt not complete and bypass missing but others present
App->>Native: getBootstrapStatus()
App->>App: set status "Repairing bionic bypass..."
App->>Native: installBionicBypass()
App->>Native: isBootstrapComplete() (recheck)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.Add a .trivyignore file to your project to customize which findings Trivy reports. |
Build FailedThe build failed for commit 2437709. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
flutter_app/lib/services/gateway_service.dart (1)
304-321: Consider caching the PreferencesService instance.
prefs.init()is called on each health check transition torunning. While not a hot path, you could consider caching the initializedPreferencesServiceinstance at the class level to avoid repeated initialization.♻️ Optional refactor to cache PreferencesService
class GatewayService { Timer? _healthTimer; Timer? _initialDelayTimer; StreamSubscription? _logSubscription; final _stateController = StreamController<GatewayState>.broadcast(); GatewayState _state = const GatewayState(); DateTime? _startingAt; bool _startInProgress = false; + PreferencesService? _prefs; static final _tokenUrlRegex = RegExp(r'https?://(?:localhost|127\.0\.0\.1):18789/#token=[0-9a-f]+');Then use a helper:
Future<PreferencesService> _getPrefs() async { _prefs ??= PreferencesService(); await _prefs!.init(); return _prefs!; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@flutter_app/lib/services/gateway_service.dart` around lines 304 - 321, Cache the PreferencesService instance to avoid repeated initialization: add a private field (e.g., PreferencesService? _prefs) on the GatewayService class and implement a helper method Future<PreferencesService> _getPrefs() that assigns _prefs if null, awaits _prefs!.init() and returns it; then replace the local creation in the block that calls _readTokenFromConfig() so it awaits _getPrefs() instead of creating a new PreferencesService() and calling init() each time; keep the rest of the logic (setting prefs.dashboardUrl) the same.flutter_app/lib/screens/splash_screen.dart (1)
133-133: Consider logging repair failures for debugging.The empty catch block silently swallows any repair errors. While the fallback to
SetupWizardScreenis correct behavior, logging the exception would help diagnose persistent repair failures.♻️ Optional: Add debug logging
- } catch (_) {} + } catch (e) { + debugPrint('Bionic bypass repair failed: $e'); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@flutter_app/lib/screens/splash_screen.dart` at line 133, The empty catch block that currently swallows exceptions (the "catch (_)" in splash_screen.dart where the code falls back to SetupWizardScreen) should log the caught error for debugging; update that catch to capture the exception (and optionally stackTrace) and call the app's logging mechanism (e.g., debugPrint or your Logger) with a brief message like "Repair failed" plus the error details to aid diagnosis while keeping the fallback to SetupWizardScreen unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@flutter_app/android/build.gradle`:
- Around line 28-35: The project.afterEvaluate callback is registered too late
(after evaluationHasBeen forced by evaluationDependsOn(":app")) which causes the
"already evaluated" error; replace the project.afterEvaluate usage by using
gradle.projectsEvaluated and run the repository adjustments for every subproject
there: in the gradle.projectsEvaluated block iterate the relevant
projects/subprojects and ensure each project.repositories contains
mavenCentral() and remove jcenter entries (detect via instanceof
MavenArtifactRepository and repo.url.toString().contains("jcenter")); this
ensures the repository changes run after all projects are evaluated without
attempting to register afterEvaluate on an already-evaluated project.
---
Nitpick comments:
In `@flutter_app/lib/screens/splash_screen.dart`:
- Line 133: The empty catch block that currently swallows exceptions (the "catch
(_)" in splash_screen.dart where the code falls back to SetupWizardScreen)
should log the caught error for debugging; update that catch to capture the
exception (and optionally stackTrace) and call the app's logging mechanism
(e.g., debugPrint or your Logger) with a brief message like "Repair failed" plus
the error details to aid diagnosis while keeping the fallback to
SetupWizardScreen unchanged.
In `@flutter_app/lib/services/gateway_service.dart`:
- Around line 304-321: Cache the PreferencesService instance to avoid repeated
initialization: add a private field (e.g., PreferencesService? _prefs) on the
GatewayService class and implement a helper method Future<PreferencesService>
_getPrefs() that assigns _prefs if null, awaits _prefs!.init() and returns it;
then replace the local creation in the block that calls _readTokenFromConfig()
so it awaits _getPrefs() instead of creating a new PreferencesService() and
calling init() each time; keep the rest of the logic (setting
prefs.dashboardUrl) the same.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0927448d-e022-44c2-a598-27b5cbf5270f
📒 Files selected for processing (8)
flutter_app/android/build.gradleflutter_app/lib/constants.dartflutter_app/lib/models/gateway_state.dartflutter_app/lib/screens/setup_wizard_screen.dartflutter_app/lib/screens/splash_screen.dartflutter_app/lib/services/gateway_service.dartflutter_app/lib/widgets/progress_step.dartflutter_app/pubspec.yaml
flutter_app/android/build.gradle
Outdated
| project.afterEvaluate { | ||
| project.repositories { | ||
| mavenCentral() | ||
| } | ||
| project.repositories.removeIf { repo -> | ||
| repo instanceof MavenArtifactRepository && repo.url.toString().contains("jcenter") | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Read-only verification: locate lifecycle/repository hooks in Gradle files
rg -n -C3 --type-add 'gradle:*.gradle' --type gradle \
'evaluationDependsOn|afterEvaluate|projectsEvaluated|repositories\.removeIf|jcenter|mavenCentral'Repository: mithun50/openclaw-termux
Length of output: 1804
afterEvaluate registration is too late and breaks the Gradle build.
At line 28, project.afterEvaluate { ... } is registered inside the subprojects block after project.evaluationDependsOn(":app") has already forced :app evaluation. Once a project is evaluated, registering afterEvaluate callbacks fails with "Cannot run Project.afterEvaluate(Closure) when the project is already evaluated."
Proposed fix (use gradle.projectsEvaluated instead)
subprojects {
project.evaluationDependsOn(":app")
-
- // Fix plugins that still reference the deprecated jcenter() repository (`#69`).
- // Force all subprojects to use mavenCentral() instead.
- project.afterEvaluate {
- project.repositories {
- mavenCentral()
- }
- project.repositories.removeIf { repo ->
- repo instanceof MavenArtifactRepository && repo.url.toString().contains("jcenter")
- }
- }
}
+
+// Fix plugins that still reference the deprecated jcenter() repository (`#69`).
+// Apply once after project evaluation phase has completed.
+gradle.projectsEvaluated {
+ subprojects { subproject ->
+ subproject.repositories {
+ mavenCentral()
+ }
+ subproject.repositories.removeIf { repo ->
+ repo instanceof MavenArtifactRepository && repo.url.toString().contains("jcenter")
+ }
+ }
+}🧰 Tools
🪛 GitHub Actions: Build OpenClaw Apps
[error] 28-28: Gradle build failed while evaluating root project 'android': Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@flutter_app/android/build.gradle` around lines 28 - 35, The
project.afterEvaluate callback is registered too late (after evaluationHasBeen
forced by evaluationDependsOn(":app")) which causes the "already evaluated"
error; replace the project.afterEvaluate usage by using gradle.projectsEvaluated
and run the repository adjustments for every subproject there: in the
gradle.projectsEvaluated block iterate the relevant projects/subprojects and
ensure each project.repositories contains mavenCentral() and remove jcenter
entries (detect via instanceof MavenArtifactRepository and
repo.url.toString().contains("jcenter")); this ensures the repository changes
run after all projects are evaluated without attempting to register
afterEvaluate on an already-evaluated project.
Build SuccessfulVersion: Download APKs
Built from baec708 by GitHub Actions |
Summary
jcenter()withmavenCentral()in subproject repositories, fixing theusb_serialplugin build erroropenclaw.jsonconfig file as source of truth instead of relying solely on stdout regex capture; clear stale tokens on gateway start; addclearDashboardUrlto state managementbionic-bypass.jsafter app update instead of forcing full re-setup when rootfs, node, and openclaw are all intactChanges
flutter_app/android/build.gradlejcenter()withmavenCentral()in plugin reposflutter_app/lib/widgets/progress_step.dartflutter_app/lib/screens/setup_wizard_screen.dartflutter_app/lib/models/gateway_state.dartclearDashboardUrltocopyWithflutter_app/lib/services/gateway_service.dartflutter_app/lib/screens/splash_screen.dartflutter_app/pubspec.yaml+constants.dartTest plan
jcenter()build errorsopenclaw.jsonconfigSummary by cubic
Fixes Android build failures, improves setup progress UX, and makes gateway auth consistent. Also auto-repairs a missing bionic-bypass after updates to avoid re-setup.
jcenter()fallback inallprojects.repositorieswithmavenCentral()to fixusb_serial0.5.x dependency resolution (A problem occurred evaluating project ':usb_serial'. #69).openclaw.jsonas source of truth; clear stale tokens on start; persist updated dashboard URL; addclearDashboardUrlto state (Can the token displayed on the app homepage and the web dashboard be based on the actual token? #74, OpenClaw-v1.8.4-arm64-v8a.apk on arm64-v8a + android13 board,it shows me disconned4008 #82).bionic-bypass.jswhen other components are intact to avoid full re-setup (After Openclaw update, Openclaw-Termux no longer finds Prootfs and Openclaw #70, The update of openclaw caused the entire project to crash, and even resetting could not resolve the issue. #73).Written for commit 02b7da0. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Chores