Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,20 +970,18 @@ describe("Working shelf (beta)", () => {
});

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);
},
);
// Returning to the window resyncs the shell on a healthy connection, so a
// connected environment holds its rows in the shelf whatever the shell is doing.
["connected", false],
["connecting", false],
["reconnecting", true],
["offline", true],
["error", true],
["unsupported", true],
["available", true],
] as const)("lists threads outside the shelf on a %s environment: %s", (phase, disconnected) => {
expect(isSidebarEnvironmentDisconnected(phase)).toBe(disconnected);
});

it("lists a running thread outside the shelf while its environment is disconnected", () => {
const thread = { ...idle, runtime, environmentId: localEnvironmentId };
Expand Down
7 changes: 2 additions & 5 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,8 @@ export function resolveSidebarThreadSection(input: {
}

// 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 isSidebarEnvironmentDisconnected(phase: EnvironmentConnectionPhase): boolean {
return phase !== "connecting" && phase !== "connected";
}

export function belongsInSidebarWorkingShelf<T extends { readonly environmentId: EnvironmentId }>(
Expand Down
9 changes: 1 addition & 8 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -442,15 +441,9 @@ function useSidebarThreads(input: {
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),
),
)
.filter((environment) => isSidebarEnvironmentDisconnected(environment.connectionState))
.map((environment) => environment.environmentId),
);
const inboxReturnsVersion = useSyncExternalStore(
Expand Down
Loading