Skip to content

feat: Dynamic title in problem set initial message #156

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

Merged
merged 1 commit into from
Aug 8, 2025
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
2 changes: 1 addition & 1 deletion src/components/AiChat/AiChat.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const AssignmentSelection: Story = {
problemSetInitialMessages: [
{
role: "assistant",
content: "Which question are you working on?",
content: "Can I help you with any of the problems in <title>?",
},
],
},
Expand Down
6 changes: 5 additions & 1 deletion src/components/AiChat/AiChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ const AiChatDisplay: FC<AiChatDisplayProps> = ({
if (problemSetInitialMessages) {
setMessages(
problemSetInitialMessages.map((message, i) => ({
...message,
content: message.content?.replace(
"<title>",
event.target.value as string,
),
role: message.role,
id: `initial-${i}`,
})),
)
Expand Down
1 change: 1 addition & 0 deletions src/components/AiChat/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type AiChatDisplayProps = {

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

Expand Down
Loading