Skip to content

feat(android): add Wear OS app MVP - #47604

Closed
sibbl wants to merge 39 commits into
openclaw:mainfrom
sibbl:codex/wearos-app
Closed

sibbl wants to merge 39 commits into
openclaw:mainfrom
sibbl:codex/wearos-app

Conversation

@sibbl

@sibbl sibbl commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Summary

This is the follow up PR of #46279
It was heavily written with the help of Gemini 3.1 Pro (mainly for building UI) and Codex GPT 5.4, including lots of review iterations.
During the implementation of the previous PR I moved more and more logic into a shared layer, which caused lots of review comments about code I didn't write. I tried to let Codex write regression tests for several of these cases to ensure that I don't break features.
Manual testing with my Pixel Watch 2 and Pixel 8 Pro was part of the whole process.

Describe the problem and fix in 2–5 bullets:

  • Problem: OpenClaw did not have a Wear OS companion.
  • Why it matters: The watch needs a compact, reliable chat surface with fast reply actions, honest connection state, and behavior that still works on tiny round screens and when the app is backgrounded.
  • What changed: Added a new Wear OS app module, phone-side Wear proxy service for Tailscale support, direct watch gateway client, transcript-first chat UI, session picker, split settings screens, tile + complication support, background reply notifications with quick reply.
  • What did NOT change (scope boundary): This PR does not change gateway orchestration semantics, tools/skills behavior, desktop/iOS/macOS clients, or the Android phone app's broader UI theme beyond the phone-side Wear proxy integration.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes # (none)
  • Related # (none)

User-visible / Behavior Changes

List user-visible changes (including defaults/config).
If none, write None.

  • New Wear OS companion app with a transcript-first chat flow and a two-page swipe layout.
  • Chat opens on the transcript page and follows the latest message by default; the primary edge action switches between Reply and Latest.
  • Added session picker, chat settings, connection settings, reconnect flow, and direct-vs-phone-proxy connection support on the watch.
  • Added Wear tile and complication entry points.
  • Added native watch notifications for background replies, including quick reply via text/voice dictation.
  • Added optional TTS playback and configurable screen-awake behavior on the watch.

Security Impact (required)

  • New permissions/capabilities? (Yes)
  • Secrets/tokens handling changed? (Yes)
  • New/changed network calls? (Yes)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (Yes)
  • If any Yes, explain risk + mitigation: The Wear app adds POST_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

  • OS: Android phone + Wear OS 3/4 watches; manually tested on Pixel Watch 2 and Wear round emulators (small + large)
  • Runtime/container: Android Studio/Gradle debug builds
  • Model/provider: Existing OpenClaw gateway via phone proxy and direct gateway modes
  • Integration/channel (if any): Wear Data Layer between paired phone and watch
  • Relevant config (redacted): Matching debug-signed phone + watch builds; direct mode host/port/token/TLS when used; phone-proxy mode with phone app installed and signed the same way

Steps

  1. Build and install matching debug phone and Wear builds, then launch the Wear app on a paired watch.
  2. Verify transcript flow, reply actions, session switching, settings, direct mode, phone-proxy mode, tile/complication entry points, and reopen/background behavior.
  3. Send assistant replies while the watch app is foregrounded and backgrounded, then verify reply notifications, quick reply, reconnect/disconnect behavior, and latest-message scrolling.

Expected

  • The watch should show a compact, reliable chat UX with correct connection state, preserved transcript state, working reply paths, and background reply notifications.

Actual

  • Matches expected in manual testing on Pixel Watch 2 and both small/large Wear emulators.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Actual screenshots from Pixel Watch 2:

Empty tanscript view Empty transcript view Swipe over to menu
Scroll down in menu Scroll further down Click behavior settings button
Scroll down Click screen awake setting Click screen awake setting again
Go back and enter connection settings Scroll down to helper text Disable phone proxy
Scroll down to gateway config Scroll further down Go back to transcript view
Scroll down to see reply edge button (default view if you open the app≈) Reply button toggles voice input (or let's you pick first, if disabled in settings) Thinking animation
When closing app, notification is delivered Tile adding dialog with preview of tile Actual tile
Watch face with complication at top and bottom right (different formats)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Manually tested on a Pixel Watch 2 via Tailscale phone proxy and in both small and large round Wear emulators. Verified chat launch, latest-message behavior, reply flow, session picker, chat settings, connection settings, direct gateway mode, phone-proxy mode, tile launch, complication launch, background reply notifications, and quick reply from the notification.
  • Edge cases checked: Reopening the app after backgrounding, disconnect/reconnect flow, switching away from and back to the transcript page, scrolling away from latest and jumping back, and testing on both small and large round watch layouts.
  • What you did not verify: every possible Android OEM pairing/background-policy variant, and exhaustive real-network failure cases beyond the implemented reconnect/error handling paths.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

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

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: None.

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the Wear branch commits or ship only the phone build without installing the Wear module; on-device, switch the watch back to phone-proxy or disconnect direct mode if direct gateway behavior is problematic.
  • Files/config to restore: 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, and apps/android/app/build.gradle.kts.
  • Known bad symptoms reviewers should watch for: watch stuck showing connected when the proxy/direct gateway is not actually usable, sent messages disappearing after history refresh, explicit disconnect reconnecting by itself, reply notification not surfacing or lacking quick reply, and transcript reopening at the wrong position.

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: Phone-proxy mode depends on both Wear Data Layer reachability and the phone app having a live operator session.
    • Mitigation: The watch exposes direct mode as an alternative, surfaces connection state in the UI, and includes reconnect/disconnect controls.
  • Risk: The second page is dense on the smallest round watches, especially with long session names/keys.
    • Mitigation: Manual testing covered both small and large round emulator sizes and a real Pixel Watch 2.
  • Risk: Background reply notifications depend on platform permission and Wear notification presentation.
    • Mitigation: The app requests notification permission explicitly, and manual verification covered notification delivery plus quick reply behavior.

@greptile-apps

greptile-apps Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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 gatewayshared, secrets are stored in EncryptedSharedPreferences, the phone-side proxy uses the existing NodeRuntime.operatorSession without widening its trust boundary, and the proxy/direct client interfaces are abstracted for testability.

Key findings:

  • connectionEpoch data race in WearGatewayClient — the field is modified in the coroutine scope and read from OkHttp's WebSocket callback threads without @Volatile, which can cause stale epoch checks and incorrect reconnect/disconnect behavior.
  • sideResults memory leak on session switches — clearSideResults() is only called from switchClient(), not switchSession(), so the per-session side-result map grows without bound during a long session with many switches — a meaningful concern on constrained watch hardware.
  • Migration guard partial-migration bug in WearGatewayConfig — the OR condition (secureToken != null || securePassword != null) skips migration if either secret was previously written; a partially-completed prior migration would leave the other secret in plaintext prefs indefinitely.
  • connect.challenge timeout result silently discarded — withTimeoutOrNull result is not checked, and the nonce value is not forwarded to sendConnect. If the challenge is purely a server-ready sentinel this is fine, but it should be documented to prevent future confusion.

Confidence Score: 4/5

  • Safe to merge with minor fixes recommended before release; no critical security regressions introduced.
  • The implementation is broadly correct — secrets are encrypted, proxy traffic is constrained to the existing authenticated gateway path, and the Wear Data Layer boundary is properly respected. The connectionEpoch thread-safety issue and sideResults memory growth are real bugs but are unlikely to cause data loss or security breaches in the MVP testing window. The migration guard and connect-challenge concerns are low-severity edge cases. All three client/chat test suites were added, which improves confidence significantly.
  • WearGatewayClient.kt (connectionEpoch thread safety), WearChatController.kt (sideResults growth), WearGatewayConfig.kt (migration guard logic).
Prompt To Fix All With AI
This 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

@sibbl

sibbl commented Mar 15, 2026

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@sibbl
sibbl force-pushed the codex/wearos-app branch from 6466b06 to 2f1bc4e Compare March 16, 2026 11:29
@sibbl

sibbl commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@sibbl
sibbl force-pushed the codex/wearos-app branch from 2f1bc4e to b2de9f3 Compare March 17, 2026 06:15
@obviyus obviyus self-assigned this Mar 19, 2026
@sibbl
sibbl force-pushed the codex/wearos-app branch from b2de9f3 to 04f239d Compare March 24, 2026 23:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +225 to +229
useTls = tls != null,
token = token,
bootstrapToken = bootstrapToken,
password = password,
tlsFingerprintSha256 = fingerprint,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +351 to +353
handshake.gatewayConfig?.let { syncedConfig ->
onGatewayConfigSynced(syncedConfig, handshake.tlsFingerprintSha256)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@npmisantosh

Copy link
Copy Markdown

+1. Good one. was looking to do something similar.

@sibbl
sibbl force-pushed the codex/wearos-app branch from 41f78cf to 60e7415 Compare April 6, 2026 14:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +375 to +376
acceptConnectedPhoneNode(sourceNodeId, connectionGeneration)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +166 to +170
val connectPlan = resolveConnectPlan(auth)
desiredNodeConnectAuth = connectPlan.nodeAuth
desiredOperatorConnectAuth = connectPlan.operatorAuth
shouldConnectOperator = connectPlan.connectOperator
val tls = connectionManager.resolveTlsParams(endpoint)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +530 to +534
clearPendingProbe()
phoneNodeId = null
_connected.value = false
_statusText.value = statusText
scheduleReconnect(generation = generation)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@sibbl
sibbl force-pushed the codex/wearos-app branch from 78df271 to 8bc30da Compare April 7, 2026 13:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +129 to +130
clearPendingRuns()
clearQueuedOutboundMessages()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +50 to +51
val passwordLauncher = remoteInputLauncher(PASSWORD_KEY) { value ->
onConfigChange(config.copy(password = value))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@vincentkoc vincentkoc added the stale Marked as stale due to inactivity label Apr 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member

This assigned pull request has been marked as stale after being open for 27 days.
Please add updates or it will be closed.

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 13, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 9, 2026
@sibbl

sibbl commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

When is a good time to bring the PR back alive and not have yet another PR lying around?

@steipete

Copy link
Copy Markdown
Contributor

@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:

  1. product and transport contract;
  2. shared gateway helpers;
  3. phone proxy;
  4. Wear app, tiles, and notifications.

Each stage needs module gates, license notices, and paired phone/watch proof. No more rebase churn on this branch meanwhile.

@steipete

Copy link
Copy Markdown
Contributor

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.

@steipete steipete closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. no-stale Exclude from stale automation P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants