@jsb188/ai-chat 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,7 @@ import type { ReactDivElement } from '@jsb188/react-web/types/dom.d';
9
9
  import { AvatarImg } from '@jsb188/react-web/ui/Avatar';
10
10
  import { ProgressCircle } from '@jsb188/react-web/ui/Loading';
11
11
  import Markdown, { type RenderMappedCodeFn } from '@jsb188/react-web/ui/Markdown';
12
- import { createContext, forwardRef, Fragment, memo, useContext } from 'react';
13
- import { createPortal } from 'react-dom';
12
+ import { forwardRef, Fragment, memo } from 'react';
14
13
  import { AIChatContent } from '../modules/AIChatContent';
15
14
  import type { ChatContentStatus } from '../types/content';
16
15
  import './AIChatUI.css';
@@ -23,41 +22,6 @@ const FILE_CONSTANTS = {
23
22
  textareaDropOverlayStyle: { background: 'rgba(var(--color-bg), 0.75)' },
24
23
  };
25
24
 
26
- /**
27
- * Max-width class paired with .cw on every chat bubble and composer; a screen that embeds
28
- * the chat in a different column width provides its own class (default: 780px .df)
29
- */
30
-
31
- export const AIChatWidthContext = createContext('df');
32
-
33
- /*
34
- * Return the max-width class for chat bubbles and the composer in the current chat column.
35
- */
36
- export function useAIChatWidthClassName() {
37
- return useContext(AIChatWidthContext);
38
- }
39
-
40
- /**
41
- * Element a screen provides to render the chat composer outside its message scroller (e.g. so the scroller can
42
- * fade out with a mask); null while that element is mounting. Without a provider, the composer renders inline.
43
- */
44
-
45
- export const AIChatTextareaSlotContext = createContext<HTMLElement | null | undefined>(undefined);
46
-
47
- /*
48
- * Render the chat composer into the screen's textarea slot when one is provided, or inline otherwise.
49
- */
50
- export function AIChatTextareaPortal(p: { children: React.ReactNode }) {
51
- const slotEl = useContext(AIChatTextareaSlotContext);
52
-
53
- if (slotEl === undefined) {
54
- return p.children;
55
- }
56
-
57
- // Render nothing until the slot mounts, so the composer never mounts inline and then moves (and remounts)
58
- return slotEl ? createPortal(p.children, slotEl) : null;
59
- }
60
-
61
25
  /**
62
26
  * Types
63
27
  */
@@ -99,9 +63,9 @@ interface MockMessageBubblesProps {
99
63
 
100
64
  export const AIChatDateSeparator = memo((p: { dayText: string; timeText: string }) => {
101
65
  return (
102
- <div className='v_center py_md mt_md ft_xs cl_lt'>
66
+ <div className="v_center py_md mt_md ft_xs cl_lt">
103
67
  <span>
104
- <span className='ft_medium'>{p.dayText}</span> {p.timeText}
68
+ <span className="ft_medium">{p.dayText}</span> {p.timeText}
105
69
  </span>
106
70
  </div>
107
71
  );
@@ -145,7 +109,6 @@ MessageContainer.displayName = 'MessageContainer';
145
109
 
146
110
  function MockMessageBubbles(p: MockMessageBubblesProps) {
147
111
  const { longer, isSelf } = p;
148
- const widthClassName = useAIChatWidthClassName();
149
112
 
150
113
  let mockTexts;
151
114
  if (isSelf && longer) {
@@ -224,7 +187,7 @@ function MockMessageBubbles(p: MockMessageBubblesProps) {
224
187
  return (
225
188
  <MessageContainer
226
189
  key={i}
227
- className={cn('cw', widthClassName)}
190
+ className="cw df"
228
191
  isSelf={isSelf}
229
192
  isMock
230
193
  spaced={top}
@@ -333,7 +296,7 @@ export const MessageBody = memo((p: MessageBodyProps) => {
333
296
  </>
334
297
  ) : (
335
298
  <Markdown
336
- as='p'
299
+ as="p"
337
300
  preset={isSelf ? undefined : 'article'}
338
301
  codesMap={codesMap}
339
302
  MappedCodeComponent={MappedCodeComponent}
@@ -359,7 +322,7 @@ export const MessageOptions = memo((p: Partial<MessageOptionsProps>) => {
359
322
  <div className={cn('mdy_msg_opts', hidden ? 'cmo_hidden' : '')}>
360
323
  {!showAvatar || hidden ? null : (
361
324
  <AvatarImg
362
- size='small'
325
+ size="small"
363
326
  displayName={displayName}
364
327
  urlPath={photoUri}
365
328
  />
@@ -376,8 +339,8 @@ MessageOptions.displayName = 'MessageOptions';
376
339
 
377
340
  export const AIGeneratingIndicator = memo(() => {
378
341
  return (
379
- <span className='cm_loader_cnt'>
380
- <span className='cm_loader' />
342
+ <span className="cm_loader_cnt">
343
+ <span className="cm_loader" />
381
344
  </span>
382
345
  );
383
346
  });
@@ -424,7 +387,7 @@ export const MessageTextarea = memo(
424
387
 
425
388
  const submitButton = (
426
389
  <button
427
- type='button'
390
+ type="button"
428
391
  onClick={generating ? onStopGenerating : onSubmit}
429
392
  disabled={!generating && (!formIsEnabled || disabled)}
430
393
  className={cn(
@@ -447,10 +410,10 @@ export const MessageTextarea = memo(
447
410
 
448
411
  {submitTooltipMessage ? (
449
412
  <TooltipButton
450
- as='span'
451
- className='cm_btn_right'
452
- tooltipClassName='a_c'
453
- position='top'
413
+ as="span"
414
+ className="cm_btn_right"
415
+ tooltipClassName="a_c"
416
+ position="top"
454
417
  offsetY={-6}
455
418
  message={submitTooltipMessage}
456
419
  >
@@ -472,7 +435,7 @@ MessageTextarea.displayName = 'MessageTextarea';
472
435
  */
473
436
 
474
437
  export const TextareaAttachmentsRow = memo((p: { children: React.ReactNode }) => {
475
- return <div className='rel z1 h_wrap gap_5 pt_6 pb_4 px_6'>{p.children}</div>;
438
+ return <div className="rel z1 h_wrap gap_5 pt_6 pb_4 px_6">{p.children}</div>;
476
439
  });
477
440
 
478
441
  TextareaAttachmentsRow.displayName = 'TextareaAttachmentsRow';
@@ -511,10 +474,10 @@ const TextareaAttachmentThumbnail = memo(
511
474
  )}
512
475
 
513
476
  {uploading && (
514
- <span className='abs_full z1 v_center'>
477
+ <span className="abs_full z1 v_center">
515
478
  <ProgressCircle
516
- className='cl_primary'
517
- trackColor='rgba(var(--color-bg), .3)'
479
+ className="cl_primary"
480
+ trackColor="rgba(var(--color-bg), .3)"
518
481
  percent={progress}
519
482
  size={22}
520
483
  strokeWidth={4}
@@ -558,11 +521,11 @@ export const TextareaAttachmentChip = memo(
558
521
  errored={errored}
559
522
  />
560
523
 
561
- {hasMediaPreview ? null : <span className='ft_xs'>{truncateFileName(name, 20)}</span>}
524
+ {hasMediaPreview ? null : <span className="ft_xs">{truncateFileName(name, 20)}</span>}
562
525
 
563
526
  {!uploading ? (
564
527
  <button
565
- type='button'
528
+ type="button"
566
529
  className={cn(
567
530
  'link w_18 h_18 ic_xs r v_center no_shrink',
568
531
  hasMediaPreview ? 'abs_tr z2 bg_contrast_hv cl_solid mt_3 mr_3' : 'mx_2 bg_active bg_medium_hv',
@@ -570,7 +533,7 @@ export const TextareaAttachmentChip = memo(
570
533
  )}
571
534
  onClick={onRemove}
572
535
  >
573
- <Icon name='x' />
536
+ <Icon name="x" />
574
537
  </button>
575
538
  ) : !hasMediaPreview ? (
576
539
  <span />
@@ -589,20 +552,20 @@ TextareaAttachmentChip.displayName = 'TextareaAttachmentChip';
589
552
  export const TextareaDropOverlay = memo((p: { text: string }) => {
590
553
  return (
591
554
  <div
592
- className='fixed_full z10 v_center bg_blur_sm anim_appear on_mount spd_2'
555
+ className="fixed_full z10 v_center bg_blur_sm anim_appear on_mount spd_2"
593
556
  style={FILE_CONSTANTS.textareaDropOverlayStyle}
594
557
  >
595
558
  <DashedBackgroundArea
596
- className='fs v_center m_md z1 fade_bg_radial'
597
- contentClassName='h_center gap_sm ic_lg'
559
+ className="fs v_center m_md z1 fade_bg_radial"
560
+ contentClassName="h_center gap_sm ic_lg"
598
561
  radius={10}
599
- strokeColor='rgba(var(--color-darker-rgb), .05)'
562
+ strokeColor="rgba(var(--color-darker-rgb), .05)"
600
563
  strokeWidth={6}
601
564
  dashLength={12}
602
565
  dashGapMultiplier={3}
603
566
  >
604
- <Icon name='drag-drop-hand' />
605
- <span className='ft_lg ls_5 shift_down'>{p.text}</span>
567
+ <Icon name="drag-drop-hand" />
568
+ <span className="ft_lg ls_5 shift_down">{p.text}</span>
606
569
  </DashedBackgroundArea>
607
570
  </div>
608
571
  );
@@ -651,7 +614,7 @@ export const MessageAttachmentBody = memo(
651
614
  // Use the image-specific background rather than the standard message bubble background
652
615
  return (
653
616
  <button
654
- type='button'
617
+ type="button"
655
618
  className={cn('mdy_msg p_n link of no_shrink', className, top ? 'top' : '', bottom ? 'bottom' : '')}
656
619
  style={imageDimensions || undefined}
657
620
  onClick={onClick}
@@ -664,7 +627,7 @@ export const MessageAttachmentBody = memo(
664
627
  <img
665
628
  src={file?.previewUrl || makeUploadsUrl(fileUri, 'medium')}
666
629
  alt={displayName}
667
- className='img_auto img_contain max_w_320 max_h_320 noclick unsel'
630
+ className="img_auto img_contain max_w_320 max_h_320 noclick unsel"
668
631
  />
669
632
  </div>
670
633
  </button>
@@ -673,22 +636,22 @@ export const MessageAttachmentBody = memo(
673
636
 
674
637
  return (
675
638
  <button
676
- type='button'
639
+ type="button"
677
640
  className={cn('mdy_msg attachment_file link bg_alt_hv', className, top ? 'top' : '', bottom ? 'bottom' : '')}
678
641
  onClick={onClick}
679
642
  disabled={!onClick}
680
643
  >
681
- <div className='h_item gap_sm p_xs r_sm bd_1 bd_lt bg bg_alt_hv max_w_330'>
682
- <span className='w_46 h_46 r_xs bg_fade bd_1 bd_lt v_center ic_df no_shrink'>
644
+ <div className="h_item gap_sm p_xs r_sm bd_1 bd_lt bg bg_alt_hv max_w_330">
645
+ <span className="w_46 h_46 r_xs bg_fade bd_1 bd_lt v_center ic_df no_shrink">
683
646
  <Icon
684
647
  name={getFileTypeIconName('', displayName)}
685
648
  tryColor
686
649
  />
687
650
  </span>
688
651
 
689
- <span className='ellip_cnt ft_sm f lh_2 shift_down'>
690
- <span className='ellip ft_medium'>{displayName}</span>
691
- {fileExtension ? <span className='bl cl_md'>{fileExtension}</span> : null}
652
+ <span className="ellip_cnt ft_sm f lh_2 shift_down">
653
+ <span className="ellip ft_medium">{displayName}</span>
654
+ {fileExtension ? <span className="bl cl_md">{fileExtension}</span> : null}
692
655
  </span>
693
656
  </div>
694
657
  </button>
@@ -731,7 +694,7 @@ export const MessageImageAttachmentGroup = memo(
731
694
  {files.map((file) => (
732
695
  <button
733
696
  key={file.id}
734
- type='button'
697
+ type="button"
735
698
  className={cn(
736
699
  'link attachment_btn p_n of w_140 h_140 no_shrink no_link op_90_hv',
737
700
  !file.imageData?.averageColor && 'bg_contrast',
@@ -742,7 +705,7 @@ export const MessageImageAttachmentGroup = memo(
742
705
  <img
743
706
  src={file.previewUrl || makeUploadsUrl(file.uri, 'medium')}
744
707
  alt={file.name || file.uri.substring(file.uri.lastIndexOf('/') + 1)}
745
- className='img_auto noclick unsel'
708
+ className="img_auto noclick unsel"
746
709
  />
747
710
  </button>
748
711
  ))}
@@ -795,8 +758,8 @@ export const MemoizedContentEditable = memo(
795
758
  <div
796
759
  ref={ref}
797
760
  id={domId}
798
- className='cm_textarea stock y_scr subtle f'
799
- role='textbox'
761
+ className="cm_textarea stock y_scr subtle f"
762
+ role="textbox"
800
763
  tabIndex={0}
801
764
  contentEditable={locked || disabled ? 'false' : 'true'}
802
765
  data-placeholder={notReady ? undefined : placeholder}
@@ -134,7 +134,7 @@ const AgentNoteActionButton = (p: {
134
134
  className={cn('ic_sm', p.active && 'cl_contrast')}
135
135
  aria-hidden="true"
136
136
  >
137
- {p.action.busy ? <ActivityIndicator size="tn" /> : <Icon name={p.icon} />}
137
+ {p.action.busy ? <ActivityIndicator size="xs" /> : <Icon name={p.icon} />}
138
138
  </span>
139
139
  {p.warning ? (
140
140
  <span
@@ -148,14 +148,15 @@ const AgentNoteActionButton = (p: {
148
148
 
149
149
  /*
150
150
  * Keep note actions inside the disclosure row and expanded content outside its click target.
151
- * Collapsed, the row shows the headline; expanded, the header shows the last update time and the body starts with
152
- * the headline. A note that needs attention
151
+ * The collapsed row uses the saved title when present and falls back to the headline.
152
+ * The expanded header shows the last update time and the body shows the optional title above the headline. A note that needs attention
153
153
  * carries a marker in its row and says so in the row's accessible name. Without a refresh action
154
154
  * (an archived note), the expanded header offers no refresh.
155
155
  */
156
156
  export const AgentNoteItemUI = memo(
157
157
  (p: {
158
158
  emoji: string;
159
+ title?: string | null;
159
160
  headline: string;
160
161
  expanded: boolean;
161
162
  needsAttention: boolean;
@@ -176,7 +177,7 @@ export const AgentNoteItemUI = memo(
176
177
  // The disclosure's own label names it, so the attention state must be part of that label to be announced
177
178
  const label = p.expanded
178
179
  ? p.refreshLabel || i18n.t('c.last_updated', { date: getFullDateTime(p.publishedAt, { textDateStyle: 'short' }) })
179
- : p.headline;
180
+ : p.title || p.headline;
180
181
  return (
181
182
  <ToggleExpand
182
183
  id={p.controlsId}
@@ -247,6 +248,7 @@ export const AgentNoteItemUI = memo(
247
248
  </ToggleExpandHeader>
248
249
  }
249
250
  >
251
+ {p.title && <p className="ft_medium cl_md">{p.title}</p>}
250
252
  <p className="ft_md ofw mt_sm mb_20">{p.headline}</p>
251
253
  {p.children}
252
254
  </ToggleExpand>
@@ -1,5 +1,6 @@
1
1
  import parseEmojiText from '@jsb188/app/utils/emoji.ts';
2
- import { memo } from 'react';
2
+ import { memo, useContext } from 'react';
3
+ import { ChatLinkHandlerContext } from '../modules/ChatLinkHandlerContext';
3
4
  import type { InlineNode } from '../types/content.ts';
4
5
  import { getChatInlineText } from './ChatInline.helpers.ts';
5
6
 
@@ -24,12 +25,13 @@ const ChatText = memo((p: { text: string }) => {
24
25
  */
25
26
  const ChatInlineNode = memo((p: { node: InlineNode }) => {
26
27
  const { node } = p;
28
+ const handleLink = useContext(ChatLinkHandlerContext);
27
29
  switch (node.kind) {
28
30
  case 'break':
29
31
  return <br />;
30
32
  case 'code':
31
33
  return (
32
- <code className='bg_alt r_4 px_4 ofw pre_wrap'>
34
+ <code className="bg_alt r_4 px_4 ofw pre_wrap">
33
35
  <span>{node.value}</span>
34
36
  </code>
35
37
  );
@@ -40,6 +42,11 @@ const ChatInlineNode = memo((p: { node: InlineNode }) => {
40
42
  href={node.destination}
41
43
  target={external ? '_blank' : undefined}
42
44
  rel={external ? 'noopener noreferrer' : undefined}
45
+ onClick={(event) => {
46
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
47
+ return;
48
+ if (handleLink?.(node.destination)) event.preventDefault();
49
+ }}
43
50
  >
44
51
  <ChatInline nodes={node.children} />
45
52
  </a>
@@ -53,13 +60,13 @@ const ChatInlineNode = memo((p: { node: InlineNode }) => {
53
60
  node.styles.includes('semibold') && 'ft_semibold',
54
61
  node.styles.includes('underline') && 'u',
55
62
  node.styles.includes('strike') && 'strikethrough',
56
- node.styles.includes('highlight') && 'em_text',
63
+ node.styles.includes('highlight') && 'em_link',
57
64
  ]
58
65
  .filter(Boolean)
59
66
  .join(' ') || undefined;
60
67
  const children = <ChatInline nodes={node.children} />;
61
68
  return (
62
- <Tag className={className}>{node.styles.includes('highlight') ? <span className='rel z1'>{children}</span> : children}</Tag>
69
+ <Tag className={className}>{node.styles.includes('highlight') ? <span className="rel z1">{children}</span> : children}</Tag>
63
70
  );
64
71
  }
65
72
  }
@@ -1,32 +1,6 @@
1
1
  import { DEFAULT_PARSER_LIMITS, type ParserLimits } from '../types/content.ts';
2
2
 
3
- /*
4
- * Accept explicit web/contact links and relative destinations without permitting browser scheme normalization bypasses.
5
- */
6
- export function getSafeLinkDestination(destination: string): string | null {
7
- if (!destination || /[\s\u0000-\u001f\u007f-\u009f\\]/u.test(destination) || /&(?:#(?:x[\da-f]+|\d+)|[a-z]+);/i.test(destination)) {
8
- return null;
9
- }
10
-
11
- const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(destination)?.[1]?.toLowerCase();
12
- if (scheme) {
13
- if (!['http', 'https', 'mailto', 'tel'].includes(scheme)) {
14
- return null;
15
- }
16
- if (scheme === 'http' || scheme === 'https') {
17
- try {
18
- const url = new URL(destination);
19
- return url.hostname ? destination : null;
20
- } catch {
21
- return null;
22
- }
23
- }
24
- return destination.length > scheme.length + 1 ? destination : null;
25
- }
26
-
27
- // A colon before a path/query/fragment boundary is never a relative path.
28
- return /^[^/?#]*:/.test(destination) ? null : destination;
29
- }
3
+ export { getSafeLinkDestination } from '@jsb188/app/utils/url_client.ts';
30
4
 
31
5
  /*
32
6
  * Decode only escaped punctuation from link destinations, leaving URL encoding and literal values untouched.
package/VERIFICATION.md DELETED
@@ -1,118 +0,0 @@
1
- # AI chat content verification
2
-
3
- ## October 14, 2026: performance-only update
4
-
5
- Verified on Apple M1 Max/macOS, Node 24.15.0, Vite 8.1.5, and headless Chromium 151.0.7922.34. The comparison uses locally built production bundles with React's profiling renderer, the same checked-in synthetic preview, and no application API calls. The unchanged baseline was captured before edits from application commit `df006d667b2da32f7a4f4f77b5c126c681fdecd8` and packages commit `3c4e16390bfde300a06d610a2ffbcb45856e1a40`.
6
-
7
- The renderer now retains safe source prefixes, reopens the last two blocks, reuses validated Markdown cells and diagnostics, and caches immutable node counts. Plain inline text avoids delimiter indexing. Text and emoji rendering omit one internal React component layer while retaining identical spans and keys. No CSS, DOM structure, animation, update scheduling, streaming cadence, scrolling, table virtualization, or transport behavior was changed.
8
-
9
- ### Browser comparison
10
-
11
- Each figure is the median of five samples after one warm-up. Content mount means mounting the fixture's content inside the existing assistant message, after an open CSV code block has removed previous tables. Streamed React peak is `Profiler.actualDuration` across the fixture's approximately 60 animation-frame updates. Browser JavaScript time comes from Chromium performance counters over that stream; it includes the fixture and app, not just parsing. These are local synthetic observations, not production latency guarantees.
12
-
13
- | Fixture | Content mount before → after | Peak streamed React render before → after | Streaming JavaScript before → after |
14
- | --- | ---: | ---: | ---: |
15
- | Receipt, CSV, and prose | 2.3 → 1.6 ms | 1.0 → 0.9 ms | 55.39 → 53.10 ms |
16
- | 10 tables × 35 rows | 24.8 → 21.9 ms | 2.9 → 1.1 ms | 126.60 → 64.59 ms |
17
- | 500-row × 5-column table | 52.8 → 40.3 ms | 9.7 → 1.6 ms | 363.03 → 109.45 ms |
18
- | 192,000-character unfinished paragraph | 23.3 → 3.1 ms | 11.6 → 0.7 ms | 401.13 → 48.50 ms |
19
-
20
- The large table's peak streamed React work decreased about 84%, its streaming JavaScript time about 70%, and its content mount about 24%. Browser layout work remains: the long paragraph still spent about 340 ms cumulatively in layout across the stream. Median maximum observed frame intervals fell from 35.1 to 27.2 ms for the large table and 37.0 to 27.3 ms for the paragraph; these results do not establish a universal frame-time guarantee.
21
-
22
- All five completed DOM snapshots for each of the four fixtures had exactly matching SHA-256 hashes across the builds, including identical element counts. The mobile dark-mode screenshot PNG bytes and CSV download contents also matched exactly. Browser checks passed at 320/420/780px content widths and a 375px mobile viewport, including keyboard horizontal scrolling, preserved table DOM/scroll offsets after appending prose, overflow containment, and status-only CSV promotion/interruption. Both builds start measurements after the existing 250 ms message-animation warm-up, so differences in measurement overhead cannot change the captured animation state.
23
-
24
- ### Parsing plus reconciliation
25
-
26
- The Node benchmark compares the saved original pure-parser bundle with the final incremental renderer path, including identity reconciliation on every update. It alternates execution order, discards one warm-up, records five samples, and validates final output. Values below use 256-character chunks; the runner also covers 2,048-character chunks.
27
-
28
- | Fixture | Updates | Cumulative work before → after | Per-update p95 before → after |
29
- | --- | ---: | ---: | ---: |
30
- | 10 tables × 35 rows | 105 | 105.769 → 4.819 ms | 1.852 → 0.056 ms |
31
- | 500-row × 5-column table | 645 | 3,368.447 → 258.910 ms | 10.016 → 0.737 ms |
32
- | 192,000-character unfinished paragraph | 750 | 3,783.147 → 279.518 ms | 9.484 → 0.715 ms |
33
-
34
- The active table still scans physical lines and retained row references. Complex unfinished paragraphs, active lists, and CSV fences can still require repeated parsing. Prefix checking and reconciliation also retain some work proportional to existing content. These improvements do not claim universally linear cumulative cost.
35
-
36
- ### Correctness and integration
37
-
38
- - Package: 163 tests pass, including full-parser equivalence, immutable prior snapshots, late table fallback, diagnostic retention, resource budgets, CRLF boundaries, status transitions, source replacement/truncation, hydration, selection, and stable DOM identities. Package typecheck passes.
39
- - Application chat integration/work/reconnect: 43 tests pass. Shared table and virtualized-list pagination/scroll behavior: 26 tests pass. Total: 232 tests.
40
- - An independent audit against parser files extracted from the unchanged packages commit passed 183,900 comparisons across 2,400 deterministic adversarial sources and varied lifecycle states/budgets. This additionally checked changes shared by the full and incremental parsers.
41
- - Review caught and fixed metadata loss through table reconciliation and stale reuse after changing parser budgets. Budget metadata follows each parse's diagnostics array, which reconciliation preserves. Different budgets invalidate structural reuse. WeakMap values contain counts/budgets/diagnostics rather than references that keep whole documents alive.
42
- - Repository formatter and whitespace checks pass. The production profiling fixture builds successfully. Full Marketday typecheck remains blocked by the same pre-existing ambient-context errors in `app/routes/app.d.$dataTableId.helpers.ts` at lines 8, 9, and 11; that file was not changed.
43
-
44
- ### Reproduction
45
-
46
- From the repository root, build the synthetic preview with production profiling enabled:
47
-
48
- ```sh
49
- node --input-type=module <<'JS'
50
- import { build } from 'vite';
51
- import { resolve } from 'node:path';
52
- await build({
53
- configFile: 'apps/marketday/tests/fixtures/ai-chat.vite.config.ts',
54
- resolve: { alias: { 'react-dom/client': 'react-dom/profiling' } },
55
- build: {
56
- outDir: '/tmp/chat-profile',
57
- emptyOutDir: true,
58
- rollupOptions: { input: resolve('apps/marketday/tests/fixtures/AIChatContentPreview.html') },
59
- },
60
- });
61
- JS
62
- node packages/@jsb188:ai-chat/benchmarks/browser.mjs /tmp/chat-profile /tmp/chat-browser.json
63
- node packages/@jsb188:ai-chat/benchmarks/streaming.mjs /tmp/chat-streaming.json
64
- ```
65
-
66
- The browser runner uses the installed Playwright Chromium and localhost port 3010, falling back to 3011 only if necessary. It closes its browser/server afterward and saves raw timing samples, completed DOM hashes/HTML, a mobile screenshot, and interaction results. Repeat against separately preserved before/after build directories using the same runner. Compare matching fixtures' `htmlHash` values and `interactions` results before interpreting timing changes.
67
-
68
- For a parser comparison against an earlier implementation, preserve a bundle exporting `parseContent` before editing (`esbuild` with `bundle: true`, `platform: 'node'`, `format: 'esm'` and entry `packages/@jsb188:ai-chat/src/parser.ts`), then pass its path as the optional second argument to `benchmarks/streaming.mjs`. Without that argument, the runner compares the current full parser against incremental parsing. Timings are reported rather than asserted, avoiding hardware-dependent test failures.
69
-
70
- ## Original October 3 verification
71
-
72
- Verified October 3, 2026, on the local macOS development workspace with Node 24.15.0, Vite 8.1.5, React development/profiling builds, and the Codex in-app browser. Browser measurements use the checked-in synthetic preview and real `AIChatMessage`/shared table components; no production records were created.
73
-
74
- ## Automated checks
75
-
76
- | Check | Result |
77
- | --- | --- |
78
- | `yarn workspace @jsb188/ai-chat test` | 110 passing tests in 6 files |
79
- | `yarn workspace @jsb188/ai-chat typecheck` | Pass |
80
- | Shared `TableListUI.test.tsx` and `VirtualizedList.pagination.test.tsx` | 23 passing tests; table defaults, roles, and scroll-follow behavior |
81
- | App `AIChatContent.integration`, `AIChatWork`, `AIChatThread.work`, `AIChatStreamReconnect` | 39 passing tests |
82
- | Pure parser bundle inspection with esbuild | 9 local TypeScript modules; no dependency, React, or TSX imports |
83
- | Repository-configured Biome formatting and both repositories' `git diff --check` | Pass |
84
- | `yarn workspace marketday typecheck` | Blocked by three pre-existing ambient-context errors in `app/routes/app.d.$dataTableId.helpers.ts`, lines 8, 9, and 11 (TS1183, TS1254, TS1036); no feature errors |
85
-
86
- The app checks exercise full accumulated source, stable table DOM, source/status-only CSV transitions, loading vs settled empty messages, interrupted indicators, deletion, unchanged user formatting, existing work disclosures, and reconnection. Shared-list tests explicitly exercise growth while following the bottom, preserving an older reading position, navigation to older pagination windows, and observer cleanup. Renderer tests cover hydration, every streamed prefix against a fresh pure parse, provisional tails, resource fallback, and stable row/cell identities through appends and edits.
87
-
88
- ## Browser observations
89
-
90
- - Desktop 1280px and mobile 375px viewports; chat containers 320px, 420px, and 780px; light and dark modes.
91
- - Five-column receipt table and three-column CSV table retain source order with surrounding prose, lists, headings, and code. Duplicate/empty cells, leading zeros, explicit zero values, and multiline CSV remain intact.
92
- - No horizontal page or message-container overflow. Wide tables scroll inside their own wrapper, with complete header/row/cell roles and a translated accessible overflow label.
93
- - Arrow keys scroll the focused table. After its native scroll animation settled at 80px, appending later prose retained the same wrapper and scroll offset.
94
- - Open CSV showed code while streaming, promoted to a table on completion with unchanged text, and stayed source/code when interrupted with the incomplete-response indicator.
95
- - Text remains selectable browser text, and leaf text keeps protective span wrappers. Third-party browser translation services were not invoked; markup and dynamic-update coverage verify the wrapper strategy.
96
-
97
- ## Performance
98
-
99
- Measurements are development-build observations, not production guarantees. Parser figures are median/max of 20 synchronous full-input parses. Streaming peak is React Profiler `actualDuration` across approximately 60 accumulated-source updates at animation-frame boundaries. DOM counts include the assistant container. The fixture exposes the measurement values as visible output.
100
-
101
- | Synthetic input | Characters | Parser median / max | DOM elements | Peak streamed React render |
102
- | --- | ---: | ---: | ---: | ---: |
103
- | Receipt, CSV, and prose | 476 | 0.1 / 0.9 ms | 111 | Small initial render: 5.4–9.2 ms |
104
- | 10 tables × 35 data rows | 26,681 | 2.1 / 2.9 ms | 3,673 | 5.5 ms |
105
- | 500-row × 5-column active table | 164,934 | 9.2 / 10.2 ms | 8,526 | 12.4 ms |
106
- | Long unfinished paragraph | 192,000 | 8.1 / 11.5 ms | 5 (8 with loading UI) | 9.6 ms |
107
-
108
- The initial implementation's 500-row streaming peak was 120.6 ms. Reusing completed table rows/cells and memoizing their shared-table presentation reduced that measured peak to 12.4 ms. Earlier completed blocks remain memoized. No animation-frame coalescer was added to production: the measured update cost was addressed directly, and status finalization remains synchronous.
109
-
110
- Large cold mounts still construct all rows: the near-limit table measured about 195 ms for its initial development render (earlier run 174 ms). There is deliberately no virtualization in this release. Input, node, cell, column, and row limits bound the work and provide intact literal fallback. Repeated full-input parsing still has potentially quadratic cumulative streaming cost; these measurements do not establish a universal frame-time guarantee.
111
-
112
- ## Environment notes
113
-
114
- Yarn Classic workspace linkage requires no new registry dependency or lock entry. An offline install attempt encountered unrelated existing Stripe version/cache mismatches; the new workspace symlink was linked locally for validation. Existing package manifests and lockfile versions were not upgraded as part of this rendering feature.
115
-
116
- The existing application server cached a missing-file import during parallel package creation. A Vite config-triggered restart cleared it; the existing port 3010 application returned HTTP 200 afterward. Verification used an isolated fixture server on port 3011; standalone React Router routing redirects arbitrary fixture HTML, so its dedicated Vite config serves the fixture without application routing. Neither transport nor production data was involved.
117
-
118
- The original plan contains no screenshot transcriptions. Fixtures demonstrate the specified five-column receipt shape and three-column/two-row CSV shape with clearly synthetic values.