@galaxycore/ai-chat 0.10.0 → 0.11.0
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/CHANGELOG.md +12 -0
- package/dist/{appearance-Dpvr1osR.d.ts → appearance-CdnhPTwk.d.ts} +2 -2
- package/dist/appearance.d.ts +2 -2
- package/dist/appearance.js +1 -1
- package/dist/{branches-CUAJceMN.d.ts → branches-CZkkLIra.d.ts} +117 -3
- package/dist/{branches-CRxWPjfD.js → branches-asMPZLXd.js} +89 -2
- package/dist/branches-asMPZLXd.js.map +1 -0
- package/dist/context.js +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/{icons-BkHI--R-.d.ts → icons-iagkwNls.d.ts} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +301 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +117 -1
- package/dist/{ui-primitives-XhFvDm8o.js → ui-primitives-CV3lrveW.js} +4 -2
- package/dist/ui-primitives-CV3lrveW.js.map +1 -0
- package/docs/api-reference.md +10 -2
- package/docs/publishing.md +5 -5
- package/package.json +1 -1
- package/dist/branches-CRxWPjfD.js.map +0 -1
- package/dist/ui-primitives-XhFvDm8o.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { _ as
|
|
4
|
-
import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-
|
|
3
|
+
import { _ as enUS, a as resolveChatModelSelection, b as useAiChat, c as formatChatTokens, d as filterMentions, f as filterSkills, g as useComposerTrigger, h as slugifySkillName, i as isChatReasoningEffort, l as resolveChatContextUsage, m as replaceComposerTrigger, n as useChatBranches, o as selectChatModel, p as parseSkillMarkdown, r as CHAT_REASONING_EFFORTS, s as CHAT_CONTEXT_USAGE_TONES, t as projectChatBranches, u as detectComposerTrigger, v as resolveLabels, y as zhCN } from "./branches-asMPZLXd.js";
|
|
4
|
+
import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-CV3lrveW.js";
|
|
5
5
|
import { i as safeUrl, n as asError, r as getMessageText, t as acceptsFile } from "./utils-DqBGBYA1.js";
|
|
6
6
|
import { SpeechInputError, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
|
|
7
7
|
import { MarkdownResponse } from "./markdown.js";
|
|
@@ -329,6 +329,259 @@ function ChatPlusMenu({ open, onClose, actions, labels: overrides, className = "
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
//#endregion
|
|
332
|
+
//#region src/context-usage-control.tsx
|
|
333
|
+
function interpolate(template, values) {
|
|
334
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => Object.prototype.hasOwnProperty.call(values, key) ? String(values[key]) : `{${key}}`);
|
|
335
|
+
}
|
|
336
|
+
const RING_RADIUS = 7;
|
|
337
|
+
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
|
|
338
|
+
/**
|
|
339
|
+
* Circular context-window utilization indicator for chat composers, opening a Cursor-style
|
|
340
|
+
* segmented per-category token breakdown panel anchored above the composer.
|
|
341
|
+
*/
|
|
342
|
+
function ChatContextUsage({ usedTokens, contextWindowTokens, estimated = true, modelLabel, compacted = false, compactedSavedTokens = 0, compactionCount = 0, segments, disabled = false, warnThreshold, highThreshold, headerAction, open: controlledOpen, defaultOpen = false, onOpenChange, labels: overrides, className = "", popoverClassName = "" }) {
|
|
343
|
+
const labels = resolveLabels(overrides);
|
|
344
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
345
|
+
const isControlled = controlledOpen !== void 0;
|
|
346
|
+
const open = !disabled && (isControlled ? controlledOpen : uncontrolledOpen);
|
|
347
|
+
const rootRef = useRef(null);
|
|
348
|
+
const triggerRef = useRef(null);
|
|
349
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
350
|
+
onOpenChangeRef.current = onOpenChange;
|
|
351
|
+
const dialogId = useId();
|
|
352
|
+
function setOpen(next) {
|
|
353
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
354
|
+
onOpenChangeRef.current?.(next);
|
|
355
|
+
}
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
if (disabled && !isControlled && uncontrolledOpen) setUncontrolledOpen(false);
|
|
358
|
+
}, [
|
|
359
|
+
disabled,
|
|
360
|
+
isControlled,
|
|
361
|
+
uncontrolledOpen
|
|
362
|
+
]);
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
if (!open) return;
|
|
365
|
+
function onPointerDown(event) {
|
|
366
|
+
if (rootRef.current && !rootRef.current.contains(event.target)) {
|
|
367
|
+
if (!isControlled) setUncontrolledOpen(false);
|
|
368
|
+
onOpenChangeRef.current?.(false);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function onKeyDown(event) {
|
|
372
|
+
if (event.key === "Escape") {
|
|
373
|
+
event.preventDefault();
|
|
374
|
+
if (!isControlled) setUncontrolledOpen(false);
|
|
375
|
+
onOpenChangeRef.current?.(false);
|
|
376
|
+
triggerRef.current?.focus();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
380
|
+
document.addEventListener("keydown", onKeyDown);
|
|
381
|
+
return () => {
|
|
382
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
383
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
384
|
+
};
|
|
385
|
+
}, [open, isControlled]);
|
|
386
|
+
const resolved = resolveChatContextUsage({
|
|
387
|
+
usedTokens,
|
|
388
|
+
contextWindowTokens,
|
|
389
|
+
estimated,
|
|
390
|
+
modelLabel,
|
|
391
|
+
compacted,
|
|
392
|
+
compactedSavedTokens,
|
|
393
|
+
compactionCount,
|
|
394
|
+
segments
|
|
395
|
+
}, {
|
|
396
|
+
warnThreshold,
|
|
397
|
+
highThreshold
|
|
398
|
+
});
|
|
399
|
+
const dashOffset = RING_CIRCUMFERENCE * (1 - resolved.ratio);
|
|
400
|
+
const triggerLabel = interpolate(labels.contextUsageTrigger, {
|
|
401
|
+
percent: resolved.percent,
|
|
402
|
+
used: resolved.usedDisplay,
|
|
403
|
+
window: resolved.windowFormatted
|
|
404
|
+
});
|
|
405
|
+
const percentLabel = interpolate(labels.contextUsagePercent, { percent: resolved.percent });
|
|
406
|
+
const tokensRatioLabel = interpolate(labels.contextUsageTokens, {
|
|
407
|
+
used: resolved.usedDisplay,
|
|
408
|
+
window: resolved.windowFormatted
|
|
409
|
+
});
|
|
410
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
411
|
+
ref: rootRef,
|
|
412
|
+
className: `gc-chat__context-usage ${className}`.trim(),
|
|
413
|
+
"data-open": open || void 0,
|
|
414
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
415
|
+
ref: triggerRef,
|
|
416
|
+
type: "button",
|
|
417
|
+
className: "gc-chat__context-usage-trigger",
|
|
418
|
+
disabled,
|
|
419
|
+
"aria-label": triggerLabel,
|
|
420
|
+
title: triggerLabel,
|
|
421
|
+
"aria-haspopup": "dialog",
|
|
422
|
+
"aria-expanded": open,
|
|
423
|
+
"aria-controls": open ? dialogId : void 0,
|
|
424
|
+
"data-open": open || void 0,
|
|
425
|
+
onClick: () => setOpen(!open),
|
|
426
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
427
|
+
className: "gc-chat__context-usage-ring",
|
|
428
|
+
viewBox: "0 0 18 18",
|
|
429
|
+
"data-level": resolved.level,
|
|
430
|
+
"aria-hidden": "true",
|
|
431
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
432
|
+
className: "gc-chat__context-usage-ring-track",
|
|
433
|
+
cx: "9",
|
|
434
|
+
cy: "9",
|
|
435
|
+
r: RING_RADIUS
|
|
436
|
+
}), resolved.usedTokens > 0 ? /* @__PURE__ */ jsx("circle", {
|
|
437
|
+
className: "gc-chat__context-usage-ring-fill",
|
|
438
|
+
cx: "9",
|
|
439
|
+
cy: "9",
|
|
440
|
+
r: RING_RADIUS,
|
|
441
|
+
strokeDasharray: RING_CIRCUMFERENCE,
|
|
442
|
+
strokeDashoffset: dashOffset
|
|
443
|
+
}) : null]
|
|
444
|
+
})
|
|
445
|
+
}), open ? /* @__PURE__ */ jsx("div", {
|
|
446
|
+
id: dialogId,
|
|
447
|
+
role: "dialog",
|
|
448
|
+
"aria-label": labels.contextUsage,
|
|
449
|
+
className: `gc-chat__popover gc-chat__context-usage-popover ${popoverClassName}`.trim(),
|
|
450
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
451
|
+
className: "gc-chat__context-usage-panel",
|
|
452
|
+
children: [
|
|
453
|
+
/* @__PURE__ */ jsxs("div", {
|
|
454
|
+
className: "gc-chat__context-usage-header",
|
|
455
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
456
|
+
className: "gc-chat__context-usage-heading",
|
|
457
|
+
children: [
|
|
458
|
+
/* @__PURE__ */ jsx("span", {
|
|
459
|
+
className: "gc-chat__context-usage-title",
|
|
460
|
+
children: labels.contextUsage
|
|
461
|
+
}),
|
|
462
|
+
resolved.modelLabel ? /* @__PURE__ */ jsx("span", {
|
|
463
|
+
className: "gc-chat__context-usage-model",
|
|
464
|
+
title: resolved.modelLabel,
|
|
465
|
+
children: resolved.modelLabel
|
|
466
|
+
}) : null,
|
|
467
|
+
headerAction
|
|
468
|
+
]
|
|
469
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
470
|
+
type: "button",
|
|
471
|
+
className: "gc-chat__context-usage-close",
|
|
472
|
+
"aria-label": labels.contextUsageClose,
|
|
473
|
+
onClick: () => {
|
|
474
|
+
setOpen(false);
|
|
475
|
+
triggerRef.current?.focus();
|
|
476
|
+
},
|
|
477
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
478
|
+
name: "minus",
|
|
479
|
+
width: 15,
|
|
480
|
+
height: 15
|
|
481
|
+
})
|
|
482
|
+
})]
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ jsxs("div", {
|
|
485
|
+
className: "gc-chat__context-usage-meter",
|
|
486
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
487
|
+
className: "gc-chat__context-usage-summary",
|
|
488
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
489
|
+
className: "gc-chat__context-usage-percent",
|
|
490
|
+
"data-level": resolved.level,
|
|
491
|
+
children: percentLabel
|
|
492
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
493
|
+
className: "gc-chat__context-usage-tokens",
|
|
494
|
+
children: tokensRatioLabel
|
|
495
|
+
})]
|
|
496
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
497
|
+
className: "gc-chat__context-usage-bar",
|
|
498
|
+
role: "meter",
|
|
499
|
+
"aria-label": labels.contextUsage,
|
|
500
|
+
"aria-valuemin": 0,
|
|
501
|
+
"aria-valuemax": resolved.contextWindowTokens,
|
|
502
|
+
"aria-valuenow": resolved.usedTokens,
|
|
503
|
+
children: resolved.visibleSegments.length > 0 && resolved.usedTokens > 0 ? /* @__PURE__ */ jsx("div", {
|
|
504
|
+
className: "gc-chat__context-usage-bar-fill",
|
|
505
|
+
style: { width: `${resolved.fillPercent}%` },
|
|
506
|
+
children: resolved.visibleSegments.map((segment) => /* @__PURE__ */ jsx("span", {
|
|
507
|
+
className: "gc-chat__context-usage-bar-segment",
|
|
508
|
+
"data-tone": segment.tone,
|
|
509
|
+
style: { flexGrow: segment.tokens },
|
|
510
|
+
title: interpolate(labels.contextUsageSegment, {
|
|
511
|
+
label: segment.label,
|
|
512
|
+
tokens: formatChatTokens(segment.tokens)
|
|
513
|
+
})
|
|
514
|
+
}, segment.id))
|
|
515
|
+
}) : null
|
|
516
|
+
})]
|
|
517
|
+
}),
|
|
518
|
+
resolved.visibleSegments.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
519
|
+
className: "gc-chat__context-usage-legend",
|
|
520
|
+
children: resolved.visibleSegments.map((segment) => /* @__PURE__ */ jsxs("li", {
|
|
521
|
+
className: "gc-chat__context-usage-legend-row",
|
|
522
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
523
|
+
className: "gc-chat__context-usage-legend-label",
|
|
524
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
525
|
+
className: "gc-chat__context-usage-swatch",
|
|
526
|
+
"data-tone": segment.tone,
|
|
527
|
+
"aria-hidden": "true"
|
|
528
|
+
}), /* @__PURE__ */ jsx("span", { children: segment.label })]
|
|
529
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
530
|
+
className: "gc-chat__context-usage-legend-value",
|
|
531
|
+
children: formatChatTokens(segment.tokens)
|
|
532
|
+
})]
|
|
533
|
+
}, segment.id))
|
|
534
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
535
|
+
className: "gc-chat__context-usage-empty",
|
|
536
|
+
children: labels.contextUsageEmpty
|
|
537
|
+
}),
|
|
538
|
+
resolved.compacted ? /* @__PURE__ */ jsxs("div", {
|
|
539
|
+
className: "gc-chat__context-usage-compacted",
|
|
540
|
+
role: "status",
|
|
541
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
542
|
+
name: "minimize",
|
|
543
|
+
width: 13,
|
|
544
|
+
height: 13
|
|
545
|
+
}), /* @__PURE__ */ jsx("span", { children: resolved.compactedSavedTokens > 0 ? interpolate(labels.contextCompactedSaved, { saved: formatChatTokens(resolved.compactedSavedTokens) }) : labels.contextCompacted })]
|
|
546
|
+
}) : null
|
|
547
|
+
]
|
|
548
|
+
})
|
|
549
|
+
}) : null]
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Calm inline horizontal divider rendered in the conversation stream when automatic
|
|
554
|
+
* context compaction is running or completed on a turn.
|
|
555
|
+
*/
|
|
556
|
+
function ChatCompactionNotice({ status, beforeTokens, afterTokens, savedTokens, labels: overrides, className = "" }) {
|
|
557
|
+
const labels = resolveLabels(overrides);
|
|
558
|
+
const running = status === "running";
|
|
559
|
+
const deltaSaved = savedTokens != null && savedTokens > 0 ? savedTokens : beforeTokens != null && afterTokens != null && beforeTokens > afterTokens ? beforeTokens - afterTokens : 0;
|
|
560
|
+
const text = running ? labels.contextCompacting : beforeTokens != null && afterTokens != null && beforeTokens > afterTokens ? interpolate(labels.contextCompactedRange, {
|
|
561
|
+
before: formatChatTokens(beforeTokens),
|
|
562
|
+
after: formatChatTokens(afterTokens)
|
|
563
|
+
}) : deltaSaved > 0 ? interpolate(labels.contextCompactedSaved, { saved: formatChatTokens(deltaSaved) }) : labels.contextCompacted;
|
|
564
|
+
const tooltip = !running && deltaSaved > 0 ? interpolate(labels.contextCompactedSaved, { saved: formatChatTokens(deltaSaved) }) : text;
|
|
565
|
+
return /* @__PURE__ */ jsx("div", {
|
|
566
|
+
className: `gc-chat__compaction-notice ${className}`.trim(),
|
|
567
|
+
"data-status": status,
|
|
568
|
+
role: "status",
|
|
569
|
+
"aria-live": running ? "polite" : void 0,
|
|
570
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
571
|
+
className: "gc-chat__compaction-pill",
|
|
572
|
+
title: tooltip,
|
|
573
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
574
|
+
name: "minimize",
|
|
575
|
+
width: 12,
|
|
576
|
+
height: 12
|
|
577
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
578
|
+
className: "gc-chat__compaction-text",
|
|
579
|
+
children: text
|
|
580
|
+
})]
|
|
581
|
+
})
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
//#endregion
|
|
332
585
|
//#region src/model-picker-control.tsx
|
|
333
586
|
function effortLabel(effort, labels) {
|
|
334
587
|
switch (effort) {
|
|
@@ -526,7 +779,7 @@ function ChatModelPicker({ models, value, onChange, disabled = false, labels: ov
|
|
|
526
779
|
function ChatComposer(props) {
|
|
527
780
|
return /* @__PURE__ */ jsx(Composer, { ...props }, props.chat.id);
|
|
528
781
|
}
|
|
529
|
-
function Composer({ chat, labels: overrides, attachments, speech, skills, onSelectSkill, onAddSkill, onBrowseSkills, mentions, onSelectMention, plusMenuActions, modelPicker, toolbar, context, requestOptions, disabled, className = "", onActionError }) {
|
|
782
|
+
function Composer({ chat, labels: overrides, attachments, speech, skills, onSelectSkill, onAddSkill, onBrowseSkills, mentions, onSelectMention, plusMenuActions, modelPicker, contextUsage, toolbar, context, requestOptions, disabled, className = "", onActionError }) {
|
|
530
783
|
const labels = resolveLabels(overrides);
|
|
531
784
|
const [text, setText] = useState("");
|
|
532
785
|
const [cursor, setCursor] = useState(0);
|
|
@@ -954,6 +1207,11 @@ function Composer({ chat, labels: overrides, attachments, speech, skills, onSele
|
|
|
954
1207
|
labels: overrides,
|
|
955
1208
|
disabled: disabled || chat.isBusy || modelPicker.disabled
|
|
956
1209
|
}) : null,
|
|
1210
|
+
contextUsage ? /* @__PURE__ */ jsx(ChatContextUsage, {
|
|
1211
|
+
...contextUsage,
|
|
1212
|
+
labels: overrides,
|
|
1213
|
+
disabled: disabled || contextUsage.disabled
|
|
1214
|
+
}) : null,
|
|
957
1215
|
speech && /* @__PURE__ */ jsx(ChatIconButton, {
|
|
958
1216
|
label: voiceLabels.start,
|
|
959
1217
|
icon: "mic",
|
|
@@ -1243,7 +1501,7 @@ function ToolActivity({ part, chat, labels, active, presentation, requestOptions
|
|
|
1243
1501
|
//#region src/use-message-scroll.ts
|
|
1244
1502
|
const useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
1245
1503
|
/** One scroll writer. Resize observations change the target, never the reader's intent. */
|
|
1246
|
-
function useMessageScroll(messages) {
|
|
1504
|
+
function useMessageScroll(messages, isBusy = false) {
|
|
1247
1505
|
const scroller = useRef(null);
|
|
1248
1506
|
const content = useRef(null);
|
|
1249
1507
|
const following = useRef(true);
|
|
@@ -1254,6 +1512,7 @@ function useMessageScroll(messages) {
|
|
|
1254
1512
|
const endScrollbarGesture = useRef(void 0);
|
|
1255
1513
|
const touchY = useRef(void 0);
|
|
1256
1514
|
const previousMessages = useRef(messages.map(({ id }) => id));
|
|
1515
|
+
const previousBusy = useRef(isBusy);
|
|
1257
1516
|
const [awayFromBottom, setAwayFromBottom] = useState(false);
|
|
1258
1517
|
const cancel = useCallback(() => {
|
|
1259
1518
|
if (frame.current !== void 0) cancelAnimationFrame(frame.current);
|
|
@@ -1341,18 +1600,32 @@ function useMessageScroll(messages) {
|
|
|
1341
1600
|
]);
|
|
1342
1601
|
useClientLayoutEffect(() => {
|
|
1343
1602
|
const previous = previousMessages.current;
|
|
1344
|
-
const tail = previous.at(-1);
|
|
1345
|
-
const tailIndex = tail === void 0 ? -1 : messages.findIndex((message) => message.id === tail);
|
|
1346
1603
|
const known = new Set(previous);
|
|
1347
|
-
|
|
1604
|
+
let anchorIndex = -1;
|
|
1605
|
+
for (let index = messages.length - 1; index >= 0; index--) if (known.has(messages[index].id)) {
|
|
1606
|
+
anchorIndex = index;
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
const appendedUser = (previous.length === 0 || anchorIndex !== -1) && messages.slice(anchorIndex + 1).some((message) => message.role === "user");
|
|
1610
|
+
const startedRun = !previousBusy.current && isBusy;
|
|
1348
1611
|
previousMessages.current = messages.map(({ id }) => id);
|
|
1349
|
-
|
|
1612
|
+
previousBusy.current = isBusy;
|
|
1613
|
+
if (appendedUser || startedRun) scrollToLatest();
|
|
1350
1614
|
schedule();
|
|
1351
1615
|
}, [
|
|
1352
1616
|
messages,
|
|
1617
|
+
isBusy,
|
|
1353
1618
|
scrollToLatest,
|
|
1354
1619
|
schedule
|
|
1355
1620
|
]);
|
|
1621
|
+
function resumeAtBottom(element) {
|
|
1622
|
+
if (following.current) return false;
|
|
1623
|
+
if (Math.max(0, element.scrollHeight - element.clientHeight) - element.scrollTop > 4) return false;
|
|
1624
|
+
following.current = true;
|
|
1625
|
+
setAwayFromBottom(false);
|
|
1626
|
+
schedule();
|
|
1627
|
+
return true;
|
|
1628
|
+
}
|
|
1356
1629
|
function onScroll() {
|
|
1357
1630
|
const element = scroller.current;
|
|
1358
1631
|
if (!element) return;
|
|
@@ -1361,12 +1634,13 @@ function useMessageScroll(messages) {
|
|
|
1361
1634
|
lastTop.current = top;
|
|
1362
1635
|
if (writtenTop.current !== void 0 && Math.abs(top - writtenTop.current) < 1) return;
|
|
1363
1636
|
writtenTop.current = void 0;
|
|
1637
|
+
const maxTop = Math.max(0, element.scrollHeight - element.clientHeight);
|
|
1364
1638
|
if (top < previous - 1) {
|
|
1365
|
-
if (endScrollbarGesture.current) pause();
|
|
1639
|
+
if (endScrollbarGesture.current && maxTop - top > 1) pause();
|
|
1366
1640
|
else schedule();
|
|
1367
1641
|
return;
|
|
1368
1642
|
}
|
|
1369
|
-
if (top > previous &&
|
|
1643
|
+
if (top > previous && maxTop - top <= 4) {
|
|
1370
1644
|
following.current = true;
|
|
1371
1645
|
setAwayFromBottom(false);
|
|
1372
1646
|
schedule();
|
|
@@ -1404,7 +1678,13 @@ function useMessageScroll(messages) {
|
|
|
1404
1678
|
return false;
|
|
1405
1679
|
}
|
|
1406
1680
|
function onWheel(event) {
|
|
1407
|
-
if (event.
|
|
1681
|
+
if (event.ctrlKey || Math.abs(event.deltaX) > Math.abs(event.deltaY)) return;
|
|
1682
|
+
if (event.deltaY > 0) {
|
|
1683
|
+
const element = scroller.current;
|
|
1684
|
+
if (element) resumeAtBottom(element);
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
if (event.deltaY >= 0 || event.deltaMode === 0 && event.deltaY > -2 || consumedByNestedScroll(event)) return;
|
|
1408
1688
|
pause();
|
|
1409
1689
|
}
|
|
1410
1690
|
function onTouchStart(event) {
|
|
@@ -1412,7 +1692,10 @@ function useMessageScroll(messages) {
|
|
|
1412
1692
|
}
|
|
1413
1693
|
function onTouchMove(event) {
|
|
1414
1694
|
const y = event.touches[0]?.clientY;
|
|
1415
|
-
if (y !== void 0 && touchY.current !== void 0
|
|
1695
|
+
if (y !== void 0 && touchY.current !== void 0) {
|
|
1696
|
+
if (y > touchY.current + 2 && !consumedByNestedScroll(event)) pause();
|
|
1697
|
+
else if (y < touchY.current - 2 && scroller.current) resumeAtBottom(scroller.current);
|
|
1698
|
+
}
|
|
1416
1699
|
touchY.current = y;
|
|
1417
1700
|
}
|
|
1418
1701
|
function onKeyDown(event) {
|
|
@@ -1535,8 +1818,11 @@ function ChatMessages(props) {
|
|
|
1535
1818
|
}
|
|
1536
1819
|
function Messages({ chat, labels: labelOverrides, renderText, smoothStreaming = true, scrollRef, renderers, tools, toolPresentation, suggestedActions, suggestionsTitle, suggestionsDescription, renderMessageActions, renderUserMessageFooter, branches, onSelectBranch, onRevertMessage, onBranchMessage, renderMessageHeader, empty, className, requestOptions, onActionError, capabilities }) {
|
|
1537
1820
|
const labels = resolveLabels(labelOverrides);
|
|
1538
|
-
const { scroller, content, awayFromBottom, scrollToLatest, reveal, scrollEvents } = useMessageScroll(chat.messages);
|
|
1539
|
-
useImperativeHandle(scrollRef, () => ({
|
|
1821
|
+
const { scroller, content, awayFromBottom, scrollToLatest, reveal, scrollEvents } = useMessageScroll(chat.messages, chat.isBusy);
|
|
1822
|
+
useImperativeHandle(scrollRef, () => ({
|
|
1823
|
+
reveal,
|
|
1824
|
+
scrollToLatest
|
|
1825
|
+
}), [reveal, scrollToLatest]);
|
|
1540
1826
|
const copyTimeout = useRef(void 0);
|
|
1541
1827
|
const actionInFlight = useRef(false);
|
|
1542
1828
|
const [copiedId, setCopiedId] = useState();
|
|
@@ -2258,6 +2544,6 @@ function ChatHistoryMenu({ conversations, currentId, onSelect, onNewChat, disabl
|
|
|
2258
2544
|
});
|
|
2259
2545
|
}
|
|
2260
2546
|
//#endregion
|
|
2261
|
-
export { AiChat, CHAT_REASONING_EFFORTS, ChatAppearanceProvider, ChatBranchSwitcher, ChatCheckpointBanner, ChatComposer, ChatHistoryMenu, Icon as ChatIcon, ChatIconButton, ChatMentionMenu, ChatMessages, ChatModelPicker, ChatPanel, ChatPlusMenu, ChatSlashMenu, ChatTargetingOverlay, ContextTray, SpeechInputError, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, enUSTargetingLabels, filterMentions, filterSkills, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatModelSelection, selectChatModel, slugifySkillName, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useComposerTrigger, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
2547
|
+
export { AiChat, CHAT_CONTEXT_USAGE_TONES, CHAT_REASONING_EFFORTS, ChatAppearanceProvider, ChatBranchSwitcher, ChatCheckpointBanner, ChatCompactionNotice, ChatComposer, ChatContextUsage, ChatHistoryMenu, Icon as ChatIcon, ChatIconButton, ChatMentionMenu, ChatMessages, ChatModelPicker, ChatPanel, ChatPlusMenu, ChatSlashMenu, ChatTargetingOverlay, ContextTray, SpeechInputError, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, enUSTargetingLabels, filterMentions, filterSkills, formatChatTokens, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatContextUsage, resolveChatModelSelection, selectChatModel, slugifySkillName, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useComposerTrigger, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
2262
2548
|
|
|
2263
2549
|
//# sourceMappingURL=index.js.map
|