Skip to content
Open
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
29 changes: 0 additions & 29 deletions .changeset/fix-redos.md

This file was deleted.

30 changes: 30 additions & 0 deletions packages/chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# @intentface/chat

## 0.1.1

### Patch Changes

- [#58](https://github.com/Intentface/intentface-chat/pull/58) [`9f74772`](https://github.com/Intentface/intentface-chat/commit/9f747721d26299de9a15f7983e875ec9c8df3ad3) Thanks [@rpvilo](https://github.com/rpvilo)! - Fix two quadratic-backtracking regexes that could hang the browser.

`parseChipSegments` is the serious one, because message text is untrusted — it
arrives from the model. The chip token pattern had two independent blowups. A long
run of `[` with no closing bracket made the label group consume to end-of-string,
fail, backtrack over every position, advance one character and repeat: 355ms at
32k characters. Worse, `[a](chip:x:` repeated with no `)` anywhere did the same
through the value group from many start positions at once: 264ms at 88k
characters. Both grow quadratically, so a large message could hang a tab for
seconds.

Every character class now excludes `[`, so no group can consume past the next
one and the work per start position is bounded by the gap to it. Safe for
anything `encodeChipMarkdown` produces — values are `encodeURIComponent`-escaped,
queries come from `URLSearchParams`, prefixes are short identifiers — and labels
containing raw brackets never parsed under the previous pattern either.

`detectActivePrefix` had the same shape via `/\S*$/`, which retries from every
position when the text ends in whitespace. It runs on every keystroke, so pasting
a large single-token blob froze the editor — 16 seconds for a 200k-character run.
Replaced with a backwards index scan, which is linear, allocation-free, and
returns identical results.

Both are covered by regression tests asserting a time budget that the previous
implementations exceeded by two orders of magnitude.

## 0.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/chat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intentface/chat",
"version": "0.1.0",
"version": "0.1.1",
"description": "Headless chat UI primitives — unstyled compound components, hooks, and wire formats for building AI chat interfaces.",
"license": "MIT",
"type": "module",
Expand Down