Skip to content

[Bug]: Mobile settings forget a selected environment while it is disconnected #38195

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. Open the T3 mobile app with no environments connected.
  2. On four other computers, run T3 and name those environments A, B, C, and D. Leave all four running, and keep each connect address and code.
  3. In the app, open Settings, then Environments, then Add environment. Enter A's address and code, tap Add environment, and wait until A shows connected.
  4. Add environment B the same way and wait until it shows connected.
  5. Add environment C the same way and wait until it shows connected.
  6. Add environment D the same way and wait until it shows connected.
  7. Go back to Settings. Tap the button labeled Filter settings environments and projects, open the environments section, and tap C so its check turns off.
  8. Open that filter again and tap D so its check turns off. A and B stay checked.
  9. Open Environments and turn off the switch labeled Enable B.
  10. Go back to Settings, open the filter, and wait until B is no longer listed. A stays checked, and C and D stay unchecked.
  11. In that filter, tap C so its check turns on. Leave D unchecked.
  12. Open Environments and turn the switch Enable B back on. Wait until B shows connected.
  13. Go back to Settings and open the filter's environments section.

Expected behavior

A, B, and C are checked. D is unchecked. The environments section is titled 3 environments.

Actual behavior

A and C are checked. B and D are unchecked. The environments section is titled 2 environments.

Start: no environments

A, B, C and D connected

Filter with A and B checked

B switched off

Filter while B is off

B connected again

Final filter environments section

Impact

Major degradation or frequent failure. People managing multiple environments lose an existing selection whenever they toggle another environment while a selected one is temporarily disconnected and at least one connected environment remains excluded.

Version or commit

main at e9b48b7809. The cause is at apps/mobile/src/features/settings/settings-environment-filter.logic.ts:9.

Environment

Pixel_9_API_37, Android 17.0.

Logs or stack traces

AssertionError: expected [ 'a', 'c' ] to deeply equal [ 'a', 'b', 'c' ]
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/apps/mobile/src/features/settings/settings-environment-filter.logic.test.ts b/apps/mobile/src/features/settings/settings-environment-filter.logic.test.ts
new file mode 100644
index 0000000000..5577960917
--- /dev/null
+++ b/apps/mobile/src/features/settings/settings-environment-filter.logic.test.ts
@@ -0,0 +1,24 @@
+import { EnvironmentId } from "@t3tools/contracts";
+import { describe, expect, it } from "vite-plus/test";
+
+import { toggleSettingsEnvironment } from "./settings-environment-filter.logic";
+
+describe("settings environment selection", () => {
+  it("keeps a selected offline environment when toggling another connected environment", () => {
+    const a = EnvironmentId.make("a");
+    const b = EnvironmentId.make("b");
+    const c = EnvironmentId.make("c");
+    const d = EnvironmentId.make("d");
+    const all = [a, b, c, d].map((environmentId) => ({ environmentId }));
+    const withoutC = toggleSettingsEnvironment(null, all, c);
+    const selected = toggleSettingsEnvironment(withoutC, all, d);
+    expect(selected).toEqual(new Set([a, b]));
+
+    const connected = all.filter((entry) => entry.environmentId !== b);
+    const next = toggleSettingsEnvironment(selected, connected, c);
+    const reconnectedTargets = all.filter(
+      (entry) => next === null || next.has(entry.environmentId),
+    );
+    expect(reconnectedTargets.map((entry) => entry.environmentId)).toEqual([a, b, c]);
+  });
+});
cd apps/mobile && pnpm exec vp test run src/features/settings/settings-environment-filter.logic.test.ts

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions