File tree 5 files changed +18
-5
lines changed
5 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,17 @@ export const MyThread: FC<MyThreadProps> = (props: MyThreadProps) => {
71
71
< div className = "md:mb-8 mb-4" >
72
72
< SuggestedQuestions />
73
73
</ div >
74
- < MyComposer messages = { props . messages } />
74
+ < MyComposer
75
+ submitDisabled = { props . submitDisabled }
76
+ messages = { props . messages }
77
+ />
75
78
</ div >
76
79
</ div >
77
80
) : (
78
- < MyComposer messages = { props . messages } />
81
+ < MyComposer
82
+ submitDisabled = { props . submitDisabled }
83
+ messages = { props . messages }
84
+ />
79
85
) }
80
86
</ ThreadPrimitive . Root >
81
87
) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ interface ThreadHistoryProps {
15
15
createThread : ( id : string ) => Promise < any > ;
16
16
assistantId : string | undefined ;
17
17
switchSelectedThread : ( thread : ThreadActual ) => void ;
18
+ getUserThreads : ( id : string ) => Promise < void > ;
18
19
}
19
20
20
21
interface ThreadProps {
@@ -159,6 +160,8 @@ export function ThreadHistory(props: ThreadHistoryProps) {
159
160
return ;
160
161
}
161
162
await props . createThread ( props . userId ) ;
163
+ // Re-fetch threads so that the new thread shows up.
164
+ await props . getUserThreads ( props . userId ) ;
162
165
} ;
163
166
164
167
return (
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export interface GraphInput {
53
53
54
54
export function useGraph ( userId : string | undefined ) {
55
55
const { toast } = useToast ( ) ;
56
- const { getThreadById } = useThreads ( userId ) ;
56
+ const { getThreadById, getUserThreads } = useThreads ( userId ) ;
57
57
const [ messages , setMessages ] = useState < BaseMessage [ ] > ( [ ] ) ;
58
58
const [ assistantId , setAssistantId ] = useState < string > ( ) ;
59
59
const [ threadId , setThreadId ] = useState < string > ( ) ;
@@ -596,7 +596,7 @@ export function useGraph(userId: string | undefined) {
596
596
}
597
597
} ;
598
598
599
- const switchSelectedThread = ( thread : ThreadActual ) => {
599
+ const switchSelectedThread = async ( thread : ThreadActual ) => {
600
600
setThreadId ( thread . thread_id ) ;
601
601
if ( ! thread . values ) {
602
602
setMessages ( [ ] ) ;
Original file line number Diff line number Diff line change @@ -51,5 +51,6 @@ export function useThreads(userId: string | undefined) {
51
51
return {
52
52
userThreads,
53
53
getThreadById,
54
+ getUserThreads,
54
55
} ;
55
56
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export default function ContentComposerChatInterface(): React.ReactElement {
33
33
threadId : currentThread ,
34
34
switchSelectedThread,
35
35
} = useGraph ( userId ) ;
36
- const { userThreads } = useThreads ( userId ) ;
36
+ const { userThreads, getUserThreads } = useThreads ( userId ) ;
37
37
const [ isRunning , setIsRunning ] = useState ( false ) ;
38
38
39
39
const isSubmitDisabled = ! userId || ! assistantId || ! currentThread ;
@@ -73,6 +73,8 @@ export default function ContentComposerChatInterface(): React.ReactElement {
73
73
} ) ;
74
74
} finally {
75
75
setIsRunning ( false ) ;
76
+ // Re-fetch threads so that the current thread's title is updated.
77
+ await getUserThreads ( userId ) ;
76
78
}
77
79
}
78
80
@@ -92,6 +94,7 @@ export default function ContentComposerChatInterface(): React.ReactElement {
92
94
< div className = "overflow-hidden w-full flex md:flex-row flex-col" >
93
95
< div >
94
96
< ThreadHistory
97
+ getUserThreads = { getUserThreads }
95
98
isEmpty = { messages . length === 0 }
96
99
switchSelectedThread = { switchSelectedThread }
97
100
currentThread = { currentThread }
You can’t perform that action at this time.
0 commit comments