Skip to content

Commit 47ec32d

Browse files
committed
refactor: Removes debug logs from chat and attachment preview
Removes excessive console logs used for debugging purposes from the chat service and attachment preview components. These logs are no longer necessary and clutter the console, making it harder to identify relevant information.
1 parent f02925d commit 47ec32d

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentPreviewDialog.svelte

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
let isPdf = $derived(displayType === PdfMimeType.PDF);
6666
let isAudio = $derived(getFileTypeCategory(displayType) === FileTypeCategory.AUDIO || displayType === 'audio');
6767
68-
// PDF preview state
69-
let pdfViewMode = $state<'text' | 'pages'>('pages'); // Default to pages view
68+
let pdfViewMode = $state<'text' | 'pages'>('pages');
7069
let pdfImages = $state<string[]>([]);
7170
let pdfImagesLoading = $state(false);
7271
let pdfImagesError = $state<string | null>(null);
@@ -91,23 +90,18 @@
9190
async function loadPdfImages() {
9291
if (!isPdf || pdfImages.length > 0 || pdfImagesLoading) return;
9392
94-
if (import.meta.env.DEV) console.log('Loading PDF images...', { isPdf, attachment, uploadedFile });
95-
9693
pdfImagesLoading = true;
9794
pdfImagesError = null;
9895
9996
try {
10097
let file: File | null = null;
10198
10299
if (uploadedFile?.file) {
103-
if (import.meta.env.DEV) console.log('Using uploaded file:', uploadedFile.file);
104100
file = uploadedFile.file;
105101
} else if (attachment?.type === 'pdfFile') {
106-
if (import.meta.env.DEV) console.log('Processing stored PDF attachment:', attachment);
107102
108103
// Check if we have pre-processed images
109104
if ((attachment as any).images && Array.isArray((attachment as any).images)) {
110-
if (import.meta.env.DEV) console.log('Using pre-processed PDF images:', (attachment as any).images.length);
111105
pdfImages = (attachment as any).images;
112106
return;
113107
}
@@ -122,28 +116,22 @@
122116
}
123117
const byteArray = new Uint8Array(byteNumbers);
124118
file = new File([byteArray], displayName, { type: PdfMimeType.PDF });
125-
if (import.meta.env.DEV) console.log('Created file from base64 data, size:', file.size);
126119
}
127120
}
128121
129122
if (file) {
130-
if (import.meta.env.DEV) console.log('Converting PDF to images...');
131123
const images = await convertPDFToImage(file);
132-
if (import.meta.env.DEV) console.log('PDF conversion successful, got', images.length, 'images');
133124
pdfImages = images;
134125
} else {
135126
throw new Error('No PDF file available for conversion');
136127
}
137128
} catch (error) {
138-
if (import.meta.env.DEV) console.error('Failed to convert PDF to images:', error);
139129
pdfImagesError = error instanceof Error ? error.message : 'Failed to load PDF images';
140-
// Don't automatically fallback to text view, let user choose
141130
} finally {
142131
pdfImagesLoading = false;
143132
}
144133
}
145134
146-
// Load PDF images when dialog opens and it's a PDF
147135
$effect(() => {
148136
if (open && isPdf && pdfViewMode === 'pages') {
149137
loadPdfImages();

tools/server/webui/src/lib/services/chat.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ export class ChatService {
160160
if (line.startsWith('data: ')) {
161161
const data = line.slice(6);
162162
if (data === '[DONE]') {
163-
// Log final separated content
164-
if (thinkContent.trim()) {
165-
console.log('🤔 Think content:', thinkContent.trim());
166-
}
167-
if (regularContent.trim()) {
168-
console.log('💬 Regular response:', regularContent.trim());
169-
}
170163
onComplete?.(fullResponse);
171164
return;
172165
}
@@ -362,9 +355,7 @@ export class ChatService {
362355
if ('id' in msg && 'convId' in msg && 'timestamp' in msg) {
363356
// This is a DatabaseMessage, convert it
364357
const dbMsg = msg as DatabaseMessage & { extra?: DatabaseMessageExtra[] };
365-
console.log('Converting message to API format:', { role: dbMsg.role, content: dbMsg.content, extra: dbMsg.extra });
366358
const converted = ChatService.convertMessageToChatServiceData(dbMsg);
367-
console.log('Converted message:', converted);
368359
return converted;
369360
} else {
370361
// This is already an ApiChatMessageData object

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,6 @@ class ChatStore {
332332
try {
333333
const partialThinking = extractPartialThinking(this.currentResponse);
334334

335-
console.log('Saving partial response:', {
336-
messageId: lastMessage.id,
337-
currentResponse: this.currentResponse,
338-
remainingContent: partialThinking.remainingContent,
339-
thinking: partialThinking.thinking
340-
});
341335

342336
const updateData: { content: string; thinking?: string } = {
343337
content: partialThinking.remainingContent || this.currentResponse
@@ -348,16 +342,14 @@ class ChatStore {
348342
}
349343

350344
await DatabaseService.updateMessage(lastMessage.id, updateData);
351-
console.log('Successfully saved partial response to database');
352345

353346
lastMessage.content = partialThinking.remainingContent || this.currentResponse;
354347
} catch (error) {
355-
console.error('Failed to save partial response:', error);
356-
357348
lastMessage.content = this.currentResponse;
349+
console.error('Failed to save partial response:', error);
358350
}
359351
} else {
360-
console.log('No assistant message found to save partial response to');
352+
console.error('Last message is not an assistant message');
361353
}
362354
}
363355

0 commit comments

Comments
 (0)