Skip to content

Commit 17aa8c6

Browse files
committed
Dynamic title in problem set initial message
1 parent 02cdc82 commit 17aa8c6

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/components/AiChat/AiChat.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const AssignmentSelection: Story = {
132132
problemSetInitialMessages: [
133133
{
134134
role: "assistant",
135-
content: "Which question are you working on?",
135+
content: "Can I help you with any of the problems in <title>?",
136136
},
137137
],
138138
},

src/components/AiChat/AiChat.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ const AiChatDisplay: FC<AiChatDisplayProps> = ({
306306
if (problemSetInitialMessages) {
307307
setMessages(
308308
problemSetInitialMessages.map((message, i) => ({
309-
...message,
309+
content: message.content?.replace(
310+
"<title>",
311+
event.target.value as string,
312+
),
313+
role: message.role,
310314
id: `initial-${i}`,
311315
})),
312316
)

src/components/AiChat/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ type AiChatDisplayProps = {
132132

133133
/**
134134
* Initial messages to display on problem set selection.
135+
* Occurrences of "<title>" in the content will be replaced with the problem set title.
135136
*/
136137
problemSetInitialMessages?: Omit<AiChatMessage, "id">[]
137138

0 commit comments

Comments
 (0)