@aparte/core 1.12.2 → 1.13.1
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/dist/client/aparte-client.d.ts +8 -1
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/wire-history.d.ts +15 -13
- package/dist/client/wire-history.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +31 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/bubble/bubble-sync.d.ts +4 -1
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +2 -0
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +4 -0
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/suggestions/aparte-suggestions.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +11 -2
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/action-provider.d.ts +6 -0
- package/dist/config/action-provider.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +31 -0
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/avatar-provider.d.ts +9 -1
- package/dist/config/avatar-provider.d.ts.map +1 -1
- package/dist/config/bubble-shell-renderer.d.ts +4 -1
- package/dist/config/bubble-shell-renderer.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts +1 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/custom-elements.json +893 -425
- package/dist/{defer-hydration-DfYJjWtk.js → defer-hydration-Dm6F4kq6.js} +335 -173
- package/dist/defer-hydration-Dm6F4kq6.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +2 -0
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/host/aparte-chat-host.d.ts +22 -7
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +265 -111
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +2 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +66 -64
- package/dist/index.node.js.map +1 -1
- package/dist/interop/element-props.d.ts +1 -1
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/types/chat.d.ts +7 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +2 -1
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +26 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/imperative-api.d.ts +7 -1
- package/dist/types/imperative-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models.d.ts +40 -0
- package/dist/types/models.d.ts.map +1 -1
- package/dist/utils/is-awaiting-reply.d.ts +1 -1
- package/dist/utils/is-awaiting-reply.d.ts.map +1 -1
- package/dist/utils/is-model-reply.d.ts +14 -0
- package/dist/utils/is-model-reply.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/defer-hydration-DfYJjWtk.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v,
|
|
1
|
+
import { N as deferHydrationOf, al as resolveConfig, at as subscribeConfigChange, ao as runWithConfig, o as AparteElicitationAbortError, x as buildApprovalPanel, y as buildElicitationPanel, z as chatIdOf, az as gateGlide, T as escapeAttr, aq as segmentTiming, aA as chatBoundaryOf, aB as relabelCodeLanguages, aC as relabelCitations, aD as toolCallRenderer, aE as activityRenderer, t as aparteGlobalConfig, aF as isMountedRenderer, aG as renderingVersionOf, a8 as onRenderersChange, aH as renderSourceList, aI as mergeSegmentUpdate, w as authorTypeOf, a6 as isSegmentSettled, ac as pluralize, Y as formatDuration, aJ as toolNameOf, U as escapeHtml, aK as writeStreamedMarkdown, aL as replaceHighlighted, a5 as isSafeUrl, R as dispatchChatEvent, aM as openConversationOf, E as copyText, _ as getSegmentRenderer, a0 as installDefaultRenderersOnce, aN as toolRendererThatDrew, aO as activityRendererThatDrew, r as AparteMessageRepository, aP as CheckpointStateWatcher, aQ as stampSegmentActivity, aR as stampSegmentOnInsert, aS as stampSegmentOnUpdate, aT as renumberSegments, aU as openSegmentIds, aV as isTerminalStatus, a2 as isAwaitingReply, aW as adoptMessageSegments, ad as populateBubbleFromMessage, ax as uuid, am as revokeAttachmentUrls, a4 as isModelReply, ab as parseMarkdownToSegments, aX as APARTE_DERIVED_SEGMENTS, aY as rememberConversationStatus, aZ as tellConversationStatus, a_ as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, a$ as visibleReply, b0 as usageTokens, q as AparteErrorCode, a7 as measureContext, b1 as inRenderedContent, g as APARTE_HOST_ATTR, a1 as installDialogTriggersOnce } from "./defer-hydration-Dm6F4kq6.js";
|
|
2
|
+
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, B, C, D, F, G, H, I, J, K, L, M, O, P, Q, V, W, X, Z, $, a3, a9, aa, ae, af, ag, ah, ai, aj, ak, an, ap, ar, as, au, av, aw, ay } from "./defer-hydration-Dm6F4kq6.js";
|
|
3
3
|
import { d as eventOrigin, f as activeElementIn, c as cssEscape, a as enhanceMenu, e as enhanceContextMenu, p as placeFloating, r as rootOf } from "./kit-keyboard-BUSLQ5i4.js";
|
|
4
4
|
import { b as b2 } from "./kit-keyboard-BUSLQ5i4.js";
|
|
5
5
|
function presenceOn(value) {
|
|
@@ -1410,11 +1410,11 @@ function draw(root, content, token) {
|
|
|
1410
1410
|
const walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
1411
1411
|
while (walker.nextNode()) {
|
|
1412
1412
|
const node = walker.currentNode;
|
|
1413
|
-
for (let
|
|
1413
|
+
for (let at = node.data.indexOf(token.text); at >= 0; at = node.data.indexOf(token.text, at + token.text.length)) {
|
|
1414
1414
|
if (skip-- > 0) continue;
|
|
1415
1415
|
const range = doc.createRange();
|
|
1416
|
-
range.setStart(node,
|
|
1417
|
-
range.setEnd(node,
|
|
1416
|
+
range.setStart(node, at);
|
|
1417
|
+
range.setEnd(node, at + token.text.length);
|
|
1418
1418
|
range.deleteContents();
|
|
1419
1419
|
range.insertNode(pill(doc, token));
|
|
1420
1420
|
return;
|
|
@@ -1423,7 +1423,7 @@ function draw(root, content, token) {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
function drawMessageTokens(root, content, tokens) {
|
|
1425
1425
|
if (root.querySelector(".aparte-inline-token")) return;
|
|
1426
|
-
for (const token of [...tokens].sort((
|
|
1426
|
+
for (const token of [...tokens].sort((a2, b3) => b3.start - a2.start)) {
|
|
1427
1427
|
if (token.text) draw(root, content, token);
|
|
1428
1428
|
}
|
|
1429
1429
|
}
|
|
@@ -1626,6 +1626,12 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1626
1626
|
_avatarCleanup = null;
|
|
1627
1627
|
/** Whether the avatar slot holds what a provider drew, which goes when the provider does. */
|
|
1628
1628
|
_avatarFromProvider = false;
|
|
1629
|
+
/** Who wrote the message, when it names them (`setAuthor`). */
|
|
1630
|
+
_author;
|
|
1631
|
+
/** The line under the message (`setNote`). */
|
|
1632
|
+
_note;
|
|
1633
|
+
/** Whether the avatar slot holds the author's picture, which goes when the author does. */
|
|
1634
|
+
_avatarFromAuthor = false;
|
|
1629
1635
|
/** Sibling count for tree-based branch navigation (set by setSiblings()) */
|
|
1630
1636
|
_siblingCount = 1;
|
|
1631
1637
|
/**
|
|
@@ -1651,7 +1657,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1651
1657
|
*/
|
|
1652
1658
|
_editReturnAction = null;
|
|
1653
1659
|
static get observedAttributes() {
|
|
1654
|
-
return ["data-role", "content", "timestamp", "message-id", "streaming", "name", "data-checkpoint", "data-checkpoint-reason"];
|
|
1660
|
+
return ["data-role", "content", "timestamp", "message-id", "streaming", "name", "data-checkpoint", "data-checkpoint-reason", "data-kind"];
|
|
1655
1661
|
}
|
|
1656
1662
|
constructor() {
|
|
1657
1663
|
super();
|
|
@@ -1930,6 +1936,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1930
1936
|
connectedCallback() {
|
|
1931
1937
|
this._render();
|
|
1932
1938
|
this._updateContent();
|
|
1939
|
+
this._updateNote();
|
|
1933
1940
|
this._updateTimestamp(this.getAttribute("timestamp"));
|
|
1934
1941
|
if (this._releasedWhileDetached) {
|
|
1935
1942
|
this._releasedWhileDetached = false;
|
|
@@ -1964,6 +1971,10 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1964
1971
|
_redrawFrameIfChanged() {
|
|
1965
1972
|
if (!this.isConnected || this._editing) return;
|
|
1966
1973
|
if ((this._cfg.getBubbleShellRenderer?.() ?? null) === this._drawnShell) return;
|
|
1974
|
+
this._redrawFrame();
|
|
1975
|
+
}
|
|
1976
|
+
/** Throw the frame away and draw it again, with everything the message holds. */
|
|
1977
|
+
_redrawFrame() {
|
|
1967
1978
|
if (this._avatarCleanup) {
|
|
1968
1979
|
try {
|
|
1969
1980
|
this._avatarCleanup();
|
|
@@ -1981,6 +1992,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1981
1992
|
this._updateTimestamp(this.getAttribute("timestamp"));
|
|
1982
1993
|
this._updateBranchPicker();
|
|
1983
1994
|
this._updateCheckpoint();
|
|
1995
|
+
this._updateNote();
|
|
1984
1996
|
}
|
|
1985
1997
|
disconnectedCallback() {
|
|
1986
1998
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
@@ -2028,6 +2040,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2028
2040
|
case "name":
|
|
2029
2041
|
this._updateName();
|
|
2030
2042
|
break;
|
|
2043
|
+
case "data-kind":
|
|
2044
|
+
if (this.isConnected && oldValue === "notice" !== (newValue === "notice")) this._redrawFrame();
|
|
2045
|
+
break;
|
|
2031
2046
|
}
|
|
2032
2047
|
}
|
|
2033
2048
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -2269,6 +2284,65 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2269
2284
|
this._finishReason = reason ?? null;
|
|
2270
2285
|
this._updateFinishNote();
|
|
2271
2286
|
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Who wrote the message (`AparteMessage.author`): its name in the header and in the label
|
|
2289
|
+
* a screen reader reads, `data-author-type` for styling, and its picture in the avatar
|
|
2290
|
+
* slot. `undefined` takes back what a previous author set — never a `name` written on the
|
|
2291
|
+
* element by hand. Redraws the avatar only when the author changed.
|
|
2292
|
+
*/
|
|
2293
|
+
setAuthor(author) {
|
|
2294
|
+
if (JSON.stringify(author ?? null) === JSON.stringify(this._author ?? null)) return;
|
|
2295
|
+
this._author = author ? { ...author } : void 0;
|
|
2296
|
+
if (author) {
|
|
2297
|
+
this.setAttribute("name", author.name);
|
|
2298
|
+
this.setAttribute("data-author-name", author.name);
|
|
2299
|
+
this.setAttribute("data-author-type", authorTypeOf({ role: this._role, author }));
|
|
2300
|
+
} else {
|
|
2301
|
+
if (this.hasAttribute("data-author-name") && this.getAttribute("name") === this.getAttribute("data-author-name")) {
|
|
2302
|
+
this.removeAttribute("name");
|
|
2303
|
+
}
|
|
2304
|
+
this.removeAttribute("data-author-name");
|
|
2305
|
+
this.removeAttribute("data-author-type");
|
|
2306
|
+
}
|
|
2307
|
+
this._renderAvatar();
|
|
2308
|
+
this._updateActionBar();
|
|
2309
|
+
}
|
|
2310
|
+
/** Who wrote the message, as core acts on it: the author's type, else the side it is on. */
|
|
2311
|
+
_authorType() {
|
|
2312
|
+
return authorTypeOf({ role: this._role, author: this._author });
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* What kind of row the message is (`AparteMessage.kind`): `'notice'` draws a line across
|
|
2316
|
+
* the transcript instead of a bubble. `undefined` takes back a notice, and leaves the
|
|
2317
|
+
* `data-kind="compaction"` stamp of an older summary message alone.
|
|
2318
|
+
*/
|
|
2319
|
+
setKind(kind) {
|
|
2320
|
+
if (kind) this.setAttribute("data-kind", kind);
|
|
2321
|
+
else if (this.getAttribute("data-kind") === "notice") this.removeAttribute("data-kind");
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* A short line under the message (`AparteMessage.note`): "Read by Marie", "Seen at
|
|
2325
|
+
* 14:05". In the flow after the content, outside the footer; `undefined` or empty removes it.
|
|
2326
|
+
*/
|
|
2327
|
+
setNote(note) {
|
|
2328
|
+
this._note = note || void 0;
|
|
2329
|
+
this._updateNote();
|
|
2330
|
+
}
|
|
2331
|
+
_updateNote() {
|
|
2332
|
+
let el2 = this.querySelector(":scope .aparte-message-note");
|
|
2333
|
+
if (!this._note) {
|
|
2334
|
+
el2?.remove();
|
|
2335
|
+
return;
|
|
2336
|
+
}
|
|
2337
|
+
if (!el2) {
|
|
2338
|
+
const region = this.querySelector(".aparte-message-content");
|
|
2339
|
+
if (!region) return;
|
|
2340
|
+
el2 = document.createElement("p");
|
|
2341
|
+
el2.className = "aparte-message-note";
|
|
2342
|
+
(this.querySelector(".aparte-finish-note") ?? region).after(el2);
|
|
2343
|
+
}
|
|
2344
|
+
el2.textContent = this._note;
|
|
2345
|
+
}
|
|
2272
2346
|
/**
|
|
2273
2347
|
* Say that the messages before this one were summarised for the model, or that they no
|
|
2274
2348
|
* longer are (`null`).
|
|
@@ -2330,6 +2404,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2330
2404
|
this._updateWaiting();
|
|
2331
2405
|
}
|
|
2332
2406
|
if ("finishReason" in updates) this.setFinishReason(updates.finishReason);
|
|
2407
|
+
if ("author" in updates) this.setAuthor(updates.author);
|
|
2408
|
+
if ("kind" in updates) this.setKind(updates.kind);
|
|
2409
|
+
if ("note" in updates) this.setNote(updates.note);
|
|
2333
2410
|
if ("contextSummary" in updates || "compaction" in updates) {
|
|
2334
2411
|
this.setContextSummary(
|
|
2335
2412
|
"contextSummary" in updates ? updates.contextSummary : this._contextSummary,
|
|
@@ -2700,12 +2777,24 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2700
2777
|
const dataRole = this.getAttribute("data-role");
|
|
2701
2778
|
const role = dataRole === "user" || dataRole === "assistant" ? dataRole : "assistant";
|
|
2702
2779
|
this._role = role;
|
|
2703
|
-
|
|
2704
|
-
|
|
2780
|
+
const isNotice = this.getAttribute("data-kind") === "notice";
|
|
2781
|
+
const ariaRole = isNotice ? "note" : "article";
|
|
2782
|
+
if (this.getAttribute("role") !== ariaRole) {
|
|
2783
|
+
this.setAttribute("role", ariaRole);
|
|
2705
2784
|
}
|
|
2706
2785
|
if (!this.hasAttribute("data-role")) {
|
|
2707
2786
|
this.setAttribute("data-role", role);
|
|
2708
2787
|
}
|
|
2788
|
+
if (isNotice) {
|
|
2789
|
+
if (this.querySelector(".aparte-notice")) return;
|
|
2790
|
+
this._drawnShell = this._cfg.getBubbleShellRenderer?.() ?? null;
|
|
2791
|
+
this._avatarFromProvider = false;
|
|
2792
|
+
this._wroteRootLabel = this._wroteBarLabel = this._wroteArrowLabels = false;
|
|
2793
|
+
this.innerHTML = '<div class="aparte-notice aparte-divider aparte-divider--label"><span class="aparte-divider__label aparte-notice__text"></span></div>';
|
|
2794
|
+
this._contentEl = this._segmentsEl = this._attachmentsEl = this._actionBarEl = null;
|
|
2795
|
+
this._branchPickerEl = this._footerEl = null;
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2709
2798
|
if (this.querySelector(".aparte-message")) return;
|
|
2710
2799
|
const displayName = this._getDisplayName();
|
|
2711
2800
|
const initial = this._getAvatarInitial();
|
|
@@ -2867,6 +2956,21 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2867
2956
|
}
|
|
2868
2957
|
this._avatarCleanup = null;
|
|
2869
2958
|
}
|
|
2959
|
+
if (this._author?.avatar) {
|
|
2960
|
+
const img = document.createElement("img");
|
|
2961
|
+
img.className = "aparte-avatar__img";
|
|
2962
|
+
img.src = this._author.avatar;
|
|
2963
|
+
img.alt = "";
|
|
2964
|
+
avatar.replaceChildren(img);
|
|
2965
|
+
this._avatarFromAuthor = true;
|
|
2966
|
+
this._avatarFromProvider = false;
|
|
2967
|
+
this._markAvatarImage(avatar);
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
if (this._avatarFromAuthor) {
|
|
2971
|
+
avatar.replaceChildren();
|
|
2972
|
+
this._avatarFromAuthor = false;
|
|
2973
|
+
}
|
|
2870
2974
|
const provider = this._cfg.getAvatarProvider();
|
|
2871
2975
|
if (!provider) {
|
|
2872
2976
|
if (this._avatarFromProvider) {
|
|
@@ -2877,7 +2981,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2877
2981
|
return;
|
|
2878
2982
|
}
|
|
2879
2983
|
avatar.textContent = "";
|
|
2880
|
-
const cleanup = provider.render(this._role, avatar);
|
|
2984
|
+
const cleanup = this._author ? provider.render(this._role, avatar, { author: this._author }) : provider.render(this._role, avatar);
|
|
2881
2985
|
this._avatarFromProvider = true;
|
|
2882
2986
|
if (typeof cleanup === "function") this._avatarCleanup = cleanup;
|
|
2883
2987
|
this._markAvatarImage(avatar);
|
|
@@ -2889,7 +2993,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2889
2993
|
* config change, in a batch with the other bubbles' (see `pendingAvatarMarks`).
|
|
2890
2994
|
*/
|
|
2891
2995
|
_markAvatarImage(avatar) {
|
|
2892
|
-
|
|
2996
|
+
const humanAssistant = this._role === "assistant" && this._author !== void 0 && authorTypeOf({ role: this._role, author: this._author }) === "human";
|
|
2997
|
+
if (avatar.firstChild || humanAssistant) {
|
|
2893
2998
|
pendingAvatarMarks.delete(avatar);
|
|
2894
2999
|
avatar.removeAttribute("data-image");
|
|
2895
3000
|
return;
|
|
@@ -2928,6 +3033,11 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2928
3033
|
if (this._wroteRootLabel && message?.getAttribute("role") === "article") message.setAttribute("aria-label", this._getAriaLabel());
|
|
2929
3034
|
}
|
|
2930
3035
|
_updateContent() {
|
|
3036
|
+
const notice = this.querySelector(":scope > .aparte-notice .aparte-notice__text");
|
|
3037
|
+
if (notice) {
|
|
3038
|
+
notice.textContent = this._content;
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
2931
3041
|
if (!this._contentEl) return;
|
|
2932
3042
|
if (this._segments.length > 0) {
|
|
2933
3043
|
this._contentEl.style.display = "none";
|
|
@@ -3055,19 +3165,19 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3055
3165
|
const customAttachment = this._cfg.getAttachmentRenderer?.();
|
|
3056
3166
|
if (customAttachment) {
|
|
3057
3167
|
this._attachmentsEl.replaceChildren();
|
|
3058
|
-
for (const
|
|
3059
|
-
const el2 = segmentRenderResultToElement(runWithConfig(this._cfg, () => customAttachment(
|
|
3168
|
+
for (const a2 of this._attachments) {
|
|
3169
|
+
const el2 = segmentRenderResultToElement(runWithConfig(this._cfg, () => customAttachment(a2)));
|
|
3060
3170
|
if (el2) this._attachmentsEl.appendChild(el2);
|
|
3061
3171
|
}
|
|
3062
3172
|
return;
|
|
3063
3173
|
}
|
|
3064
|
-
this._attachmentsEl.innerHTML = this._attachments.map((
|
|
3065
|
-
const name = escapeHtml(
|
|
3066
|
-
if (
|
|
3067
|
-
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--image" title="${name}" data-type="${escapeHtml(
|
|
3174
|
+
this._attachmentsEl.innerHTML = this._attachments.map((a2) => {
|
|
3175
|
+
const name = escapeHtml(a2.name);
|
|
3176
|
+
if (a2.type.startsWith("image/") && this._isShowableUrl(a2.url)) {
|
|
3177
|
+
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--image" title="${name}" data-type="${escapeHtml(a2.type)}"><img class="aparte-thumbnail__image" src="${escapeHtml(a2.url)}" alt="${name}" loading="lazy" /><span class="aparte-thumb__name">${name}</span></div>`;
|
|
3068
3178
|
}
|
|
3069
|
-
const openable = this._isOpenableUrl(
|
|
3070
|
-
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--file" title="${name}" data-type="${escapeHtml(
|
|
3179
|
+
const openable = this._isOpenableUrl(a2.url) ? ` data-url="${escapeHtml(a2.url)}"` : "";
|
|
3180
|
+
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--file" title="${name}" data-type="${escapeHtml(a2.type)}"${openable}><span class="aparte-thumbnail__label">${escapeHtml(this._fileExt(a2.name))}</span><span class="aparte-thumb__name">${name}</span></div>`;
|
|
3071
3181
|
}).join("");
|
|
3072
3182
|
const { attachmentPreview, filePreview } = this._cfg.getHostHandlers();
|
|
3073
3183
|
const kinds = [attachmentPreview ? ".aparte-thumb--image" : "", filePreview ? ".aparte-thumb--file[data-url]" : ""].filter(Boolean);
|
|
@@ -3176,8 +3286,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3176
3286
|
}
|
|
3177
3287
|
_applyTranscriptBusy() {
|
|
3178
3288
|
if (!this._actionBarEl) return;
|
|
3289
|
+
const aiOff = !this._cfg.getAutoReply(openConversationOf(this) ?? void 0);
|
|
3179
3290
|
for (const btn of this._actionBarEl.querySelectorAll('[data-action="retry"], [data-action="edit"]')) {
|
|
3180
|
-
btn.disabled = this._transcriptBusy;
|
|
3291
|
+
btn.disabled = this._transcriptBusy || aiOff;
|
|
3181
3292
|
}
|
|
3182
3293
|
}
|
|
3183
3294
|
_updateBranchPicker() {
|
|
@@ -3246,14 +3357,18 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3246
3357
|
const buttons = [];
|
|
3247
3358
|
if (this._role === "user") {
|
|
3248
3359
|
if (config.user) {
|
|
3249
|
-
for (const
|
|
3360
|
+
for (const a2 of config.user) buttons.push(this._actionButtonHtml(a2, icons, locale));
|
|
3250
3361
|
} else {
|
|
3251
3362
|
if (config.copy) buttons.push(this._actionButtonHtml("copy", icons, locale));
|
|
3252
3363
|
if (config.edit) buttons.push(this._actionButtonHtml("edit", icons, locale));
|
|
3253
3364
|
}
|
|
3254
3365
|
} else if (this._role === "assistant") {
|
|
3366
|
+
const human = this._authorType() === "human";
|
|
3367
|
+
const forModel = (a2) => !human || !["retry", "thumbUp", "thumbDown", "info"].includes(a2);
|
|
3255
3368
|
if (config.assistant) {
|
|
3256
|
-
for (const
|
|
3369
|
+
for (const a2 of config.assistant) if (forModel(a2)) buttons.push(this._actionButtonHtml(a2, icons, locale));
|
|
3370
|
+
} else if (human) {
|
|
3371
|
+
if (config.copy) buttons.push(this._actionButtonHtml("copy", icons, locale));
|
|
3257
3372
|
} else {
|
|
3258
3373
|
if (config.copy) buttons.push(this._actionButtonHtml("copy", icons, locale));
|
|
3259
3374
|
if (config.retry) buttons.push(this._actionButtonHtml("retry", icons, locale));
|
|
@@ -3354,18 +3469,20 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3354
3469
|
if (!this._actionBarEl) return;
|
|
3355
3470
|
const locale = this._cfg.getLocale();
|
|
3356
3471
|
const start = [];
|
|
3357
|
-
for (const
|
|
3358
|
-
const roles =
|
|
3472
|
+
for (const a2 of this._cfg.getActions("bubble")) {
|
|
3473
|
+
const roles = a2.bubble?.roles ?? ["user", "assistant"];
|
|
3359
3474
|
if (!roles.includes(this._role)) continue;
|
|
3360
|
-
const
|
|
3361
|
-
|
|
3362
|
-
const
|
|
3363
|
-
const
|
|
3475
|
+
const authorTypes = a2.bubble?.authorTypes;
|
|
3476
|
+
if (authorTypes && !authorTypes.includes(this._authorType())) continue;
|
|
3477
|
+
const word = Object.hasOwn(locale, a2.label) ? locale[a2.label] : void 0;
|
|
3478
|
+
const label = typeof word === "string" ? word : a2.label;
|
|
3479
|
+
const icon = a2.display === "label" || !a2.icon ? "" : a2.icon.startsWith("<") ? a2.icon : this._cfg.getIcon(a2.icon) ?? a2.iconFallback ?? "";
|
|
3480
|
+
const written = a2.display === "label" || a2.display === "both" || icon === "";
|
|
3364
3481
|
const btn = document.createElement("button");
|
|
3365
3482
|
btn.type = "button";
|
|
3366
3483
|
btn.className = "aparte-btn aparte-btn--sm aparte-action-btn aparte-action-custom";
|
|
3367
3484
|
if (!written) btn.classList.add("aparte-btn--icon");
|
|
3368
|
-
btn.dataset["action"] = `custom:${
|
|
3485
|
+
btn.dataset["action"] = `custom:${a2.id}`;
|
|
3369
3486
|
btn.innerHTML = icon;
|
|
3370
3487
|
if (written) {
|
|
3371
3488
|
btn.append(label);
|
|
@@ -3373,7 +3490,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3373
3490
|
btn.setAttribute("aria-label", label);
|
|
3374
3491
|
btn.setAttribute("title", label);
|
|
3375
3492
|
}
|
|
3376
|
-
if (
|
|
3493
|
+
if (a2.position === "start") start.push(btn);
|
|
3377
3494
|
else this._actionBarEl.appendChild(btn);
|
|
3378
3495
|
}
|
|
3379
3496
|
this._actionBarEl.prepend(...start);
|
|
@@ -3809,7 +3926,7 @@ if (!customElements.get("aparte-chat-status")) {
|
|
|
3809
3926
|
customElements.define("aparte-chat-status", AparteChatStatus);
|
|
3810
3927
|
}
|
|
3811
3928
|
function withParsedSegments(message, blocks) {
|
|
3812
|
-
if (message
|
|
3929
|
+
if (!isModelReply(message) || message.segments?.length) return message;
|
|
3813
3930
|
if (typeof message.content !== "string" || !message.content.trim()) return message;
|
|
3814
3931
|
const segments = parseMarkdownToSegments(message.content, { blocks });
|
|
3815
3932
|
const onlyProse = segments.length <= 1 && segments.every((s2) => s2.type === "text");
|
|
@@ -3822,11 +3939,11 @@ function markDerivedSegments(message) {
|
|
|
3822
3939
|
function hasDerivedSegments(message) {
|
|
3823
3940
|
return message[APARTE_DERIVED_SEGMENTS] === true;
|
|
3824
3941
|
}
|
|
3825
|
-
function longDate(
|
|
3942
|
+
function longDate(at, tag) {
|
|
3826
3943
|
try {
|
|
3827
|
-
return new Intl.DateTimeFormat(tag || void 0, { dateStyle: "long" }).format(
|
|
3944
|
+
return new Intl.DateTimeFormat(tag || void 0, { dateStyle: "long" }).format(at);
|
|
3828
3945
|
} catch {
|
|
3829
|
-
return
|
|
3946
|
+
return at.toDateString();
|
|
3830
3947
|
}
|
|
3831
3948
|
}
|
|
3832
3949
|
class AparteChatViewport extends HTMLElement {
|
|
@@ -4176,9 +4293,12 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4176
4293
|
*/
|
|
4177
4294
|
_activeMessageId() {
|
|
4178
4295
|
const head = this._repo.headId;
|
|
4179
|
-
const
|
|
4180
|
-
if (
|
|
4181
|
-
return
|
|
4296
|
+
const open = this._repo.getAllMessages().filter((m2) => m2.isStreaming);
|
|
4297
|
+
if (open.length === 0) return head;
|
|
4298
|
+
if (open.length > 1) return null;
|
|
4299
|
+
const streaming = open[0].id;
|
|
4300
|
+
if (streaming === head) return head;
|
|
4301
|
+
return this._repo.getMessages().some((m2) => m2.id === streaming) ? streaming : null;
|
|
4182
4302
|
}
|
|
4183
4303
|
/**
|
|
4184
4304
|
* The id of the message currently streaming, if any — searched across the whole
|
|
@@ -4256,10 +4376,10 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4256
4376
|
this._notifyBubble(messageId, "addSegment", stamped);
|
|
4257
4377
|
this._autoScroll();
|
|
4258
4378
|
}
|
|
4259
|
-
updateSegment(
|
|
4379
|
+
updateSegment(a2, b3, c2) {
|
|
4260
4380
|
const clientForm = c2 === void 0 && typeof b3 === "object";
|
|
4261
|
-
const messageId = clientForm ? this._activeMessageId() :
|
|
4262
|
-
const segmentId = clientForm ?
|
|
4381
|
+
const messageId = clientForm ? this._activeMessageId() : a2;
|
|
4382
|
+
const segmentId = clientForm ? a2 : b3;
|
|
4263
4383
|
const updates = clientForm ? b3 : c2;
|
|
4264
4384
|
if (!messageId) return;
|
|
4265
4385
|
const message = this._repo.getMessageById(messageId);
|
|
@@ -4272,10 +4392,10 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4272
4392
|
this._notifyBubble(messageId, "updateSegment", { segmentId, updates: stamped });
|
|
4273
4393
|
}
|
|
4274
4394
|
}
|
|
4275
|
-
removeSegment(
|
|
4395
|
+
removeSegment(a2, b3) {
|
|
4276
4396
|
const clientForm = b3 === void 0;
|
|
4277
|
-
const messageId = clientForm ? this._activeMessageId() :
|
|
4278
|
-
const segmentId = clientForm ?
|
|
4397
|
+
const messageId = clientForm ? this._activeMessageId() : a2;
|
|
4398
|
+
const segmentId = clientForm ? a2 : b3;
|
|
4279
4399
|
if (!messageId || !segmentId) return;
|
|
4280
4400
|
const message = this._repo.getMessageById(messageId);
|
|
4281
4401
|
if (message?.segments) {
|
|
@@ -4372,6 +4492,18 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4372
4492
|
this._notifyBubble(messageId, "update", updates);
|
|
4373
4493
|
if (updates.status) this._syncBusy();
|
|
4374
4494
|
this._autoScroll();
|
|
4495
|
+
this._announceWrite(message, "update");
|
|
4496
|
+
}
|
|
4497
|
+
/**
|
|
4498
|
+
* Say that the app wrote into the transcript outside a turn (`aparte-transcript-change`),
|
|
4499
|
+
* so a conversation controller saves it — during a human takeover no turn runs, and
|
|
4500
|
+
* nothing else would. Not for the AI's empty shell, not while a reply streams (the
|
|
4501
|
+
* turn's end saves then), and not under a framework, where the host says it.
|
|
4502
|
+
*/
|
|
4503
|
+
_announceWrite(message, change) {
|
|
4504
|
+
if (this._frameworkManagedDOM) return;
|
|
4505
|
+
if (this._streamingMessageId() !== null || isAwaitingReply(message)) return;
|
|
4506
|
+
dispatchChatEvent(this, "aparte-transcript-change", { messageId: message.id, change });
|
|
4375
4507
|
}
|
|
4376
4508
|
/**
|
|
4377
4509
|
* Add a complete message to the message registry.
|
|
@@ -4420,9 +4552,11 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4420
4552
|
const bubble = document.createElement("aparte-chat-bubble");
|
|
4421
4553
|
bubble.setAttribute("message-id", message.id);
|
|
4422
4554
|
bubble.setAttribute("data-role", message.role);
|
|
4423
|
-
|
|
4555
|
+
const kind = message.kind ?? (message.compaction ? "compaction" : void 0);
|
|
4556
|
+
if (kind) bubble.setAttribute("data-kind", kind);
|
|
4424
4557
|
if (message.timestamp) bubble.setAttribute("timestamp", String(message.timestamp));
|
|
4425
4558
|
if (message.content) bubble.setAttribute("content", message.content);
|
|
4559
|
+
if (message.author) bubble.setAuthor?.(message.author);
|
|
4426
4560
|
if (isAwaitingReply(message)) {
|
|
4427
4561
|
bubble.setAttribute("streaming", "");
|
|
4428
4562
|
}
|
|
@@ -4434,6 +4568,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4434
4568
|
populateBubbleFromMessage(bubble, stored);
|
|
4435
4569
|
}
|
|
4436
4570
|
}
|
|
4571
|
+
if (!options?.historical && !this._bulkAppend) this._announceWrite(stored, "append");
|
|
4437
4572
|
if (this._bulkAppend) return;
|
|
4438
4573
|
this._pruneRenderedBubbles();
|
|
4439
4574
|
this._syncBusy();
|
|
@@ -4451,12 +4586,13 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4451
4586
|
}
|
|
4452
4587
|
}
|
|
4453
4588
|
/**
|
|
4454
|
-
* Update the
|
|
4455
|
-
*
|
|
4589
|
+
* Update the content of the turn's message, optionally appending: the message being
|
|
4590
|
+
* streamed while a turn runs, else the last one — the same resolution as the
|
|
4591
|
+
* 1-argument segment writes. Implements the same contract as the wrappers' host,
|
|
4456
4592
|
* making aparte-chat-viewport a fully standalone streaming target for aparte-client.
|
|
4457
4593
|
*/
|
|
4458
4594
|
updateLastMessage(content, options) {
|
|
4459
|
-
const lastId = this.
|
|
4595
|
+
const lastId = this._activeMessageId();
|
|
4460
4596
|
if (!lastId) return;
|
|
4461
4597
|
if (options?.append) {
|
|
4462
4598
|
this.appendToken(lastId, content);
|
|
@@ -4744,7 +4880,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4744
4880
|
break;
|
|
4745
4881
|
case "update": {
|
|
4746
4882
|
const updates = payload;
|
|
4747
|
-
const renderable = ["status", "segments", "content", "attachments", "usage", "finishReason", "contextSummary", "compaction"];
|
|
4883
|
+
const renderable = ["status", "segments", "content", "attachments", "usage", "finishReason", "contextSummary", "compaction", "author", "kind", "note"];
|
|
4748
4884
|
if (renderable.some((key) => key in updates)) {
|
|
4749
4885
|
bubble.updateMessage?.(payload);
|
|
4750
4886
|
}
|
|
@@ -4761,21 +4897,21 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4761
4897
|
const on = cfg.getDateSeparators();
|
|
4762
4898
|
if (!on && !this.querySelector("aparte-chat-bubble[data-date]")) return;
|
|
4763
4899
|
const now = /* @__PURE__ */ new Date();
|
|
4764
|
-
const dayOf = (
|
|
4900
|
+
const dayOf = (at) => new Date(at.getFullYear(), at.getMonth(), at.getDate()).getTime();
|
|
4765
4901
|
const today = dayOf(now);
|
|
4766
4902
|
let previous = null;
|
|
4767
4903
|
this.querySelectorAll("aparte-chat-bubble").forEach((bubble) => {
|
|
4768
4904
|
const raw = Number(bubble.getAttribute("timestamp"));
|
|
4769
|
-
const
|
|
4770
|
-
const day =
|
|
4771
|
-
const starts = on &&
|
|
4905
|
+
const at = raw ? new Date(raw) : null;
|
|
4906
|
+
const day = at ? dayOf(at) : null;
|
|
4907
|
+
const starts = on && at && day !== previous;
|
|
4772
4908
|
if (day !== null) previous = day;
|
|
4773
|
-
if (!starts || !
|
|
4909
|
+
if (!starts || !at) {
|
|
4774
4910
|
if (bubble.hasAttribute("data-date")) bubble.removeAttribute("data-date");
|
|
4775
4911
|
return;
|
|
4776
4912
|
}
|
|
4777
4913
|
const elapsed = Math.round((today - day) / 864e5);
|
|
4778
|
-
const label = elapsed === 0 ? cfg.t("conversationGroupToday") : elapsed === 1 ? cfg.t("conversationGroupYesterday") : longDate(
|
|
4914
|
+
const label = elapsed === 0 ? cfg.t("conversationGroupToday") : elapsed === 1 ? cfg.t("conversationGroupYesterday") : longDate(at, cfg.getLocale().tag);
|
|
4779
4915
|
if (bubble.getAttribute("data-date") !== label) bubble.setAttribute("data-date", label);
|
|
4780
4916
|
});
|
|
4781
4917
|
}
|
|
@@ -4809,11 +4945,13 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4809
4945
|
const bubble = document.createElement("aparte-chat-bubble");
|
|
4810
4946
|
bubble.setAttribute("message-id", message.id);
|
|
4811
4947
|
bubble.setAttribute("data-role", message.role);
|
|
4812
|
-
|
|
4948
|
+
const kind = message.kind ?? (message.compaction ? "compaction" : void 0);
|
|
4949
|
+
if (kind) bubble.setAttribute("data-kind", kind);
|
|
4813
4950
|
if (message.timestamp) bubble.setAttribute("timestamp", String(message.timestamp));
|
|
4814
4951
|
if (isAwaitingReply(message)) {
|
|
4815
4952
|
bubble.setAttribute("streaming", "");
|
|
4816
4953
|
}
|
|
4954
|
+
if (message.author) bubble.setAuthor?.(message.author);
|
|
4817
4955
|
wrapper.appendChild(bubble);
|
|
4818
4956
|
populateBubbleFromMessage(bubble, message, sibInfo);
|
|
4819
4957
|
}
|
|
@@ -5633,6 +5771,10 @@ class AparteComposer extends HTMLElement {
|
|
|
5633
5771
|
this._evaluateModelGate();
|
|
5634
5772
|
this._applyDirection();
|
|
5635
5773
|
};
|
|
5774
|
+
/** Another conversation opened: the AI may answer there and not here (`setAutoReply`). */
|
|
5775
|
+
_onConversationLoaded = (e) => {
|
|
5776
|
+
if (this._isForThisComposer(e)) this._evaluateModelGate();
|
|
5777
|
+
};
|
|
5636
5778
|
/**
|
|
5637
5779
|
* Mirror `locale.direction` onto ourselves, so everything inside — input, buttons,
|
|
5638
5780
|
* the toolbar row and whatever the consumer put in it — inherits it.
|
|
@@ -5661,6 +5803,7 @@ class AparteComposer extends HTMLElement {
|
|
|
5661
5803
|
window.addEventListener("aparte-message-error", this._onMessageDone);
|
|
5662
5804
|
window.addEventListener("aparte-message-aborted", this._onMessageDone);
|
|
5663
5805
|
window.addEventListener("aparte-config-change", this._onConfigChangeEvent);
|
|
5806
|
+
window.addEventListener("aparte-conversation-loaded", this._onConversationLoaded);
|
|
5664
5807
|
queueMicrotask(() => this._warnIfUnattached());
|
|
5665
5808
|
this._evaluateModelGate();
|
|
5666
5809
|
this._applyDirection();
|
|
@@ -5673,6 +5816,7 @@ class AparteComposer extends HTMLElement {
|
|
|
5673
5816
|
window.removeEventListener("aparte-message-error", this._onMessageDone);
|
|
5674
5817
|
window.removeEventListener("aparte-message-aborted", this._onMessageDone);
|
|
5675
5818
|
window.removeEventListener("aparte-config-change", this._onConfigChangeEvent);
|
|
5819
|
+
window.removeEventListener("aparte-conversation-loaded", this._onConversationLoaded);
|
|
5676
5820
|
this._listeners.clear();
|
|
5677
5821
|
this._offTypeToFocus?.();
|
|
5678
5822
|
this._offTypeToFocus = null;
|
|
@@ -6027,7 +6171,7 @@ class AparteComposer extends HTMLElement {
|
|
|
6027
6171
|
* every config change (e.g. the model selector's auto-select firing).
|
|
6028
6172
|
*/
|
|
6029
6173
|
_evaluateModelGate() {
|
|
6030
|
-
const gated = this._cfg.getRequireModelSelection() && !this._cfg.hasSelectedModel();
|
|
6174
|
+
const gated = this._cfg.getRequireModelSelection() && !this._cfg.hasSelectedModel() && this._aiAnswers();
|
|
6031
6175
|
if (gated === this._modelGated) return;
|
|
6032
6176
|
this._modelGated = gated;
|
|
6033
6177
|
this.toggleAttribute("data-model-gated", gated);
|
|
@@ -6095,7 +6239,15 @@ class AparteComposer extends HTMLElement {
|
|
|
6095
6239
|
if (this._streaming || this._queue.length === 0 || !this.isConnected) return;
|
|
6096
6240
|
const next = this._queue.shift();
|
|
6097
6241
|
this._queueChanged();
|
|
6098
|
-
if (this.disabled || this._modelGated || !this._send(next))
|
|
6242
|
+
if (this.disabled || this._modelGated || !this._send(next)) {
|
|
6243
|
+
this._backToField([next]);
|
|
6244
|
+
return;
|
|
6245
|
+
}
|
|
6246
|
+
if (!this._aiAnswers()) this._sendNextQueued();
|
|
6247
|
+
}
|
|
6248
|
+
/** Whether the AI answers in the conversation open in this composer's chat (see `setAutoReply`). */
|
|
6249
|
+
_aiAnswers() {
|
|
6250
|
+
return this._cfg.getAutoReply(openConversationOf(this) ?? void 0);
|
|
6099
6251
|
}
|
|
6100
6252
|
/**
|
|
6101
6253
|
* Put queued messages back into the field, before what is being written there: after a
|
|
@@ -7745,17 +7897,17 @@ class AparteConversationList extends HTMLElement {
|
|
|
7745
7897
|
push("pinned", this._t("conversationGroupPinned"), c2);
|
|
7746
7898
|
continue;
|
|
7747
7899
|
}
|
|
7748
|
-
const
|
|
7749
|
-
if (typeof
|
|
7900
|
+
const at = c2.updatedAt;
|
|
7901
|
+
if (typeof at !== "number") {
|
|
7750
7902
|
push("undated", null, c2);
|
|
7751
7903
|
continue;
|
|
7752
7904
|
}
|
|
7753
|
-
if (
|
|
7754
|
-
else if (
|
|
7755
|
-
else if (
|
|
7756
|
-
else if (
|
|
7905
|
+
if (at >= today) push("today", this._t("conversationGroupToday"), c2);
|
|
7906
|
+
else if (at >= today - DAY) push("yesterday", this._t("conversationGroupYesterday"), c2);
|
|
7907
|
+
else if (at >= today - 7 * DAY) push("week", this._t("conversationGroupWeek"), c2);
|
|
7908
|
+
else if (at >= today - 30 * DAY) push("month", this._t("conversationGroupMonth"), c2);
|
|
7757
7909
|
else {
|
|
7758
|
-
const d2 = new Date(
|
|
7910
|
+
const d2 = new Date(at);
|
|
7759
7911
|
const sameYear = d2.getFullYear() === now.getFullYear();
|
|
7760
7912
|
const raw = new Intl.DateTimeFormat(tag, sameYear ? { month: "long" } : { month: "long", year: "numeric" }).format(d2);
|
|
7761
7913
|
const label = raw.charAt(0).toLocaleUpperCase(tag) + raw.slice(1);
|
|
@@ -7763,7 +7915,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7763
7915
|
}
|
|
7764
7916
|
}
|
|
7765
7917
|
const fixed = ["pinned", "today", "yesterday", "week", "month"].map((k2) => buckets.get(k2)).filter((g) => !!g);
|
|
7766
|
-
const months = [...buckets.keys()].filter((k2) => k2.startsWith("m-")).sort((
|
|
7918
|
+
const months = [...buckets.keys()].filter((k2) => k2.startsWith("m-")).sort((a2, b3) => b3.localeCompare(a2)).map((k2) => buckets.get(k2));
|
|
7767
7919
|
const undated = buckets.get("undated");
|
|
7768
7920
|
return [...named.values(), ...fixed, ...months, ...undated ? [undated] : []];
|
|
7769
7921
|
}
|
|
@@ -8364,7 +8516,7 @@ class AparteSuggestions extends HTMLElement {
|
|
|
8364
8516
|
* offer was for the answer it came with.
|
|
8365
8517
|
*/
|
|
8366
8518
|
_applyAnswers() {
|
|
8367
|
-
const bubbles = this._transcript?.querySelectorAll(
|
|
8519
|
+
const bubbles = this._transcript?.querySelectorAll('aparte-chat-bubble:not([data-kind="notice"])');
|
|
8368
8520
|
const last = bubbles && bubbles.length ? bubbles[bubbles.length - 1] : null;
|
|
8369
8521
|
const marks = last && last.getAttribute("data-role") !== "user" ? last.querySelectorAll("[data-aparte-suggestions]") : null;
|
|
8370
8522
|
const mark = marks && marks.length ? marks[marks.length - 1] : null;
|
|
@@ -9202,8 +9354,8 @@ class AparteScrollRail extends HTMLElement {
|
|
|
9202
9354
|
}
|
|
9203
9355
|
continue;
|
|
9204
9356
|
}
|
|
9205
|
-
const
|
|
9206
|
-
const owner =
|
|
9357
|
+
const at = record.target instanceof Element ? record.target : record.target.parentElement;
|
|
9358
|
+
const owner = at?.closest("aparte-chat-bubble");
|
|
9207
9359
|
if (owner) {
|
|
9208
9360
|
this._excerpts.delete(owner);
|
|
9209
9361
|
if (this._ticked(owner)) this._queueRelabel(owner);
|
|
@@ -9362,7 +9514,7 @@ class AparteScrollRail extends HTMLElement {
|
|
|
9362
9514
|
item.remove();
|
|
9363
9515
|
existing.delete(id);
|
|
9364
9516
|
}
|
|
9365
|
-
let
|
|
9517
|
+
let at = list.firstElementChild;
|
|
9366
9518
|
for (const bubble of bubbles) {
|
|
9367
9519
|
const id = bubble.getAttribute("message-id");
|
|
9368
9520
|
let item = existing.get(id);
|
|
@@ -9386,8 +9538,8 @@ class AparteScrollRail extends HTMLElement {
|
|
|
9386
9538
|
} else {
|
|
9387
9539
|
tick.removeAttribute("aria-current");
|
|
9388
9540
|
}
|
|
9389
|
-
if (item ===
|
|
9390
|
-
else list.insertBefore(item,
|
|
9541
|
+
if (item === at) at = at.nextElementSibling;
|
|
9542
|
+
else list.insertBefore(item, at);
|
|
9391
9543
|
}
|
|
9392
9544
|
const dropped = this._currentId !== null && !known.has(this._currentId);
|
|
9393
9545
|
if (dropped) this._currentId = null;
|
|
@@ -9769,9 +9921,9 @@ function isBubble(node) {
|
|
|
9769
9921
|
function holdsBubbles(nodes) {
|
|
9770
9922
|
return Array.from(nodes).some((n2) => n2 instanceof Element && (isBubble(n2) || n2.localName === "aparte-chat-viewport" || n2.querySelector("aparte-chat-bubble") !== null));
|
|
9771
9923
|
}
|
|
9772
|
-
function sameElements(
|
|
9773
|
-
if (
|
|
9774
|
-
for (let i2 = 0; i2 <
|
|
9924
|
+
function sameElements(a2, b3) {
|
|
9925
|
+
if (a2.length !== b3.length) return false;
|
|
9926
|
+
for (let i2 = 0; i2 < a2.length; i2++) if (a2[i2] !== b3[i2]) return false;
|
|
9775
9927
|
return true;
|
|
9776
9928
|
}
|
|
9777
9929
|
deferHydrationOf(AparteScrollRail);
|
|
@@ -11742,74 +11894,76 @@ export {
|
|
|
11742
11894
|
aparteGlobalConfig,
|
|
11743
11895
|
u as applyElementProps,
|
|
11744
11896
|
v as attachConfig,
|
|
11897
|
+
authorTypeOf,
|
|
11745
11898
|
buildApprovalPanel,
|
|
11746
11899
|
buildElicitationPanel,
|
|
11747
11900
|
chatIdOf,
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11901
|
+
B as collectRendererStyles,
|
|
11902
|
+
C as contentToText,
|
|
11903
|
+
D as contextConfig,
|
|
11751
11904
|
copyText,
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11905
|
+
F as createAgentStreamRunner,
|
|
11906
|
+
G as createAparteAgentHandler,
|
|
11907
|
+
H as createAparteChatHandler,
|
|
11908
|
+
I as createModelCatalogue,
|
|
11909
|
+
J as createSegmentList,
|
|
11910
|
+
K as createStreamAdapter,
|
|
11758
11911
|
cssEscape,
|
|
11759
|
-
|
|
11760
|
-
|
|
11912
|
+
L as declineDefaultRenderers,
|
|
11913
|
+
M as defaultSanitizer,
|
|
11761
11914
|
deferHydrationOf,
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11915
|
+
O as defineMountedSegmentRenderer,
|
|
11916
|
+
P as defineMountedToolRenderer,
|
|
11917
|
+
Q as detachConfig,
|
|
11765
11918
|
dispatchChatEvent,
|
|
11766
11919
|
enhanceContextMenu,
|
|
11767
11920
|
enhanceMenu,
|
|
11768
11921
|
b2 as enhanceTabs,
|
|
11769
11922
|
escapeAttr,
|
|
11770
11923
|
escapeHtml,
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11924
|
+
V as estimateTokens,
|
|
11925
|
+
W as estimateWireTokens,
|
|
11926
|
+
X as filesToAttachments,
|
|
11774
11927
|
formatDuration,
|
|
11775
|
-
|
|
11928
|
+
Z as getAllRenderers,
|
|
11776
11929
|
getSegmentRenderer,
|
|
11777
|
-
|
|
11930
|
+
$ as historyFromCheckpoint,
|
|
11778
11931
|
installDefaultRenderersOnce,
|
|
11779
11932
|
installDialogTriggersOnce,
|
|
11780
11933
|
isAwaitingReply,
|
|
11781
|
-
|
|
11934
|
+
a3 as isFormatAdapter,
|
|
11935
|
+
isModelReply,
|
|
11782
11936
|
isSafeUrl,
|
|
11783
11937
|
isSegmentSettled,
|
|
11784
11938
|
measureContext,
|
|
11785
11939
|
onRenderersChange,
|
|
11786
|
-
|
|
11787
|
-
|
|
11940
|
+
a9 as overrideSegmentRenderer,
|
|
11941
|
+
aa as parseAparteEventStream,
|
|
11788
11942
|
parseMarkdownToSegments,
|
|
11789
11943
|
placeFloating,
|
|
11790
11944
|
pluralize,
|
|
11791
11945
|
populateBubbleFromMessage,
|
|
11792
|
-
|
|
11946
|
+
ae as readableToAsyncIterable,
|
|
11793
11947
|
registerAllComponents,
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11948
|
+
af as registerDefaultRenderers,
|
|
11949
|
+
ag as registerSegmentRenderer,
|
|
11950
|
+
ah as releaseDeferredHydration,
|
|
11951
|
+
ai as renderCitations,
|
|
11952
|
+
aj as renderCodeLanguages,
|
|
11953
|
+
ak as requestUserInput,
|
|
11800
11954
|
resolveConfig,
|
|
11801
11955
|
revokeAttachmentUrls,
|
|
11802
|
-
|
|
11956
|
+
an as runSubAgent,
|
|
11803
11957
|
runWithConfig,
|
|
11804
|
-
|
|
11958
|
+
ap as segmentDuration,
|
|
11805
11959
|
segmentTiming,
|
|
11806
|
-
|
|
11807
|
-
|
|
11960
|
+
ar as setupSuggestionBlocks,
|
|
11961
|
+
as as startSubAgent,
|
|
11808
11962
|
subscribeConfigChange,
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11963
|
+
au as toToolCallView,
|
|
11964
|
+
av as toolRefusal,
|
|
11965
|
+
aw as unregisterSegmentRenderer,
|
|
11812
11966
|
uuid,
|
|
11813
|
-
|
|
11967
|
+
ay as withoutAbandonedTurns
|
|
11814
11968
|
};
|
|
11815
11969
|
//# sourceMappingURL=index.js.map
|