Skip to content

Commit 3124ffd

Browse files
committed
Prevent auto-generated title from overwriting manual rename
1 parent e96a20f commit 3124ffd

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

apps/code/src/renderer/features/sessions/hooks/useChatTitleGenerator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ export function useChatTitleGenerator(taskId: string): void {
6565

6666
const run = async () => {
6767
try {
68-
const cachedTasks = queryClient.getQueryData<Task[]>(["tasks", "list"]);
69-
const cachedTask = cachedTasks?.find((t) => t.id === taskId);
68+
const allTaskQueries = queryClient.getQueriesData<Task[]>({
69+
queryKey: ["tasks", "list"],
70+
});
71+
const cachedTask = allTaskQueries
72+
.flatMap(([, tasks]) => tasks ?? [])
73+
.find((t) => t.id === taskId);
7074
if (cachedTask?.title_manually_set) {
7175
log.debug("Skipping auto-title, user renamed task", { taskId });
7276
return;

apps/code/src/renderer/sagas/task/task-creation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ async function generateTaskTitle(
3939
if (!result?.title) return;
4040
const { title } = result;
4141

42+
const allTaskQueries = queryClient.getQueriesData<Task[]>({
43+
queryKey: ["tasks", "list"],
44+
});
45+
const cachedTask = allTaskQueries
46+
.flatMap(([, tasks]) => tasks ?? [])
47+
.find((t) => t.id === taskId);
48+
if (cachedTask?.title_manually_set) {
49+
log.debug("Skipping auto-title, user renamed task", { taskId });
50+
return;
51+
}
52+
4253
try {
4354
await posthogClient.updateTask(taskId, { title });
4455

0 commit comments

Comments
 (0)