Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: test that escaped currency keeps long replies streaming fast (#15820)

Nilay4447544045c4
diff --git a/studio/frontend/tests/escaped-inline-math.test.ts b/studio/frontend/tests/escaped-inline-math.test.ts
index 5e61a5fbedb..be95c42a052 100644
--- a/studio/frontend/tests/escaped-inline-math.test.ts
+++ b/studio/frontend/tests/escaped-inline-math.test.ts
@@ -304,3 +304,16 @@ test("escaped currency with no math pair skips the parse, every rewrite still ru
assert.equal(mayHoldEscapedInlineMath(`\\$${"x_".repeat(101)}\\$`), false);
assert.equal(mayHoldEscapedInlineMath("\\$x\n\\$"), false);
});
+
+test("escaped currency in a long streamed reply stays within the streaming budget", () => {
+ const section =
+ "## Pricing\n\nThe plan has **two** tiers, a [docs](https://example.com) link and `code`.\n\n- first item\n- second item\n\n```python\nprint(1)\n```\n\n";
+ const reply = `The plan costs \\$20 per month, or \\$200 per year.\n\n${section.repeat(200)}`;
+ const started = performance.now();
+ for (let end = 500; end <= reply.length; end += 500) {
+ const chunk = reply.slice(0, end);
+ assert.equal(normalizeEscapedInlineMath(chunk), chunk);
+ }
+ const elapsed = performance.now() - started;
+ assert.ok(elapsed < 500, `streaming took ${elapsed.toFixed(1)}ms`);
+});