Repository navigation
Conversation
Greptile SummaryThis PR adds a well-scoped Wear OS companion app to OpenClaw, covering a direct WebSocket gateway client, a phone-proxy client, transcript-first chat UI, session picker, split settings screens, tile/complication support, and background reply notifications. The architecture is clean: shared gateway protocol types live in Key findings:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: apps/android/wear/src/main/java/ai/openclaw/wear/gateway/WearGatewayClient.kt
Line: 81
Comment:
**`connectionEpoch` missing `@Volatile` — data race across threads**
`connectionEpoch` is modified in `disconnect()` and `doConnect()` (which are launched via the coroutine scope) and read in the `WebSocketListener` callbacks (`onMessage`, `onClosed`, `onFailure`) which are delivered on OkHttp's internal thread pool. Without `@Volatile` (or a `@GuardedBy` lock), mutations to this `Long` may not be visible to other threads, leaving the epoch check `if (epoch != connectionEpoch)` stale and allowing out-of-order reconnect logic to fire incorrectly.
```suggestion
@Volatile private var connectionEpoch = 0L
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/android/wear/src/main/java/ai/openclaw/wear/chat/WearChatController.kt
Line: 180-193
Comment:
**`sideResults` accumulates without bound across session switches**
`clearSideResults()` is called from `switchClient()` but **not** from `switchSession()`. Every unique `(sessionKey, runId)` pair received via `chat.side_result` events is held in the `sideResults` map for the lifetime of the client. On a watch with constrained heap, switching between sessions repeatedly will cause unbounded `sideResults` growth.
Consider capping the map per session key or adding a `clearSideResults()` call (or a per-session trim) inside `switchSession()`:
```kotlin
fun switchSession(key: String) {
...
clearPendingRuns()
clearQueuedOutboundMessages()
clearSideResults() // add this
lastAnnouncedAssistantId = null
loadHistory()
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/android/wear/src/main/java/ai/openclaw/wear/gateway/WearGatewayConfig.kt
Line: 105-123
Comment:
**Migration guard can silently skip a partially-migrated secret**
The early-return condition:
```kotlin
if ((legacyToken == null && legacyPassword == null) || (secureToken != null || securePassword != null)) {
return
}
```
uses `||` to bail out as soon as *either* secure value is present. If a previous migration run wrote only the token into `securePrefs` (e.g., `EncryptedSharedPreferences` was initialised mid-write and the app was killed), a legacy `gw_password` will remain in plaintext `prefs` forever because `secureToken != null` causes the whole migration to be skipped.
Migrating each credential independently avoids this window:
```kotlin
if (legacyToken != null && secureToken == null) {
securePrefs.edit { putString("gw_token", legacyToken) }
prefs.edit { remove("gw_token") }
}
if (legacyPassword != null && securePassword == null) {
securePrefs.edit { putString("gw_password", legacyPassword) }
prefs.edit { remove("gw_password") }
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/android/wear/src/main/java/ai/openclaw/wear/gateway/WearGatewayClient.kt
Line: 163-176
Comment:
**Connect proceeds even if `connect.challenge` never arrives**
`withTimeoutOrNull(5_000) { nonceDeferred.await() }` returns `null` if the server doesn't send `connect.challenge` within 5 seconds, but `sendConnect()` is called regardless. If the gateway **requires** the challenge event before it is ready to accept a `connect` request, the watch could send `connect` into a socket that isn't listening yet, causing a silent auth failure followed by an auto-reconnect loop.
The return value should at minimum be checked:
```kotlin
val nonce = withTimeoutOrNull(5_000) { nonceDeferred.await() }
if (nonce == null) {
Log.w(TAG, "connect.challenge not received within timeout; proceeding anyway")
}
sendConnect(webSocket, epoch)
```
If the challenge is purely a server-ready sentinel (and the nonce value is not used in `sendConnect`), a comment to that effect would prevent future confusion about why the nonce is discarded.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 330d6d3 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ee818f713
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6466b06619
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f1bc4e726
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04f239d003
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| useTls = tls != null, | ||
| token = token, | ||
| bootstrapToken = bootstrapToken, | ||
| password = password, | ||
| tlsFingerprintSha256 = fingerprint, |
There was a problem hiding this comment.
Block unpinned TLS fallback config from phone handshake
In NodeGatewayCoordinator.buildWearProxyGatewayConfig, the watch fallback payload is emitted with useTls=true whenever TLS is inferred, even when tlsFingerprintSha256 is missing. The watch path treats missing pins as TOFU, so in first-connect or pin-missing states it can directly trust-and-store the first certificate it sees, bypassing the phone-side explicit fingerprint trust flow for manual TLS. This weakens the trust model on the fallback path and can permit MITM during fallback activation; only advertise TLS fallback when a trusted fingerprint is present (or suppress direct fallback until trust is established).
Useful? React with 👍 / 👎.
| handshake.gatewayConfig?.let { syncedConfig -> | ||
| onGatewayConfigSynced(syncedConfig, handshake.tlsFingerprintSha256) | ||
| } |
There was a problem hiding this comment.
Sync fallback config only from the selected ready phone
handlePong applies onGatewayConfigSynced(...) before confirming that the pong corresponds to the accepted ready node for the current probe generation. In multi-phone environments, a probed-but-not-ready node can overwrite the watch’s direct fallback host/token/pin, and if the ultimately selected node does not send gatewayConfig, that stale config persists. When proxy mode later drops, direct fallback can connect to the wrong gateway or fail unexpectedly; gate config sync to pongs that are both current and selected/ready.
Useful? React with 👍 / 👎.
|
+1. Good one. was looking to do something similar. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60e7415be7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| fun emit(event: GatewayEvent) { | ||
| if (_events.subscriptionCount.value == 0) return |
There was a problem hiding this comment.
Preserve queued events when no collectors are attached
Dropping events when subscriptionCount == 0 causes real data loss in the proxy/direct failover flow: WearApp.applyConnectionPolicy can keep PhoneProxyClient running while WearChatController is collecting only the direct client, so proxy events emitted in that period (including mainSessionKey and terminal chat updates) are discarded. When the app switches back to the proxy client, those missed events are never replayed and the watch can stay on stale session/history state until a manual refresh or reconnect.
Useful? React with 👍 / 👎.
| acceptConnectedPhoneNode(sourceNodeId, connectionGeneration) | ||
| } |
There was a problem hiding this comment.
Sync fallback config from active ready-phone pongs
After initial node selection, handlePong accepts ready pongs but never applies handshake.gatewayConfig, so direct fallback settings are only synced once during probe. If the phone changes gateway host/auth/TLS pin while proxy mode stays connected, the watch keeps stale fallback config and may fail over to an outdated endpoint as soon as proxy transport drops. The active-node ready pong path should refresh config, not just connection liveness.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58dd6c3235
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val connectPlan = resolveConnectPlan(auth) | ||
| desiredNodeConnectAuth = connectPlan.nodeAuth | ||
| desiredOperatorConnectAuth = connectPlan.operatorAuth | ||
| shouldConnectOperator = connectPlan.connectOperator | ||
| val tls = connectionManager.resolveTlsParams(endpoint) |
There was a problem hiding this comment.
Recompute operator plan after bootstrap node connect
In bootstrap-only flows (bootstrapToken set, no shared token/password), connect() snapshots connectPlan.connectOperator once from the pre-connect token state and stores it in shouldConnectOperator; that is often false on first connect because no operator device token exists yet. connectSessions() then immediately disconnects the operator session, and this coordinator never re-evaluates the plan after the node session completes bootstrap handoff and persists operator credentials, so operator features (chat/history/session RPCs) can remain offline until the user manually reconnects.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e09c8610c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| clearPendingProbe() | ||
| phoneNodeId = null | ||
| _connected.value = false | ||
| _statusText.value = statusText | ||
| scheduleReconnect(generation = generation) |
There was a problem hiding this comment.
Fail all in-flight proxy RPCs on transport failure
When the proxy transport drops, handleTransportFailure marks the client disconnected and schedules reconnect, but it never completes pendingRequests. Any other in-flight RPCs (for example concurrent chat.history/sessions.list calls) keep waiting until their per-request timeout even though the connection is already known dead, which delays UI recovery/retry and can accumulate stale deferreds under repeated disconnects. Completing and clearing all pending requests in this failure path (like disconnect() already does) avoids these hangs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78df271f0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| private fun applyMainSessionKey(candidate: String?) { | ||
| val trimmed = normalizeMainKey(candidate) ?: return | ||
| if (isCanonicalMainSessionKey(_mainSessionKey.value)) return |
There was a problem hiding this comment.
Honor connect snapshot main session for canonical keys
This guard makes applyMainSessionKey(...) a no-op whenever _mainSessionKey is already canonical (the normal startup state like agent:<id>:node-...), so the mainSessionKey from onOperatorConnected is ignored. Before this change, the connect callback immediately synchronized the agent from the connect snapshot; now session-key updates depend on later refreshAgentsFromGateway/refreshBrandingFromGateway calls succeeding. If those follow-up RPCs fail or are delayed, chat/talk (and proxy consumers) keep routing to a stale session key for the entire connection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bc30da31e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| historyLoadJob = null | ||
| historyRequestVersion.incrementAndGet() | ||
| client = newClient | ||
| appliedMainSessionKey = "main" |
There was a problem hiding this comment.
Preserve main-session tracking across client switches
switchClient resets appliedMainSessionKey to "main" even when the controller is currently following a resolved main session key (for example agent:...). After a proxy↔direct failover, the next mainSessionKey event is then treated like a manual-session override (currentSessionKey != appliedMainSessionKey), so the watch can stay pinned to the old session instead of following the new main session from the active client. This breaks main-session continuity whenever the main key changes during/after client handoff.
Useful? React with 👍 / 👎.
| clearPendingRuns() | ||
| clearQueuedOutboundMessages() |
There was a problem hiding this comment.
Keep queued outbound runs when failover switches clients
The failover path clears both pendingRuns and queuedOutboundMessages during switchClient, which drops unsent user messages exactly when transport handoff is needed most (for example proxy disconnects after enqueueing a retryable send). Because dispatchQueuedOutboundMessages() only runs on later reconnect and the queue has already been wiped, those messages are never retried and disappear from the watch flow.
Useful? React with 👍 / 👎.
| val passwordLauncher = remoteInputLauncher(PASSWORD_KEY) { value -> | ||
| onConfigChange(config.copy(password = value)) |
There was a problem hiding this comment.
Drop stale bootstrap token when user edits direct auth
Editing token/password here preserves any existing bootstrapToken in WearGatewayConfig, but buildWearConnectParams prefers bootstrapToken over password when token is blank. If fallback sync previously stored a bootstrap token, a user switching to password auth can keep sending bootstrap auth unintentionally, and there is no bootstrap field in this screen to clear it. This makes direct re-auth fail persistently until config is reset elsewhere.
Useful? React with 👍 / 👎.
|
This assigned pull request has been marked as stale after being open for 27 days. |
|
When is a good time to bring the PR back alive and not have yet another PR lying around? |
|
@sibbl, another rebase is not worthwhile yet. This remains a product/security decision, not a branch-freshness problem. The current head is +11,387/-1,030 across 105 files, conflicts with main, adds two modules, and still lacks CI coverage for :shared and :wear plus resolution of the identity-backup and direct-auth blockers. Best-fix verdict: park this branch pending an Android-owner product yes. If Wear OS proceeds, revive it as staged replacement work:
Each stage needs module gates, license notices, and paired phone/watch proof. No more rebase churn on this branch meanwhile. |
|
Wear OS is approved, but we are replacing this implementation rather than asking for another rebase. The current product direction is a phone-proxy-only v1: the phone owns Gateway connectivity, authentication, TLS, and device identity; the watch never stores or receives Gateway credentials. The original 11k-line branch combines protocol, phone bridge, watch UI, tiles, notifications, and direct credential forwarding, which makes the security boundary and review surface too broad to land safely after main moved this far. The staged replacement is tracked in #108781. PR #108835 starts with the bounded shared phone/watch protocol and preserves Sebastian's contribution credit. Phone transport and the Wear app follow as independently reviewable stages. Closing this superseded branch. This is a yes to Wear OS and a no to continuing the stale all-in-one architecture. Thank you @sibbl for the original implementation and product push; it directly informed the replacement scope. |
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.ReplyandLatest.Security Impact (required)
Yes)Yes)Yes)No)Yes)Yes, explain risk + mitigation: The Wear app addsPOST_NOTIFICATIONS, Wear Data Layer messaging, direct gateway WebSocket access, and storage of watch-side gateway config including token-based direct auth. Risk is constrained by using the existing authenticated gateway paths, limiting watch data access to the same session/gateway calls already exposed by the phone client, honoring platform notification permission, and keeping watch auth/config local to the Wear app. Phone-proxy traffic stays within the paired phone/watch channel and only proxies requests through the phone's active operator session.Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Actual screenshots from Pixel Watch 2:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
apps/android/wear/**,apps/android/app/src/main/java/ai/openclaw/app/wear/WearProxyService.kt,apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt,apps/android/app/src/main/AndroidManifest.xml, andapps/android/app/build.gradle.kts.Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.