Skip to content

Commit eaf5ad5

Browse files
committed
fix(web): ignore invalid notification timestamps
1 parent 3b3fe72 commit eaf5ad5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,34 @@ function EnvironmentNotifications({ environmentId }: { environmentId: Environmen
4343
const shell = useAtomValue(environmentShell.stateValueAtom(environmentId));
4444
const mode = useClientSettings((settings) => settings.notificationMode);
4545
const navigate = useNavigate();
46-
const previous = useRef(new Map<ThreadId, { input: string | null; completion: string | null }>());
46+
const previous = useRef(new Map<ThreadId, { input: string | null; completion: number | null }>());
4747

4848
useEffect(() => {
4949
if (shell.status !== "live" || Option.isNone(shell.snapshot)) {
5050
previous.current.clear();
5151
return;
5252
}
53-
const next = new Map<ThreadId, { input: string | null; completion: string | null }>();
53+
const next = new Map<ThreadId, { input: string | null; completion: number | null }>();
5454
for (const thread of shell.snapshot.value.threads) {
5555
const status = resolveSidebarThreadStatus(thread);
5656
const prior = previous.current.get(thread.id);
5757
const input =
5858
status === "input" || status === "approval"
5959
? `${thread.latestTurn?.turnId ?? ""}:${status}`
6060
: null;
61+
const completedAt = Date.parse(thread.latestTurn?.completedAt ?? "");
6162
const completion =
62-
status === "ready" && thread.latestTurn?.state === "completed"
63-
? thread.latestTurn.completedAt
63+
status === "ready" &&
64+
thread.latestTurn?.state === "completed" &&
65+
Number.isFinite(completedAt)
66+
? completedAt
6467
: (prior?.completion ?? null);
6568
next.set(thread.id, { input, completion });
6669
if (!prior || mode === "off" || thread.archivedAt !== null) continue;
6770
const kind =
6871
input && input !== prior.input
6972
? "input"
70-
: completion &&
71-
(prior.completion === null || Date.parse(completion) > Date.parse(prior.completion))
73+
: completion !== null && (prior.completion === null || completion > prior.completion)
7274
? "completion"
7375
: null;
7476
if (!kind) continue;

0 commit comments

Comments
 (0)