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

Function useMainLoopModel

src/hooks/useMainLoopModel.ts:13–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11// API calls. Use this over getMainLoopModel() when the component needs to
12// update upon a model config change.
13export function useMainLoopModel(): ModelName {
14 const mainLoopModel = useAppState(s => s.mainLoopModel)
15 const mainLoopModelForSession = useAppState(s => s.mainLoopModelForSession)
16
17 // parseUserSpecifiedModel reads tengu_ant_model_override via
18 // _CACHED_MAY_BE_STALE (in resolveAntModel). Until GB init completes,
19 // that's the stale disk cache; after, it's the in-memory remoteEval map.
20 // AppState doesn't change when GB init finishes, so we subscribe to the
21 // refresh signal and force a re-render to re-resolve with fresh values.
22 // Without this, the alias resolution is frozen until something else
23 // happens to re-render the component — the API would sample one model
24 // while /model (which also re-resolves) displays another.
25 const [, forceRerender] = useReducer(x => x + 1, 0)
26 useEffect(() => onGrowthBookRefresh(forceRerender), [])
27
28 const model = parseUserSpecifiedModel(
29 mainLoopModelForSession ??
30 mainLoopModel ??
31 getDefaultMainLoopModelSetting(),
32 )
33 return model
34}
35

Callers 9

StatusLineInnerFunction · 0.85
LogoV2Function · 0.85
CondensedLogoFunction · 0.85
PromptInputFunction · 0.85
NotificationsFunction · 0.85
GenerateStepFunction · 0.85
ShowCurrentEffortFunction · 0.85
LoginFunction · 0.85
REPLFunction · 0.85

Calls 4

useAppStateFunction · 0.85
onGrowthBookRefreshFunction · 0.85
parseUserSpecifiedModelFunction · 0.85

Tested by

no test coverage detected