Skip to content
TypeScript

revert(web): working threads stay in the Working shelf when their environment disconnects (#31269)

Julius Marminge34701646e390
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts
index 574ae3b4021..9e7489a0ffc 100644
--- a/apps/web/src/components/Sidebar.logic.test.ts
+++ b/apps/web/src/components/Sidebar.logic.test.ts
@@ -11,8 +11,6 @@ import {
getFallbackThreadIdAfterDelete,
hasUnseenCompletion,
resolveSidebarRowThreadId,
- belongsInSidebarWorkingShelf,
- isSidebarEnvironmentDisconnected,
orderItemsByPreferredIds,
pinOrderKeyBetween,
resolveSidebarSweepKeys,
@@ -1010,38 +1008,6 @@ describe("Working shelf (beta)", () => {
).toBe(false);
});
- it.each([
- ["connected", true, false],
- ["connected", false, true],
- ["connecting", false, false],
- ["reconnecting", false, true],
- ["offline", false, true],
- ["error", false, true],
- ["unsupported", false, true],
- ["available", false, true],
- ] as const)(
- "lists threads outside the shelf on a %s environment: %s",
- (phase, shellIsLive, disconnected) => {
- expect(isSidebarEnvironmentDisconnected(phase, shellIsLive)).toBe(disconnected);
- },
- );
-
- it("lists a running thread outside the shelf while its environment is disconnected", () => {
- const thread = { ...idle, runtime, environmentId: localEnvironmentId };
- const shelve = (disconnected: ReadonlyArray<EnvironmentId>, enabled = true) =>
- belongsInSidebarWorkingShelf(thread, {
- enabled,
- disconnectedEnvironmentIds: new Set(disconnected),
- isWorking: isSidebarThreadWorking,
- });
-
- expect(shelve([])).toBe(true);
- expect(shelve([localEnvironmentId])).toBe(false);
- expect(shelve([])).toBe(true);
- expect(shelve([EnvironmentId.make("environment-other")])).toBe(true);
- expect(shelve([], false)).toBe(false);
- });
-
describe("sortInboxThreadsByReturn", () => {
const thread = (
id: string,
diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts
index 5af89dd0224..e2c6a60fc33 100644
--- a/apps/web/src/components/Sidebar.logic.ts
+++ b/apps/web/src/components/Sidebar.logic.ts
@@ -16,7 +16,6 @@ import {
type ThreadSearchShell,
} from "@t3tools/client-runtime/state/thread-search";
import { foldSearchQuery, rankSearchItems, scoreThreadSearch } from "@t3tools/shared/paletteSearch";
-import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
import {
isListedThreadLineage,
type ContextMenuItem,
@@ -185,29 +184,6 @@ export function resolveSidebarThreadSection(input: {
return "active";
}
-// Keep cached placement on the first connection attempt, matching mobile's threadRouteIsHydrating.
-export function isSidebarEnvironmentDisconnected(
- phase: EnvironmentConnectionPhase,
- shellIsLive: boolean,
-): boolean {
- return phase !== "connecting" && (phase !== "connected" || !shellIsLive);
-}
-
-export function belongsInSidebarWorkingShelf<T extends { readonly environmentId: EnvironmentId }>(
- thread: T,
- input: {
- readonly enabled: boolean;
- readonly disconnectedEnvironmentIds: ReadonlySet<EnvironmentId>;
- readonly isWorking: (thread: T) => boolean;
- },
-): boolean {
- return (
- input.enabled &&
- !input.disconnectedEnvironmentIds.has(thread.environmentId) &&
- input.isWorking(thread)
- );
-}
-
const SIDEBAR_MARKER_PREFIX = "sidebar-marker-";
export type SidebarListMarker =
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 18aa27709e4..a10183a32d8 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1,4 +1,3 @@
-import { liveShellEnvironmentIdsAtom } from "../state/shell";
import { attachSidebarTree } from "../lib/sidebarTree";
import { type EnvironmentId, type ScopedProjectRef } from "@t3tools/contracts";
import type { EnvironmentServerConfig } from "@t3tools/client-runtime/connection";
@@ -140,7 +139,6 @@ import { useNowMinute } from "../hooks/useNowMinute";
import {
useEnvironmentIdentities,
useConnectedEnvironmentIds,
- useEnvironmentConnectionSummaries,
useEnvironmentMachines,
usePrimaryEnvironmentId,
} from "../state/environments";
@@ -187,8 +185,6 @@ import {
deleteSelectedThreadEntries,
filterSidebarProjectScopeItems,
firstValidTimestampMs,
- belongsInSidebarWorkingShelf,
- isSidebarEnvironmentDisconnected,
isSidebarNestedLinkClick,
isTrailingDoubleClick,
orderItemsByPreferredIds,
@@ -356,7 +352,6 @@ interface SidebarThreadPartitionInput {
readonly workingShelfEnabled: boolean;
/** Boring mode: folders list active threads by the user's latest message. */
readonly sortActiveBySend: boolean;
- readonly disconnectedEnvironmentIds: ReadonlySet<EnvironmentId>;
// Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend
// on the clock, so the minute tick, the precise snooze-wake tick and the inbox
// tracker's expiry version are inputs: a new key repartitions.
@@ -442,18 +437,6 @@ function useSidebarThreads(input: {
// Folders already separate the work, so boring mode has no Working shelf.
const workingShelfEnabled =
useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null;
- const environmentConnections = useEnvironmentConnectionSummaries();
- const liveShellEnvironmentIds = useAtomValue(liveShellEnvironmentIdsAtom);
- const disconnectedEnvironmentIds = new Set(
- environmentConnections
- .filter((environment) =>
- isSidebarEnvironmentDisconnected(
- environment.connectionState,
- liveShellEnvironmentIds.has(environment.environmentId),
- ),
- )
- .map((environment) => environment.environmentId),
- );
const inboxReturnsVersion = useSyncExternalStore(
inboxReturns.subscribe,
inboxReturns.getSnapshot,
@@ -498,7 +481,6 @@ function useSidebarThreads(input: {
optimisticDrop,
workingShelfEnabled,
sortActiveBySend: folderGroups !== null,
- disconnectedEnvironmentIds,
clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
});
@@ -634,7 +616,6 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
optimisticDrop,
workingShelfEnabled,
sortActiveBySend,
- disconnectedEnvironmentIds,
} = input;
const preciseNow = new Date().toISOString();
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent);
@@ -643,11 +624,8 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
const active: EnvironmentThreadShell[] = [];
const working: EnvironmentThreadShell[] = [];
const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) =>
- belongsInSidebarWorkingShelf(thread, {
- enabled: workingShelfEnabled,
- disconnectedEnvironmentIds,
- isWorking: manuallyMoved ? isThreadWorking : inboxObservation.isWorking,
- })
+ workingShelfEnabled &&
+ (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread))
? working
: active;
const snoozed: EnvironmentThreadShell[] = [];
diff --git a/apps/web/src/state/environments.ts b/apps/web/src/state/environments.ts
index a35af5e094a..0b2cab287d2 100644
--- a/apps/web/src/state/environments.ts
+++ b/apps/web/src/state/environments.ts
@@ -114,7 +114,3 @@ export function useEnvironmentMachines() {
export function useConnectedEnvironmentIds() {
return useAtomValue(environmentSummaries.connectedEnvironmentIdsAtom);
}
-
-export function useEnvironmentConnectionSummaries() {
- return useAtomValue(environmentSummaries.environmentsAtom);
-}