📄 File detail

hooks/useCommandQueue.ts

🧩 .ts📏 16 lines💾 543 bytes📝 text
← Back to All Files

🎯 Use case

This file lives under “hooks/”, which covers reusable UI or integration hooks. On the API surface it exposes useCommandQueue — mainly functions, hooks, or classes. Dependencies touch React UI. It composes internal code from types and utils (relative imports).

Generated from folder role, exports, dependency roots, and inline comments — not hand-reviewed for every path.

🧠 Inline summary

import { useSyncExternalStore } from 'react' import type { QueuedCommand } from '../types/textInputTypes.js' import { getCommandQueueSnapshot, subscribeToCommandQueue,

📤 Exports (heuristic)

  • useCommandQueue

📚 External import roots

Package roots from from "…" (relative paths omitted).

  • react

🖥️ Source preview

import { useSyncExternalStore } from 'react'
import type { QueuedCommand } from '../types/textInputTypes.js'
import {
  getCommandQueueSnapshot,
  subscribeToCommandQueue,
} from '../utils/messageQueueManager.js'

/**
 * React hook to subscribe to the unified command queue.
 * Returns a frozen array that only changes reference on mutation.
 * Components re-render only when the queue changes.
 */
export function useCommandQueue(): readonly QueuedCommand[] {
  return useSyncExternalStore(subscribeToCommandQueue, getCommandQueueSnapshot)
}