GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): a snoozed thread wakes in the open chat view (#21019) · Pipyakas/t3code@ef64a40

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components
    • ChatView.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/ChatView.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.tsx
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7014,25 +7014,35 @@ export default function ChatView(props: ChatViewProps) {
70147014
const supportsSnooze = serverConfig?.environment.capabilities.threadSnooze === true;
70157015
const supportsPinning = serverConfig?.environment.capabilities.threadPinning === true;
70167016
const activeThreadPinned = supportsPinning && activeThreadShell?.pinnedAt != null;
7017+
// The compiler caches render results on their inputs, so a clock read in render
7018+
// stays frozen until the shell changes. The clock is state: reset with the shell,
7019+
// and moved by the wake timer.
7020+
const [snoozeClockState, setSnoozeClockState] = useState(() => ({
7021+
shell: activeThreadShell,
7022+
now: new Date().toISOString(),
7023+
}));
7024+
if (snoozeClockState.shell !== activeThreadShell) {
7025+
setSnoozeClockState({ shell: activeThreadShell, now: new Date().toISOString() });
7026+
}
7027+
const snoozeClock = snoozeClockState.now;
70177028
const activeThreadSnoozed =
70187029
activeThreadShell !== null &&
70197030
supportsSnooze &&
7020-
effectiveSnoozed(activeThreadShell, { now: new Date().toISOString() });
7021-
const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
7031+
effectiveSnoozed(activeThreadShell, { now: snoozeClock });
70227032
useEffect(() => {
7023-
void snoozeWakeTick;
7033+
void snoozeClock;
70247034
if (!activeThreadSnoozed) return;
70257035
const wakeAtMs = Date.parse(activeThreadShell?.snoozedUntil ?? "");
70267036
if (!Number.isFinite(wakeAtMs)) return;
70277037
const id = window.setTimeout(
7028-
() => bumpSnoozeWakeTick((tick) => tick + 1),
7038+
() => setSnoozeClockState((clock) => ({ ...clock, now: new Date().toISOString() })),
70297039
Math.min(Math.max(0, wakeAtMs - Date.now()) + 50, 2_147_483_647),
70307040
);
70317041
return () => window.clearTimeout(id);
7032-
}, [activeThreadShell?.snoozedUntil, activeThreadSnoozed, snoozeWakeTick]);
7042+
}, [activeThreadShell?.snoozedUntil, activeThreadSnoozed, snoozeClock]);
70337043
const activeThreadWokeAt =
70347044
activeThreadShell !== null && supportsSnooze
7035-
? threadWokeAt(activeThreadShell, { now: new Date().toISOString() })
7045+
? threadWokeAt(activeThreadShell, { now: snoozeClock })
70367046
: null;
70377047
const acknowledgeThreadWoke = useAcknowledgeThreadWoke();
70387048
const acknowledgeActiveThreadWoke = () => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.