@devries-cameron20 / t3code Mirror · read-only / commits / 033a753e34
Fork 0

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 22, 09:30 UTC

fix(web): threads on an unreachable environment no longer hide in the Working shelf (#26195)

Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Alex Southwell committed Nov 1, 2026 at 02:07 UTC 033a753e34b6f42c2eed023777010741886144fa
4 files changed +86 -2
apps/web/src/components/Sidebar.logic.test.ts
+34
@@ -12,6 +12,8 @@ import {
12 getFallbackThreadIdAfterDelete,
13 hasUnseenCompletion,
14 resolveSidebarRowThreadId,
15 + belongsInSidebarWorkingShelf,
16 + isSidebarEnvironmentDisconnected,
17 orderItemsByPreferredIds,
18 pinOrderKeyBetween,
19 resolveProjectStatusIndicator,
@@ -1089,6 +1091,38 @@ describe("Working shelf (beta)", () => {
1091 ).toBe(false);
1092 });
1093
1094 + it.each([
1095 + ["connected", true, false],
1096 + ["connected", false, true],
1097 + ["connecting", false, false],
1098 + ["reconnecting", false, true],
1099 + ["offline", false, true],
1100 + ["error", false, true],
1101 + ["unsupported", false, true],
1102 + ["available", false, true],
1103 + ] as const)(
1104 + "lists threads outside the shelf on a %s environment: %s",
1105 + (phase, shellIsLive, disconnected) => {
1106 + expect(isSidebarEnvironmentDisconnected(phase, shellIsLive)).toBe(disconnected);
1107 + },
1108 + );
1109 +
1110 + it("lists a running thread outside the shelf while its environment is disconnected", () => {
1111 + const thread = { ...idle, runtime, environmentId: localEnvironmentId };
1112 + const shelve = (disconnected: ReadonlyArray<EnvironmentId>, enabled = true) =>
1113 + belongsInSidebarWorkingShelf(thread, {
1114 + enabled,
1115 + disconnectedEnvironmentIds: new Set(disconnected),
1116 + isWorking: isSidebarThreadWorking,
1117 + });
1118 +
1119 + expect(shelve([])).toBe(true);
1120 + expect(shelve([localEnvironmentId])).toBe(false);
1121 + expect(shelve([])).toBe(true);
1122 + expect(shelve([EnvironmentId.make("environment-other")])).toBe(true);
1123 + expect(shelve([], false)).toBe(false);
1124 + });
1125 +
1126 describe("sortInboxThreadsByReturn", () => {
1127 const thread = (
1128 id: string,
apps/web/src/components/Sidebar.logic.ts
+24
@@ -16,6 +16,7 @@ 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";
20 import {
21 isListedThreadLineage,
22 type ContextMenuItem,
@@ -184,6 +185,29 @@ export function resolveSidebarThreadSection(input: {
185 return "active";
186 }
187
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 +
211 const SIDEBAR_MARKER_PREFIX = "sidebar-marker-";
212
213 export type SidebarListMarker =
apps/web/src/components/Sidebar.tsx
+24 -2
@@ -1,3 +1,4 @@
1 +import { liveShellEnvironmentIdsAtom } from "../state/shell";
2 import { attachSidebarTree, SIDEBAR_TREE_PROPS } from "../lib/sidebarTree";
3 import { type EnvironmentId, type ScopedProjectRef } from "@t3tools/contracts";
4 import type { EnvironmentServerConfig } from "@t3tools/client-runtime/connection";
@@ -138,6 +139,7 @@ import { useNowMinute } from "../hooks/useNowMinute";
139 import {
140 useEnvironmentIdentities,
141 useConnectedEnvironmentIds,
142 + useEnvironmentConnectionSummaries,
143 useEnvironmentMachines,
144 usePrimaryEnvironmentId,
145 } from "../state/environments";
@@ -184,6 +186,8 @@ import {
186 deleteSelectedThreadEntries,
187 filterSidebarProjectScopeItems,
188 firstValidTimestampMs,
189 + belongsInSidebarWorkingShelf,
190 + isSidebarEnvironmentDisconnected,
191 isSidebarNestedLinkClick,
192 isTrailingDoubleClick,
193 orderItemsByPreferredIds,
@@ -351,6 +355,7 @@ interface SidebarThreadPartitionInput {
355 readonly workingShelfEnabled: boolean;
356 /** Boring mode: folders list active threads by the user's latest message. */
357 readonly sortActiveBySend: boolean;
358 + readonly disconnectedEnvironmentIds: ReadonlySet<EnvironmentId>;
359 // Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend
360 // on the clock, so the minute tick, the precise snooze-wake tick and the inbox
361 // tracker's expiry version are inputs: a new key repartitions.
@@ -432,6 +437,18 @@ 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;
440 + const environmentConnections = useEnvironmentConnectionSummaries();
441 + const liveShellEnvironmentIds = useAtomValue(liveShellEnvironmentIdsAtom);
442 + const disconnectedEnvironmentIds = new Set(
443 + environmentConnections
444 + .filter((environment) =>
445 + isSidebarEnvironmentDisconnected(
446 + environment.connectionState,
447 + liveShellEnvironmentIds.has(environment.environmentId),
448 + ),
449 + )
450 + .map((environment) => environment.environmentId),
451 + );
452 const inboxReturnsVersion = useSyncExternalStore(
453 inboxReturns.subscribe,
454 inboxReturns.getSnapshot,
@@ -476,6 +493,7 @@ function useSidebarThreads(input: {
493 optimisticDrop,
494 workingShelfEnabled,
495 sortActiveBySend: folderGroups !== null,
496 + disconnectedEnvironmentIds,
497 clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
498 });
499
@@ -611,6 +629,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
629 optimisticDrop,
630 workingShelfEnabled,
631 sortActiveBySend,
632 + disconnectedEnvironmentIds,
633 } = input;
634 const preciseNow = new Date().toISOString();
635 const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent);
@@ -619,8 +638,11 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
638 const active: EnvironmentThreadShell[] = [];
639 const working: EnvironmentThreadShell[] = [];
640 const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) =>
622 - workingShelfEnabled &&
623 - (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread))
641 + belongsInSidebarWorkingShelf(thread, {
642 + enabled: workingShelfEnabled,
643 + disconnectedEnvironmentIds,
644 + isWorking: manuallyMoved ? isThreadWorking : inboxObservation.isWorking,
645 + })
646 ? working
647 : active;
648 const snoozed: EnvironmentThreadShell[] = [];
apps/web/src/state/environments.ts
+4
@@ -114,3 +114,7 @@ export function useEnvironmentMachines() {
114 export function useConnectedEnvironmentIds() {
115 return useAtomValue(environmentSummaries.connectedEnvironmentIdsAtom);
116 }
117 +
118 +export function useEnvironmentConnectionSummaries() {
119 + return useAtomValue(environmentSummaries.environmentsAtom);
120 +}