MCPcopy Index your code
hub / github.com/Dimillian/CodexMonitor / useThreadActions

Function useThreadActions

src/features/threads/hooks/useThreadActions.ts:75–874  ·  view source on GitHub ↗
({
  dispatch,
  itemsByThread,
  threadsByWorkspace,
  activeThreadIdByWorkspace,
  activeTurnIdByThread,
  threadParentById,
  threadListCursorByWorkspace,
  threadStatusById,
  threadSortKey,
  onDebug,
  getCustomName,
  threadActivityRef,
  loadedThreadsRef,
  replaceOnResumeRef,
  applyCollabThreadLinksFromThread,
  updateThreadParent,
  onSubagentThreadDetected,
  onThreadCodexMetadataDetected,
}: UseThreadActionsOptions)

Source from the content-addressed store, hash-verified

73};
74
75export function useThreadActions({
76 dispatch,
77 itemsByThread,
78 threadsByWorkspace,
79 activeThreadIdByWorkspace,
80 activeTurnIdByThread,
81 threadParentById,
82 threadListCursorByWorkspace,
83 threadStatusById,
84 threadSortKey,
85 onDebug,
86 getCustomName,
87 threadActivityRef,
88 loadedThreadsRef,
89 replaceOnResumeRef,
90 applyCollabThreadLinksFromThread,
91 updateThreadParent,
92 onSubagentThreadDetected,
93 onThreadCodexMetadataDetected,
94}: UseThreadActionsOptions) {
95 const resumeInFlightByThreadRef = useRef<Record<string, number>>({});
96 const threadStatusByIdRef = useRef(threadStatusById);
97 const activeTurnIdByThreadRef = useRef(activeTurnIdByThread);
98 threadStatusByIdRef.current = threadStatusById;
99 activeTurnIdByThreadRef.current = activeTurnIdByThread;
100
101 const applyThreadMetadata = useCallback(
102 (
103 workspaceId: string,
104 threadId: string,
105 thread: Record<string, unknown>,
106 options?: { notifySubagent?: boolean },
107 ) => {
108 const codexMetadata = extractThreadCodexMetadata(thread);
109 if (codexMetadata.modelId || codexMetadata.effort) {
110 onThreadCodexMetadataDetected?.(workspaceId, threadId, codexMetadata);
111 }
112 const sourceParentId = getParentThreadIdFromThread(thread);
113 if (sourceParentId) {
114 updateThreadParent(sourceParentId, [threadId]);
115 if (options?.notifySubagent) {
116 onSubagentThreadDetected(workspaceId, threadId);
117 }
118 }
119 },
120 [
121 onSubagentThreadDetected,
122 onThreadCodexMetadataDetected,
123 updateThreadParent,
124 ],
125 );
126
127 const dispatchPreviewMessage = useCallback(
128 (threadId: string, text: string, timestamp: number) => {
129 dispatch({
130 type: "setLastAgentMessage",
131 threadId,
132 text,

Callers 2

useThreadsFunction · 0.90
renderActionsFunction · 0.90

Calls 14

buildResumeHydrationPlanFunction · 0.90
buildWorkspacePathLookupFunction · 0.90
getThreadListNextCursorFunction · 0.90
saveThreadActivityFunction · 0.90
asStringFunction · 0.90

Tested by 1

renderActionsFunction · 0.72