Skip to content

Commit 649bd50

Browse files
committed
clean up
1 parent 9bf5fc2 commit 649bd50

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

apps/web/client/src/app/project/[id]/_components/right-panel/chat-tab/chat-messages/message-content/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { ToolUIPart, UIMessage } from 'ai';
22
import { observer } from 'mobx-react-lite';
3+
import { useMemo } from 'react';
34
import { MarkdownRenderer } from '../markdown-renderer';
45
import { ToolCallDisplay } from './tool-call-display';
5-
import { useMemo } from 'react';
66

77
export const MessageContent = observer(
88
({
@@ -16,17 +16,18 @@ export const MessageContent = observer(
1616
applied: boolean;
1717
isStream: boolean;
1818
}) => {
19-
if (!parts) {
20-
return null;
21-
}
2219
// Find the index of the last tool-*** part
23-
const lastToolInvocationIdx = useMemo(() =>
20+
const lastToolInvocationIdx = useMemo(() =>
2421
parts?.map((part, index) => ({ type: part.type, index }))
2522
.filter(item => item.type.startsWith('tool-'))
2623
.pop()?.index ?? -1,
2724
[parts]
2825
);
2926

27+
if (!parts.length) {
28+
return null;
29+
}
30+
3031
const renderedParts = parts.map((part, idx) => {
3132
if (part.type === 'text') {
3233
return (

apps/web/client/src/app/project/[id]/_components/right-panel/chat-tab/chat-messages/message-content/tool-call-display.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import {
1414
import type { WebSearchResult } from '@onlook/models';
1515
import { Icons } from '@onlook/ui/icons/index';
1616
import { cn } from '@onlook/ui/utils';
17+
import type { ToolUIPart } from 'ai';
1718
import { type z } from 'zod';
1819
import { BashCodeDisplay } from '../../code-display/bash-code-display';
1920
import { CollapsibleCodeBlock } from '../../code-display/collapsible-code-block';
2021
import { SearchSourcesDisplay } from '../../code-display/search-sources-display';
2122
import { ToolCallSimple } from './tool-call-simple';
22-
import type { ToolUIPart } from 'ai';
2323

2424
export const ToolCallDisplay = ({
2525
messageId,
@@ -160,7 +160,7 @@ export const ToolCallDisplay = ({
160160
if (toolName === SEARCH_REPLACE_MULTI_EDIT_FILE_TOOL_NAME) {
161161
const args = toolInvocation.input as z.infer<typeof SEARCH_REPLACE_MULTI_EDIT_FILE_TOOL_PARAMETERS>;
162162
const filePath = args?.file_path;
163-
const codeContent = args?.edits.map((edit) => edit.new_string).join('\n...\n');
163+
const codeContent = args?.edits?.map((edit) => edit.new_string).join('\n...\n');
164164
if (!filePath || !codeContent) {
165165
return (
166166
<ToolCallSimple

apps/web/client/src/app/project/[id]/_components/right-panel/chat-tab/error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export const ErrorSection = observer(() => {
1818

1919
const sendFixError = async () => {
2020
try {
21-
const message = await editorEngine.chat.addFixErrorMessage();
22-
sendMessageToChat(ChatType.FIX);
21+
await editorEngine.chat.addFixErrorMessage();
22+
await sendMessageToChat(ChatType.FIX);
2323
} catch (error) {
2424
console.error('Error sending fix error message', error);
2525
toast.error('Failed to send fix error message. Please try again.');

apps/web/client/src/components/store/editor/chat/conversation.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export class ConversationManager {
5555
}
5656
const newConversation = await api.chat.conversation.upsert.mutate({
5757
projectId: this.editorEngine.projectId,
58-
suggestions: [],
5958
});
6059
this.current = {
6160
conversation: newConversation,
@@ -167,12 +166,10 @@ export class ConversationManager {
167166
messageId: message.id,
168167
checkpoints: newCheckpoints,
169168
});
170-
console.log('attachCommitToUserMessage', userMessage);
171169
await this.addOrReplaceMessage(userMessage);
172170
}
173171

174172
async addOrReplaceMessage(message: ChatMessage) {
175-
console.log('addOrReplaceMessage', message);
176173
if (!this.current) {
177174
console.error('No conversation found');
178175
return;

apps/web/client/src/components/store/hosting/provider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ export const HostingProvider = ({ children }: HostingProviderProps) => {
156156
deployment: {
157157
status: DeploymentStatus.FAILED,
158158
error: error instanceof Error ? error.message : 'Unknown error',
159-
envVars: {},
160159
},
161160
});
162161
return {

apps/web/client/src/components/tools/tools.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { getToolSetFromType } from '@/app/api/chat/helperts';
12
import type { EditorEngine } from '@/components/store/editor/engine';
3+
import type { ToolCall } from '@ai-sdk/provider-utils';
24
import {
35
BASH_EDIT_TOOL_NAME,
46
BASH_EDIT_TOOL_PARAMETERS,
@@ -55,8 +57,6 @@ import {
5557
handleWriteFileTool
5658
} from './handlers';
5759
import { EMPTY_TOOL_PARAMETERS } from './helpers';
58-
import type { ToolCall } from '@ai-sdk/provider-utils';
59-
import { getToolSetFromType } from '@/app/api/chat/helperts';
6060

6161
interface ClientToolMap extends Record<string, {
6262
name: string;
@@ -81,13 +81,13 @@ const TOOL_HANDLERS: ClientToolMap = {
8181
[READ_STYLE_GUIDE_TOOL_NAME]: {
8282
name: READ_STYLE_GUIDE_TOOL_NAME,
8383
inputSchema: EMPTY_TOOL_PARAMETERS,
84-
handler: async (editorEngine: EditorEngine) =>
84+
handler: async (args: unknown, editorEngine: EditorEngine) =>
8585
handleReadStyleGuideTool(editorEngine),
8686
},
8787
[ONLOOK_INSTRUCTIONS_TOOL_NAME]: {
8888
name: ONLOOK_INSTRUCTIONS_TOOL_NAME,
8989
inputSchema: EMPTY_TOOL_PARAMETERS,
90-
handler: async () => ONLOOK_INSTRUCTIONS,
90+
handler: async (_args: unknown, _editorEngine: EditorEngine) => ONLOOK_INSTRUCTIONS,
9191
},
9292
[SEARCH_REPLACE_EDIT_FILE_TOOL_NAME]: {
9393
name: SEARCH_REPLACE_EDIT_FILE_TOOL_NAME,
@@ -176,17 +176,17 @@ export async function handleToolCall(toolCall: ToolCall<string, unknown>, editor
176176
const currentChatMode = editorEngine.state.chatMode;
177177
const availableTools = await getToolSetFromType(currentChatMode);
178178

179-
if (!availableTools[toolName]) {
179+
if (!availableTools[toolName]) {
180180
toast.error(`Tool "${toolName}" not available in ask mode`, {
181181
description: `Switch to build mode to use this tool.`,
182182
duration: 2000,
183183
});
184-
184+
185185
throw new Error(`Tool "${toolName}" is not available in ${currentChatMode} mode`);
186186
}
187187

188188
const clientTool = TOOL_HANDLERS[toolName];
189-
189+
190190
if (!clientTool) {
191191
throw new Error(`Unknown tool call: ${toolName}`);
192192
}

0 commit comments

Comments
 (0)