Skip to content

Refresh miniapp capabilities after pairing - #3687

Open
aisraelov wants to merge 5 commits into
stagingfrom
aisraelov/fix-slack-reported-bug
Open

Refresh miniapp capabilities after pairing#3687
aisraelov wants to merge 5 commits into
stagingfrom
aisraelov/fix-slack-reported-bug

Conversation

@aisraelov

@aisraelov aisraelov commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

  • refresh connected miniapp capability snapshots whenever pairing changes the selected wearable
  • resolve the CONNECT_ACK capability profile after asynchronous auth completes
  • preserve an explicit hasDisplay: false in Mentra Maps capability normalization
  • bump and bundle Mentra Maps 1.1.30

Root cause

Prod report rep_01KZA6T034CWQDMHGWGMQ1PZ8Y shows Mentra Maps connecting while default_wearable was still Simulated Glasses. G2 was promoted about 816 ms after CONNECT, but the local runtime only sent capabilities in CONNECT_ACK and never sent CAPABILITIES_UPDATE. The miniapp therefore kept the simulated/basic display profile even though the phone build already defined G2 with display.canPosition: true.

This replaces the compatibility workaround from #3686 with capability lifecycle synchronization; it does not hardcode behavior by model name.

Context: https://mentra-labs.slack.com/archives/C0A8015JBPT/p1785975342337889

Validation

  • cd miniapps/navigation && bun test — 86 passed
  • cd mobile && bun run test --runInBand src/services/__tests__/localMiniappCapabilities.test.ts src/services/__tests__/localMiniappButtonSubscriptions.test.ts — 2 passed
  • cd mobile && bun run compile
  • focused ESLint on the changed runtime and test — no errors (one existing import warning)
  • packed and verified bundled Mentra Maps 1.1.30

Follow-up to #3682 and #3686.


Summary by cubic

Keeps miniapp capabilities in sync with wearable pairing and hardens CONNECT/AUTH flows against races and stale retries, including crash-respawn resets. Fixes Mentra Maps display detection and bundles com.mentra.navigation 1.1.30.

  • Bug Fixes

    • Push CAPABILITIES_UPDATE when defaultWearable changes; stop listening when no apps are connected.
    • Resolve CONNECT_ACK after async auth. Bind initial AUTH retries to the current handshake and clear stale timers; ignore stale CONNECTs and drop late auth after respawn/reset.
    • In Mentra Maps, treat hasDisplay: false as authoritative; canPosition stays off without a display or with a legacy descriptor.
  • Dependencies

    • Bundle com.mentra.navigation-1.1.30.zip and update bundledMiniapps.ts.

Written for commit ff333d4. Summary will update on new commits.

Review in cubic


Note

Medium Risk
Changes the local miniapp CONNECT/auth lifecycle and live capability delivery, which affects every miniapp session, but behavior is covered by new focused tests and is narrowly scoped to pairing races and respawn safety.

Overview
Fixes miniapps (notably Mentra Maps) keeping a stale simulated/basic display profile when G2 is promoted shortly after CONNECT.

Local miniapp runtime now resolves CONNECT_ACK capabilities after async auth (not at CONNECT start) and broadcasts CAPABILITIES_UPDATE to all handshook sessions when defaultWearable changes, with the subscription torn down when no apps are connected. Handshake generation invalidates stale async CONNECT completions, initial AUTH retries, and late mints after crash-respawn/resetHandshake.

Mentra Maps treats explicit hasDisplay: false as authoritative so a legacy display descriptor cannot re-enable HUD positioning. Ships 1.1.30 in the app bundle.

Reviewed by Cursor Bugbot for commit ff333d4. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📋 PR Review Helper

📱 Mobile App Build

Ready to test! (commit ff333d4)

📥 Download APK

🕶️ ASG Client Build

Waiting for build...


🔀 Test Locally

gh pr checkout 3687

@aisraelov
aisraelov marked this pull request as ready for review August 6, 2026 01:55
@aisraelov
aisraelov requested a review from isaiahb as a code owner August 6, 2026 01:55

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="mobile/src/services/__tests__/localMiniappCapabilities.test.ts">

<violation number="1" location="mobile/src/services/__tests__/localMiniappCapabilities.test.ts:46">
P3: Consider adding coverage for the two remaining behaviors this PR changed: the hasDisplay:false / display.canPosition:false normalization for a display-less wearable, and that CAPABILITIES_UPDATE stops being emitted (unsubscribe) once the last miniapp is unregistered. The current test only exercises the positive display-capable path.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread mobile/modules/engine/src/services/LocalMiniappRuntime.ts
sent.length = 0
setDefaultWearable(DeviceTypes.G2)

const update = payloads().find((payload) => payload.type === MiniappResponseType.CAPABILITIES_UPDATE)

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.

P3: Consider adding coverage for the two remaining behaviors this PR changed: the hasDisplay:false / display.canPosition:false normalization for a display-less wearable, and that CAPABILITIES_UPDATE stops being emitted (unsubscribe) once the last miniapp is unregistered. The current test only exercises the positive display-capable path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At mobile/src/services/__tests__/localMiniappCapabilities.test.ts, line 46:

<comment>Consider adding coverage for the two remaining behaviors this PR changed: the hasDisplay:false / display.canPosition:false normalization for a display-less wearable, and that CAPABILITIES_UPDATE stops being emitted (unsubscribe) once the last miniapp is unregistered. The current test only exercises the positive display-capable path.</comment>

<file context>
@@ -0,0 +1,65 @@
+    sent.length = 0
+    setDefaultWearable(DeviceTypes.G2)
+
+    const update = payloads().find((payload) => payload.type === MiniappResponseType.CAPABILITIES_UPDATE)
+    expect(update?.capabilities).toMatchObject({
+      modelName: DeviceTypes.G2,
</file context>

Comment thread mobile/src/services/__tests__/localMiniappCapabilities.test.ts

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread mobile/modules/engine/src/services/LocalMiniappRuntime.ts Outdated

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread mobile/modules/engine/src/services/LocalMiniappRuntime.ts
Comment thread mobile/src/services/__tests__/localMiniappCapabilities.test.ts

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread mobile/modules/engine/src/services/LocalMiniappRuntime.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant