fix(mobile): removing a saved environment from the trash button never silently no-ops #18228
main fromrefs/pull/18228/head·opened View on GitHubProblem#
Refs #12012 (maintainer triage).
The trash on a saved direct environment row calls onRemoveEnvironmentPress, which in two cases gave the user no feedback at all:
- If the environment was not found in
connectedEnvironments, the handler hit a barereturnbeforeAlert.alert, so the tap was silently dropped. - On confirm, it did
void controller.removeEnvironment(id)and discarded the result. A failed removal (for example a failed SecureStore write) only reachedconsole.warn, so "Remove" looked identical to a tap that did nothing, and the row stayed.
Fix#
apps/mobile only. The decision logic moved out of the hook into presentRemoveEnvironmentConfirm (remove-environment-confirm.ts):
- The confirm is always presented. An environment missing from the connected list is labelled by its id instead of dropping the tap. Copy and the T3 Connect "Open T3 Account" variant are unchanged.
- The removal result is no longer discarded. A failure shows "Could not remove environment" with the error message; interrupts stay quiet.
Tests (vp test run src/state/remove-environment-confirm.test.ts, 4 passing): missing environment still confirms and removes by id, relay copy, failed removal is reported, successful removal stays quiet. tsc --noEmit for apps/mobile, lint and format on the touched files are clean.
What I could and could not reproduce (iOS simulator only)#
Unmodified main (18656a3402), iPhone 17 Pro iOS 26.3 and iPhone 16 Pro iOS 18.3, isolated backend in the worktree .t3, Settings → Environments → row → trash:
- Natural flow works on current main. For a connected row and for an offline row, the native confirm does appear inside the Settings form sheet, Remove removes the row, and it is still gone after an app relaunch. So I could not reproduce the "confirm is presented but invisible behind the form sheet" theory from the triage, and I did not change how the confirm is presented. 26.3 connected, 26.3 offline, 18.3, removed + relaunch recording.
- Neither silent-drop state is reachable through the UI on this commit. The row list and the handler read the same
connectedEnvironmentsarray, and I could not make a removal fail for real. I forced each state with a temporary, uncommitted local patch (afindpredicate that never matches; aremoveEnvironmentthat returns a failure), applied identically to BEFORE and AFTER, each run from a fresh app launch. These show the code path, not the original reporter's failure.
| Forced state | Before (unmodified handler) | After (this PR) |
|---|---|---|
| Lookup miss | Tap on trash does nothing (screenshot, recording) | Confirm appears labelled with the environment id (screenshot); Remove removes it (screenshot); still gone after relaunch (screenshot, recording) |
| Removal fails | Confirm, Remove, nothing visible, row stays (screenshot, recording) | "Could not remove environment" alert, row stays (screenshot, recording) |
| Natural, no forcing (regression check) | See above | Offline direct row: trash, confirm, Remove, row gone, still gone after relaunch (recording) |
All evidence files are in this gist, not in the repository.
Not checked, and not done#
- Android (no device or emulator on this machine).
- A physical iPhone and the 2026-09-15 App Store binary. That build predates the current Environments detail screen, so the reported failure may come from the older UI, which I could not run.
- Keychain persistence across delete and reinstall. I only checked persistence across an app relaunch.
- The triage's in-tree confirm (
showConfirmDialog) and the "Forget saved environments" escape hatch in Client Storage. I left the nativeAlert.alertbecause it renders correctly in the form sheet on both iOS versions above, and the escape hatch is a separate feature. - Local build note: this machine's Xcode 27.0 SDK lacks the iOS 27.1 APIs that
T3LayoutMetricsView.swiftguards with#if compiler(>=6.4). I disabled those blocks locally to build the dev client and did not commit that.
Prior attempt#
#12730 was closed by its author with no maintainer closure comment, so I looked at its review feedback. It asked for a removal entry point for a saved environment missing from the connected list. This PR makes the existing trash always respond for such a row, but this commit has no UI that lists a saved environment outside connectedEnvironments, so I added no new entry point.
Model and harness: Claude Sonnet 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
f162c01Macroscope's review found this PR approvable — This is a localized mobile bug fix that makes an existing environment-removal action respond in stale-row and failure cases while preserving normal removal behavior. The production changes are small and focused, with targeted tests covering the added handling.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge added labelsmacroscope-review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2218e8b9-1dc8-47de-ae79-8fda3fecd9b0
📥 Commits
-
Reviewing files that changed from the base of the PR and between a9cdf03e21b93b45863d23baf9b086792f7d1df6 and f162c0180c0765823e8fe3be52f0f8dfa6d7e13e.
📒 Files selected for processing: 2
-
apps/mobile/src/state/remove-environment-confirm.tsapps/mobile/src/state/use-remote-environment-registry.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
📝 Walkthrough
-
The change adds a shared environment-removal confirmation helper and uses it in remote environment management. The helper handles missing environment details, relay-managed prompts, removal results, and failure alerts.
Changes: Environment removal confirmation
Layer / File(s) Summary Confirmation and removal behavior
apps/mobile/src/state/remove-environment-confirm.ts,apps/mobile/src/state/remove-environment-confirm.test.tsThe helper uses the trimmed environment label or falls back to its ID. It presents different prompts for relay-managed and other environments, and reports failed removal results. Tests cover missing environment details, relay-managed messaging, and removal outcomes. Remote registry integration
apps/mobile/src/state/use-remote-environment-registry.tsRemote environment management delegates confirmation to the helper and passes the optional matching environment, removal callback, account navigation callback, and alert function. Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
f162c-
The change makes removing a saved environment always show a confirmation and report real failures, with no actionable merge risk found.
Security architecture risk: ⚪ Minimal · up to
f162c-
The change improves confirmation and failure feedback without expanding removal privileges. The existing registry still validates the selected environment and controls cleanup; account deregistration remains a separate action.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- observed — The inspected production path starts from a rendered environment row and targets that environment's local registration and associated cleanup. The new helper does not itself gain account-management or remote-host deletion authority.
Trust Boundaries and Controls
- observed — Removing the connected-summary prerequisite does not remove the authoritative registry checks. Platform-managed environments remain protected, and an unregistered ID fails lookup before deletion. Cancel has no removal callback.
Resilience and Maintainability Implications
- observed — Existing removal is not transactional across registration, runtime state, and downstream cleanup: a later cleanup failure can follow visible removal, and repetition can return a not-registered error. These limitations predate this PR. The change exposes ordinary failure results without changing cleanup ordering or adding rollback.
-
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly identifies the mobile bug and the primary fix: removing a saved environment no longer silently does nothing. Description check The description clearly explains the problem, fix, scope, linked triage, verification results, UI evidence, and limitations. It uses a "Fix" heading instead of the template's "Change" heading, but the… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description clearly explains the problem, fix, scope, linked triage, verification results, UI evidence, and limitations. It uses a "Fix" heading instead of the template's "Change" heading, but the required information is present and complete.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
claude-opus-5-5on behalf of MariaThanks for this. I'm closing it as part of PR triage. We couldn't confirm a bug that users actually hit here.
From the review: Trash rows and removal lookup use the same environment list. The added tests inject missing entries and storage failures without establishing a failure through the normal removal flow.
If you think this was a mistake, message me on Twitter at @maria_rcks and I'll take another look.
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed