Download apps/vis/web/src/hooks/useContext.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vis/web/src/hooks/useContext.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vis/web/src/hooks/useContext.ts
-
curl -L -o useContext.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vis/web/src/hooks/useContext.ts
1.07 kB
| import { useQuery } from '@tanstack/react-query'; | |
| import { api } from '../api'; | |
| /** | |
| * Fetch the projected context for a given agent in a session. | |
| * | |
| * The `/api/sessions/:id/context?agent=<agentId>` route returns the | |
| * full `ContextProjection` (messages, usage totals, contextTokens, | |
| * config snapshot, permission mode, plan mode, goal, swarm). Defaults | |
| * to `main` when no agent id is provided, but callers should pass an | |
| * explicit id for clarity. | |
| * | |
| * `mode` selects the projection view: `'model'` (default) mirrors what | |
| * the model currently sees (post-compaction/undo/clear), while `'full'` | |
| * requests the full reconstructed history for debugging. Both modes are | |
| * cached independently (the mode is part of the React Query key). | |
| */ | |
| export function useContext( | |
| sessionId: string, | |
| agentId: string, | |
| mode: 'model' | 'full' = 'model', | |
| ) { | |
| return useQuery({ | |
| queryKey: ['context', sessionId, agentId, mode] as const, | |
| queryFn: () => api.getContext(sessionId, agentId, mode), | |
| enabled: sessionId.length > 0 && agentId.length > 0, | |
| }); | |
| } | |