MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / useProfileMutations

Function useProfileMutations

apps/web/src/hooks/useCloudAgentProfiles.ts:173–409  ·  view source on GitHub ↗
(options: UseProfileMutationsOptions = {})

Source from the content-addressed store, hash-verified

171 * Hook returning all profile mutation functions
172 */
173export function useProfileMutations(options: UseProfileMutationsOptions = {}) {
174 const { organizationId } = options;
175 const queryClient = useQueryClient();
176 const trpc = useTRPC();
177
178 const invalidateProfiles = async () => {
179 await queryClient.invalidateQueries({
180 queryKey: trpc.agentProfiles.list.queryKey({ organizationId }),
181 });
182 };
183
184 const invalidateProfile = async (profileId: string) => {
185 await queryClient.invalidateQueries({
186 queryKey: trpc.agentProfiles.get.queryKey({ profileId, organizationId }),
187 });
188 await invalidateProfiles();
189 };
190
191 const createProfile = useMutation(
192 trpc.agentProfiles.create.mutationOptions({
193 onSuccess: async () => {
194 await invalidateProfiles();
195 },
196 })
197 );
198
199 const updateProfile = useMutation(
200 trpc.agentProfiles.update.mutationOptions({
201 onSuccess: async (_data, variables) => {
202 await invalidateProfile(variables.profileId);
203 },
204 })
205 );
206
207 const deleteProfile = useMutation(
208 trpc.agentProfiles.delete.mutationOptions({
209 onSuccess: async (_data, variables) => {
210 await invalidateProfile(variables.profileId);
211 },
212 })
213 );
214
215 const setAsDefault = useMutation(
216 trpc.agentProfiles.setAsDefault.mutationOptions({
217 onSuccess: async () => {
218 // Setting a default flips isDefault on both the new and previous default,
219 // so invalidate every single-profile get query in addition to the list.
220 await queryClient.invalidateQueries({
221 queryKey: trpc.agentProfiles.get.queryKey(),
222 });
223 await invalidateProfiles();
224 },
225 })
226 );
227
228 const clearDefault = useMutation(
229 trpc.agentProfiles.clearDefault.mutationOptions({
230 onSuccess: async () => {

Callers 15

ProfilesListDialogFunction · 0.90
SaveProfileDialogFunction · 0.90
AgentRowFunction · 0.90
AgentFormFunction · 0.90
McpServerRowFunction · 0.90
McpFormFunction · 0.90
SkillsTabFunction · 0.90
SkillRowFunction · 0.90
SkillFormFunction · 0.90
KiloCommandRowFunction · 0.90
KiloCommandFormFunction · 0.90
ProfilesListDialogFunction · 0.90

Calls 2

invalidateProfilesFunction · 0.85
invalidateProfileFunction · 0.85

Tested by

no test coverage detected