Rename chat (#673)

Fixes #102
This commit is contained in:
Will Chen
2025-07-21 17:44:56 -07:00
committed by GitHub
parent c5fdbeb90f
commit de21c6ff25
7 changed files with 338 additions and 81 deletions

View File

@@ -9,6 +9,7 @@ import { createLoggedHandler } from "./safe_handle";
import log from "electron-log";
import { getDyadAppPath } from "../../paths/paths";
import { UpdateChatParams } from "../ipc_types";
const logger = log.scope("chat_handlers");
const handle = createLoggedHandler(logger);
@@ -107,6 +108,10 @@ export function registerChatHandlers() {
await db.delete(chats).where(eq(chats.id, chatId));
});
handle("update-chat", async (_, { chatId, title }: UpdateChatParams) => {
await db.update(chats).set({ title }).where(eq(chats.id, chatId));
});
handle("delete-messages", async (_, chatId: number): Promise<void> => {
await db.delete(messages).where(eq(messages.chatId, chatId));
});

View File

@@ -49,6 +49,7 @@ import type {
IsVercelProjectAvailableParams,
SaveVercelAccessTokenParams,
VercelProject,
UpdateChatParams,
} from "./ipc_types";
import type { AppChatContext, ProposalResult } from "@/lib/schemas";
import { showError } from "@/lib/toast";
@@ -351,6 +352,10 @@ export class IpcClient {
return this.ipcRenderer.invoke("create-chat", appId);
}
public async updateChat(params: UpdateChatParams): Promise<void> {
return this.ipcRenderer.invoke("update-chat", params);
}
public async deleteChat(chatId: number): Promise<void> {
await this.ipcRenderer.invoke("delete-chat", chatId);
}

View File

@@ -316,3 +316,8 @@ export interface VercelProject {
name: string;
framework: string | null;
}
export interface UpdateChatParams {
chatId: number;
title: string;
}