MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / removeFunctionHook

Function removeFunctionHook

source code/utils/hooks/sessionHooks.ts:122–164  ·  view source on GitHub ↗
(
  setAppState: (updater: (prev: AppState) => AppState) => void,
  sessionId: string,
  event: HookEvent,
  hookId: string,
)

Source from the content-addressed store, hash-verified

120 * Remove a function hook by ID from the session.
121 */
122export function removeFunctionHook(
123 setAppState: (updater: (prev: AppState) => AppState) => void,
124 sessionId: string,
125 event: HookEvent,
126 hookId: string,
127): void {
128 setAppState(prev => {
129 const store = prev.sessionHooks.get(sessionId)
130 if (!store) {
131 return prev
132 }
133
134 const eventMatchers = store.hooks[event] || []
135
136 // Remove the hook with matching ID from all matchers
137 const updatedMatchers = eventMatchers
138 .map(matcher => {
139 const updatedHooks = matcher.hooks.filter(h => {
140 if (h.hook.type !== 'function') return true
141 return h.hook.id !== hookId
142 })
143
144 return updatedHooks.length > 0
145 ? { ...matcher, hooks: updatedHooks }
146 : null
147 })
148 .filter((m): m is SessionHookMatcher => m !== null)
149
150 const newHooks =
151 updatedMatchers.length > 0
152 ? { ...store.hooks, [event]: updatedMatchers }
153 : Object.fromEntries(
154 Object.entries(store.hooks).filter(([e]) => e !== event),
155 )
156
157 prev.sessionHooks.set(sessionId, { hooks: newHooks })
158 return prev
159 })
160
161 logForDebugging(
162 `Removed function hook ${hookId} for event ${event} in session ${sessionId}`,
163 )
164}
165
166/**
167 * Internal helper to add a hook to session state

Callers

nothing calls this directly

Calls 4

logForDebuggingFunction · 0.85
entriesMethod · 0.80
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected