GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — claude-code-source-code/src/hooks/useSkillsChange.ts at main · chaoswork/claude-code-source-code Expand file tree/ Copy pathuseSkillsChange.tsMore file actions 62 lines (58 loc) · 2.04 KB / Copy pathuseSkillsChange.tsFile metadata and controls62 lines (58 loc) · 2.04 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 import { useCallback, useEffect } from 'react' import type { Command } from '../commands.js' import { clearCommandMemoizationCaches, clearCommandsCache, getCommands, } from '../commands.js' import { onGrowthBookRefresh } from '../services/analytics/growthbook.js' import { logError } from '../utils/log.js' import { skillChangeDetector } from '../utils/skills/skillChangeDetector.js' /** * Keep the commands list fresh across two triggers: * * 1. Skill file changes (watcher) — full cache clear + disk re-scan, since * skill content changed on disk. * 2. GrowthBook init/refresh — memo-only clear, since only `isEnabled()` * predicates may have changed. Handles commands like /btw whose gate * reads a flag that isn't in the disk cache yet on first session after * a flag rename: getCommands() runs before GB init (main.tsx:2855 vs * showSetupScreens at :3106), so the memoized list is baked with the * default. Once init populates remoteEvalFeatureValues, re-filter. */ export function useSkillsChange( cwd: string | undefined, onCommandsChange: (commands: Command[]) => void, ): void { const handleChange = useCallback(async () => { if (!cwd) return try { // Clear all command caches to ensure fresh load clearCommandsCache() const commands = await getCommands(cwd) onCommandsChange(commands) } catch (error) { // Errors during reload are non-fatal - log and continue if (error instanceof Error) { logError(error) } } }, [cwd, onCommandsChange]) useEffect(() => skillChangeDetector.subscribe(handleChange), [handleChange]) const handleGrowthBookRefresh = useCallback(async () => { if (!cwd) return try { clearCommandMemoizationCaches() const commands = await getCommands(cwd) onCommandsChange(commands) } catch (error) { if (error instanceof Error) { logError(error) } } }, [cwd, onCommandsChange]) useEffect( () => onGrowthBookRefresh(handleGrowthBookRefresh), [handleGrowthBookRefresh], ) } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |