Skip to content

feat(android): adopt device chat session on connect#101927

Closed
snowzlmbot wants to merge 5 commits into
openclaw:mainfrom
snowzlmbot:android-app-dedicated-session-pr
Closed

feat(android): adopt device chat session on connect#101927
snowzlmbot wants to merge 5 commits into
openclaw:mainfrom
snowzlmbot:android-app-dedicated-session-pr

Conversation

@snowzlmbot

@snowzlmbot snowzlmbot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Related: #45854

What Problem This Solves

Android already isolates each device on a stable agent:<agent>:node-<device> chat key, but the app did not explicitly create/adopt that session before connected history loaded. A new installation could read history before the app-owned session was ready, while renaming the key would strand existing Android conversations.

Why This Change Was Made

  • keep the shipped node-<device> key so upgrades retain existing history and context
  • derive a device-unique OpenClaw App · <device> · <id> label
  • describe and create/adopt the same explicit key before connected history can load
  • patch metadata non-destructively when an existing upgrade session lacks a label
  • serialize readiness per gateway and make reconnect, agent-switch, refresh, and deleted-session paths wait for the current adoption
  • preserve a user-customized existing label and recreate a deleted session on reconnect
  • keep unread acknowledgement intact when agent selection prepares the app-owned session
  • remove the proposed 257-line manual emulator workflow from the product diff

The Gateway's explicit-key sessions.create path preserves an existing session ID/transcript. The final implementation therefore adopts the established key rather than migrating to openclaw-app-*.

User Impact

Android users keep their existing device-specific conversation across upgrades. New and reconnected app sessions are ready before history loads, receive a recognizable device-unique label, and retain correct unread state across agent switches.

Evidence

  • exact-head hosted CI is required for final head 04e7d30cfabc; prior-head Android Play/third-party tests, ktlint, native-i18n, and repository lint passed
  • focused regressions cover create-before-history ordering, metadata-only labeling, adoption failure fallback, reconnect revalidation, custom-label preservation, deleted-session recreation, agent-switch supersession, stale-transport cancellation/retry, reconnect readiness, and unread acknowledgement
  • Gateway sessions.create implementation and tests inspected: an existing explicit key keeps its session ID/transcript while applying metadata
  • structured autoreview is clean after fixing the existing-unlabeled metadata path and stale-transport reconnect ownership
  • the contributor's earlier emulator artifact demonstrated the end-to-end sessions.create then chat.history integration shape

Evidence Source Map

Risk

Bounded to Android chat connection/session lifecycle. Adoption failures remain non-blocking so older or temporarily unavailable Gateways still load history under the already-bound key. The existing key and transcript are unchanged.

Rollback

Revert this PR to stop explicit readiness/adoption; the existing node-* session and history remain intact.

Docs Updated

  • apps/android/README.md
  • apps/android/CHANGELOG.md

Release note: create/adopt Android's existing per-device chat session before history loads, preserving prior conversations and unread state. Thanks @snowzlmbot.

@snowzlmbot

Copy link
Copy Markdown
Contributor Author

Ready for review. The PR body includes the passing GitHub Actions run, Android emulator media artifact, and captured sessions.create payload.

@clawsweeper review-pr

@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 12, 2026, 3:44 AM ET / 07:44 UTC.

Summary
The PR makes Android describe and create or adopt its stable device-scoped chat session before connected history loads, adding device labeling and reconnect, agent-switch, and unread-state coordination.

PR surface: Docs +2, Other +533. Total +535 across 8 files.

Reproducibility: yes. at the exact-head source and focused-test level. Leave the first session describe pending, switch to a second session, and this branch incorrectly expects zero history calls even though the newest session should proceed after creation.

Review metrics: none identified.

Root-cause cluster
Relationship: superseded
Canonical: #105115
Summary: The maintainer-owned replacement carries the same implementation with the corrected latest-session regression, but is not yet proof-positive enough to justify closing this source PR.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Use the canonical replacement’s corrected latest-session regression and obtain green exact-head Android checks.
  • Attach redacted final-head emulator proof or a Gateway trace showing latest-key adoption before history while preserving transcript and unread state.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The linked emulator artifact demonstrates an earlier implementation shape, not the final existing-key describe/adopt flow; add a redacted final-head emulator recording or Gateway trace, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] Merging this head leaves a regression test with the wrong session-readiness invariant and failing Android validation.
  • [P1] Session adoption is upgrade-sensitive: incorrect gateway or readiness ownership could load history under a stale key or disturb existing transcripts, custom labels, and unread state.
  • [P1] Closing now would depend on an open replacement that has not yet demonstrated the final flow with redacted exact-head emulator or Gateway-trace proof.

Maintainer options:

  1. Finish the canonical replacement (recommended)
    Require green exact-head Android checks and final-head runtime proof on the corrected replacement before closing this PR.
  2. Repair this branch if needed
    If the replacement ceases to be viable, update this branch’s stale-adoption assertion to validate latest-session ordering and targeting, then rerun the same proof gates.
  3. Pause both branches
    Keep both unmerged if the final adoption flow cannot be proven without upgrade or session-state regressions.

Next step before merge

  • [P1] The narrow correction already exists on the protected replacement, so maintainers should validate that canonical branch rather than dispatch another repair for this divergent shadow ref.

Security
Cleared: The Android runtime, tests, docs, and generated i18n changes add no concrete dependency, permission, secret, package, download, or supply-chain concern.

Review findings

  • [P2] Allow the latest session to proceed past stale adoption — apps/android/app/src/test/java/ai/openclaw/app/chat/ChatControllerReconnectRestoreTest.kt:230
Review details

Best possible solution:

Validate and land the replacement’s corrected latest-session invariant with green exact-head Android checks and redacted final-head emulator or Gateway-trace proof, then close this divergent branch as superseded while preserving contributor credit.

Do we have a high-confidence way to reproduce the issue?

Yes at the exact-head source and focused-test level. Leave the first session describe pending, switch to a second session, and this branch incorrectly expects zero history calls even though the newest session should proceed after creation.

Is this the best way to solve the issue?

No for this exact branch: the runtime ownership and Gateway API direction are appropriate, but the regression assertion encodes the wrong behavior. The replacement’s latest-session-specific assertion is the narrow correction.

Full review comments:

  • [P2] Allow the latest session to proceed past stale adoption — apps/android/app/src/test/java/ai/openclaw/app/chat/ChatControllerReconnectRestoreTest.kt:230
    This assertion treats the stale session as a global blocker: after selecting the second session, its create has completed and its history request should proceed even while the first describe remains pending. The runtime does that, so assertEquals(0, ...) fails; assert that history follows the second session’s create and targets only the second key, as the replacement does.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0b30a3292f70.

Label changes

Label justifications:

  • P2: The change affects Android chat continuity and reconnect behavior with meaningful but platform-limited impact.
  • merge-risk: 🚨 compatibility: The adoption path must preserve shipped device keys, existing transcripts, and user-customized labels across upgrades.
  • merge-risk: 🚨 session-state: Incorrect readiness ownership can block or mis-order the newest session’s history and unread acknowledgement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The linked emulator artifact demonstrates an earlier implementation shape, not the final existing-key describe/adopt flow; add a redacted final-head emulator recording or Gateway trace, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Docs +2, Other +533. Total +535 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 2 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 6 562 29 +533
Total 8 564 29 +535

What I checked:

Likely related people:

  • steipete: Assigned this PR, authored its current commits, and opened the protected replacement containing the corrected latest-session regression. (role: recent area contributor and replacement author; confidence: high; commits: 7ee122814f2e, 3066f62df9c5, 13ce6b8cdec8; files: apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt, apps/android/app/src/test/java/ai/openclaw/app/chat/ChatControllerReconnectRestoreTest.kt)
  • lixuankai: Authored the merged work that established the stable per-device Android session key retained and adopted by this change. (role: introduced device-scoped Android sessions; confidence: high; commits: f0a57fad42e1; files: apps/android/app/src/main/java/ai/openclaw/app/SessionKey.kt, apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (8 earlier review cycles)
  • reviewed 2026-07-08T01:10:15.898Z sha 4ff7b98 :: found issues before merge. :: [P1] Scope session-create success to the connected gateway
  • reviewed 2026-07-08T01:19:16.467Z sha 209bafe :: needs changes before merge. :: [P1] Scope session-create success to the connected gateway
  • reviewed 2026-07-08T02:09:17.564Z sha cb1d8f1 :: needs changes before merge. :: [P1] Scope session-create success to the connected gateway
  • reviewed 2026-07-08T02:19:19.227Z sha cb1d8f1 :: needs changes before merge. :: [P1] Scope session creation to the connected gateway
  • reviewed 2026-07-09T14:14:38.859Z sha 9e1c569 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T06:56:39.259Z sha 47cc3e8 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T07:07:41.055Z sha 44f8264 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-12T07:36:27.544Z sha 04e7d30 :: needs real behavior proof before merge. :: [P2] Allow the latest session to proceed past stale adoption

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Jul 8, 2026
@snowzlmbot
snowzlmbot force-pushed the android-app-dedicated-session-pr branch 3 times, most recently from fb9c98f to 9e1c569 Compare July 9, 2026 13:47
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 9, 2026
@steipete steipete self-assigned this Jul 12, 2026
@steipete
steipete force-pushed the android-app-dedicated-session-pr branch from 9e1c569 to 2b3f4ad Compare July 12, 2026 06:40
@steipete steipete changed the title feat(android): bind app chat to a dedicated session feat(android): adopt device chat session on connect Jul 12, 2026
@steipete
steipete force-pushed the android-app-dedicated-session-pr branch 2 times, most recently from 9d534c0 to 47cc3e8 Compare July 12, 2026 06:49
@clawsweeper clawsweeper Bot removed the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Jul 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Jul 12, 2026
@steipete
steipete force-pushed the android-app-dedicated-session-pr branch from 47cc3e8 to 44f8264 Compare July 12, 2026 06:58
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 12, 2026
@steipete
steipete force-pushed the android-app-dedicated-session-pr branch from 44f8264 to 978dcef Compare July 12, 2026 07:20
@steipete
steipete force-pushed the android-app-dedicated-session-pr branch from 04e7d30 to ef0a577 Compare July 12, 2026 08:07
@steipete

steipete commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Thanks @snowzlmbot — this work is now landed through the canonical replacement PR #105115 as commit 448b90a.

GitHub's maintainer-edit shadow ref for this fork diverged from the branch ref, so the final reviewed fixups could not be made to reach this PR head reliably. The replacement preserves your contributor credit with a Co-authored-by trailer and adds the reconnect/readiness coverage needed for landing.

A final race hardening follow-up also landed in #105144 as commit d31eeea: session bootstrap now uses an atomic label-only patch so concurrent identity fields cannot be overwritten.

Closing this PR as superseded. For future fork PRs, keeping Allow edits by maintainers enabled helps avoid this path; if GitHub's shadow ref still diverges, recreating the branch may be necessary.

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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants