fix(mobile): live activity toggle no longer re-links saved environments#32779

open2
main
GitHub fork: fix/mobile-live-activity-relink
opened3d agobyDDeji-Techh
View on GitHubTwo-way sync enabledPR last imported 12h ago

Problem

Turning Live Activity Updates (iOS) or Ongoing Agent Activity (Android) on in Settings → Notifications fails on every device with:

Ongoing activity unavailable Could not obtain environment link proof: Invalid managed endpoint origin.

The toggle re-linked every saved environment that grants relay:write through the host's POST /api/connect/link-proof. Since #19271, that endpoint signs a proof only when the request arrives on the loopback origin it names (the WSL desktop-bootstrap session is the sole exception). A phone reaches the host over the LAN, Tailscale, or the T3 Connect tunnel, so the proof is always refused and the whole toggle rolls back.

Reproduced on this machine with the Android app: the host logged two POST http://192.168.0.196:3773/api/connect/link-proof requests from the phone (okhttp, 400) at 02:30:57 and 02:31:51, each failing in environment.cloud.makeLinkProof with CloudLinkOriginInvalidError: Invalid managed endpoint origin. The desktop app on the host succeeded over 127.0.0.1:3773 in the same window.

Change

The toggle now only updates this device's relay registration preference and no longer links environments from the phone:

  • The relay already decides Live Activity and ongoing-activity delivery per device from that preference.
  • Every desktop, web, and CLI link already enables activity updates for the environment (liveActivitiesEnabled: true), so the phone relink was redundant.
  • Removed the mobile environment-link module and its tests, the liveActivityPreferences wrapper, refreshManagedRelayEnvironments, and the Clerk token / relay:write plumbing in the settings screen.
  • Android registrations now apply the new native activity configuration before the relay write and restore the stored configuration if the permission lookup, preference update, or relay write fails, unless a newer registration has configured the device since.

The server's loopback-only link-proof check is unchanged. This follows the direction in #27412 and is the mobile counterpart to #32426's clearer message for remote desktop clients.

Scope and approval

Fixes pingdotgg/t3code#27412

This is @juliusmarminge's #27432 rebased onto current main after it went conflicting (DIRTY). The only substantive adjustment is a typing fix for the newer Effect version on main (Effect.onError cleanup inference in remoteRegistration.ts). If you would rather land the original branch, close this and rebase #27432 instead.

Verification

  • pnpm --filter @t3tools/mobile typecheck: exits 0. Only the pre-existing effect(schemaClassMissingBrand) suggestions remain.
  • Mobile unit suite: 281 test files, 3309 tests pass.
  • vp test run src/features/agent-awareness/remoteRegistration.test.ts: 17 passed.
  • vp fmt --check and vp lint on the changed files pass.
  • Not checked on a physical device: enabling still needs a signed-in T3 Connect account, which this machine does not have. The dialog text changes were not captured, and the pre-commit knip task could not run here because only the mobile dependency graph is installed (it fails resolving untouched apps/web and apps/marketing configs); CI covers it.

AI-assisted: diagnosed from the host's server trace for the real failing request, then rebased and re-verified locally.

Checks

21 successful · 10 skipped
All checks passed
30747bd

Added 1 commit

  • fix(mobile): live activity toggle no longer re-links saved environments799f229
Synced from GitHub
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code Review✅ Completed 2026-11-08T02:06:28.214218Z799f229PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Synced from GitHub

Approvability

Verdict: Approved at 799f229

Macroscope's review found this PR approvable — The activity toggle now changes only this device's preference instead of re-linking saved environments. Android failure recovery restores prior native settings, keeping the change bounded without altering product defaults or access permissions.

You can add or adjust custom eligibility rules. Learn more.

Cchatgpt-codex-connectorBotreviewed · 1 inline thread3d ago
Synced from GitHub

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 799f229f48

ℹ️ 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".

……@@ -273,31 +242,9 @@ function ConfiguredSettingsNotificationsRouteScreen() {
298- clerkToken: tokenResult.value,
299- connections,
300- }),
247+ updateAgentAwarenessRegistrationPreferences({ liveActivitiesEnabled: true }),

P2 Badge Restore legacy environment opt-ins when enabling

When an upgraded device has a relay link whose liveActivitiesEnabled was set to false by an older mobile version, this path updates only the device registration. The relay still filters out activities for that environment in AgentActivityRows.listForUser, so the toggle can report success while no activities arrive until the link is re-enabled elsewhere. Preserve a reset or migration path for those legacy link preferences.

AGENTS.md reference: AGENTS.md:L75-L75

Useful? React with 👍 / 👎.

Synced from GitHub

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The mobile Live Activity toggle now updates device registration preferences without relinking saved environments. Android registration configures notification preferences before push-token lookup and conditionally restores prior preferences after errors.

Changes: Live Activity preference flow

Layer / File(s)Summary
Direct device preference updates
apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx, apps/mobile/src/features/agent-awareness/liveActivityPreferences.ts, apps/mobile/src/features/agent-awareness/liveActivityPreferences.test.ts, apps/mobile/src/features/cloud/linkEnvironment.ts, apps/mobile/src/features/cloud/linkEnvironment.test.ts, apps/mobile/src/features/cloud/managedRelayState.ts
The settings screen updates the device registration preference when enabling or disabling Live Activity updates. It uses updating status in place of linking. The previous environment-linking workflow, related tests, and managed-relay refresh helper are removed.
Guarded Android preference restoration
apps/mobile/src/features/agent-awareness/remoteRegistration.ts, apps/mobile/src/features/agent-awareness/remoteRegistration.test.ts
Android notification preferences are configured before push-token lookup. Errors restore stored preferences only when the registration generation and configuration-write counter are still current. Tests cover relay and permission failures, plus a newer update following an older failed request.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Possibly related issues

  • Issue 31534 — Reports a mobile Live Activity toggle failure during environment linking. This change removes that relinking step from the toggle flow.
  • Issue 31753 — Reports the preference reverting after disabling. This change updates the device registration preference without relinking environments.

Possibly related PRs

  • pingdotgg/t3code#32469 — Both changes address mobile agent-awareness preference updates and registration sequencing.
  • pingdotgg/t3code#27432 — Both changes remove phone-side environment relinking and update the device preference directly.
  • pingdotgg/t3code#32592 — Both changes modify the mobile notification settings flow and Live Activity update operation.

Suggested reviewers: juliusmarminge, pixpmusic

Merge Risk: External image Minimal · up to 30747

The Live Activity toggle now updates the device registration preference directly instead of relinking saved environments. No actionable merge-blocking risk was found, though the change was not verified on a physical device.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title is concise, uses the required conventional format, and clearly describes the main change: the mobile Live Activity toggle no longer re-links saved environments.
Description checkPassedThe description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the failure, implementation, linked issue, test results, and known verification limits. It…
Linked Issues checkPassedIssue [#27412] requires the mobile Live Activities toggle to work without obtaining a new environment link proof. The settings screen now updates only the device relay registration preference. It no l…
Out of Scope Changes checkPassedThe changes stay within issue [#27412]. The deleted link modules, tests, managed-relay refresh, and settings authentication plumbing remove the phone-side relinking that caused the failure. The settin…
Full details: Description check

Explanation

The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the failure, implementation, linked issue, test results, and known verification limits. It also states that physical-device testing and UI screenshots were not completed.

Full details: Linked Issues check

Explanation

Issue [#27412] requires the mobile Live Activities toggle to work without obtaining a new environment link proof. The settings screen now updates only the device relay registration preference. It no longer reads a Clerk token or calls the mobile environment-link flow. The removed flow included the phone-side link-proof request. The server loopback-only check remains unchanged because no server file changed. Android registration now applies activity configuration before the relay write and restores the stored configuration on failure. New tests cover relay failure, permission lookup failure, and stale concurrent registration. The reported typecheck and mobile test suite pass. The relay implementation is outside this repository, so end-to-end delivery cannot be independently verified here, but the required mobile code path is implemented.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue [#27412]. The deleted link modules, tests, managed-relay refresh, and settings authentication plumbing remove the phone-side relinking that caused the failure. The settings screen changes update the device preference directly. The Android registration ordering and rollback changes support the same toggle and include focused tests. The Effect typing adjustment supports the changed registration code on the current main branch. No unrelated feature or server security change is demonstrated.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between 799f229f48012431138f1752af092d99e21074e0 and 30747bd36b9f464513dd30cf62a1b64dc27144f3.

External image Files selected for processing: 2

  • apps/mobile/src/features/agent-awareness/remoteRegistration.test.ts
  • apps/mobile/src/features/agent-awareness/remoteRegistration.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Added 1 commit

  • Merge remote-tracking branch 'origin/main' into fix/mobile-live-activity-relink30747bd

The automated pipeline stopped on this pull request and will not merge it:

the proof has no capture anyone can open:

  • Permanent blocker: T3 Connect is unavailable on this VM, preventing the required signed-in, already-linked-host starting state.
  • Base toggle rollback and the reported invalid managed endpoint origin error were not observed.
  • Head enable/disable persistence and absence of another environment link-proof request were not observed.
  • No captures exist and no ghdrop upload was attempted; no public evidence URLs are available.

It stays open for a person to finish or close.