From bd6def3f13e2fd2d83601f676d2c1da55aa23daa Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:29:45 +0000 Subject: [PATCH 1/2] fix(web): show linked environments as connected and clear their Failed pill A server-linked environment is reachable but has no catalog connection, so the Environments filter painted it gray forever. A listed link is reachable by construction, so the filter now treats it as connected. Linked thread shells carried no visit time, so a failed run looked unseen even after the host was visited or finished. The thread list now forwards the host's lastVisitedAt and the shell uses it. Co-Authored-By: Claude Fable 5.2 --- apps/server/src/mcp/OrchestratorMcpService.ts | 4 ++ apps/server/src/peer/linkedSidebar.test.ts | 2 + apps/server/src/peer/linkedSidebar.ts | 1 + .../sidebar/SidebarThreadFilterMenu.tsx | 10 +++- apps/web/src/state/linkedSidebar.test.ts | 13 ++++- apps/web/src/state/linkedSidebar.ts | 6 +++ .../src/state/linkedSidebar.test.ts | 48 +++++++++++++++++++ .../client-runtime/src/state/linkedSidebar.ts | 3 ++ packages/contracts/src/linkedSidebar.ts | 2 + packages/contracts/src/orchestratorMcp.ts | 2 + 10 files changed, 88 insertions(+), 3 deletions(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 8ff41b8650f6d..d3763eb60ce61 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -957,6 +957,10 @@ function listItemFromShell( itemCount: shell.visibleItemCount, createdAt: DateTime.formatIso(shell.createdAt), updatedAt: DateTime.formatIso(shell.updatedAt), + lastVisitedAt: + shell.lastVisitedAt === undefined || shell.lastVisitedAt === null + ? null + : DateTime.formatIso(shell.lastVisitedAt), }; } diff --git a/apps/server/src/peer/linkedSidebar.test.ts b/apps/server/src/peer/linkedSidebar.test.ts index 9235a20ab8768..2455196e20b5e 100644 --- a/apps/server/src/peer/linkedSidebar.test.ts +++ b/apps/server/src/peer/linkedSidebar.test.ts @@ -92,6 +92,7 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable itemCount: 4, createdAt: "2026-11-19T12:00:00.000Z", updatedAt: "2026-11-20T04:00:00.000Z", + lastVisitedAt: "2026-11-20T03:59:00.000Z", }, ], }); @@ -103,5 +104,6 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable "10-model copy eval", ]); expect(result.environments[0]?.threads[0]?.inbox?.owner).toBe("jeff"); + expect(result.environments[0]?.threads[0]?.lastVisitedAt).toBe("2026-11-20T03:59:00.000Z"); }), ); diff --git a/apps/server/src/peer/linkedSidebar.ts b/apps/server/src/peer/linkedSidebar.ts index ff643d9e3aaa4..375e8b8b88840 100644 --- a/apps/server/src/peer/linkedSidebar.ts +++ b/apps/server/src/peer/linkedSidebar.ts @@ -94,6 +94,7 @@ const slimThread = ( itemCount: thread.itemCount, createdAt: thread.createdAt, updatedAt: thread.updatedAt, + ...(thread.lastVisitedAt === undefined ? {} : { lastVisitedAt: thread.lastVisitedAt }), }); export const collectLinkedSidebar = Effect.fn("linkedSidebar.collect")(function* (input: { diff --git a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx index 73de563cdba85..29691cb2208b1 100644 --- a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx @@ -15,7 +15,10 @@ import type { ReactNode } from "react"; import { updateClientSettings, useClientSettings } from "../../hooks/useSettings"; import { cn } from "../../lib/utils"; import { useConnectedEnvironmentIds } from "../../state/environments"; -import { useSidebarEnvironmentIdentities } from "../../state/linkedSidebar"; +import { + linkedSidebarEnvironmentIds, + useSidebarEnvironmentIdentities, +} from "../../state/linkedSidebar"; import { Menu, MenuCheckboxItem, @@ -124,6 +127,7 @@ function SidebarThreadFilterOptions({ isChanged: boolean; }) { const connectedEnvironmentIds = useConnectedEnvironmentIds(); + const linkedEnvironmentIds = linkedSidebarEnvironmentIds(); const inboxOrder = inboxMenuOrder(owner); const older = olderSettled(); const counts = threadListFilterCounts( @@ -201,7 +205,9 @@ function SidebarThreadFilterOptions({ {environments.map((environment) => { const checked = shownEnvironmentIds.includes(environment.environmentId); const isLast = checked && shownEnvironmentIds.length === 1; - const connected = connectedEnvironmentIds.includes(environment.environmentId); + const connected = + connectedEnvironmentIds.includes(environment.environmentId) || + linkedEnvironmentIds.includes(environment.environmentId); const count = counts.environments.get(environment.environmentId) ?? EMPTY_THREAD_LIST_FILTER_BUCKETS; diff --git a/apps/web/src/state/linkedSidebar.test.ts b/apps/web/src/state/linkedSidebar.test.ts index 2743fe7959914..c0f8ab4bd7c31 100644 --- a/apps/web/src/state/linkedSidebar.test.ts +++ b/apps/web/src/state/linkedSidebar.test.ts @@ -11,7 +11,11 @@ import { import { afterEach, describe, expect, it } from "vite-plus/test"; import { appAtomRegistry } from "../rpc/atomRegistry"; -import { linkedSidebarByHostAtom, readLinkedSidebarThreadShell } from "./linkedSidebar"; +import { + linkedSidebarByHostAtom, + linkedSidebarEnvironmentIds, + readLinkedSidebarThreadShell, +} from "./linkedSidebar"; const laptop = EnvironmentId.make("primary-mac-laptop"); const omarcy = EnvironmentId.make("omarcy-desktop"); @@ -67,3 +71,10 @@ describe("readLinkedSidebarThreadShell", () => { expect(readLinkedSidebarThreadShell({ environmentId: laptop, threadId })).toBeNull(); }); }); + +describe("linkedSidebarEnvironmentIds", () => { + it("reports a server-only link, which the filter paints connected", () => { + appAtomRegistry.set(linkedSidebarByHostAtom, new Map([[laptop, hostResult]])); + expect(linkedSidebarEnvironmentIds()).toEqual([omarcy]); + }); +}); diff --git a/apps/web/src/state/linkedSidebar.ts b/apps/web/src/state/linkedSidebar.ts index f7711b5611ba3..cd03e2ec9532d 100644 --- a/apps/web/src/state/linkedSidebar.ts +++ b/apps/web/src/state/linkedSidebar.ts @@ -116,6 +116,12 @@ export function readLinkedSidebarThreadShell(ref: ScopedThreadRef): EnvironmentT ); } +export function linkedSidebarEnvironmentIds(): ReadonlyArray { + return appAtomRegistry + .get(linkedSidebarSupplementAtom) + .identities.map((identity) => identity.environmentId); +} + export function useLinkedOnlyEnvironment(environmentId: EnvironmentId | null) { const identities = useAtomValue(linkedSidebarSupplementAtom).identities; return environmentId === null diff --git a/packages/client-runtime/src/state/linkedSidebar.test.ts b/packages/client-runtime/src/state/linkedSidebar.test.ts index aa379a2818523..9beee9d753800 100644 --- a/packages/client-runtime/src/state/linkedSidebar.test.ts +++ b/packages/client-runtime/src/state/linkedSidebar.test.ts @@ -3,12 +3,14 @@ import { makeThreadInbox, ProjectId, ProviderInstanceId, + RunId, ThreadId, type LinkedSidebarThread, } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; import { sidebarFromServerLinks } from "./linkedSidebar.ts"; +import { hasUnseenRunFailure } from "./threadSettled.ts"; import { matchesThreadListFilter, threadListFilterOf } from "./threadListFilter.ts"; const laptop = EnvironmentId.make("primary-mac-laptop"); @@ -101,4 +103,50 @@ describe("sidebarFromServerLinks", () => { expect(listed.threads.map((thread) => thread.id)).toEqual([threadId]); expect(listed.projects).toHaveLength(1); }); + + it("keeps a failed run unseen until the host records a later visit", () => { + const failed = { + ...jeffThread, + status: "failed" as const, + latestRunId: RunId.make("run-eval"), + updatedAt: "2026-11-20T05:00:00.000Z", + } satisfies LinkedSidebarThread; + const listed = (thread: LinkedSidebarThread) => + sidebarFromServerLinks({ + catalogEnvironmentIds: [laptop], + environments: [ + { environmentId: omarcy, label: "omarcy-desktop", projects: [], threads: [thread] }, + ], + }).threads[0]!; + const unseen = listed(failed); + expect(unseen.latestRun?.status).toBe("failed"); + expect(hasUnseenRunFailure(unseen)).toBe(true); + const seen = listed({ ...failed, lastVisitedAt: "2026-11-20T05:01:00.000Z" }); + expect(hasUnseenRunFailure(seen)).toBe(false); + const failedAgain = listed({ ...failed, lastVisitedAt: "2026-11-20T04:59:00.000Z" }); + expect(hasUnseenRunFailure(failedAgain)).toBe(true); + }); + + it("drops the failed pill once the host completes the thread", () => { + const listed = sidebarFromServerLinks({ + catalogEnvironmentIds: [laptop], + environments: [ + { + environmentId: omarcy, + label: "omarcy-desktop", + projects: [], + threads: [ + { + ...jeffThread, + status: "idle", + latestRunId: RunId.make("run-eval"), + lastVisitedAt: "2026-11-20T04:30:00.000Z", + }, + ], + }, + ], + }).threads[0]!; + expect(listed.latestRun?.status).toBe("completed"); + expect(hasUnseenRunFailure(listed)).toBe(false); + }); }); diff --git a/packages/client-runtime/src/state/linkedSidebar.ts b/packages/client-runtime/src/state/linkedSidebar.ts index c6b181634200d..147aaa5162771 100644 --- a/packages/client-runtime/src/state/linkedSidebar.ts +++ b/packages/client-runtime/src/state/linkedSidebar.ts @@ -70,6 +70,9 @@ function threadShellFromLinkedThread( visibleItemCount: thread.itemCount, createdAt: utc(thread.createdAt), updatedAt: utc(thread.updatedAt), + ...(thread.lastVisitedAt === undefined + ? {} + : { lastVisitedAt: utcOrNull(thread.lastVisitedAt) }), archivedAt: null, settledOverride: thread.settled ? "settled" : null, settledAt: utcOrNull(thread.settledAt), diff --git a/packages/contracts/src/linkedSidebar.ts b/packages/contracts/src/linkedSidebar.ts index f0fa4587d96fe..c3d4dc3246bb3 100644 --- a/packages/contracts/src/linkedSidebar.ts +++ b/packages/contracts/src/linkedSidebar.ts @@ -43,6 +43,8 @@ export const LinkedSidebarThread = Schema.Struct({ itemCount: NonNegativeInt, createdAt: IsoDateTime, updatedAt: IsoDateTime, + /** Absent from linked environments that predate it. */ + lastVisitedAt: Schema.optional(Schema.NullOr(IsoDateTime)), }); export type LinkedSidebarThread = typeof LinkedSidebarThread.Type; diff --git a/packages/contracts/src/orchestratorMcp.ts b/packages/contracts/src/orchestratorMcp.ts index 2b91f933341ca..41c283e15d479 100644 --- a/packages/contracts/src/orchestratorMcp.ts +++ b/packages/contracts/src/orchestratorMcp.ts @@ -449,6 +449,8 @@ export const OrchestratorMcpThreadListItem = Schema.Struct({ itemCount: NonNegativeInt, createdAt: IsoDateTime, updatedAt: IsoDateTime, + /** Absent from linked environments that predate it. */ + lastVisitedAt: Schema.optional(Schema.NullOr(IsoDateTime)), }); export type OrchestratorMcpThreadListItem = typeof OrchestratorMcpThreadListItem.Type; From de2c230798c10142f9d432baf2e8272353bf85b1 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:40:08 +0000 Subject: [PATCH 2/2] fix(web): keep a seen linked failure seen after a later update The linked shell dated a failed run by updatedAt, so a rename or settle after the visit looked like a new failure. The list now carries the run's own completion time. A visit that changes nothing else was also dropped, because the sidebar compared threads without their visit time. Co-Authored-By: Claude Fable 5.2 --- apps/server/src/mcp/OrchestratorMcpService.ts | 4 ++ apps/server/src/peer/linkedSidebar.test.ts | 4 ++ apps/server/src/peer/linkedSidebar.ts | 3 ++ apps/web/src/state/linkedSidebar.test.ts | 39 +++++++++++++++++++ apps/web/src/state/linkedSidebar.ts | 2 + .../src/state/linkedSidebar.test.ts | 7 ++++ .../client-runtime/src/state/linkedSidebar.ts | 3 ++ packages/contracts/src/linkedSidebar.ts | 2 + packages/contracts/src/orchestratorMcp.ts | 2 + 9 files changed, 66 insertions(+) diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index d3763eb60ce61..442ab88633220 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -941,6 +941,10 @@ function listItemFromShell( creationSource: shell.creationSource, status: listedThreadStatus(shell), latestRunId: shell.latestRunId, + latestRunCompletedAt: + shell.latestRunCompletedAt === undefined || shell.latestRunCompletedAt === null + ? null + : DateTime.formatIso(shell.latestRunCompletedAt), providerInstanceId: shell.modelSelection.instanceId, model: shell.modelSelection.model, runtimeMode: shell.runtimeMode, diff --git a/apps/server/src/peer/linkedSidebar.test.ts b/apps/server/src/peer/linkedSidebar.test.ts index 2455196e20b5e..11dc074a60962 100644 --- a/apps/server/src/peer/linkedSidebar.test.ts +++ b/apps/server/src/peer/linkedSidebar.test.ts @@ -93,6 +93,7 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable createdAt: "2026-11-19T12:00:00.000Z", updatedAt: "2026-11-20T04:00:00.000Z", lastVisitedAt: "2026-11-20T03:59:00.000Z", + latestRunCompletedAt: "2026-11-20T03:58:00.000Z", }, ], }); @@ -105,5 +106,8 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable ]); expect(result.environments[0]?.threads[0]?.inbox?.owner).toBe("jeff"); expect(result.environments[0]?.threads[0]?.lastVisitedAt).toBe("2026-11-20T03:59:00.000Z"); + expect(result.environments[0]?.threads[0]?.latestRunCompletedAt).toBe( + "2026-11-20T03:58:00.000Z", + ); }), ); diff --git a/apps/server/src/peer/linkedSidebar.ts b/apps/server/src/peer/linkedSidebar.ts index 375e8b8b88840..6cf869054239c 100644 --- a/apps/server/src/peer/linkedSidebar.ts +++ b/apps/server/src/peer/linkedSidebar.ts @@ -80,6 +80,9 @@ const slimThread = ( creationSource: thread.creationSource, status: thread.status, latestRunId: thread.latestRunId, + ...(thread.latestRunCompletedAt === undefined + ? {} + : { latestRunCompletedAt: thread.latestRunCompletedAt }), providerInstanceId: thread.providerInstanceId, model: thread.model, runtimeMode: thread.runtimeMode, diff --git a/apps/web/src/state/linkedSidebar.test.ts b/apps/web/src/state/linkedSidebar.test.ts index c0f8ab4bd7c31..402db1592e4b7 100644 --- a/apps/web/src/state/linkedSidebar.test.ts +++ b/apps/web/src/state/linkedSidebar.test.ts @@ -72,6 +72,45 @@ describe("readLinkedSidebarThreadShell", () => { }); }); +const visited = "2026-11-20T05:01:00.000Z"; + +describe("linked sidebar refresh", () => { + it("picks up a visit that changes nothing else", () => { + const result = { + environments: [ + { + environmentId: omarcy, + label: "omarcy-desktop", + projects: [], + threads: [{ ...linkedThread, status: "failed" as const }], + }, + ], + } satisfies LinkedSidebarResult; + appAtomRegistry.set(linkedSidebarByHostAtom, new Map([[laptop, result]])); + const before = readLinkedSidebarThreadShell({ environmentId: omarcy, threadId }); + appAtomRegistry.set( + linkedSidebarByHostAtom, + new Map([ + [ + laptop, + { + environments: [ + { + ...result.environments[0]!, + threads: [{ ...linkedThread, status: "failed" as const, lastVisitedAt: visited }], + }, + ], + }, + ], + ]), + ); + const after = readLinkedSidebarThreadShell({ environmentId: omarcy, threadId }); + expect(before?.lastVisitedAt ?? null).toBeNull(); + expect(after?.lastVisitedAt).toBe(visited); + expect(after).not.toBe(before); + }); +}); + describe("linkedSidebarEnvironmentIds", () => { it("reports a server-only link, which the filter paints connected", () => { appAtomRegistry.set(linkedSidebarByHostAtom, new Map([[laptop, hostResult]])); diff --git a/apps/web/src/state/linkedSidebar.ts b/apps/web/src/state/linkedSidebar.ts index cd03e2ec9532d..a1a04ce8a75ac 100644 --- a/apps/web/src/state/linkedSidebar.ts +++ b/apps/web/src/state/linkedSidebar.ts @@ -37,6 +37,8 @@ const sameThread = (left: EnvironmentThreadShell, right: EnvironmentThreadShell) left.settledOverride === right.settledOverride && left.snoozedUntil === right.snoozedUntil && left.runtime?.status === right.runtime?.status && + left.lastVisitedAt === right.lastVisitedAt && + left.latestRun?.completedAt === right.latestRun?.completedAt && left.source.inbox?.owner === right.source.inbox?.owner && left.source.inbox?.audience === right.source.inbox?.audience && left.source.inbox?.attentionKind === right.source.inbox?.attentionKind; diff --git a/packages/client-runtime/src/state/linkedSidebar.test.ts b/packages/client-runtime/src/state/linkedSidebar.test.ts index 9beee9d753800..21b18f1bb5e53 100644 --- a/packages/client-runtime/src/state/linkedSidebar.test.ts +++ b/packages/client-runtime/src/state/linkedSidebar.test.ts @@ -109,6 +109,7 @@ describe("sidebarFromServerLinks", () => { ...jeffThread, status: "failed" as const, latestRunId: RunId.make("run-eval"), + latestRunCompletedAt: "2026-11-20T05:00:00.000Z", updatedAt: "2026-11-20T05:00:00.000Z", } satisfies LinkedSidebarThread; const listed = (thread: LinkedSidebarThread) => @@ -125,6 +126,12 @@ describe("sidebarFromServerLinks", () => { expect(hasUnseenRunFailure(seen)).toBe(false); const failedAgain = listed({ ...failed, lastVisitedAt: "2026-11-20T04:59:00.000Z" }); expect(hasUnseenRunFailure(failedAgain)).toBe(true); + const renamedAfter = listed({ + ...failed, + lastVisitedAt: "2026-11-20T05:01:00.000Z", + updatedAt: "2026-11-20T05:02:00.000Z", + }); + expect(hasUnseenRunFailure(renamedAfter)).toBe(false); }); it("drops the failed pill once the host completes the thread", () => { diff --git a/packages/client-runtime/src/state/linkedSidebar.ts b/packages/client-runtime/src/state/linkedSidebar.ts index 147aaa5162771..88f9cc75ee048 100644 --- a/packages/client-runtime/src/state/linkedSidebar.ts +++ b/packages/client-runtime/src/state/linkedSidebar.ts @@ -57,6 +57,9 @@ function threadShellFromLinkedThread( forkedFrom: null, activeProviderThreadId: null, latestRunId: thread.latestRunId, + ...(thread.latestRunCompletedAt === undefined + ? {} + : { latestRunCompletedAt: utcOrNull(thread.latestRunCompletedAt) }), activeRunId: active ? thread.latestRunId : null, ...(active ? { activityRunStatus: thread.status } : {}), status: thread.status, diff --git a/packages/contracts/src/linkedSidebar.ts b/packages/contracts/src/linkedSidebar.ts index c3d4dc3246bb3..4ff712bd49ca0 100644 --- a/packages/contracts/src/linkedSidebar.ts +++ b/packages/contracts/src/linkedSidebar.ts @@ -29,6 +29,8 @@ export const LinkedSidebarThread = Schema.Struct({ creationSource: OrchestrationV2CreationSource, status: OrchestratorMcpThreadStatus, latestRunId: Schema.NullOr(RunId), + /** Absent from linked environments that predate it. */ + latestRunCompletedAt: Schema.optional(Schema.NullOr(IsoDateTime)), providerInstanceId: ProviderInstanceId, model: Schema.String, runtimeMode: RuntimeMode, diff --git a/packages/contracts/src/orchestratorMcp.ts b/packages/contracts/src/orchestratorMcp.ts index 41c283e15d479..f82e3f22b98c3 100644 --- a/packages/contracts/src/orchestratorMcp.ts +++ b/packages/contracts/src/orchestratorMcp.ts @@ -423,6 +423,8 @@ export const OrchestratorMcpThreadListItem = Schema.Struct({ creationSource: OrchestrationV2CreationSource, status: OrchestratorMcpThreadStatus, latestRunId: Schema.NullOr(RunId), + /** Absent from linked environments that predate it. */ + latestRunCompletedAt: Schema.optional(Schema.NullOr(IsoDateTime)), providerInstanceId: ProviderInstanceId, model: Schema.String, runtimeMode: RuntimeMode,