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, 15:45 UTC
fix(web): thread jump hints wait for their delay on every hold (#25636)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 26, 2026 at 15:02 UTC
5effca10b3ebfe0f917a5e549007ed46662fa497
2 files changed
+35
-6
apps/web/src/components/Sidebar.logic.browser.test.tsx
+28
-2
@@ -1,7 +1,7 @@
1
import { describe, expect, it, vi } from "vite-plus/test";
2
3
-import { render } from "../../test/render";
4
-import { useSnoozeWakeClock } from "./Sidebar.logic";
3
+import { act, fakeTimers, render } from "../../test/render";
4
+import { useSnoozeWakeClock, useThreadJumpHintsVisible } from "./Sidebar.logic";
5
6
const MOUNTED_AT_MS = Date.parse("2026-10-24T08:00:00.000Z");
7
@@ -31,3 +31,29 @@ describe("useSnoozeWakeClock", () => {
31
await expect.element(screen.getByRole("status")).toHaveTextContent(String(lastWakeMs));
32
});
33
});
34
+
35
+function JumpHints(props: { readonly held: boolean }) {
36
+ return <output>{useThreadJumpHintsVisible(props.held) ? "shown" : "hidden"}</output>;
37
+}
38
+
39
+describe("useThreadJumpHintsVisible", () => {
40
+ it("waits for the delay again on a second hold", async () => {
41
+ // The first render reads the clock.
42
+ using _timers = fakeTimers({ now: 0 });
43
+ await using screen = await render(<JumpHints held />, {
44
+ // A bare hook host; nothing here links or navigates.
45
+ router: false,
46
+ });
47
+ await act(() => vi.advanceTimersByTime(1_000));
48
+ await expect.element(screen.getByRole("status")).toHaveTextContent("shown");
49
+
50
+ await screen.rerender(<JumpHints held={false} />);
51
+ await expect.element(screen.getByRole("status")).toHaveTextContent("hidden");
52
+ await act(() => vi.advanceTimersByTime(1_000));
53
+
54
+ await screen.rerender(<JumpHints held />);
55
+ await expect.element(screen.getByRole("status")).toHaveTextContent("hidden");
56
+ await act(() => vi.advanceTimersByTime(1_000));
57
+ await expect.element(screen.getByRole("status")).toHaveTextContent("shown");
58
+ });
59
+});
apps/web/src/components/Sidebar.logic.ts
+7
-4
@@ -670,10 +670,13 @@ type ThreadStatusInput = Pick<
670
*/
671
export function useThreadJumpHintsVisible(shouldShow: boolean): boolean {
672
const [showAt, setShowAt] = React.useState<number | null>(null);
673
- let nextShowAt = shouldShow ? showAt : null;
674
- if (shouldShow && showAt === null) nextShowAt = deadlineAfter(THREAD_JUMP_HINT_SHOW_DELAY_MS);
675
- if (nextShowAt !== showAt) setShowAt(nextShowAt);
676
- return useDeadlinePassed(nextShowAt);
673
+ // The clock is read inside the updater: the compiler caches a bare clock read
674
+ // in render once per instance, so a second hold would reuse the first deadline.
675
+ // React discards this render and re-runs with the update.
676
+ if (shouldShow !== (showAt !== null)) {
677
+ setShowAt(shouldShow ? () => deadlineAfter(THREAD_JUMP_HINT_SHOW_DELAY_MS) : null);
678
+ }
679
+ return useDeadlinePassed(showAt);
680
}
681
682
export function resolveThreadLastVisitedAt(