Fix beta build: satisfy MessageContext hook deps (#140)
## Summary - Closes #139. - [Deploy Beta run 1025](https://git.aimloperations.com/ai_ml_operations/chat_web_app/actions/runs/1025/jobs/1743) failed `npm run build:beta` on `ai-server-4080` because `CI=true` turns `react-hooks/exhaustive-deps` warnings into errors. - `GetConversationDetails` is a `useCallback` and is listed on the post-stream refetch, the selected-conversation effect, and the reconnect effect. `setConversationDetails` stays stable, so those effects still run only when their real inputs change. - Adds a project rule to lint changed `llm-fe` files with warnings as errors before pushing a merge request. ## Test plan - [x] `CI=true ./node_modules/.bin/eslint --max-warnings 0 src/llm-fe/contexts/MessageContext.tsx` - [x] `MessageContext.test.tsx` and `MessageContext.order.test.tsx` (8 passed) - [ ] Deploy Beta `build:beta` succeeds on `ai-server-4080` after merge Reviewed-on: #140
This commit was merged in pull request #140.
This commit is contained in:
1 parent
ae59c2731d
commit
608fb37413
2 files changed
+30
-7
No files matched your search
@@ -95,7 +95,7 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
||||
setActivityHistory([])
|
||||
}
|
||||
|
||||
async function GetConversationDetails(conversationId: number | undefined) {
|
||||
const GetConversationDetails = useCallback(async (conversationId: number | undefined) => {
|
||||
if (!conversationId) {
|
||||
setConversationDetails([])
|
||||
return
|
||||
@@ -134,7 +134,7 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
||||
} catch (err) {
|
||||
console.log('Failed to refetch conversation after reconnect', err)
|
||||
}
|
||||
}
|
||||
}, [setConversationDetails])
|
||||
|
||||
const schedulePostStreamRefetch = useCallback(() => {
|
||||
if (refetchTimerRef.current) clearTimeout(refetchTimerRef.current)
|
||||
@@ -145,11 +145,11 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
||||
refetchTimerRef.current = setTimeout(() => {
|
||||
void GetConversationDetails(conversationId)
|
||||
}, 800)
|
||||
}, [])
|
||||
}, [GetConversationDetails])
|
||||
|
||||
useEffect(() => {
|
||||
GetConversationDetails(selectedConversation)
|
||||
}, [selectedConversation])
|
||||
void GetConversationDetails(selectedConversation)
|
||||
}, [selectedConversation, GetConversationDetails])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
@@ -198,9 +198,9 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
||||
}
|
||||
|
||||
if (selectedConversationRef.current) {
|
||||
GetConversationDetails(selectedConversationRef.current)
|
||||
void GetConversationDetails(selectedConversationRef.current)
|
||||
}
|
||||
}, [reconnectGeneration])
|
||||
}, [reconnectGeneration, GetConversationDetails, setConversationDetails])
|
||||
|
||||
useEffect(() => {
|
||||
/* register a consistent channel name for identifing this chat messages */
|
||||
|
||||
Reference in new issue
Block a user