@devries-cameron20 / t3code Mirror · read-only / commits / a0056dddb1
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, 02:00 UTC

perf(web): switching threads no longer re-renders every sidebar row (#29150)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Andrei committed Nov 9, 2026 at 22:29 UTC a0056dddb15fb6295dcbd2cbfd583c289e264c19
2 files changed +26 -24
apps/web/src/components/Sidebar.tsx
+22 -23
@@ -2241,7 +2241,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2241 threadKey,
2242 currentThreadKey: readRouteThreadKey(router),
2243 action: "snooze",
2244 - // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
2244 now: new Date().toISOString(),
2245 thread: readThreadShell(threadRef),
2246 })
@@ -2250,26 +2249,28 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2249 }
2250 return { status: "success" } as const;
2251 };
2253 - const attemptSnooze = (
2254 - threadRef: ScopedThreadRef,
2255 - preset: Pick<SnoozePreset, "snoozedUntil">,
2256 - opts: { coSnoozingKeys?: ReadonlySet<string> } = {},
2257 - ) => {
2258 - void (async () => {
2259 - const outcome = await performSnooze(threadRef, preset, opts);
2260 - if (outcome.status === "failure") {
2261 - toastManager.add(
2262 - stackedThreadToast({
2263 - type: "error",
2264 - title: "Failed to snooze thread",
2265 - description:
2266 - outcome.error instanceof Error ? outcome.error.message : "An error occurred.",
2267 - }),
2268 - );
2269 - return;
2270 - }
2271 - })();
2272 - };
2252 + const attemptSnooze = useStableCallback(
2253 + (
2254 + threadRef: ScopedThreadRef,
2255 + preset: Pick<SnoozePreset, "snoozedUntil">,
2256 + opts: { coSnoozingKeys?: ReadonlySet<string> } = {},
2257 + ) => {
2258 + void (async () => {
2259 + const outcome = await performSnooze(threadRef, preset, opts);
2260 + if (outcome.status === "failure") {
2261 + toastManager.add(
2262 + stackedThreadToast({
2263 + type: "error",
2264 + title: "Failed to snooze thread",
2265 + description:
2266 + outcome.error instanceof Error ? outcome.error.message : "An error occurred.",
2267 + }),
2268 + );
2269 + return;
2270 + }
2271 + })();
2272 + },
2273 + );
2274
2275 const handleMultiSelectContextMenu = useStableCallback(
2276 async (position: { x: number; y: number }) => {
@@ -2281,7 +2282,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2282 );
2283 if (threadKeys.length === 0) return;
2284 const count = threadKeys.length;
2284 - // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
2285 const selectionNow = new Date();
2286 const selectedThreads = threadKeys.flatMap((threadKey) => {
2287 const thread = threadByKeyRef.current.get(threadKey);
@@ -2312,7 +2312,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2312 pinnedCount: pinnedSelectedThreads.length,
2313 });
2314 // Presets sync across environments, so the first selected thread's stand for all.
2315 - // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
2315 const menuOpenedAt = new Date();
2316 const snoozePresets = resolveSnoozePresets(
2317 menuOpenedAt,
apps/web/test/appScenarios.renders.tsx
+4 -1
@@ -278,7 +278,10 @@ it("app-switch-thread", async () => {
278 );
279 await expect.element(lastAnswer(threadId)).toBeVisible();
280 };
281 - await report("app-switch-thread", [await measure(go(B)), await measure(go(A))]);
281 + const windows = [await measure(go(B)), await measure(go(A))];
282 + // Only the rows losing and gaining the active highlight change.
283 + for (const window of windows) expect(window.components.SidebarThreadRow).toBe(2);
284 + await report("app-switch-thread", windows);
285 });
286
287 // Through the diff.toggle shortcut, the same handler as the header's diff button.