@devries-cameron20 / t3code Mirror · read-only / commits / 45bd3b631b
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 24, 10:15 UTC

fix(sidebar): mute background working threads (#9759)

maria committed Sep 4, 2026 at 15:20 UTC 45bd3b631bf1e84520c90ebdfdd1b135871ced14
3 files changed +85 -20
apps/web/src/components/Sidebar.logic.test.ts
+46
@@ -29,6 +29,7 @@ import {
29 formatWorkingDurationLabel,
30 shouldNavigateAfterProjectRemoval,
31 shouldClearThreadSelectionOnMouseDown,
32 + shouldRecedeSidebarThread,
33 sortLogicalProjectsForSidebar,
34 sortSettledThreadsForSidebar,
35 pinOrderKeyBetween,
@@ -295,6 +296,51 @@ describe("hasUnseenCompletion", () => {
296 });
297 });
298
299 +describe("shouldRecedeSidebarThread", () => {
300 + it.each(["working", "monitoring"] as const)(
301 + "recedes an inactive %s thread even when it is unread and woke",
302 + (status) => {
303 + expect(
304 + shouldRecedeSidebarThread({
305 + status,
306 + isUnread: true,
307 + isWoke: true,
308 + isActive: false,
309 + isSelected: false,
310 + }),
311 + ).toBe(true);
312 + },
313 + );
314 +
315 + it.each(["ready", "approval", "input"] as const)(
316 + "keeps an unread %s thread prominent",
317 + (status) => {
318 + expect(
319 + shouldRecedeSidebarThread({
320 + status,
321 + isUnread: true,
322 + isWoke: false,
323 + isActive: false,
324 + isSelected: false,
325 + }),
326 + ).toBe(false);
327 + },
328 + );
329 +
330 + it("keeps active and selected working threads prominent", () => {
331 + const input = {
332 + status: "working" as const,
333 + isUnread: true,
334 + isWoke: true,
335 + isActive: false,
336 + isSelected: false,
337 + };
338 +
339 + expect(shouldRecedeSidebarThread({ ...input, isActive: true })).toBe(false);
340 + expect(shouldRecedeSidebarThread({ ...input, isSelected: true })).toBe(false);
341 + });
342 +});
343 +
344 describe("createThreadJumpHintVisibilityController", () => {
345 beforeEach(() => {
346 vi.useFakeTimers();
apps/web/src/components/Sidebar.logic.ts
+15
@@ -532,6 +532,21 @@ export type SidebarThreadStatus =
532 | "failed"
533 | "ready";
534
535 +export function shouldRecedeSidebarThread(input: {
536 + status: SidebarThreadStatus;
537 + isUnread: boolean;
538 + isWoke: boolean;
539 + isActive: boolean;
540 + isSelected: boolean;
541 +}): boolean {
542 + if (input.isActive || input.isSelected) return false;
543 + if (input.status === "working" || input.status === "monitoring") return true;
544 + if (input.status === "ready" || input.status === "approval" || input.status === "input") {
545 + return !input.isUnread && !input.isWoke;
546 + }
547 + return false;
548 +}
549 +
550 type SidebarThreadStatusInput = Pick<
551 SidebarThreadSummary,
552 "hasPendingApprovals" | "hasPendingUserInput" | "session" | "backgroundLiveness"
apps/web/src/components/Sidebar.tsx
+24 -20
@@ -144,6 +144,7 @@ import {
144 resolveSidebarThreadStatus,
145 searchSidebarThreadsByTitle,
146 shouldCreateNewThreadInCurrentProject,
147 + shouldRecedeSidebarThread,
148 resolveWorkingStartedAt,
149 sortLogicalProjectsForSidebar,
150 sortPinnedThreadsForSidebar,
@@ -874,6 +875,8 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
875 // switching sidebars must not light up every historical thread as unread.
876 const isUnread = hasUnseenCompletion({ ...thread, lastVisitedAt });
877 const status = resolveSidebarThreadStatus(thread);
878 + const isInFlight =
879 + status === "working" || status === "monitoring" || status === "approval" || status === "input";
880 // A woken thread reappears at its original position (the sort is
881 // deliberately static), so the pill has to carry the weight. Snoozing is
882 // an explicit act, so the pill clears only when the user re-engages:
@@ -887,17 +890,16 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
890 wokeAtDate !== null &&
891 (lastVisitedDate === null || lastVisitedDate < wokeAtDate) &&
892 thread.settledOverride !== "settled";
890 - // In-flight rows (working, or waiting on approval/input) fade as a whole:
891 - // there is nothing for the user to do yet, so prominence is reserved for
892 - // rows that need a human — done (unread), read-but-unsettled, failed, and
893 - // freshly woken. The status label keeps its hue, so waiting rows stay
894 - // findable. In-flight rows recede the same as read-ready ones (inbox-zero:
895 - // working threads aren't your problem yet) — only the colored status label
896 - // stands out.
897 - const isInFlight =
898 - status === "working" || status === "monitoring" || status === "approval" || status === "input";
899 - const shouldRecede =
900 - (status === "ready" || isInFlight) && !isUnread && !isWoke && !props.isActive && !isSelected;
893 + // Background work always recedes when it is not selected: an unread parent
894 + // completion must not pull a still-working thread back into the foreground.
895 + // Ready and action-required rows keep their unread and wake prominence.
896 + const shouldRecede = shouldRecedeSidebarThread({
897 + status,
898 + isUnread,
899 + isWoke,
900 + isActive: props.isActive,
901 + isSelected,
902 + });
903 // Status hues follow the system-wide convention set by sidebar v1 and the
904 // mobile Live Activity/widgets (amber approval, indigo input, sky working)
905 // so a thread reads the same color everywhere it surfaces.
@@ -1210,21 +1212,23 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
1212 variant === "card"
1213 ? cn(
1214 "truncate",
1213 - isUnread || isWoke
1214 - ? "text-foreground"
1215 - : shouldRecede
1216 - ? "text-secondary-label"
1215 + shouldRecede
1216 + ? "text-secondary-label"
1217 + : isUnread || isWoke
1218 + ? "text-foreground"
1219 : status === "failed"
1220 ? "text-foreground/95"
1221 : "text-foreground/90",
1222 )
1223 : cn(
1224 "truncate group-hover/sidebar-row:text-foreground",
1223 - props.isActive || isWoke
1224 - ? "text-foreground"
1225 - : isUnread
1226 - ? "text-muted-foreground"
1227 - : "text-secondary-label/70",
1225 + shouldRecede
1226 + ? "text-secondary-label/70"
1227 + : props.isActive || isWoke
1228 + ? "text-foreground"
1229 + : isUnread
1230 + ? "text-muted-foreground"
1231 + : "text-secondary-label/70",
1232 ),
1233 isRegeneratingTitle && "opacity-[0.55]",
1234 )}