Skip to content

Commit d440b02

Browse files
committed
Fixes errors from 'yarn build'
1 parent 23888f7 commit d440b02

39 files changed

+325
-351
lines changed

components/Avatar/SystemAvatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IconPasswordUser, IconUserPentagon } from '@tabler/icons-react';
1+
import { IconPasswordUser } from '@tabler/icons-react';
22
import React from 'react';
33

44
export const SystemAgentAvatar = ({ height = 7, width = 7 }) => {

components/Avatar/UserAvatar.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
22

3-
import { getInitials } from '@/utils/app/helper';
4-
53
export const UserAvatar = ({ src = '', height = 30, width = 30 }) => {
64
const profilePicUrl = src || ``;
75

components/Chat/Chat.tsx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11

22
'use client';
33

4-
import { ChatInput } from './ChatInput';
5-
import { ChatLoader } from './ChatLoader';
6-
import { MemoizedChatMessage } from './MemoizedChatMessage';
4+
import { v4 as uuidv4 } from 'uuid';
5+
import toast from 'react-hot-toast';
6+
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
7+
78
import { InteractionModal } from '@/components/Chat/ChatInteractionMessage';
89
import HomeContext from '@/pages/api/home/home.context';
910
import { ChatBody, Conversation, Message } from '@/types/chat';
1011
import {
1112
WebSocketInbound,
12-
validateWebSocketMessage,
1313
validateWebSocketMessageWithConversationId,
14-
validateConversationId,
1514
isSystemResponseMessage,
1615
isSystemIntermediateMessage,
1716
isSystemInteractionMessage,
1817
isErrorMessage,
19-
isSystemResponseInProgress,
2018
isSystemResponseComplete,
21-
isOAuthConsentMessage,
2219
extractOAuthUrl,
23-
shouldAppendResponseContent,
2420
} from '@/types/websocket';
2521
import { getEndpoint } from '@/utils/app/api';
2622
import { webSocketMessageTypes } from '@/utils/app/const';
2723
import {
2824
saveConversation,
2925
saveConversations,
30-
updateConversation,
3126
} from '@/utils/app/conversation';
3227
import {
3328
fetchLastMessage,
3429
processIntermediateMessage,
35-
updateConversationTitle,
3630
} from '@/utils/app/helper';
3731
import {
3832
shouldAppendResponse,
@@ -44,14 +38,11 @@ import {
4438
shouldRenderAssistantMessage,
4539
} from '@/utils/chatTransform';
4640
import { throttle } from '@/utils/data/throttle';
47-
import { useTranslation } from 'next-i18next';
48-
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
49-
import toast from 'react-hot-toast';
50-
import { v4 as uuidv4 } from 'uuid';
51-
5241
import { SESSION_COOKIE_NAME } from '@/constants/constants';
5342

54-
43+
import { ChatInput } from './ChatInput';
44+
import { ChatLoader } from './ChatLoader';
45+
import { MemoizedChatMessage } from './MemoizedChatMessage';
5546

5647
// Streaming utilities for handling SSE and NDJSON safely
5748
function normalizeNewlines(s: string): string {
@@ -144,7 +135,6 @@ function parsePossiblyConcatenatedJson(payload: string): any[] {
144135
// };
145136

146137
export const Chat = () => {
147-
const { t } = useTranslation('chat');
148138
const {
149139
state: {
150140
selectedConversation,
@@ -161,13 +151,11 @@ export const Chat = () => {
161151
intermediateStepOverride,
162152
enableIntermediateSteps,
163153
},
164-
handleUpdateConversation,
165154
dispatch: homeDispatch,
166155
} = useContext(HomeContext);
167156

168157
const [currentMessage, setCurrentMessage] = useState<Message>();
169158
const [autoScrollEnabled, setAutoScrollEnabled] = useState<boolean>(true);
170-
const [showSettings, setShowSettings] = useState<boolean>(false);
171159
const [showScrollDownButton, setShowScrollDownButton] =
172160
useState<boolean>(false);
173161

@@ -320,7 +308,9 @@ export const Chat = () => {
320308
'ws://127.0.0.1:8000/websocket';
321309

322310
// Determine if this is a cross-origin connection
311+
// eslint-disable-next-line no-unused-vars
323312
const wsUrlObj = new URL(wsUrl);
313+
// eslint-disable-next-line no-unused-vars
324314
const isCrossOrigin = wsUrlObj.origin !== window.location.origin;
325315

326316
// Always add session cookie as query parameter for reliability
@@ -388,7 +378,7 @@ export const Chat = () => {
388378
}
389379
};
390380

391-
ws.onerror = error => {
381+
ws.onerror = _error => {
392382
homeDispatch({ field: 'webSocketConnected', value: false });
393383
webSocketConnectedRef.current = false;
394384
homeDispatch({ field: 'loading', value: false });
@@ -411,7 +401,8 @@ export const Chat = () => {
411401
/**
412402
* Handles OAuth consent flow by opening popup window
413403
*/
414-
const handleOAuthConsent = (message: WebSocketInbound) => {
404+
// eslint-disable-next-line no-unused-vars
405+
const _handleOAuthConsent = (message: WebSocketInbound) => {
415406
if (!isSystemInteractionMessage(message)) return false;
416407

417408
if (message.content?.input_type === 'oauth_consent') {
@@ -422,7 +413,7 @@ export const Chat = () => {
422413
'oauth-popup',
423414
'width=600,height=700,scrollbars=yes,resizable=yes'
424415
);
425-
const handleOAuthComplete = (event: MessageEvent) => {
416+
const handleOAuthComplete = (_event: MessageEvent) => {
426417
if (popup && !popup.closed) popup.close();
427418
window.removeEventListener('message', handleOAuthComplete);
428419
};
@@ -702,7 +693,7 @@ export const Chat = () => {
702693
};
703694

704695
const handleSend = useCallback(
705-
async (message: Message, deleteCount = 0, retry = false) => {
696+
async (message: Message, deleteCount = 0, _retry = false) => {
706697
message.id = uuidv4();
707698

708699
// Set the active user message ID for WebSocket message tracking
@@ -862,8 +853,7 @@ export const Chat = () => {
862853
};
863854

864855
const endpoint = getEndpoint({ service: 'chat' });
865-
let body;
866-
body = JSON.stringify({
856+
const body = JSON.stringify({
867857
...chatBody,
868858
});
869859

@@ -981,6 +971,7 @@ export const Chat = () => {
981971
chunkValue = String(chunkValue ?? '');
982972
}
983973

974+
// eslint-disable-next-line no-unused-vars
984975
counter++;
985976

986977
// First, handle any partial chunk from previous iteration
@@ -1005,8 +996,8 @@ export const Chat = () => {
1005996
}
1006997

1007998
// Process complete intermediate steps
1008-
let rawIntermediateSteps: any[] = [];
1009-
let stepMatches =
999+
const rawIntermediateSteps: any[] = [];
1000+
const stepMatches =
10101001
chunkValue.match(
10111002
/<intermediatestep>([\s\S]*?)<\/intermediatestep>/g
10121003
) || [];
@@ -1016,7 +1007,7 @@ export const Chat = () => {
10161007
.replace('<intermediatestep>', '')
10171008
.replace('</intermediatestep>', '')
10181009
.trim();
1019-
let rawIntermediateMessage = tryParseJson<any>(jsonString);
1010+
const rawIntermediateMessage = tryParseJson<any>(jsonString);
10201011
// handle intermediate data
10211012
if (rawIntermediateMessage?.type === 'system_intermediate') {
10221013
rawIntermediateSteps.push(rawIntermediateMessage);

components/Chat/ChatHeader.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import {
1010
IconChevronRight,
1111
} from '@tabler/icons-react';
1212
import React, { useContext, useState, useRef, useEffect } from 'react';
13-
1413
import { env } from 'next-runtime-env';
1514

1615
import { getWorkflowName } from '@/utils/app/helper';
1716
import { useTheme } from '@/contexts/ThemeContext';
18-
1917
import HomeContext from '@/pages/api/home/home.context';
2018

2119
import { DataStreamControls } from './DataStreamControls';
@@ -77,7 +75,7 @@ export const ChatHeader = ({ webSocketModeRef = {} }) => {
7775
) : (
7876
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 mx-auto flex flex-col space-y-5 md:space-y-10 px-3 pt-5 md:pt-12 sm:max-w-[600px] text-center">
7977
<div className="text-3xl font-semibold text-gray-800 dark:text-white">
80-
Hi, I'm {workflow}
78+
Hi, I&apos;m {workflow}
8179
</div>
8280
<div className="text-lg text-gray-600 dark:text-gray-400">
8381
How can I assist you today?

components/Chat/ChatInput.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
IconArrowDown,
3-
IconBolt,
43
IconPaperclip,
54
IconPhoto,
65
IconPlayerStop,
@@ -9,7 +8,6 @@ import {
98
IconTrash,
109
IconMicrophone,
1110
IconPlayerStopFilled,
12-
IconMicrophone2,
1311
} from '@tabler/icons-react';
1412
import {
1513
KeyboardEvent,
@@ -22,18 +20,15 @@ import {
2220
useState,
2321
} from 'react';
2422
import toast from 'react-hot-toast';
25-
2623
import { useTranslation } from 'next-i18next';
2724

2825
import { appConfig } from '@/utils/app/const';
2926
import { compressImage, getWorkflowName } from '@/utils/app/helper';
30-
3127
import { Message } from '@/types/chat';
32-
3328
import HomeContext from '@/pages/api/home/home.context';
3429

3530
interface Props {
36-
onSend: (message: Message) => void;
31+
onSend: (_message: Message) => void;
3732
onRegenerate: () => void;
3833
onScrollDownClick: () => void;
3934
textareaRef: MutableRefObject<HTMLTextAreaElement | null>;
@@ -48,14 +43,13 @@ export const ChatInput = ({
4843
onScrollDownClick,
4944
textareaRef,
5045
showScrollDownButton,
51-
controller,
46+
controller: _controller,
5247
onStopConversation,
5348
}: Props) => {
5449
const { t } = useTranslation('chat');
5550

5651
const {
57-
state: { selectedConversation, messageIsStreaming, loading, webSocketMode },
58-
dispatch: homeDispatch,
52+
state: { selectedConversation, messageIsStreaming }
5953
} = useContext(HomeContext);
6054

6155
const workflow = getWorkflowName();
@@ -67,8 +61,10 @@ export const ChatInput = ({
6761
const [isTyping, setIsTyping] = useState<boolean>(false);
6862
const fileInputRef = useRef(null);
6963
const [inputFile, setInputFile] = useState(null);
64+
// eslint-disable-next-line no-unused-vars
7065
const [inputFileExtension, setInputFileExtension] = useState('');
7166
const [inputFileContent, setInputFileContent] = useState('');
67+
// eslint-disable-next-line no-unused-vars
7268
const [inputFileContentCompressed, setInputFileContentCompressed] =
7369
useState('');
7470
const [isRecording, setIsRecording] = useState(false);
@@ -78,7 +74,7 @@ export const ChatInput = ({
7874
fileInputRef?.current.click();
7975
};
8076

81-
const handleInputFileDelete = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
77+
const handleInputFileDelete = (_e: React.ChangeEvent<HTMLTextAreaElement>) => {
8278
setInputFile(null);
8379
setInputFileExtension('');
8480
setInputFileContent('');
@@ -220,6 +216,7 @@ export const ChatInput = ({
220216
}
221217
};
222218

219+
// eslint-disable-next-line no-unused-vars
223220
const handleInitModal = () => {
224221
const selectedPrompt = filteredPrompts[activePromptIndex];
225222
if (selectedPrompt) {
@@ -235,6 +232,7 @@ export const ChatInput = ({
235232
setShowPromptList(false);
236233
};
237234

235+
// eslint-disable-next-line no-unused-vars
238236
const parseVariables = (content: string) => {
239237
const regex = /{{(.*?)}}/g;
240238
const foundVariables = [];
@@ -247,6 +245,7 @@ export const ChatInput = ({
247245
return foundVariables;
248246
};
249247

248+
// eslint-disable-next-line no-unused-vars
250249
const handleSubmit = (updatedVariables: string[]) => {
251250
const newContent = content?.replace(/{{(.*?)}}/g, (match, variable) => {
252251
const index = variables.indexOf(variable);
@@ -285,7 +284,7 @@ export const ChatInput = ({
285284
}) => {
286285
const clipboardData =
287286
event.clipboardData || event.originalEvent.clipboardData;
288-
let items = clipboardData.items;
287+
const items = clipboardData.items;
289288
let isImagePasted = false;
290289

291290
if (items) {
@@ -307,7 +306,7 @@ export const ChatInput = ({
307306

308307
// Handle text only if no image was pasted
309308
if (!isImagePasted) {
310-
let text = clipboardData.getData('text/plain');
309+
const text = clipboardData.getData('text/plain');
311310
if (text) {
312311
// setContent(text); // Set text content only if text is pasted
313312
}

components/Chat/ChatInteractionMessage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export const InteractionModal = ({
1010
onClose,
1111
onSubmit,
1212
}) => {
13+
const [userInput, setUserInput] = useState('');
14+
const [error, setError] = useState('');
15+
1316
if (!isOpen || !interactionMessage) return null;
1417

1518
const { content } = interactionMessage;
16-
const [userInput, setUserInput] = useState('');
17-
const [error, setError] = useState('');
1819

1920
// Validation for Text Input
2021
const handleTextSubmit = () => {

0 commit comments

Comments
 (0)