Skip to content

Commit 759c857

Browse files
committed
some fixes
1 parent 08db4db commit 759c857

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

packages/client/src/hooks/use-eliza-chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useSSEChat } from './use-sse-chat';
77
import { useHTTPChat } from './use-http-chat';
88
import { getEntityId, randomUUID } from '@/lib/utils';
99
import { USER_NAME } from '@/constants';
10+
import clientLogger from '@/lib/logger';
1011

1112
interface UseElizaChatOptions {
1213
channelId: UUID | undefined;
@@ -283,7 +284,7 @@ export function useElizaChat({
283284
await socketSend(text, serverId, source, attachments, tempId, undefined, targetChannelId);
284285
}
285286
} catch (error) {
286-
console.error('[useElizaChat] Error sending message:', error);
287+
clientLogger.error('[useElizaChat] Error sending message:', error);
287288
onError?.(error instanceof Error ? error : new Error(String(error)));
288289
}
289290
},

packages/client/src/hooks/use-http-chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { UUID, Media } from '@elizaos/core';
33
import { getElizaClient } from '@/lib/api-client-config';
44
import { getEntityId, randomUUID, getAttachmentType } from '@/lib/utils';
55
import { USER_NAME } from '@/constants';
6+
import clientLogger from '@/lib/logger';
67
import type { UiMessage } from '../types';
78

89
interface UseHTTPChatOptions {
@@ -90,7 +91,7 @@ export function useHTTPChat({
9091
onAddMessage(agentMessage);
9192
}
9293
} catch (error) {
93-
console.error('[useHTTPChat] Error sending message:', error);
94+
clientLogger.error('[useHTTPChat] Error sending message:', error);
9495
onUpdateMessage(tempId, {
9596
isLoading: false,
9697
text: `${text} (Failed to send)`,

packages/client/src/hooks/use-sse-chat.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { UUID, Media } from '@elizaos/core';
33
import { createApiClientConfig } from '@/lib/api-client-config';
44
import { getEntityId, randomUUID, getAttachmentType } from '@/lib/utils';
55
import { USER_NAME } from '@/constants';
6+
import clientLogger from '@/lib/logger';
67
import type { UiMessage } from '../types';
78

89
interface UseSSEChatOptions {
@@ -167,8 +168,12 @@ export function useSSEChat({
167168
} else if (chunk.type === 'error') {
168169
throw new Error(chunk.error || 'Stream error');
169170
}
170-
} catch {
171+
} catch (parseError) {
171172
// Non-JSON data, treat as text chunk
173+
clientLogger.debug('[useSSEChat] Non-JSON SSE data, treating as text chunk', {
174+
data,
175+
parseError,
176+
});
172177
accumulatedText += data;
173178
onUpdateMessage(agentMessageId, {
174179
text: accumulatedText,
@@ -190,7 +195,7 @@ export function useSSEChat({
190195
return;
191196
}
192197

193-
console.error('[useSSEChat] Error sending message:', error);
198+
clientLogger.error('[useSSEChat] Error sending message:', error);
194199
onUpdateMessage(tempId, {
195200
isLoading: false,
196201
text: `${text} (Failed to send)`,

packages/client/src/lib/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { AVATAR_IMAGE_MAX_SIZE } from '@/constants';
2-
import type { UUID } from '@elizaos/core';
32
import { type ClassValue, clsx } from 'clsx';
43
import dayjs from 'dayjs';
54
import localizedFormat from 'dayjs/plugin/localizedFormat';
65
import { twMerge } from 'tailwind-merge';
7-
import { AgentStatus, type Agent, type UUID as CoreUUID } from '@elizaos/core';
6+
import { AgentStatus, type Agent, type UUID } from '@elizaos/core';
87
import type { MessageChannel as ClientMessageChannel } from '@/types';
98

109
/**
@@ -170,7 +169,7 @@ export function getAttachmentType(contentType: string | undefined): AttachmentTy
170169
export const generateGroupName = (
171170
channel: Partial<ClientMessageChannel> | undefined,
172171
participants: Partial<Agent>[] | undefined,
173-
currentUserId: CoreUUID | string | undefined
172+
currentUserId: UUID | string | undefined
174173
): string => {
175174
if (channel?.name && channel.name.trim() !== '') {
176175
return channel.name;

0 commit comments

Comments
 (0)