Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: thread error handling #4307

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions web/containers/Providers/ModelHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,10 @@ export default function ModelHandler() {

const generateThreadTitle = (message: ThreadMessage, thread: Thread) => {
// If this is the first ever prompt in the thread
if (
(thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle
) {
if ((thread.title ?? thread.metadata?.title)?.trim() !== defaultThreadTitle)
return
}

if (!activeModelRef.current) {
return
}
if (!activeModelRef.current) return

// Check model engine; we don't want to generate a title when it's not a local engine. remote model using first promp
if (!isLocalEngine(activeModelRef.current?.engine as InferenceEngine)) {
Expand All @@ -332,6 +327,7 @@ export default function ModelHandler() {
...updatedThread,
})
})
.catch(console.error)
}

// This is the first time message comes in on a new thread
Expand Down
7 changes: 7 additions & 0 deletions web/hooks/useDeleteThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@
async (threadId: string) => {
const thread = threads.find((c) => c.id === threadId)
if (!thread) return
const availableThreads = threads.filter((c) => c.id !== threadId)
setThreads(availableThreads)

// delete the thread state
deleteThreadState(threadId)

const assistantInfo = await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.getThreadAssistant(thread.id)
.catch(console.error)

if (!assistantInfo) return
const model = models.find((c) => c.id === assistantInfo?.model?.id)
Expand All @@ -64,13 +71,13 @@
?.deleteThread(threadId)
.catch(console.error)
},
[assistants, models, requestCreateNewThread, threads]

Check warning on line 74 in web/hooks/useDeleteThread.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

React Hook useCallback has missing dependencies: 'deleteThreadState' and 'setThreads'. Either include them or remove the dependency array

Check warning on line 74 in web/hooks/useDeleteThread.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

React Hook useCallback has missing dependencies: 'deleteThreadState' and 'setThreads'. Either include them or remove the dependency array

Check warning on line 74 in web/hooks/useDeleteThread.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

React Hook useCallback has missing dependencies: 'deleteThreadState' and 'setThreads'. Either include them or remove the dependency array

Check warning on line 74 in web/hooks/useDeleteThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

React Hook useCallback has missing dependencies: 'deleteThreadState' and 'setThreads'. Either include them or remove the dependency array
)

const deleteThread = async (threadId: string) => {
if (!threadId) {
alert('No active thread')
return

Check warning on line 80 in web/hooks/useDeleteThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

79-80 lines are not covered with tests
}
await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
Expand Down
Loading