The best way to control Claude Code, Codex and more from any computer or phone
revert(web): working threads stay in the Working shelf when their environment disconnects (#31269)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 4, 2026 at 19:22 UTC
34701646e39077be00302a7fd66a12a96e2fcf37
4 files changed
+2
-86
apps/web/src/components/Sidebar.logic.test.ts
-34
@@ -11,8 +11,6 @@ import {
11
getFallbackThreadIdAfterDelete,
12
hasUnseenCompletion,
13
resolveSidebarRowThreadId,
14
- belongsInSidebarWorkingShelf,
15
- isSidebarEnvironmentDisconnected,
14
orderItemsByPreferredIds,
15
pinOrderKeyBetween,
16
resolveSidebarSweepKeys,
@@ -1010,38 +1008,6 @@ describe("Working shelf (beta)", () => {
1008
).toBe(false);
1009
});
1010
1013
- it.each([
1014
- ["connected", true, false],
1015
- ["connected", false, true],
1016
- ["connecting", false, false],
1017
- ["reconnecting", false, true],
1018
- ["offline", false, true],
1019
- ["error", false, true],
1020
- ["unsupported", false, true],
1021
- ["available", false, true],
1022
- ] as const)(
1023
- "lists threads outside the shelf on a %s environment: %s",
1024
- (phase, shellIsLive, disconnected) => {
1025
- expect(isSidebarEnvironmentDisconnected(phase, shellIsLive)).toBe(disconnected);
1026
- },
1027
- );
1028
-
1029
- it("lists a running thread outside the shelf while its environment is disconnected", () => {
1030
- const thread = { ...idle, runtime, environmentId: localEnvironmentId };
1031
- const shelve = (disconnected: ReadonlyArray<EnvironmentId>, enabled = true) =>
1032
- belongsInSidebarWorkingShelf(thread, {
1033
- enabled,
1034
- disconnectedEnvironmentIds: new Set(disconnected),
1035
- isWorking: isSidebarThreadWorking,
1036
- });
1037
-
1038
- expect(shelve([])).toBe(true);
1039
- expect(shelve([localEnvironmentId])).toBe(false);
1040
- expect(shelve([])).toBe(true);
1041
- expect(shelve([EnvironmentId.make("environment-other")])).toBe(true);
1042
- expect(shelve([], false)).toBe(false);
1043
- });
1044
-
1011
describe("sortInboxThreadsByReturn", () => {
1012
const thread = (
1013
id: string,
apps/web/src/components/Sidebar.logic.ts
-24
@@ -16,7 +16,6 @@ import {
16
type ThreadSearchShell,
17
} from "@t3tools/client-runtime/state/thread-search";
18
import { foldSearchQuery, rankSearchItems, scoreThreadSearch } from "@t3tools/shared/paletteSearch";
19
-import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
19
import {
20
isListedThreadLineage,
21
type ContextMenuItem,
@@ -185,29 +184,6 @@ export function resolveSidebarThreadSection(input: {
184
return "active";
185
}
186
188
-// Keep cached placement on the first connection attempt, matching mobile's threadRouteIsHydrating.
189
-export function isSidebarEnvironmentDisconnected(
190
- phase: EnvironmentConnectionPhase,
191
- shellIsLive: boolean,
192
-): boolean {
193
- return phase !== "connecting" && (phase !== "connected" || !shellIsLive);
194
-}
195
-
196
-export function belongsInSidebarWorkingShelf<T extends { readonly environmentId: EnvironmentId }>(
197
- thread: T,
198
- input: {
199
- readonly enabled: boolean;
200
- readonly disconnectedEnvironmentIds: ReadonlySet<EnvironmentId>;
201
- readonly isWorking: (thread: T) => boolean;
202
- },
203
-): boolean {
204
- return (
205
- input.enabled &&
206
- !input.disconnectedEnvironmentIds.has(thread.environmentId) &&
207
- input.isWorking(thread)
208
- );
209
-}
210
-
187
const SIDEBAR_MARKER_PREFIX = "sidebar-marker-";
188
189
export type SidebarListMarker =
apps/web/src/components/Sidebar.tsx
+2
-24
@@ -1,4 +1,3 @@
1
-import { liveShellEnvironmentIdsAtom } from "../state/shell";
1
import { attachSidebarTree } from "../lib/sidebarTree";
2
import { type EnvironmentId, type ScopedProjectRef } from "@t3tools/contracts";
3
import type { EnvironmentServerConfig } from "@t3tools/client-runtime/connection";
@@ -140,7 +139,6 @@ import { useNowMinute } from "../hooks/useNowMinute";
139
import {
140
useEnvironmentIdentities,
141
useConnectedEnvironmentIds,
143
- useEnvironmentConnectionSummaries,
142
useEnvironmentMachines,
143
usePrimaryEnvironmentId,
144
} from "../state/environments";
@@ -187,8 +185,6 @@ import {
185
deleteSelectedThreadEntries,
186
filterSidebarProjectScopeItems,
187
firstValidTimestampMs,
190
- belongsInSidebarWorkingShelf,
191
- isSidebarEnvironmentDisconnected,
188
isSidebarNestedLinkClick,
189
isTrailingDoubleClick,
190
orderItemsByPreferredIds,
@@ -356,7 +352,6 @@ interface SidebarThreadPartitionInput {
352
readonly workingShelfEnabled: boolean;
353
/** Boring mode: folders list active threads by the user's latest message. */
354
readonly sortActiveBySend: boolean;
359
- readonly disconnectedEnvironmentIds: ReadonlySet<EnvironmentId>;
355
// Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend
356
// on the clock, so the minute tick, the precise snooze-wake tick and the inbox
357
// tracker's expiry version are inputs: a new key repartitions.
@@ -442,18 +437,6 @@ function useSidebarThreads(input: {
437
// Folders already separate the work, so boring mode has no Working shelf.
438
const workingShelfEnabled =
439
useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null;
445
- const environmentConnections = useEnvironmentConnectionSummaries();
446
- const liveShellEnvironmentIds = useAtomValue(liveShellEnvironmentIdsAtom);
447
- const disconnectedEnvironmentIds = new Set(
448
- environmentConnections
449
- .filter((environment) =>
450
- isSidebarEnvironmentDisconnected(
451
- environment.connectionState,
452
- liveShellEnvironmentIds.has(environment.environmentId),
453
- ),
454
- )
455
- .map((environment) => environment.environmentId),
456
- );
440
const inboxReturnsVersion = useSyncExternalStore(
441
inboxReturns.subscribe,
442
inboxReturns.getSnapshot,
@@ -498,7 +481,6 @@ function useSidebarThreads(input: {
481
optimisticDrop,
482
workingShelfEnabled,
483
sortActiveBySend: folderGroups !== null,
501
- disconnectedEnvironmentIds,
484
clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
485
});
486
@@ -634,7 +616,6 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
616
optimisticDrop,
617
workingShelfEnabled,
618
sortActiveBySend,
637
- disconnectedEnvironmentIds,
619
} = input;
620
const preciseNow = new Date().toISOString();
621
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent);
@@ -643,11 +624,8 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
624
const active: EnvironmentThreadShell[] = [];
625
const working: EnvironmentThreadShell[] = [];
626
const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) =>
646
- belongsInSidebarWorkingShelf(thread, {
647
- enabled: workingShelfEnabled,
648
- disconnectedEnvironmentIds,
649
- isWorking: manuallyMoved ? isThreadWorking : inboxObservation.isWorking,
650
- })
627
+ workingShelfEnabled &&
628
+ (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread))
629
? working
630
: active;
631
const snoozed: EnvironmentThreadShell[] = [];
apps/web/src/state/environments.ts
-4
@@ -114,7 +114,3 @@ export function useEnvironmentMachines() {
114
export function useConnectedEnvironmentIds() {
115
return useAtomValue(environmentSummaries.connectedEnvironmentIdsAtom);
116
}
117
-
118
-export function useEnvironmentConnectionSummaries() {
119
- return useAtomValue(environmentSummaries.environmentsAtom);
120
-}