Add turbo resend for testing

This commit is contained in:
Jack Kingsman
2026-02-15 23:49:50 -08:00
parent 1f3042f360
commit 945053c20a
+28 -1
View File
@@ -159,6 +159,7 @@ export function MessageList({
} | null>(null);
const [resendableIds, setResendableIds] = useState<Set<number>>(new Set());
const resendTimersRef = useRef<Map<number, ReturnType<typeof setTimeout>>>(new Map());
const activeBurstsRef = useRef<Map<number, ReturnType<typeof setTimeout>[]>>(new Map());
// Capture scroll state in the scroll handler BEFORE any state updates
const scrollStateRef = useRef({
@@ -259,6 +260,17 @@ export function MessageList({
};
}, [messages, onResendChannelMessage]);
// Clean up burst timers on unmount
useEffect(() => {
const bursts = activeBurstsRef.current;
return () => {
for (const timers of bursts.values()) {
for (const t of timers) clearTimeout(t);
}
bursts.clear();
};
}, []);
// Handle scroll - capture state and detect when user is near top/bottom
const handleScroll = useCallback(() => {
if (!listRef.current) return;
@@ -511,7 +523,22 @@ export function MessageList({
className="text-muted-foreground hover:text-primary ml-1 text-xs cursor-pointer"
onClick={(e) => {
e.stopPropagation();
onResendChannelMessage(msg.id);
if (e.altKey) {
// Burst resend: 5 times, 2 seconds apart
if (activeBurstsRef.current.has(msg.id)) return;
onResendChannelMessage(msg.id); // first send (immediate)
const timers: ReturnType<typeof setTimeout>[] = [];
for (let i = 1; i <= 4; i++) {
const timer = setTimeout(() => {
onResendChannelMessage(msg.id);
if (i === 4) activeBurstsRef.current.delete(msg.id);
}, i * 2000);
timers.push(timer);
}
activeBurstsRef.current.set(msg.id, timers);
} else {
onResendChannelMessage(msg.id);
}
}}
title="Resend message"
>