Skip to content

Commit ece19d4

Browse files
authored
Fix: [devtools] Respect plain text line breaks (#375)
skip-test-verification - Update README.md of `tests/ai` to list correct variable names for Azure OpenAI - Update devtools to parse `\n` and `\r\n` line breaks as HTML `<br />` With fix, the following is rendered as shown in image: ```typescript const paragraphs = [ 'This is the first paragraph of our test stream. It contains several sentences to demonstrate how streaming works with longer content.<br><br>', 'Short paragraph\n', 'Here\'s the second paragraph. Notice how each paragraph is sent as a separate chunk, creating a nice streaming effect for the user.\r\n', 'This is a third paragraph to show multiple paragraphs streaming in sequence.\n\n', 'fourth' ]; ``` <img width="964" height="266" alt="image" src="https://github.com/user-attachments/assets/ba9c0243-d7bf-4726-b43a-79f9d22771f6" /> As reported at microsoft/teams-sdk#2654 --------- Co-authored-by: Corina Gum <>
1 parent b2198b8 commit ece19d4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/devtools/src/components/HtmlMessageContent/HtmlMessageContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ const renderNode = (node: any, key: number = 0): React.ReactNode => {
100100

101101
const HtmlMessageContent = React.memo(function HtmlMessageContent ({ content }: Props) {
102102
const classes = useClasses();
103-
const dom = parseDocument(content, { });
103+
104+
// Respect \r\n and \n as line breaks
105+
const processedContent = content.replace(/\r?\n/g, '<br />');
106+
107+
const dom = parseDocument(processedContent, { });
104108
const body = dom.children || [];
105109
return <div className={classes.contentContainer} >{body.map((node, i) => renderNode(node, i))}</div>;
106110
});

tests/ai/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Then run the sample via ttk.
2929

3030
```bash
3131
AZURE_OPENAI_API_KEY=<your_azure_openai_api_key>
32-
AZURE_OPENAI_API_ENDPOINT=<your_azure_openai_api_endpoint>
33-
AZURE_OPENAI_MODEL_NAME=<your_azure_openai_model_deployment_name>
32+
AZURE_OPENAI_ENDPOINT=<your_azure_openai_api_endpoint>
33+
AZURE_OPENAI_MODEL_DEPLOYMENT_NAME=<your_azure_openai_model_deployment_name>
3434
AZURE_OPENAI_API_VERSION=<your_azure_openai_api_version>
3535

3636
# Alternatively, set the OpenAI API key:

0 commit comments

Comments
 (0)