Skip to content

Commit fe49472

Browse files
committed
cr
1 parent edeacfb commit fe49472

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

frontend/app/components/Primitives.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ export const MyThread: FC<MyThreadProps> = (props: MyThreadProps) => {
7171
<div className="md:mb-8 mb-4">
7272
<SuggestedQuestions />
7373
</div>
74-
<MyComposer messages={props.messages} />
74+
<MyComposer
75+
submitDisabled={props.submitDisabled}
76+
messages={props.messages}
77+
/>
7578
</div>
7679
</div>
7780
) : (
78-
<MyComposer messages={props.messages} />
81+
<MyComposer
82+
submitDisabled={props.submitDisabled}
83+
messages={props.messages}
84+
/>
7985
)}
8086
</ThreadPrimitive.Root>
8187
);

frontend/app/components/ThreadHistory.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface ThreadHistoryProps {
1515
createThread: (id: string) => Promise<any>;
1616
assistantId: string | undefined;
1717
switchSelectedThread: (thread: ThreadActual) => void;
18+
getUserThreads: (id: string) => Promise<void>;
1819
}
1920

2021
interface ThreadProps {
@@ -159,6 +160,8 @@ export function ThreadHistory(props: ThreadHistoryProps) {
159160
return;
160161
}
161162
await props.createThread(props.userId);
163+
// Re-fetch threads so that the new thread shows up.
164+
await props.getUserThreads(props.userId);
162165
};
163166

164167
return (

frontend/app/hooks/useGraph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface GraphInput {
5353

5454
export function useGraph(userId: string | undefined) {
5555
const { toast } = useToast();
56-
const { getThreadById } = useThreads(userId);
56+
const { getThreadById, getUserThreads } = useThreads(userId);
5757
const [messages, setMessages] = useState<BaseMessage[]>([]);
5858
const [assistantId, setAssistantId] = useState<string>();
5959
const [threadId, setThreadId] = useState<string>();
@@ -596,7 +596,7 @@ export function useGraph(userId: string | undefined) {
596596
}
597597
};
598598

599-
const switchSelectedThread = (thread: ThreadActual) => {
599+
const switchSelectedThread = async (thread: ThreadActual) => {
600600
setThreadId(thread.thread_id);
601601
if (!thread.values) {
602602
setMessages([]);

frontend/app/hooks/useThreads.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ export function useThreads(userId: string | undefined) {
5151
return {
5252
userThreads,
5353
getThreadById,
54+
getUserThreads,
5455
};
5556
}

frontend/app/new/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function ContentComposerChatInterface(): React.ReactElement {
3333
threadId: currentThread,
3434
switchSelectedThread,
3535
} = useGraph(userId);
36-
const { userThreads } = useThreads(userId);
36+
const { userThreads, getUserThreads } = useThreads(userId);
3737
const [isRunning, setIsRunning] = useState(false);
3838

3939
const isSubmitDisabled = !userId || !assistantId || !currentThread;
@@ -73,6 +73,8 @@ export default function ContentComposerChatInterface(): React.ReactElement {
7373
});
7474
} finally {
7575
setIsRunning(false);
76+
// Re-fetch threads so that the current thread's title is updated.
77+
await getUserThreads(userId);
7678
}
7779
}
7880

@@ -92,6 +94,7 @@ export default function ContentComposerChatInterface(): React.ReactElement {
9294
<div className="overflow-hidden w-full flex md:flex-row flex-col">
9395
<div>
9496
<ThreadHistory
97+
getUserThreads={getUserThreads}
9598
isEmpty={messages.length === 0}
9699
switchSelectedThread={switchSelectedThread}
97100
currentThread={currentThread}

0 commit comments

Comments
 (0)