diff --git a/src/atoms/chatAtoms.ts b/src/atoms/chatAtoms.ts index fd0742a..6a26399 100644 --- a/src/atoms/chatAtoms.ts +++ b/src/atoms/chatAtoms.ts @@ -1,4 +1,4 @@ -import type { Message } from "ai"; +import type { Message } from "@/ipc/ipc_types"; import { atom } from "jotai"; import type { ChatSummary } from "@/lib/schemas"; diff --git a/src/components/chat/ChatMessage.tsx b/src/components/chat/ChatMessage.tsx index 0512ee6..79ac89a 100644 --- a/src/components/chat/ChatMessage.tsx +++ b/src/components/chat/ChatMessage.tsx @@ -1,5 +1,5 @@ import { memo } from "react"; -import type { Message } from "ai"; +import type { Message } from "@/ipc/ipc_types"; import { DyadMarkdownParser } from "./DyadMarkdownParser"; import { motion } from "framer-motion"; import { useStreamChat } from "@/hooks/useStreamChat"; @@ -66,6 +66,19 @@ const ChatMessage = ({ message }: ChatMessageProps) => { )} + {message.approvalState && ( +
+ {message.approvalState === "approved" ? ( +
+ Approved +
+ ) : message.approvalState === "rejected" ? ( +
+ Rejected +
+ ) : null} +
+ )} ); diff --git a/src/components/chat/MessagesList.tsx b/src/components/chat/MessagesList.tsx index ffca042..85758c5 100644 --- a/src/components/chat/MessagesList.tsx +++ b/src/components/chat/MessagesList.tsx @@ -1,5 +1,5 @@ import type React from "react"; -import type { Message } from "ai"; +import type { Message } from "@/ipc/ipc_types"; import { forwardRef } from "react"; import ChatMessage from "./ChatMessage"; import { SetupBanner } from "../SetupBanner"; diff --git a/src/hooks/useStreamChat.ts b/src/hooks/useStreamChat.ts index 5c7fb21..41d1868 100644 --- a/src/hooks/useStreamChat.ts +++ b/src/hooks/useStreamChat.ts @@ -1,5 +1,5 @@ import { useCallback, useState } from "react"; -import type { Message } from "ai"; +import type { Message } from "@/ipc/ipc_types"; import { useAtom, useSetAtom } from "jotai"; import { chatErrorAtom, diff --git a/src/ipc/handlers/proposal_handlers.ts b/src/ipc/handlers/proposal_handlers.ts index edba535..3219a74 100644 --- a/src/ipc/handlers/proposal_handlers.ts +++ b/src/ipc/handlers/proposal_handlers.ts @@ -50,9 +50,17 @@ const getProposalHandler = async ( columns: { id: true, // Fetch the ID content: true, // Fetch the content to parse + approvalState: true, }, }); + if ( + latestAssistantMessage?.approvalState === "approved" || + latestAssistantMessage?.approvalState === "rejected" + ) { + return null; + } + if (latestAssistantMessage?.content && latestAssistantMessage.id) { const messageId = latestAssistantMessage.id; // Get the message ID console.log( diff --git a/src/ipc/ipc_client.ts b/src/ipc/ipc_client.ts index 27f61c4..a715faf 100644 --- a/src/ipc/ipc_client.ts +++ b/src/ipc/ipc_client.ts @@ -1,4 +1,3 @@ -import type { Message } from "ai"; import type { IpcRenderer } from "electron"; import { type ChatSummary, @@ -15,6 +14,7 @@ import type { CreateAppResult, ListAppsResponse, NodeSystemInfo, + Message, Version, } from "./ipc_types"; import type { Proposal } from "@/lib/schemas"; diff --git a/src/ipc/ipc_types.ts b/src/ipc/ipc_types.ts index f8670c9..1daea80 100644 --- a/src/ipc/ipc_types.ts +++ b/src/ipc/ipc_types.ts @@ -1,5 +1,3 @@ -import type { Message } from "ai"; - export interface AppOutput { type: "stdout" | "stderr" | "info" | "client-error"; message: string; @@ -37,6 +35,13 @@ export interface CreateAppResult { chatId: number; } +export interface Message { + id: string; + role: "user" | "assistant"; + content: string; + approvalState?: "approved" | "rejected"; +} + export interface Chat { id: number; title: string;