source dump of claude code
at main 15 lines 543 B view raw
1import { useSyncExternalStore } from 'react' 2import type { QueuedCommand } from '../types/textInputTypes.js' 3import { 4 getCommandQueueSnapshot, 5 subscribeToCommandQueue, 6} from '../utils/messageQueueManager.js' 7 8/** 9 * React hook to subscribe to the unified command queue. 10 * Returns a frozen array that only changes reference on mutation. 11 * Components re-render only when the queue changes. 12 */ 13export function useCommandQueue(): readonly QueuedCommand[] { 14 return useSyncExternalStore(subscribeToCommandQueue, getCommandQueueSnapshot) 15}