The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(mobile): removing an environment drops its threads from Android launcher shortcuts (#33726)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Victor committed
Nov 14, 2026 at 11:31 UTC
fa4f6441a6655ef54d715fc847bd4c3b4ea4d2f0
2 files changed
+39
-2
apps/mobile/src/features/shortcuts/appShortcutsRuntime.test.ts
+18
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vite-plus/test";
2
3
vi.mock("expo-quick-actions", () => ({}));
4
vi.mock("react-native", () => ({ Platform: { OS: "android" } }));
5
+vi.mock("../../connection/catalog", () => ({}));
6
vi.mock("../../persistence/imperative", () => ({}));
7
vi.mock("../../state/atom-registry", () => ({}));
8
vi.mock("../../state/threads", () => ({ environmentThreadShells: {} }));
@@ -54,6 +55,23 @@ describe("createRecentThreadShortcuts", () => {
55
expect(save).toHaveBeenLastCalledWith([thread("a")]);
56
});
57
58
+ it("drops threads of environments that are no longer saved", async () => {
59
+ const gone = { environmentId: "gone", threadId: "b", title: "b" };
60
+ const kept = { environmentId: "kept", threadId: "c", title: "c" };
61
+ const { save, publish, recents } = setup(() => Promise.resolve([thread("a"), gone, kept]));
62
+ recents.retainEnvironments(new Set(["env", "kept"]));
63
+ await recents.loaded;
64
+ expect(publish).toHaveBeenLastCalledWith([thread("a"), kept]);
65
+
66
+ recents.retainEnvironments(new Set(["kept"]));
67
+ await recents.saved();
68
+ expect(publish).toHaveBeenLastCalledWith([kept]);
69
+ expect(save).toHaveBeenLastCalledWith([kept]);
70
+
71
+ recents.recordActiveThread(thread("a"));
72
+ expect(publish).toHaveBeenLastCalledWith([kept]);
73
+ });
74
+
75
it("records title changes of the open thread and ignores repeats", async () => {
76
const { publish, recents } = setup(() => Promise.resolve([]));
77
await recents.loaded;
apps/mobile/src/features/shortcuts/appShortcutsRuntime.ts
+21
-2
@@ -4,6 +4,7 @@ import type { NavigationState } from "@react-navigation/native";
4
import type { ScopedThreadRef } from "@t3tools/contracts";
5
import { Atom } from "effect/reactivity";
6
7
+import { environmentCatalog } from "../../connection/catalog";
8
import {
9
loadRecentThreadShortcuts,
10
saveRecentThreadShortcuts,
@@ -34,6 +35,7 @@ export function createRecentThreadShortcuts(dependencies: RecentThreadShortcutsD
35
let recents: ReadonlyArray<RecentThreadShortcut> | null = null;
36
let persistable = false;
37
let active: RecentThreadShortcut | null = null;
38
+ let savedEnvironmentIds: ReadonlySet<string> | null = null;
39
// Serialize saves so older lists cannot overwrite newer ones.
40
let saveQueue: Promise<unknown> = Promise.resolve();
41
@@ -53,8 +55,11 @@ export function createRecentThreadShortcuts(dependencies: RecentThreadShortcutsD
55
});
56
};
57
58
+ const isSaved = (thread: RecentThreadShortcut) =>
59
+ savedEnvironmentIds?.has(thread.environmentId) ?? true;
60
+
61
const withActive = (list: ReadonlyArray<RecentThreadShortcut>) => {
57
- if (active === null) return list;
62
+ if (active === null || !isSaved(active)) return list;
63
const next = withRecentThreadShortcut(list, active);
64
if (next !== list) persistable = true;
65
return next;
@@ -63,7 +68,7 @@ export function createRecentThreadShortcuts(dependencies: RecentThreadShortcutsD
68
const loaded = dependencies.load().then(
69
(threads) => {
70
persistable = true;
66
- commit(withActive(threads));
71
+ commit(withActive(threads.filter(isSaved)));
72
},
73
(error: unknown) => {
74
console.warn("[app-shortcuts] failed to load recent threads", error);
@@ -81,6 +86,12 @@ export function createRecentThreadShortcuts(dependencies: RecentThreadShortcutsD
86
const updated = withActive(recents);
87
if (updated !== recents) commit(updated);
88
},
89
+ retainEnvironments(next: ReadonlySet<string>): void {
90
+ savedEnvironmentIds = next;
91
+ if (recents === null) return;
92
+ const kept = recents.filter(isSaved);
93
+ if (kept.length !== recents.length) commit(kept);
94
+ },
95
};
96
}
97
@@ -142,8 +153,16 @@ export function installAppShortcuts(navigate: (href: string) => void): () => voi
153
(active) => recents.recordActiveThread(active),
154
{ immediate: true },
155
);
156
+ const unsubscribeCatalog = appAtomRegistry.subscribe(
157
+ environmentCatalog.catalogValueAtom,
158
+ (catalog) => {
159
+ if (catalog.isReady) recents.retainEnvironments(new Set(catalog.entries.keys()));
160
+ },
161
+ { immediate: true },
162
+ );
163
return () => {
164
subscription.remove();
165
unsubscribe();
166
+ unsubscribeCatalog();
167
};
168
}