You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"- Fetch live data with TanStack options from the tool proxy: `useQuery(tools.<namespace>.<tool>.queryOptions(args))`. Do not call tools before generating the UI and paste returned data into JSX.",
69
69
"- For user-triggered writes or actions, use `useMutation(tools.<namespace>.<tool>.mutationOptions({ onSuccess }))` and call `mutate(input)` from event handlers.",
70
70
"- Invalidate or refetch reads with `useQueryClient()` and stable keys from `tools.<namespace>.<tool>.queryKey(args)`.",
71
+
"- Use the discovered output shape exactly. Do not invent wrapper fields like `data.domain` or `data.items` unless the schema/sample shows them.",
72
+
"- For toggles and switches, mutate with the checked value from the event instead of inverting possibly stale query data.",
73
+
"- For optimistic writes, use TanStack `onMutate` / `onError` / `onSettled`: cancel the query, snapshot old data, `setQueryData`, roll back on error, then invalidate.",
71
74
"- Only hardcode small display constants like labels, colors, tab names, and chart configuration. Never embed tool response rows, API results, summaries, or dashboard data as literals in the component.",
72
75
"- Always render loading and error states from `useQuery` / `useMutation`; do not replace them with hardcoded fallback data.",
73
76
"- Tools: `tools.<namespace>.<tool>(args)` — call any configured API tool (never use raw `fetch`). Tool helpers: `.queryOptions(args, options)`, `.mutationOptions(options)`, `.queryKey(args)`, `.pathKey()`, and `.mutationKey()`.",
"- Fetch live data with TanStack options from the tool proxy: `useQuery(tools.<namespace>.<tool>.queryOptions(args))`.",
79
79
"- For user-triggered writes, use `useMutation(tools.<namespace>.<tool>.mutationOptions({ onSuccess }))` and call `mutate(input)` from event handlers.",
80
80
"- Invalidate or refetch reads with `useQueryClient()` and stable keys from `tools.<namespace>.<tool>.queryKey(args)`.",
81
+
"- Use the discovered output shape exactly. Do not invent wrapper fields like `data.domain` or `data.items` unless the schema/sample shows them.",
82
+
"- For toggles and switches, mutate with the checked value from the event instead of inverting possibly stale query data.",
83
+
"- For optimistic writes, use TanStack `onMutate` / `onError` / `onSettled`: cancel the query, snapshot old data, `setQueryData`, roll back on error, then invalidate.",
81
84
"- Only hardcode small display constants like labels, colors, tab names, and chart configuration. Never embed tool response rows, API results, summaries, or dashboard data as literals in the component.",
82
85
"- Always render loading and error states from `useQuery` / `useMutation`; do not replace them with hardcoded fallback data.",
83
86
`- shadcn/ui components available by name: ${SHADCN_COMPONENTS}`,
"- `render-ui` is for the final interactive surface. Do not paste discovery results into JSX as literal rows, cards, summaries, metrics, or chart series.",
104
107
"- After discovering an API call with `execute`, put the same call in TanStack Query options inside the generated component.",
105
108
"- Example discovery: call `execute` with `return await tools.axiom_mcp.querydataset({ ... })` to confirm columns, then call `render-ui` with `useQuery(tools.axiom_mcp.querydataset.queryOptions({ ... }))`.",
109
+
"- Use discovered result shapes exactly. If a sample or schema returns `{ renew, expiresAt }`, read `data?.renew`, not `data?.domain?.renew`.",
106
110
"- Keep discovery small. Use limits, narrow time ranges, or schema/list tools when possible.",
107
111
"",
112
+
"## TanStack Query State",
113
+
"",
114
+
"- Use `const queryClient = useQueryClient()` when a mutation changes data shown by a query.",
115
+
"- For simple writes, invalidate with `queryClient.invalidateQueries(tools.<namespace>.<queryTool>.queryFilter(args))` in `onSuccess` or `onSettled`.",
116
+
"- For toggles and switches, pass the new checked value into `mutate`: `onCheckedChange={(checked) => mutation.mutate({ body: { enabled: checked } })}`.",
117
+
"- For optimistic UI, use `onMutate` to `cancelQueries`, snapshot `getQueryData`, and `setQueryData`; return the snapshot, restore it in `onError`, and invalidate in `onSettled`.",
118
+
"- Do not show success text by combining `mutation.isSuccess` with stale query data. Either update the query cache optimistically or show a neutral saved state after invalidation.",
119
+
"",
108
120
"## Available UI Components",
109
121
"",
110
122
`- shadcn/ui components available by name: ${SHADCN_COMPONENTS}`,
0 commit comments