MCPcopy
hub / github.com/codeaashu/claude-code / useSkillsChange

Function useSkillsChange

src/hooks/useSkillsChange.ts:24–62  ·  view source on GitHub ↗
(
  cwd: string | undefined,
  onCommandsChange: (commands: Command[]) => void,
)

Source from the content-addressed store, hash-verified

22 * default. Once init populates remoteEvalFeatureValues, re-filter.
23 */
24export function useSkillsChange(
25 cwd: string | undefined,
26 onCommandsChange: (commands: Command[]) => void,
27): void {
28 const handleChange = useCallback(async () => {
29 if (!cwd) return
30 try {
31 // Clear all command caches to ensure fresh load
32 clearCommandsCache()
33 const commands = await getCommands(cwd)
34 onCommandsChange(commands)
35 } catch (error) {
36 // Errors during reload are non-fatal - log and continue
37 if (error instanceof Error) {
38 logError(error)
39 }
40 }
41 }, [cwd, onCommandsChange])
42
43 useEffect(() => skillChangeDetector.subscribe(handleChange), [handleChange])
44
45 const handleGrowthBookRefresh = useCallback(async () => {
46 if (!cwd) return
47 try {
48 clearCommandMemoizationCaches()
49 const commands = await getCommands(cwd)
50 onCommandsChange(commands)
51 } catch (error) {
52 if (error instanceof Error) {
53 logError(error)
54 }
55 }
56 }, [cwd, onCommandsChange])
57
58 useEffect(
59 () => onGrowthBookRefresh(handleGrowthBookRefresh),
60 [handleGrowthBookRefresh],
61 )
62}
63

Callers 1

REPLFunction · 0.85

Calls 5

clearCommandsCacheFunction · 0.85
getCommandsFunction · 0.85
onGrowthBookRefreshFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected