You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(copilot): reattach an orphaned docstring and cut comment noise
One real defect. Adding hasSpecialTagMarker put it BETWEEN
unclosedTagCannotResolve and the docstring written for it, so two doc blocks sat
stacked and the function they described ended up with none. A reader scanning the
file would have read the first block as preamble for the wrong function. Moved
back, and while there: "14 substring scans" is SPECIAL_TAG_NAMES.length * 2, so
adding an eighth tag would have quietly made it wrong — it now says a pass per
tag name.
The rest is noise removal:
- Three comments narrating what the parser used to do. A comment is read by
someone looking at the current code, not the diff, and this branch already
writes that history at length in its commit messages.
- Three millisecond measurements. Each one already stated the durable claim —
quadratic, or a copy thrown away per opener per chunk — and then appended a
number that will rot. The one measurement kept is the blind-spot paragraph on
MAX_UNCLOSED_BODY_SCAN, where the number is what justifies the constant.
- Two of the four restatements of "the renderer concatenates adjacent text
segments". Kept where it is load-bearing, on pushText and on the test helper.
- One claim gone stale in the last commit: the read-budget doc still described
two helpers agreeing with each other, after they became one function.
Left alone deliberately: the rules that look arbitrary and are not — marker
blanking, the differing resume offsets, the accepted trades. Those are why this
file reads as heavily commented, and they are the ones worth having.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-sanitize.ts
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.test.ts
-7Lines changed: 0 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -223,8 +223,6 @@ describe('parseSpecialTags with <question>', () => {
223
223
})
224
224
225
225
it('still parses a valid tag that follows a rejected one',()=>{
226
-
// Before the rewrite, rejecting an unclosed tag abandoned the rest of the
227
-
// message, so this <options> tag was never parsed at all.
228
226
const{ segments }=parseSpecialTags(
229
227
'I use <thinking> loosely here. Anyway: <options>[{"title":"A","description":"d"}]</options> done.',
230
228
false
@@ -437,8 +435,6 @@ describe('parseSpecialTags with <question>', () => {
437
435
})
438
436
439
437
it('shows prose immediately mid-stream instead of blanking the rest',()=>{
440
-
// The failure this replaces: everything after the marker stayed invisible
441
-
// for the remainder of the stream, then reappeared when it ended.
442
438
constcontent='The `<workspace_resource>` chip only renders for a real file.'
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.tsx
+30-40Lines changed: 30 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -516,10 +516,9 @@ const JSON_BODY_TAG_NAMES: ReadonlySet<(typeof SPECIAL_TAG_NAMES)[number]> = new
516
516
* first character that breaks JSON viability — so a bounded window reaches the
517
517
* same verdict as the full remainder for any payload a tag actually carries.
518
518
* Unbounded, the check is O(body length) and runs once per opener inside a parse
519
-
* that re-runs for every streamed chunk: a long reply repeatedly mentioning a tag
520
-
* name cost seconds of main-thread time, and one 58KB reply whose early close was
521
-
* misspelled — so a single body stretched most of the message — cost 242ms per
522
-
* parse against 35ms bounded.
519
+
* that re-runs for every streamed chunk. A long reply repeatedly mentioning a
520
+
* tag name, or one whose misspelled early close stretches a single body across
521
+
* most of the message, is then quadratic in the length of the reply.
523
522
*
524
523
* The window's one blind spot, and why it is accepted: a JSON body whose
525
524
* top-level value closes BEYOND the window, followed by prose and no closing tag,
@@ -618,14 +617,24 @@ function isViableJsonPrefixOf(scannable: string): boolean {
618
617
returntrue
619
618
}
620
619
620
+
/**
621
+
* Whether `text` contains a marker for one of the tags this parser knows.
622
+
*
623
+
* Deliberately the tag NAMES rather than anything tag-shaped. A prose body may
624
+
* legitimately contain `<div>` or `Promise<void>`; only a marker the parser
625
+
* would itself act on proves the enclosing opener was text. Shared so the
626
+
* streaming and matched-pair paths cannot answer the same question differently
627
+
* — them disagreeing is what let a late close swallow content already on screen.
0 commit comments