mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: allow renaming of agent chat title (#24489)
Co-authored-by: Coder Agents <noreply@coder.com>
This commit is contained in:
co-authored by
Coder Agents
parent
18a30a7a10
commit
410f9a5e19
@@ -3171,6 +3171,13 @@ class ExperimentalApiMethods {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
proposeChatTitle = async (chatId: string): Promise<{ title: string }> => {
|
||||
const response = await this.axios.post<{ title: string }>(
|
||||
`/api/experimental/chats/${chatId}/title/propose`,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
createChatMessage = async (
|
||||
chatId: string,
|
||||
req: CreateChatMessageRequestWithClearablePlanMode,
|
||||
|
||||
@@ -826,6 +826,38 @@ export const regenerateChatTitle = (queryClient: QueryClient) => ({
|
||||
},
|
||||
});
|
||||
|
||||
type UpdateChatTitleVariables = {
|
||||
chatId: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
export const updateChatTitle = (queryClient: QueryClient) => ({
|
||||
mutationFn: ({ chatId, title }: UpdateChatTitleVariables) =>
|
||||
API.experimental.updateChat(chatId, { title }),
|
||||
|
||||
onSuccess: (_data: unknown, { chatId, title }: UpdateChatTitleVariables) => {
|
||||
queryClient.setQueryData<TypesGen.Chat | undefined>(
|
||||
chatKey(chatId),
|
||||
(chat) => (chat ? { ...chat, title } : chat),
|
||||
);
|
||||
updateInfiniteChatsCache(queryClient, (chats) =>
|
||||
chats.map((chat) => (chat.id === chatId ? { ...chat, title } : chat)),
|
||||
);
|
||||
},
|
||||
|
||||
onSettled: async (
|
||||
_data: unknown,
|
||||
_error: unknown,
|
||||
{ chatId }: UpdateChatTitleVariables,
|
||||
) => {
|
||||
await invalidateChatListQueries(queryClient);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: chatKey(chatId),
|
||||
exact: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const createChat = (queryClient: QueryClient) => ({
|
||||
mutationFn: (req: TypesGen.CreateChatRequest) =>
|
||||
API.experimental.createChat(req),
|
||||
|
||||
Generated
+8
@@ -5700,6 +5700,14 @@ export interface PrometheusConfig {
|
||||
readonly aggregate_agent_stats_by: string;
|
||||
}
|
||||
|
||||
// From codersdk/chats.go
|
||||
/**
|
||||
* ProposeChatTitleResponse is returned by the propose-title endpoint.
|
||||
*/
|
||||
export interface ProposeChatTitleResponse {
|
||||
readonly title: string;
|
||||
}
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export interface ProvisionerConfig {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user