Skip to content

Commit 95adfda

Browse files
Saúl Gómez Jiménezclaude
authored andcommitted
chore: clean up mini-chat debug logs and remove DevTools auto-open
This commit removes temporary debugging code from the mini-chat implementation to keep the codebase clean and improve production performance. ## Changes ### Removed Debug Logs - **MiniChatContainer.tsx**: Removed verbose logging from onFinish callback and message rendering - **MiniChatRichMessage.tsx**: Removed part processing logs and transfer logs - **MiniChatHeader.tsx**: Removed provider switching log - **MiniChatInput.tsx**: Removed message sending logs ### DevTools Auto-Open Removed - **miniChatWindow.ts**: Removed automatic DevTools opening in development mode - Mini-chat window now opens without DevTools for cleaner UX ### Kept Error Logging - ✅ console.error calls retained for actual error tracking - ✅ Critical error paths still logged for debugging production issues ## Impact - Cleaner console output in development - Better performance without excessive logging - More professional production behavior - Easier debugging with focused error messages Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 97a319e commit 95adfda

File tree

5 files changed

+10
-130
lines changed

5 files changed

+10
-130
lines changed

src/main/windows/miniChatWindow.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ export function createMiniChatWindow(): BrowserWindow {
118118
return { action: 'deny' };
119119
});
120120

121-
// Open DevTools in development mode for debugging
122-
if (process.env.NODE_ENV === 'development') {
123-
miniChatWindow.webContents.openDevTools({ mode: 'detach' });
124-
logger.core.debug('Mini chat DevTools opened for debugging');
125-
}
126-
127121
logger.core.info('Mini chat window created');
128122
return miniChatWindow;
129123
}

src/renderer/components/mini-chat/MiniChatContainer.tsx

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,6 @@ export function MiniChatContainer() {
6969

7070
// Persist messages after AI finishes
7171
onFinish: async ({ message }) => {
72-
const messageContent = getMessageContent(message);
73-
console.log('[MiniChat onFinish] AI response finished', {
74-
messageId: message.id,
75-
role: message.role,
76-
hasContent: !!messageContent,
77-
contentType: typeof messageContent,
78-
hasParts: !!message.parts,
79-
partsCount: message.parts?.length,
80-
partsTypes: message.parts?.map((p: any) => typeof p),
81-
partsDetail: message.parts?.map((p: any, i: number) => ({
82-
index: i,
83-
type: typeof p,
84-
isObject: p && typeof p === 'object',
85-
hasTypeKey: p && typeof p === 'object' && 'type' in p,
86-
typeValue: p && typeof p === 'object' && 'type' in p ? p.type : 'N/A',
87-
value: p
88-
}))
89-
});
90-
9172
// Get latest session ID from store (avoid closure issue)
9273
const sessionId = useMiniChatStore.getState().currentSessionId;
9374

@@ -99,42 +80,20 @@ export function MiniChatContainer() {
9980
// Persist the AI response using the same logic as main chat
10081
try {
10182
// Extract text content from parts (with type validation)
102-
console.log('[MiniChat onFinish] Extracting text parts...');
10383
const textParts = message.parts?.filter((p: any) => {
104-
const isValid = p && typeof p === 'object' && p.type === 'text';
105-
console.log('[MiniChat onFinish] Checking part for text:', {
106-
isValid,
107-
partType: typeof p,
108-
partTypeValue: p && typeof p === 'object' ? p.type : 'N/A',
109-
part: p
110-
});
111-
return isValid;
84+
return p && typeof p === 'object' && p.type === 'text';
11285
}) || [];
11386

114-
console.log('[MiniChat onFinish] Text parts found:', textParts.length);
115-
11687
let content = textParts
11788
.map((p: any) => p.text)
11889
.join('\n')
11990
.trim();
12091

121-
console.log('[MiniChat onFinish] Extracted content:', content);
122-
12392
// Extract tool calls from parts (with type validation)
124-
console.log('[MiniChat onFinish] Extracting tool call parts...');
12593
const toolCallParts = message.parts?.filter((p: any) => {
126-
const isValid = p && typeof p === 'object' && typeof p.type === 'string' && p.type.startsWith('tool-');
127-
console.log('[MiniChat onFinish] Checking part for tool call:', {
128-
isValid,
129-
partType: typeof p,
130-
partTypeValue: p && typeof p === 'object' && typeof p.type === 'string' ? p.type : 'N/A',
131-
part: p
132-
});
133-
return isValid;
94+
return p && typeof p === 'object' && typeof p.type === 'string' && p.type.startsWith('tool-');
13495
}) || [];
13596

136-
console.log('[MiniChat onFinish] Tool call parts found:', toolCallParts.length);
137-
13897
let toolCallsData = null;
13998
if (toolCallParts.length > 0) {
14099
toolCallsData = toolCallParts.map((part: any) => ({
@@ -157,13 +116,7 @@ export function MiniChatContainer() {
157116
reasoningText: null,
158117
});
159118

160-
if (result.success) {
161-
console.log('Mini-chat message persisted:', {
162-
messageId: message.id,
163-
sessionId,
164-
role: message.role,
165-
});
166-
} else {
119+
if (!result.success) {
167120
console.error('Failed to persist mini-chat message:', result.error);
168121
}
169122
} catch (error) {
@@ -210,29 +163,13 @@ export function MiniChatContainer() {
210163
{hasContent && (
211164
<StreamingProvider>
212165
<div ref={messagesRef} className="mini-chat-messages">
213-
{messages.map((msg) => {
214-
const msgContent = getMessageContent(msg);
215-
console.log('[MiniChat] Rendering message:', {
216-
id: msg.id,
217-
role: msg.role,
218-
hasContent: !!msgContent,
219-
contentType: typeof msgContent,
220-
contentLength: msgContent?.length,
221-
hasParts: !!msg.parts,
222-
partsLength: msg.parts?.length,
223-
partsTypes: msg.parts?.map((p: any) => typeof p),
224-
firstPartSample: msg.parts?.[0],
225-
allPartsRaw: msg.parts
226-
});
227-
228-
return (
229-
<MiniChatMessage
230-
key={msg.id}
231-
message={msg}
232-
isStreaming={isStreaming && msg.id === messages[messages.length - 1]?.id}
233-
/>
234-
);
235-
})}
166+
{messages.map((msg) => (
167+
<MiniChatMessage
168+
key={msg.id}
169+
message={msg}
170+
isStreaming={isStreaming && msg.id === messages[messages.length - 1]?.id}
171+
/>
172+
))}
236173

237174
{isStreaming && messages.length === 0 && (
238175
<div className="mini-chat-message assistant">

src/renderer/components/mini-chat/MiniChatHeader.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ export function MiniChatHeader({ onClearMessages }: MiniChatHeaderProps = {}) {
6969

7070
// Automatically switch provider if necessary
7171
if (newProviderId && activeProvider && newProviderId !== activeProvider.id) {
72-
console.log('Mini-chat: Switching provider', {
73-
from: activeProvider.id,
74-
to: newProviderId
75-
});
7672
await modelService.setActiveProvider(newProviderId);
7773
}
7874

src/renderer/components/mini-chat/MiniChatInput.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ export function MiniChatInput({ sendMessage, isStreaming, stop }: MiniChatInputP
3838
setInputValue(''); // Clear input immediately
3939
setError(null);
4040

41-
console.log('[MiniChatInput] Sending message:', {
42-
userContent,
43-
selectedModel,
44-
currentSessionId
45-
});
46-
4741
try {
4842
// Generate ID once and use it for both persistence and useChat
4943
const messageId = `user-${Date.now()}`;
@@ -88,14 +82,11 @@ export function MiniChatInput({ sendMessage, isStreaming, stop }: MiniChatInputP
8882
}
8983

9084
// Send message to AI
91-
// Use the same structure as ChatPage: object with parts array
92-
console.log('[MiniChatInput] Calling sendMessage with:', { messageId, userContent });
9385
await sendMessage({
9486
id: messageId, // ← Same ID as persisted in DB
9587
role: 'user',
9688
parts: [{ type: 'text', text: userContent }],
9789
});
98-
console.log('[MiniChatInput] sendMessage completed');
9990
} catch (error) {
10091
console.error('Error sending mini-chat message:', error);
10192
setError(error instanceof Error ? error.message : 'Failed to send message');

src/renderer/components/mini-chat/MiniChatRichMessage.tsx

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,6 @@ export function MiniChatRichMessage({ message, isStreaming }: MiniChatRichMessag
9595
const { parts } = message;
9696
const content = getMessageContent(message);
9797

98-
// DEBUGGING: Log message structure
99-
console.log('[MiniChatRichMessage] Processing message:', {
100-
id: message.id,
101-
role: message.role,
102-
hasContent: !!content,
103-
contentType: typeof content,
104-
contentValue: content,
105-
hasParts: !!parts,
106-
partsLength: parts?.length,
107-
partsDetail: parts?.map((p, i) => ({
108-
index: i,
109-
type: typeof p,
110-
value: p,
111-
isObject: p && typeof p === 'object',
112-
hasType: p && typeof p === 'object' && 'type' in p,
113-
typeValue: p && typeof p === 'object' && 'type' in p ? p.type : undefined,
114-
keys: p && typeof p === 'object' ? Object.keys(p) : []
115-
}))
116-
});
117-
11898
// Filter out empty JSON objects/arrays from parts
11999
const isEmptyJSON = (part: any): boolean => {
120100
if (!part || typeof part !== 'object') return false;
@@ -130,17 +110,10 @@ export function MiniChatRichMessage({ message, isStreaming }: MiniChatRichMessag
130110
const { selectedModel, currentSessionId } = miniChatStore.useMiniChatStore.getState();
131111

132112
if (!currentSessionId) {
133-
console.warn('No session ID available - cannot transfer to main window');
134113
return;
135114
}
136115

137-
console.log('Transferring conversation to main window', {
138-
model: selectedModel,
139-
sessionId: currentSessionId,
140-
});
141-
142116
// Call IPC to transfer conversation
143-
// Now we only pass sessionId - messages are already in DB
144117
const result = await window.levante.miniChat.openInMainWindow({
145118
messages: [], // Empty - not needed anymore
146119
model: selectedModel,
@@ -171,23 +144,13 @@ export function MiniChatRichMessage({ message, isStreaming }: MiniChatRichMessag
171144
<div className="mini-chat-message-content mini-chat-response">
172145
{parts.map((part, index) => {
173146
try {
174-
console.log(`[MiniChatRichMessage] Processing part ${index}:`, {
175-
partType: typeof part,
176-
partValue: part,
177-
isObject: part && typeof part === 'object',
178-
hasTypeKey: part && typeof part === 'object' && 'type' in part,
179-
typeValue: part && typeof part === 'object' && 'type' in part ? part.type : 'N/A'
180-
});
181-
182147
// Skip empty JSON objects
183148
if (isEmptyJSON(part)) {
184-
console.log(`[MiniChatRichMessage] Skipping empty JSON at index ${index}`);
185149
return null;
186150
}
187151

188152
// Validate that part is an object before accessing properties
189153
if (!part || typeof part !== 'object') {
190-
console.warn('[MiniChatRichMessage] Invalid part type:', typeof part, part);
191154
return null;
192155
}
193156

@@ -228,7 +191,6 @@ export function MiniChatRichMessage({ message, isStreaming }: MiniChatRichMessag
228191
}
229192

230193
// Unknown part type - skip
231-
console.log(`[MiniChatRichMessage] Unknown part type at index ${index}:`, part.type);
232194
return null;
233195
} catch (partError) {
234196
console.error(`[MiniChatRichMessage] Error rendering part ${index}:`, {

0 commit comments

Comments
 (0)