Ionosphere.tv
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: move allComments/pendingComments before useMemos that depend on them

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+11 -12
+11 -12
apps/ionosphere/src/app/components/TranscriptView.tsx
··· 354 354 [] 355 355 ); 356 356 357 + // Optimistic comments — rendered immediately before the round-trip completes 358 + const [pendingComments, setPendingComments] = useState<CommentData[]>([]); 359 + 360 + // Merge server comments + pending, dedup by URI 361 + const allComments = useMemo(() => { 362 + if (pendingComments.length === 0) return comments || []; 363 + const serverUris = new Set((comments || []).map((c) => c.uri)); 364 + const stillPending = pendingComments.filter((p) => !serverUris.has(p.uri)); 365 + return [...(comments || []), ...stillPending]; 366 + }, [comments, pendingComments]); 367 + 357 368 const wordHasComment = useMemo(() => { 358 369 if (allComments.length === 0) return new Set<number>(); 359 370 const set = new Set<number>(); ··· 407 418 408 419 // Expanded reaction group (which span's comments are shown) 409 420 const [expandedSpan, setExpandedSpan] = useState<string | null>(null); 410 - 411 - // Optimistic comments — rendered immediately before the round-trip completes 412 - const [pendingComments, setPendingComments] = useState<CommentData[]>([]); 413 - 414 - // Merge server comments + pending, dedup by text+anchor 415 - const allComments = useMemo(() => { 416 - if (pendingComments.length === 0) return comments || []; 417 - const serverUris = new Set((comments || []).map((c) => c.uri)); 418 - // Remove pending comments that have arrived from the server 419 - const stillPending = pendingComments.filter((p) => !serverUris.has(p.uri)); 420 - return [...(comments || []), ...stillPending]; 421 - }, [comments, pendingComments]); 422 421 423 422 const handlePublish = useCallback(async (byteStart: number, byteEnd: number, text: string) => { 424 423 if (!agent || !transcriptUri) return;