@steerable/agent-shell-web 0.12.5 → 0.12.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerable/agent-shell-web",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "type": "module",
5
5
  "description": "Steerable framework — product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/), plus the compiled vite.base config factory (vite.base.js + .d.ts) for Node-side config loading.",
6
6
  "license": "Apache-2.0",
@@ -45,8 +45,8 @@
45
45
  "react-router-dom": "^6.30.0",
46
46
  "rehype-raw": "^7.0.0",
47
47
  "remark-gfm": "^4.0.1",
48
- "@steerable/agent-protocol": "0.12.5",
49
- "@steerable/agent-ui": "0.12.5"
48
+ "@steerable/agent-protocol": "0.12.7",
49
+ "@steerable/agent-ui": "0.12.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@tailwindcss/vite": "^4.3.0",
@@ -59,7 +59,7 @@
59
59
  "typescript": "^5.8.3",
60
60
  "vite": "^5.4.21",
61
61
  "vitest": "^3.2.4",
62
- "@steerable/pack-sdk": "0.12.5"
62
+ "@steerable/pack-sdk": "0.12.7"
63
63
  },
64
64
  "scripts": {
65
65
  "gen": "echo agent-shell-web",
@@ -237,8 +237,46 @@ function mentionChipClassName(ref?: MentionReference): string {
237
237
  return `${base} bg-agent-foreground/10 text-agent-foreground`;
238
238
  }
239
239
 
240
+ function isIgnoredEditorBr(root: HTMLElement, br: HTMLBRElement): boolean {
241
+ if (
242
+ br.hasAttribute('data-empty-scaffold') ||
243
+ br.hasAttribute('data-editor-sentinel')
244
+ ) {
245
+ return true;
246
+ }
247
+ return (
248
+ (root.textContent ?? '') === '' &&
249
+ root.querySelectorAll('br').length === 1 &&
250
+ !root.querySelector('[data-mention-chip]')
251
+ );
252
+ }
253
+
240
254
  function getEditableText(element: HTMLDivElement): string {
241
- return (element.textContent ?? '').replace(/\u00a0/g, ' ');
255
+ let out = '';
256
+ const walk = (node: Node) => {
257
+ if (
258
+ node instanceof HTMLElement &&
259
+ (node.getAttribute('contenteditable') === 'false' || node.tagName === 'BUTTON')
260
+ ) {
261
+ out += (node.textContent ?? '').replace(/\u00a0/g, ' ');
262
+ return;
263
+ }
264
+ if (node.nodeType === Node.TEXT_NODE) {
265
+ out += (node.textContent ?? '').replace(/\u00a0/g, ' ');
266
+ return;
267
+ }
268
+ if (node instanceof HTMLBRElement) {
269
+ if (!isIgnoredEditorBr(element, node)) {
270
+ out += '\n';
271
+ }
272
+ return;
273
+ }
274
+ for (const child of Array.from(node.childNodes)) {
275
+ walk(child);
276
+ }
277
+ };
278
+ walk(element);
279
+ return out;
242
280
  }
243
281
  function isEditorDomEmpty(editor: HTMLDivElement): boolean {
244
282
  return getEditableText(editor).length === 0;
@@ -354,6 +392,12 @@ function parseMentionSegments(
354
392
  return segments;
355
393
  }
356
394
 
395
+ function createEditorSentinelBr(): HTMLBRElement {
396
+ const br = document.createElement('br');
397
+ br.setAttribute('data-editor-sentinel', 'true');
398
+ return br;
399
+ }
400
+
357
401
  /**
358
402
  * Empty editors need a text node (IME marked-text attachment) plus a `<br>`
359
403
  * (caret height). Replacing this while focused kills the first Pinyin letter.
@@ -369,14 +413,20 @@ function writeEditorValue(
369
413
  mcpTools: McpToolItem[] = [],
370
414
  ) {
371
415
  if (next.length === 0) {
372
- editor.replaceChildren(document.createTextNode(''), document.createElement('br'));
416
+ const scaffoldBr = document.createElement('br');
417
+ scaffoldBr.setAttribute('data-empty-scaffold', 'true');
418
+ editor.replaceChildren(document.createTextNode(''), scaffoldBr);
373
419
  return;
374
420
  }
375
421
 
376
422
  const segments = parseMentionSegments(next, mentionReferences, agents, chats, skills, mcpTools);
377
423
  const hasMentions = segments.some((s) => s.type === 'mention');
378
424
  if (!hasMentions) {
379
- editor.textContent = next;
425
+ const nodes: Node[] = [document.createTextNode(next)];
426
+ if (next.endsWith('\n')) {
427
+ nodes.push(createEditorSentinelBr());
428
+ }
429
+ editor.replaceChildren(...nodes);
380
430
  return;
381
431
  }
382
432
 
@@ -455,6 +505,8 @@ function writeEditorValue(
455
505
  const last = nodes[nodes.length - 1];
456
506
  if (last instanceof HTMLButtonElement) {
457
507
  nodes.push(document.createTextNode(''));
508
+ } else if (next.endsWith('\n')) {
509
+ nodes.push(document.createTextNode(''), createEditorSentinelBr());
458
510
  }
459
511
 
460
512
  editor.replaceChildren(...nodes);
@@ -479,6 +531,85 @@ function updateEditorHeight(editor: HTMLDivElement) {
479
531
  editor.style.height = `${next}px`;
480
532
  }
481
533
 
534
+ function domNodeTextLength(root: HTMLDivElement, node: Node): number {
535
+ if (
536
+ node instanceof HTMLElement &&
537
+ (node.getAttribute('contenteditable') === 'false' || node.tagName === 'BUTTON')
538
+ ) {
539
+ return (node.textContent ?? '').length;
540
+ }
541
+ if (node.nodeType === Node.TEXT_NODE) {
542
+ return node.textContent?.length ?? 0;
543
+ }
544
+ if (node instanceof HTMLBRElement) {
545
+ return isIgnoredEditorBr(root, node) ? 0 : 1;
546
+ }
547
+ let sum = 0;
548
+ for (const child of Array.from(node.childNodes)) {
549
+ sum += domNodeTextLength(root, child);
550
+ }
551
+ return sum;
552
+ }
553
+
554
+ function domPointToTextOffset(root: HTMLDivElement, container: Node, offset: number): number {
555
+ let acc = 0;
556
+ let found = false;
557
+
558
+ const walk = (node: Node): boolean => {
559
+ if (node === container) {
560
+ if (node.nodeType === Node.TEXT_NODE) {
561
+ acc += Math.min(Math.max(offset, 0), node.textContent?.length ?? 0);
562
+ } else if (
563
+ node instanceof HTMLElement &&
564
+ (node.getAttribute('contenteditable') === 'false' || node.tagName === 'BUTTON')
565
+ ) {
566
+ acc += offset > 0 ? (node.textContent ?? '').length : 0;
567
+ } else if (node instanceof HTMLBRElement) {
568
+ acc += offset > 0 && !isIgnoredEditorBr(root, node) ? 1 : 0;
569
+ } else {
570
+ const children = Array.from(node.childNodes);
571
+ const bound = Math.min(Math.max(offset, 0), children.length);
572
+ for (let i = 0; i < bound; i += 1) {
573
+ acc += domNodeTextLength(root, children[i]);
574
+ }
575
+ }
576
+ found = true;
577
+ return true;
578
+ }
579
+
580
+ if (
581
+ node instanceof HTMLElement &&
582
+ (node.getAttribute('contenteditable') === 'false' || node.tagName === 'BUTTON')
583
+ ) {
584
+ if (node.contains(container)) {
585
+ acc += (node.textContent ?? '').length;
586
+ found = true;
587
+ return true;
588
+ }
589
+ acc += (node.textContent ?? '').length;
590
+ return false;
591
+ }
592
+
593
+ if (node.nodeType === Node.TEXT_NODE) {
594
+ acc += node.textContent?.length ?? 0;
595
+ return false;
596
+ }
597
+
598
+ if (node instanceof HTMLBRElement) {
599
+ acc += isIgnoredEditorBr(root, node) ? 0 : 1;
600
+ return false;
601
+ }
602
+
603
+ for (const child of Array.from(node.childNodes)) {
604
+ if (walk(child)) return true;
605
+ }
606
+ return false;
607
+ };
608
+
609
+ walk(root);
610
+ return found ? acc : getEditableText(root).length;
611
+ }
612
+
482
613
  function offsetFromPoint(root: HTMLDivElement, x: number, y: number): number | null {
483
614
  const doc = document as Document & {
484
615
  caretPositionFromPoint?: (x: number, y: number) => { offsetNode: Node; offset: number } | null;
@@ -487,23 +618,17 @@ function offsetFromPoint(root: HTMLDivElement, x: number, y: number): number | n
487
618
  if (typeof doc.caretPositionFromPoint === 'function') {
488
619
  const pos = doc.caretPositionFromPoint(x, y);
489
620
  if (!pos || !root.contains(pos.offsetNode)) return null;
490
- const measure = document.createRange();
491
- measure.selectNodeContents(root);
492
- measure.setEnd(pos.offsetNode, pos.offset);
493
- return measure.toString().length;
621
+ return domPointToTextOffset(root, pos.offsetNode, pos.offset);
494
622
  }
495
623
  const range = doc.caretRangeFromPoint?.(x, y);
496
624
  if (!range || !root.contains(range.startContainer)) return null;
497
- const measure = document.createRange();
498
- measure.selectNodeContents(root);
499
- measure.setEnd(range.startContainer, range.startOffset);
500
- return measure.toString().length;
625
+ return domPointToTextOffset(root, range.startContainer, range.startOffset);
501
626
  }
502
627
 
503
628
  function getSelectionOffsets(root: HTMLDivElement): { start: number; end: number } {
504
629
  const selection = window.getSelection();
505
630
  if (!selection || selection.rangeCount === 0) {
506
- const end = root.innerText.length;
631
+ const end = getEditableText(root).length;
507
632
  return { start: end, end };
508
633
  }
509
634
 
@@ -512,28 +637,14 @@ function getSelectionOffsets(root: HTMLDivElement): { start: number; end: number
512
637
  !root.contains(range.startContainer) ||
513
638
  !root.contains(range.endContainer)
514
639
  ) {
515
- const end = root.textContent?.length ?? 0;
640
+ const end = getEditableText(root).length;
516
641
  return { start: end, end };
517
642
  }
518
643
 
519
- const getOffset = (container: Node, offset: number) => {
520
- const measureRange = document.createRange();
521
- measureRange.selectNodeContents(root);
522
- measureRange.setEnd(container, offset);
523
- return measureRange.toString().length;
644
+ return {
645
+ start: domPointToTextOffset(root, range.startContainer, range.startOffset),
646
+ end: domPointToTextOffset(root, range.endContainer, range.endOffset),
524
647
  };
525
-
526
- try {
527
- return {
528
- start: getOffset(range.startContainer, range.startOffset),
529
- end: getOffset(range.endContainer, range.endOffset),
530
- };
531
- } catch {
532
- // The caret can sit on the empty scaffold's <br> with an offset the
533
- // range rejects. Paste still belongs at the end of the draft.
534
- const end = getEditableText(root).length;
535
- return { start: end, end };
536
- }
537
648
  }
538
649
 
539
650
  function setCaretOffset(root: HTMLDivElement, offset: number) {
@@ -577,7 +688,16 @@ function setCaretOffset(root: HTMLDivElement, offset: number) {
577
688
  }
578
689
 
579
690
  if (node instanceof HTMLBRElement) {
580
- if (remaining <= 1) {
691
+ if (isIgnoredEditorBr(root, node)) {
692
+ return false;
693
+ }
694
+ if (remaining === 0) {
695
+ range.setStartBefore(node);
696
+ range.collapse(true);
697
+ placed = true;
698
+ return true;
699
+ }
700
+ if (remaining === 1) {
581
701
  range.setStartAfter(node);
582
702
  range.collapse(true);
583
703
  placed = true;
@@ -885,6 +1005,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
885
1005
  // this guard that Enter falls through to the "insert newline" branch below
886
1006
  // and the user ends up with a stray blank line after committing text.
887
1007
  const compositionEndAtRef = useRef<number>(0);
1008
+ const enterPressedDuringCompositionRef = useRef(false);
1009
+ const swallowPostCompositionEnterRef = useRef(false);
888
1010
 
889
1011
  const fileInputRef = useRef<HTMLInputElement>(null);
890
1012
  const dropBoxRef = useRef<HTMLDivElement>(null);
@@ -1182,11 +1304,16 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1182
1304
  return;
1183
1305
  }
1184
1306
 
1307
+ const needsTrailingSentinel =
1308
+ value.endsWith('\n') &&
1309
+ !editor.querySelector('br[data-editor-sentinel="true"]');
1310
+
1185
1311
  const wrote =
1186
1312
  editorText !== value ||
1187
1313
  pendingCaretOffset !== null ||
1314
+ needsTrailingSentinel ||
1188
1315
  (!value && !hasEmptyImeScaffold(editor));
1189
- if (editorText !== value || pendingCaretOffset !== null) {
1316
+ if (editorText !== value || pendingCaretOffset !== null || needsTrailingSentinel) {
1190
1317
  writeEditorValue(
1191
1318
  editor,
1192
1319
  value,
@@ -1397,9 +1524,19 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1397
1524
  return { start: caret, end: caret };
1398
1525
  };
1399
1526
 
1527
+ const flushPendingInputSync = () => {
1528
+ if (inputSyncTimerRef.current === null) return;
1529
+ cancelPendingInputSync();
1530
+ if (!isComposingRef.current) {
1531
+ editorRef.current?.removeAttribute('data-composing');
1532
+ syncFromEditor();
1533
+ }
1534
+ };
1535
+
1400
1536
  const replaceSelection = (insertText: string) => {
1401
1537
  const editor = editorRef.current;
1402
1538
  if (!editor) return;
1539
+ flushPendingInputSync();
1403
1540
  const { start, end } = editCaret(editor);
1404
1541
  applyEdit((current) => ({
1405
1542
  next: `${current.slice(0, start)}${insertText}${current.slice(end)}`,
@@ -1428,6 +1565,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1428
1565
  };
1429
1566
 
1430
1567
  const handleEditorPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {
1568
+ swallowPostCompositionEnterRef.current = false;
1431
1569
  if (event.button !== 0) return;
1432
1570
  const editor = editorRef.current;
1433
1571
  if (!editor) return;
@@ -1470,6 +1608,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1470
1608
 
1471
1609
  const markComposing = () => {
1472
1610
  isComposingRef.current = true;
1611
+ enterPressedDuringCompositionRef.current = false;
1612
+ swallowPostCompositionEnterRef.current = false;
1473
1613
  cancelPendingInputSync();
1474
1614
  editorRef.current?.setAttribute('data-composing', 'true');
1475
1615
  };
@@ -1542,6 +1682,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1542
1682
  const handleCompositionEnd = () => {
1543
1683
  isComposingRef.current = false;
1544
1684
  compositionEndAtRef.current = Date.now();
1685
+ swallowPostCompositionEnterRef.current = !enterPressedDuringCompositionRef.current;
1686
+ enterPressedDuringCompositionRef.current = false;
1545
1687
  editorRef.current?.removeAttribute('data-composing');
1546
1688
  syncFromEditor();
1547
1689
  // Safari can flush the committed glyphs after compositionend.
@@ -1566,6 +1708,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1566
1708
  setComposerPasteTarget(editor);
1567
1709
  const onCompositionStart = () => {
1568
1710
  isComposingRef.current = true;
1711
+ enterPressedDuringCompositionRef.current = false;
1712
+ swallowPostCompositionEnterRef.current = false;
1569
1713
  inputSyncGenRef.current += 1;
1570
1714
  if (inputSyncTimerRef.current !== null) {
1571
1715
  clearTimeout(inputSyncTimerRef.current);
@@ -1648,6 +1792,13 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1648
1792
  // no-op without mirror overlay
1649
1793
  };
1650
1794
 
1795
+ const handleKeyUp = (event: KeyboardEvent<HTMLDivElement>) => {
1796
+ if (event.key === 'Enter') {
1797
+ enterPressedDuringCompositionRef.current = false;
1798
+ swallowPostCompositionEnterRef.current = false;
1799
+ }
1800
+ };
1801
+
1651
1802
  const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
1652
1803
  // Cmd/Ctrl+V never reaches a paste event when the app menu owns the
1653
1804
  // shortcut, and WKWebView leaves that event's clipboard empty. Read the
@@ -1661,14 +1812,21 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1661
1812
  requestHostPaste(event.currentTarget);
1662
1813
  return;
1663
1814
  }
1664
- // An open composition session owns the keystroke, including Enter used
1665
- // to confirm the highlighted candidate. Returning without
1666
- // preventDefault lets the IME commit the word. WKWebView can report
1667
- // isComposing / keyCode 229 on Enter after the session has already
1668
- // ended; that case is not an open session (`isComposingRef` is false)
1669
- // and must still send.
1670
- if (isComposingRef.current) return;
1671
- if (event.key !== 'Enter' && event.nativeEvent.isComposing) return;
1815
+ // An open composition session (including Chinese IME English sub-buffers
1816
+ // where nativeEvent.isComposing is true) owns the keystroke, including
1817
+ // Enter used to confirm raw English or highlighted candidates. WKWebView
1818
+ // reports keyCode 229 with isComposing === false on plain Enter, which
1819
+ // passes through here and still submits.
1820
+ if (isComposingRef.current || event.nativeEvent.isComposing) {
1821
+ if (event.key === 'Enter') {
1822
+ enterPressedDuringCompositionRef.current = true;
1823
+ }
1824
+ return;
1825
+ }
1826
+
1827
+ if (event.key !== 'Enter') {
1828
+ swallowPostCompositionEnterRef.current = false;
1829
+ }
1672
1830
 
1673
1831
  if (event.key === 'Backspace' || event.key === 'Delete') {
1674
1832
  const editor = editorRef.current;
@@ -1700,10 +1858,17 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1700
1858
  ) {
1701
1859
  editorRef.current?.setAttribute('data-composing', 'true');
1702
1860
  }
1703
- // See `compositionEndAtRef` above: treat an Enter that lands right after
1704
- // `compositionend` as "confirm candidate", not "submit/newline".
1705
- if (event.key === 'Enter' && Date.now() - compositionEndAtRef.current < 50) {
1706
- return;
1861
+ // Treat an Enter that lands right after `compositionend` (same physical
1862
+ // keystroke confirming IME text) as "confirm candidate", not "submit/newline".
1863
+ if (event.key === 'Enter') {
1864
+ const sinceCompositionEnd = Date.now() - compositionEndAtRef.current;
1865
+ if (
1866
+ (swallowPostCompositionEnterRef.current && sinceCompositionEnd < 300) ||
1867
+ sinceCompositionEnd < 50
1868
+ ) {
1869
+ swallowPostCompositionEnterRef.current = false;
1870
+ return;
1871
+ }
1707
1872
  }
1708
1873
 
1709
1874
  if (mentionQuery && mentionSuggestions.length > 0) {
@@ -1761,6 +1926,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1761
1926
  event.key === 'Enter' && !event.shiftKey;
1762
1927
  if (isSendCombo) {
1763
1928
  event.preventDefault();
1929
+ flushPendingInputSync();
1764
1930
  const submittedText = getEditableText(event.currentTarget).trim();
1765
1931
  // streaming 期间:Enter = follow-up 排队(本轮结束后自动作为下一轮
1766
1932
  // 发出);⌘/Ctrl+Enter = 轮中插队(注入运行中的回合;注入不了时
@@ -1788,7 +1954,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
1788
1954
  }
1789
1955
  return;
1790
1956
  }
1791
- if (canSend) {
1957
+ if (!disabled && (Boolean(submittedText) || actualFiles.length > 0)) {
1792
1958
  void onSubmit();
1793
1959
  }
1794
1960
  return;
@@ -2112,6 +2278,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
2112
2278
  onBeforeInput={handleBeforeInput}
2113
2279
  onPaste={handlePaste}
2114
2280
  onKeyDown={handleKeyDown}
2281
+ onKeyUp={handleKeyUp}
2115
2282
  onCompositionStart={handleCompositionStart}
2116
2283
  onCompositionEnd={handleCompositionEnd}
2117
2284
  onScroll={handleEditorScroll}
@@ -156,6 +156,8 @@ export interface LocalChatPanelProps {
156
156
  inputBanner?: ReactNode;
157
157
  /** W1.2.1: regenerate an assistant turn (fork-preserving). */
158
158
  onRegenerate?: (messageId: string) => Promise<void>;
159
+ /** Edit the latest user message and resubmit (fork-preserving). */
160
+ onEditUserMessage?: (messageId: string, nextContent: string) => void | Promise<void>;
159
161
  /** W7-1: 上一轮被中断(崩溃/强杀)——消息列表尾部展示「继续上次回复」卡片。 */
160
162
  interrupted?: boolean;
161
163
  /** W7-1: 点击「继续上次回复」。 */
@@ -231,6 +233,7 @@ export function LocalChatPanel({
231
233
  pendingFollowUps,
232
234
  onRemoveFollowUp,
233
235
  onRegenerate,
236
+ onEditUserMessage,
234
237
  interrupted,
235
238
  onContinueInterrupted,
236
239
  onDismissInterrupted,
@@ -543,6 +546,7 @@ export function LocalChatPanel({
543
546
  emptyState={emptyState ?? <EmptyChat onSelectPrompt={handleSelectPrompt} />}
544
547
  mode={mode}
545
548
  onRegenerate={onRegenerate}
549
+ onEditUserMessage={onEditUserMessage}
546
550
  interrupted={interrupted}
547
551
  onContinueInterrupted={onContinueInterrupted}
548
552
  onDismissInterrupted={onDismissInterrupted}
@@ -175,6 +175,8 @@ interface MessageListProps {
175
175
  mode?: ChatMode;
176
176
  /** W1.2.1: regenerate an assistant turn (fork-preserving). */
177
177
  onRegenerate?: (messageId: string) => Promise<void>;
178
+ /** Edit the latest user message and resubmit (fork-preserving). */
179
+ onEditUserMessage?: (messageId: string, nextContent: string) => void | Promise<void>;
178
180
  /**
179
181
  * W7-1: the chat's last turn was interrupted (crash/kill — no completion
180
182
  * record). Rendered as a tail card offering to continue the turn; hidden
@@ -236,6 +238,7 @@ export function MessageList({
236
238
  failureAction,
237
239
  mode,
238
240
  onRegenerate,
241
+ onEditUserMessage,
239
242
  interrupted = false,
240
243
  onContinueInterrupted,
241
244
  onDismissInterrupted,
@@ -418,6 +421,16 @@ export function MessageList({
418
421
  return turns;
419
422
  }, [visibleMessages]);
420
423
 
424
+ const lastUserId = useMemo(() => {
425
+ for (let i = visibleMessages.length - 1; i >= 0; i -= 1) {
426
+ const m = visibleMessages[i];
427
+ if (m.role === 'user' && internalTrigger(m) === null) {
428
+ return m.id;
429
+ }
430
+ }
431
+ return null;
432
+ }, [visibleMessages]);
433
+
421
434
  return (
422
435
  <div className="relative flex-1 overflow-hidden">
423
436
  <div
@@ -446,6 +459,11 @@ export function MessageList({
446
459
  message={turn.userGroup.messages[0]}
447
460
  agents={agents}
448
461
  chats={chats}
462
+ onEdit={
463
+ turn.userGroup.messages[0].id === lastUserId && onEditUserMessage
464
+ ? (nextText) => onEditUserMessage(turn.userGroup!.messages[0].id, nextText)
465
+ : undefined
466
+ }
449
467
  />
450
468
  )
451
469
  ) : (
@@ -467,6 +485,11 @@ export function MessageList({
467
485
  chats={chats}
468
486
  isGrouped
469
487
  isAppended={idx > 0}
488
+ onEdit={
489
+ msg.id === lastUserId && onEditUserMessage
490
+ ? (nextText) => onEditUserMessage(msg.id, nextText)
491
+ : undefined
492
+ }
470
493
  />
471
494
  )
472
495
  ))}