MCPcopy Create free account
hub / github.com/codeaashu/claude-code / removeSessionHook

Function removeSessionHook

src/utils/hooks/sessionHooks.ts:225–268  ·  view source on GitHub ↗
(
  setAppState: (updater: (prev: AppState) => AppState) => void,
  sessionId: string,
  event: HookEvent,
  hook: HookCommand,
)

Source from the content-addressed store, hash-verified

223 * @param hook The hook command to remove
224 */
225export function removeSessionHook(
226 setAppState: (updater: (prev: AppState) => AppState) => void,
227 sessionId: string,
228 event: HookEvent,
229 hook: HookCommand,
230): void {
231 setAppState(prev => {
232 const store = prev.sessionHooks.get(sessionId)
233 if (!store) {
234 return prev
235 }
236
237 const eventMatchers = store.hooks[event] || []
238
239 // Remove the hook from all matchers
240 const updatedMatchers = eventMatchers
241 .map(matcher => {
242 const updatedHooks = matcher.hooks.filter(
243 h => !isHookEqual(h.hook, hook),
244 )
245
246 return updatedHooks.length > 0
247 ? { ...matcher, hooks: updatedHooks }
248 : null
249 })
250 .filter((m): m is SessionHookMatcher => m !== null)
251
252 const newHooks =
253 updatedMatchers.length > 0
254 ? { ...store.hooks, [event]: updatedMatchers }
255 : { ...store.hooks }
256
257 if (updatedMatchers.length === 0) {
258 delete newHooks[event]
259 }
260
261 prev.sessionHooks.set(sessionId, { ...store, hooks: newHooks })
262 return prev
263 })
264
265 logForDebugging(
266 `Removed session hook for event ${event} in session ${sessionId}`,
267 )
268}
269
270// Extended hook matcher that includes optional skillRoot for skill-scoped hooks
271export type SessionDerivedHookMatcher = {

Callers 1

registerSkillHooksFunction · 0.85

Calls 4

isHookEqualFunction · 0.85
logForDebuggingFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected