mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-25 18:55:19 +02:00
Simplify playground chat component:
- remove unused system message - remove playgroundchat / simulation bits - general cleanup
This commit is contained in:
parent
64dba9a9f9
commit
ca3c80e96d
6 changed files with 14 additions and 105 deletions
|
|
@ -1,25 +1,19 @@
|
|||
'use client';
|
||||
import { useState, useCallback, useRef } from "react";
|
||||
import { z } from "zod";
|
||||
import { MCPServer, Message, PlaygroundChat } from "@/app/lib/types/types";
|
||||
import { Workflow, WorkflowTool } from "@/app/lib/types/workflow_types";
|
||||
import { Message } from "@/app/lib/types/types";
|
||||
import { Workflow } from "@/app/lib/types/workflow_types";
|
||||
import { Chat } from "./components/chat";
|
||||
import { Panel } from "@/components/common/panel-common";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip } from "@heroui/react";
|
||||
import { WithStringId } from "@/app/lib/types/types";
|
||||
import { CheckIcon, CopyIcon, PlusIcon, UserIcon, InfoIcon, BugIcon, BugOffIcon, CodeIcon } from "lucide-react";
|
||||
import { clsx } from "clsx";
|
||||
|
||||
const defaultSystemMessage = '';
|
||||
import { CheckIcon, CopyIcon, PlusIcon, InfoIcon, BugIcon, BugOffIcon } from "lucide-react";
|
||||
|
||||
export function App({
|
||||
hidden = false,
|
||||
projectId,
|
||||
workflow,
|
||||
messageSubscriber,
|
||||
mcpServerUrls,
|
||||
isInitialState = false,
|
||||
onPanelClick,
|
||||
triggerCopilotChat,
|
||||
}: {
|
||||
|
|
@ -27,40 +21,16 @@ export function App({
|
|||
projectId: string;
|
||||
workflow: z.infer<typeof Workflow>;
|
||||
messageSubscriber?: (messages: z.infer<typeof Message>[]) => void;
|
||||
mcpServerUrls: Array<z.infer<typeof MCPServer>>;
|
||||
isInitialState?: boolean;
|
||||
onPanelClick?: () => void;
|
||||
triggerCopilotChat?: (message: string) => void;
|
||||
}) {
|
||||
const [counter, setCounter] = useState<number>(0);
|
||||
const [systemMessage, setSystemMessage] = useState<string>(defaultSystemMessage);
|
||||
const [showDebugMessages, setShowDebugMessages] = useState<boolean>(true);
|
||||
const [chat, setChat] = useState<z.infer<typeof PlaygroundChat>>({
|
||||
projectId,
|
||||
createdAt: new Date().toISOString(),
|
||||
messages: [],
|
||||
simulated: false,
|
||||
systemMessage: defaultSystemMessage,
|
||||
});
|
||||
const [isProfileSelectorOpen, setIsProfileSelectorOpen] = useState(false);
|
||||
const [showCopySuccess, setShowCopySuccess] = useState(false);
|
||||
const getCopyContentRef = useRef<(() => string) | null>(null);
|
||||
|
||||
function handleSystemMessageChange(message: string) {
|
||||
setSystemMessage(message);
|
||||
setCounter(counter + 1);
|
||||
}
|
||||
|
||||
function handleNewChatButtonClick() {
|
||||
setCounter(counter + 1);
|
||||
setChat({
|
||||
projectId,
|
||||
createdAt: new Date().toISOString(),
|
||||
messages: [],
|
||||
simulated: false,
|
||||
systemMessage: defaultSystemMessage,
|
||||
});
|
||||
setSystemMessage(defaultSystemMessage);
|
||||
}
|
||||
|
||||
const handleCopyJson = useCallback(() => {
|
||||
|
|
@ -142,13 +112,9 @@ export function App({
|
|||
<div className="h-full overflow-auto px-4 py-4">
|
||||
<Chat
|
||||
key={`chat-${counter}`}
|
||||
chat={chat}
|
||||
projectId={projectId}
|
||||
workflow={workflow}
|
||||
messageSubscriber={messageSubscriber}
|
||||
systemMessage={systemMessage}
|
||||
onSystemMessageChange={handleSystemMessageChange}
|
||||
mcpServerUrls={mcpServerUrls}
|
||||
onCopyClick={(fn) => { getCopyContentRef.current = fn; }}
|
||||
showDebugMessages={showDebugMessages}
|
||||
triggerCopilotChat={triggerCopilotChat}
|
||||
|
|
|
|||
|
|
@ -3,49 +3,39 @@ import { useEffect, useRef, useState, useCallback } from "react";
|
|||
import { getAssistantResponseStreamId } from "@/app/actions/actions";
|
||||
import { Messages } from "./messages";
|
||||
import z from "zod";
|
||||
import { MCPServer, Message, PlaygroundChat, ToolMessage } from "@/app/lib/types/types";
|
||||
import { Workflow, WorkflowTool } from "@/app/lib/types/workflow_types";
|
||||
import { Message, ToolMessage } from "@/app/lib/types/types";
|
||||
import { Workflow } from "@/app/lib/types/workflow_types";
|
||||
import { ComposeBoxPlayground } from "@/components/common/compose-box-playground";
|
||||
import { Button } from "@heroui/react";
|
||||
import { WithStringId } from "@/app/lib/types/types";
|
||||
import { ProfileContextBox } from "./profile-context-box";
|
||||
import { BillingUpgradeModal } from "@/components/common/billing-upgrade-modal";
|
||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { FeedbackModal } from "./feedback-modal";
|
||||
import { FIX_WORKFLOW_PROMPT, FIX_WORKFLOW_PROMPT_WITH_FEEDBACK, EXPLAIN_WORKFLOW_PROMPT_ASSISTANT, EXPLAIN_WORKFLOW_PROMPT_TOOL, EXPLAIN_WORKFLOW_PROMPT_TRANSITION } from "../copilot-prompts";
|
||||
|
||||
export function Chat({
|
||||
chat,
|
||||
projectId,
|
||||
workflow,
|
||||
messageSubscriber,
|
||||
systemMessage,
|
||||
onSystemMessageChange,
|
||||
mcpServerUrls,
|
||||
onCopyClick,
|
||||
showDebugMessages = true,
|
||||
showJsonMode = false,
|
||||
triggerCopilotChat,
|
||||
}: {
|
||||
chat: z.infer<typeof PlaygroundChat>;
|
||||
projectId: string;
|
||||
workflow: z.infer<typeof Workflow>;
|
||||
messageSubscriber?: (messages: z.infer<typeof Message>[]) => void;
|
||||
systemMessage: string;
|
||||
onSystemMessageChange: (message: string) => void;
|
||||
mcpServerUrls: Array<z.infer<typeof MCPServer>>;
|
||||
onCopyClick: (fn: () => string) => void;
|
||||
showDebugMessages?: boolean;
|
||||
showJsonMode?: boolean;
|
||||
triggerCopilotChat?: (message: string) => void;
|
||||
}) {
|
||||
const [messages, setMessages] = useState<z.infer<typeof Message>[]>(chat.messages);
|
||||
const [messages, setMessages] = useState<z.infer<typeof Message>[]>([]);
|
||||
const [loadingAssistantResponse, setLoadingAssistantResponse] = useState<boolean>(false);
|
||||
const [fetchResponseError, setFetchResponseError] = useState<string | null>(null);
|
||||
const [billingError, setBillingError] = useState<string | null>(null);
|
||||
const [lastAgenticRequest, setLastAgenticRequest] = useState<unknown | null>(null);
|
||||
const [lastAgenticResponse, setLastAgenticResponse] = useState<unknown | null>(null);
|
||||
const [optimisticMessages, setOptimisticMessages] = useState<z.infer<typeof Message>[]>(chat.messages);
|
||||
const [optimisticMessages, setOptimisticMessages] = useState<z.infer<typeof Message>[]>([]);
|
||||
const [isLastInteracted, setIsLastInteracted] = useState(false);
|
||||
const [showFeedbackModal, setShowFeedbackModal] = useState(false);
|
||||
const [pendingFixMessage, setPendingFixMessage] = useState<string | null>(null);
|
||||
|
|
@ -82,14 +72,11 @@ export function Chat({
|
|||
|
||||
const getCopyContent = useCallback(() => {
|
||||
return JSON.stringify({
|
||||
messages: [{
|
||||
role: 'system',
|
||||
content: systemMessage,
|
||||
}, ...messages],
|
||||
messages,
|
||||
lastRequest: lastAgenticRequest,
|
||||
lastResponse: lastAgenticResponse,
|
||||
}, null, 2);
|
||||
}, [messages, systemMessage, lastAgenticRequest, lastAgenticResponse]);
|
||||
}, [messages, lastAgenticRequest, lastAgenticResponse]);
|
||||
|
||||
// Expose copy function to parent
|
||||
useEffect(() => {
|
||||
|
|
@ -206,13 +193,7 @@ export function Chat({
|
|||
const response = await getAssistantResponseStreamId(
|
||||
projectId,
|
||||
workflow,
|
||||
[
|
||||
{
|
||||
role: 'system',
|
||||
content: systemMessage || '',
|
||||
},
|
||||
...messages,
|
||||
],
|
||||
messages,
|
||||
);
|
||||
if (ignore) {
|
||||
return;
|
||||
|
|
@ -329,8 +310,6 @@ export function Chat({
|
|||
messages,
|
||||
projectId,
|
||||
workflow,
|
||||
systemMessage,
|
||||
mcpServerUrls,
|
||||
fetchResponseError,
|
||||
]);
|
||||
|
||||
|
|
@ -362,9 +341,6 @@ export function Chat({
|
|||
toolCallResults={toolCallResults}
|
||||
loadingAssistantResponse={loadingAssistantResponse}
|
||||
workflow={workflow}
|
||||
systemMessage={systemMessage}
|
||||
onSystemMessageChange={onSystemMessageChange}
|
||||
showSystemMessage={false}
|
||||
showDebugMessages={showDebugMessages}
|
||||
showJsonMode={showJsonMode}
|
||||
onFix={handleFix}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,6 @@ function ToolCalls({
|
|||
messages,
|
||||
sender,
|
||||
workflow,
|
||||
systemMessage,
|
||||
delta,
|
||||
onFix,
|
||||
onExplain,
|
||||
|
|
@ -226,7 +225,6 @@ function ToolCalls({
|
|||
messages: z.infer<typeof Message>[];
|
||||
sender: string | null | undefined;
|
||||
workflow: z.infer<typeof Workflow>;
|
||||
systemMessage: string | undefined;
|
||||
delta: number;
|
||||
onFix?: (message: string, index: number) => void;
|
||||
onExplain?: (type: 'tool' | 'transition', message: string, index: number) => void;
|
||||
|
|
@ -672,9 +670,6 @@ export function Messages({
|
|||
toolCallResults,
|
||||
loadingAssistantResponse,
|
||||
workflow,
|
||||
systemMessage,
|
||||
onSystemMessageChange,
|
||||
showSystemMessage,
|
||||
showDebugMessages = true,
|
||||
showJsonMode = false,
|
||||
onFix,
|
||||
|
|
@ -685,9 +680,6 @@ export function Messages({
|
|||
toolCallResults: Record<string, z.infer<typeof ToolMessage>>;
|
||||
loadingAssistantResponse: boolean;
|
||||
workflow: z.infer<typeof Workflow>;
|
||||
systemMessage: string | undefined;
|
||||
onSystemMessageChange: (message: string) => void;
|
||||
showSystemMessage: boolean;
|
||||
showDebugMessages?: boolean;
|
||||
showJsonMode?: boolean;
|
||||
onFix?: (message: string, index: number) => void;
|
||||
|
|
@ -726,7 +718,6 @@ export function Messages({
|
|||
messages={messages}
|
||||
sender={message.agentName ?? ''}
|
||||
workflow={workflow}
|
||||
systemMessage={systemMessage}
|
||||
delta={latency}
|
||||
onFix={onFix}
|
||||
onExplain={onExplain}
|
||||
|
|
@ -792,15 +783,6 @@ export function Messages({
|
|||
return message.role === 'assistant' && (!('toolCalls' in message) || !Array.isArray(message.toolCalls) || !message.toolCalls.some(tc => tc.function.name.startsWith('transfer_to_')));
|
||||
};
|
||||
|
||||
if (showSystemMessage) {
|
||||
return (
|
||||
<ProfileContextBox
|
||||
content={systemMessage || ''}
|
||||
onChange={onSystemMessageChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// Just render the messages, no scroll container or unread bubble
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-2 sm:px-8 relative">
|
||||
|
|
|
|||
|
|
@ -1158,8 +1158,6 @@ export function WorkflowEditor({
|
|||
projectId={projectId}
|
||||
workflow={state.present.workflow}
|
||||
messageSubscriber={updateChatMessages}
|
||||
mcpServerUrls={mcpServerUrls}
|
||||
isInitialState={isInitialState}
|
||||
onPanelClick={handlePlaygroundClick}
|
||||
triggerCopilotChat={triggerCopilotChat}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue