@aparte/core 1.9.0 → 1.10.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/dist/client/aparte-client.d.ts +48 -11
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/stream-adapter.d.ts +5 -0
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/client/wire-history.d.ts +21 -1
- package/dist/client/wire-history.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-action.d.ts +2 -1
- package/dist/components/composer/aparte-composer-action.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +2 -1
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/context/aparte-context.d.ts +1 -1
- package/dist/components/context/aparte-context.d.ts.map +1 -1
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +43 -1
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/conversation-list/index.d.ts +1 -1
- package/dist/components/conversation-list/index.d.ts.map +1 -1
- package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/launcher/aparte-launcher.d.ts.map +1 -1
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts +1 -1
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts.map +1 -1
- package/dist/components/sidebar/aparte-sidebar.d.ts +14 -1
- package/dist/components/sidebar/aparte-sidebar.d.ts.map +1 -1
- package/dist/components/split/aparte-split.d.ts +1 -1
- package/dist/components/split/aparte-split.d.ts.map +1 -1
- package/dist/components/suggestions/aparte-suggestions.d.ts +3 -2
- package/dist/components/suggestions/aparte-suggestions.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +3 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +24 -3
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/context/checkpoint-state.d.ts +0 -7
- package/dist/context/checkpoint-state.d.ts.map +1 -1
- package/dist/context/measure.d.ts +3 -1
- package/dist/context/measure.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts +48 -6
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/custom-elements.json +1553 -671
- package/dist/{defer-hydration-Ch3TOEJC.js → defer-hydration-OFqdbk3O.js} +647 -248
- package/dist/defer-hydration-OFqdbk3O.js.map +1 -0
- package/dist/elicitation/approval-panel.d.ts +1 -1
- package/dist/elicitation/approval-panel.d.ts.map +1 -1
- package/dist/elicitation/option-keys.d.ts +26 -0
- package/dist/elicitation/option-keys.d.ts.map +1 -0
- package/dist/elicitation/types.d.ts +16 -0
- package/dist/elicitation/types.d.ts.map +1 -1
- package/dist/generated/element-attributes.d.ts +2 -2
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/{glyphs-LolG04CC.js → glyphs-BgKFtByg.js} +10 -10
- package/dist/{glyphs-LolG04CC.js.map → glyphs-BgKFtByg.js.map} +1 -1
- package/dist/host/aparte-chat-host.d.ts +42 -1
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/icons/extended.d.ts +9 -0
- package/dist/icons/extended.d.ts.map +1 -1
- package/dist/icons.js +20 -11
- package/dist/icons.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -190
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +7 -2
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +61 -58
- package/dist/index.node.js.map +1 -1
- package/dist/interop/chat-events.d.ts +64 -0
- package/dist/interop/chat-events.d.ts.map +1 -0
- package/dist/interop/element-props.d.ts +6 -0
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/interop/element-spec.d.ts +85 -0
- package/dist/interop/element-spec.d.ts.map +1 -0
- package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts +1 -1
- package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts.map +1 -1
- package/dist/primitives/select/aparte-option.d.ts +1 -1
- package/dist/primitives/select/aparte-option.d.ts.map +1 -1
- package/dist/primitives/select/aparte-select.d.ts.map +1 -1
- package/dist/renderers/citations.d.ts.map +1 -1
- package/dist/transport/agent-handler.d.ts +8 -4
- package/dist/transport/agent-handler.d.ts.map +1 -1
- package/dist/types/events.d.ts +11 -10
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/imperative-api.d.ts +11 -0
- package/dist/types/imperative-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models.d.ts +26 -0
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/segments.d.ts +2 -1
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/tools.d.ts +51 -5
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/segments.d.ts +1 -0
- package/dist/utils/segments.d.ts.map +1 -1
- package/dist/utils/tool-line.d.ts +9 -8
- package/dist/utils/tool-line.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/defer-hydration-Ch3TOEJC.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 { L as deferHydrationOf, ai as resolveConfig, aq as subscribeConfigChange, al as runWithConfig, o as AparteElicitationAbortError, w as buildApprovalPanel, x as buildElicitationPanel, y as chatIdOf, aw as gateGlide, Q as escapeAttr, an as segmentTiming, ax as chatBoundaryOf, ay as relabelCodeLanguages, az as relabelCitations, aA as toolCallRenderer, aB as activityRenderer, t as aparteGlobalConfig, aC as isMountedRenderer, aD as renderingVersionOf, a5 as onRenderersChange, aE as renderSourceList, aF as mergeSegmentUpdate, a3 as isSegmentSettled, a9 as pluralize, W as formatDuration, aG as toolNameOf, R as escapeHtml, aH as writeStreamedMarkdown, aI as replaceHighlighted, a2 as isSafeUrl, P as dispatchChatEvent, D as copyText, Y as getSegmentRenderer, _ as installDefaultRenderersOnce, aJ as toolRendererThatDrew, aK as activityRendererThatDrew, r as AparteMessageRepository, aL as CheckpointStateWatcher, aM as stampSegmentActivity, aN as stampSegmentOnInsert, aO as stampSegmentOnUpdate, aP as renumberSegments, aQ as openSegmentIds, aR as isTerminalStatus, aS as adoptMessageSegments, a0 as isAwaitingReply, aa as populateBubbleFromMessage, au as uuid, aj as revokeAttachmentUrls, a8 as parseMarkdownToSegments, aT as APARTE_DERIVED_SEGMENTS, aU as rememberConversationStatus, aV as tellConversationStatus, aW as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, aX as visibleReply, aY as usageTokens, q as AparteErrorCode, a4 as measureContext, aZ as inRenderedContent, g as APARTE_HOST_ATTR, $ as installDialogTriggersOnce } from "./defer-hydration-OFqdbk3O.js";
|
|
2
|
+
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, z, B, C, E, F, G, H, I, J, K, M, N, O, T, U, V, X, Z, a1, a6, a7, ab, ac, ad, ae, af, ag, ah, ak, am, ao, ap, ar, as, at, av } from "./defer-hydration-OFqdbk3O.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) {
|
|
@@ -14,7 +14,8 @@ class AparteOption extends HTMLElement {
|
|
|
14
14
|
this._updateAriaSelected();
|
|
15
15
|
this._updateStatusDot();
|
|
16
16
|
}
|
|
17
|
-
attributeChangedCallback(name) {
|
|
17
|
+
attributeChangedCallback(name, previous, value) {
|
|
18
|
+
if (previous === value) return;
|
|
18
19
|
if (name === "selected") {
|
|
19
20
|
this._updateAriaSelected();
|
|
20
21
|
}
|
|
@@ -249,6 +250,7 @@ class AparteSelect extends HTMLElement {
|
|
|
249
250
|
this._observer?.disconnect();
|
|
250
251
|
}
|
|
251
252
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
253
|
+
if (oldValue === newValue) return;
|
|
252
254
|
if (!this.isConnected) return;
|
|
253
255
|
if (name === "value" && oldValue !== newValue && newValue !== this._value) {
|
|
254
256
|
this._value = newValue || "";
|
|
@@ -674,11 +676,11 @@ class AparteSelect extends HTMLElement {
|
|
|
674
676
|
const sizer = this._trigger?.querySelector(".aparte-select-label-sizer");
|
|
675
677
|
if (sizer) {
|
|
676
678
|
const labels = [placeholder, ...Array.from(this.querySelectorAll("aparte-option"), (o) => optionLabelText(o))];
|
|
677
|
-
const current = Array.from(sizer.children, (s2) => s2.
|
|
679
|
+
const current = Array.from(sizer.children, (s2) => s2.getAttribute("data-label") ?? "");
|
|
678
680
|
if (labels.length !== current.length || labels.some((l2, i2) => l2 !== current[i2])) {
|
|
679
681
|
sizer.replaceChildren(...labels.map((text) => {
|
|
680
682
|
const span = document.createElement("span");
|
|
681
|
-
span.
|
|
683
|
+
span.setAttribute("data-label", text);
|
|
682
684
|
return span;
|
|
683
685
|
}));
|
|
684
686
|
}
|
|
@@ -746,7 +748,8 @@ class AparteProgressSpinner extends HTMLElement {
|
|
|
746
748
|
connectedCallback() {
|
|
747
749
|
this._render();
|
|
748
750
|
}
|
|
749
|
-
attributeChangedCallback() {
|
|
751
|
+
attributeChangedCallback(_name, previous, value) {
|
|
752
|
+
if (previous === value) return;
|
|
750
753
|
this._render();
|
|
751
754
|
}
|
|
752
755
|
_render() {
|
|
@@ -796,6 +799,43 @@ deferHydrationOf(AparteIcon);
|
|
|
796
799
|
if (!customElements.get("aparte-icon")) {
|
|
797
800
|
customElements.define("aparte-icon", AparteIcon);
|
|
798
801
|
}
|
|
802
|
+
const OPTION = ".aparte-elic-option--command, .aparte-approval-option";
|
|
803
|
+
const TEXT_FIELD = 'input:not([type="checkbox"]):not([type="radio"]):not([type="button"]), textarea, select, [contenteditable]:not([contenteditable="false"])';
|
|
804
|
+
function numberOptions(panel) {
|
|
805
|
+
const options = [...panel.querySelectorAll(OPTION)];
|
|
806
|
+
options.forEach((option, i2) => {
|
|
807
|
+
if (i2 >= 9) return;
|
|
808
|
+
option.setAttribute("data-shortcut", String(i2 + 1));
|
|
809
|
+
option.setAttribute("aria-keyshortcuts", String(i2 + 1));
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function bindOptionKeys(panel) {
|
|
813
|
+
const onKeyDown2 = (e) => {
|
|
814
|
+
if (e.defaultPrevented || e.repeat || e.isComposing || e.keyCode === 229) return;
|
|
815
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
816
|
+
if (panel.hasAttribute("data-collapsed")) return;
|
|
817
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
818
|
+
if (!target || target.closest(TEXT_FIELD)) return;
|
|
819
|
+
if (/^[1-9]$/.test(e.key)) {
|
|
820
|
+
if (!target.closest(OPTION)) return;
|
|
821
|
+
const option = panel.querySelectorAll(OPTION)[Number(e.key) - 1];
|
|
822
|
+
if (!option) return;
|
|
823
|
+
e.preventDefault();
|
|
824
|
+
option.click();
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (e.key === "Escape") {
|
|
828
|
+
const skip = panel.querySelector(".aparte-elic-skip");
|
|
829
|
+
const denies = panel.querySelectorAll(".aparte-approval-option--deny");
|
|
830
|
+
const answer = skip ?? (denies.length === 1 ? denies[0] : null);
|
|
831
|
+
if (!answer) return;
|
|
832
|
+
e.preventDefault();
|
|
833
|
+
answer.click();
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
panel.addEventListener("keydown", onKeyDown2);
|
|
837
|
+
return () => panel.removeEventListener("keydown", onKeyDown2);
|
|
838
|
+
}
|
|
799
839
|
function deepActiveElement(root) {
|
|
800
840
|
let active = root.activeElement;
|
|
801
841
|
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
@@ -944,7 +984,7 @@ class AparteElicitation extends HTMLElement {
|
|
|
944
984
|
status(message);
|
|
945
985
|
return;
|
|
946
986
|
}
|
|
947
|
-
const x = window.scrollX,
|
|
987
|
+
const x = window.scrollX, y = window.scrollY;
|
|
948
988
|
if (typing && inChat) {
|
|
949
989
|
if (!panel2.el.hasAttribute("tabindex")) panel2.el.setAttribute("tabindex", "-1");
|
|
950
990
|
if (!panel2.el.hasAttribute("role")) panel2.el.setAttribute("role", "group");
|
|
@@ -953,7 +993,7 @@ class AparteElicitation extends HTMLElement {
|
|
|
953
993
|
} else {
|
|
954
994
|
panel2.focus();
|
|
955
995
|
}
|
|
956
|
-
if (fromNobody && (window.scrollX !== x || window.scrollY !==
|
|
996
|
+
if (fromNobody && (window.scrollX !== x || window.scrollY !== y)) window.scrollTo(x, y);
|
|
957
997
|
};
|
|
958
998
|
const close = () => {
|
|
959
999
|
if (done) return false;
|
|
@@ -987,7 +1027,9 @@ class AparteElicitation extends HTMLElement {
|
|
|
987
1027
|
const sendable = () => panel2.isComplete() && !panel2.el.hasAttribute("data-collapsed");
|
|
988
1028
|
const approvalMode = () => sendable() ? "submit" : "none";
|
|
989
1029
|
const syncSubmit2 = () => composer.setPanelSubmitEnabled(sendable(), approvalMode());
|
|
990
|
-
const panel2 = runWithConfig(cfg, () => buildApprovalPanel(request.message, request.options ?? [], syncSubmit2, request.details, request.allowOther ?? true));
|
|
1030
|
+
const panel2 = runWithConfig(cfg, () => buildApprovalPanel(request.message, request.options ?? [], syncSubmit2, request.details, request.allowOther ?? true, request.preview));
|
|
1031
|
+
numberOptions(panel2.el);
|
|
1032
|
+
bindOptionKeys(panel2.el);
|
|
991
1033
|
panel2.onSettle((answer) => settle({ action: "accept", content: answer }));
|
|
992
1034
|
const retract2 = addRetract(panel2.el, panel2.dismiss, cfg, () => panel2.focus(), syncSubmit2);
|
|
993
1035
|
this._pending = {
|
|
@@ -1021,6 +1063,8 @@ class AparteElicitation extends HTMLElement {
|
|
|
1021
1063
|
skip.textContent = cfg.t("elicitationSkip");
|
|
1022
1064
|
skip.addEventListener("click", () => settle({ action: "decline" }));
|
|
1023
1065
|
panel.dismiss.appendChild(skip);
|
|
1066
|
+
numberOptions(panel.el);
|
|
1067
|
+
bindOptionKeys(panel.el);
|
|
1024
1068
|
const retract = addRetract(panel.el, panel.dismiss, cfg, () => panel.focus(), syncSubmit);
|
|
1025
1069
|
panel.onSettle((content) => settle({ action: "accept", content }));
|
|
1026
1070
|
this._pending = {
|
|
@@ -1066,14 +1110,7 @@ class AparteElicitation extends HTMLElement {
|
|
|
1066
1110
|
* resolves `undefined` on three wrappers out of four.
|
|
1067
1111
|
*/
|
|
1068
1112
|
_pendingTargetId() {
|
|
1069
|
-
|
|
1070
|
-
while (el2) {
|
|
1071
|
-
const tag = el2.tagName?.toLowerCase();
|
|
1072
|
-
const isHost = tag === "aparte-chat" || el2.hasAttribute?.("data-aparte-chat");
|
|
1073
|
-
if (isHost && el2.id) return el2.id;
|
|
1074
|
-
el2 = el2.parentElement;
|
|
1075
|
-
}
|
|
1076
|
-
return void 0;
|
|
1113
|
+
return chatIdOf(this._pending?.composer ?? null);
|
|
1077
1114
|
}
|
|
1078
1115
|
/**
|
|
1079
1116
|
* The composer to present in: the nearest one in an ancestor subtree, and
|
|
@@ -1373,11 +1410,11 @@ function draw(root, content, token) {
|
|
|
1373
1410
|
const walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
1374
1411
|
while (walker.nextNode()) {
|
|
1375
1412
|
const node = walker.currentNode;
|
|
1376
|
-
for (let
|
|
1413
|
+
for (let at2 = node.data.indexOf(token.text); at2 >= 0; at2 = node.data.indexOf(token.text, at2 + token.text.length)) {
|
|
1377
1414
|
if (skip-- > 0) continue;
|
|
1378
1415
|
const range = doc.createRange();
|
|
1379
|
-
range.setStart(node,
|
|
1380
|
-
range.setEnd(node,
|
|
1416
|
+
range.setStart(node, at2);
|
|
1417
|
+
range.setEnd(node, at2 + token.text.length);
|
|
1381
1418
|
range.deleteContents();
|
|
1382
1419
|
range.insertNode(pill(doc, token));
|
|
1383
1420
|
return;
|
|
@@ -2012,11 +2049,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2012
2049
|
dismiss: this._cfg.t("feedbackReasonDismiss"),
|
|
2013
2050
|
onPick: (reason) => {
|
|
2014
2051
|
panel.remove();
|
|
2015
|
-
this
|
|
2016
|
-
bubbles: true,
|
|
2017
|
-
composed: true,
|
|
2018
|
-
detail: { messageId, reason }
|
|
2019
|
-
}));
|
|
2052
|
+
dispatchChatEvent(this, "aparte-feedback-reason", { messageId, reason });
|
|
2020
2053
|
},
|
|
2021
2054
|
onClose: () => panel.remove()
|
|
2022
2055
|
});
|
|
@@ -3028,11 +3061,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3028
3061
|
const open = () => {
|
|
3029
3062
|
const url = tile.querySelector(".aparte-thumbnail__image")?.src ?? tile.dataset["url"];
|
|
3030
3063
|
if (!url) return;
|
|
3031
|
-
this
|
|
3032
|
-
bubbles: true,
|
|
3033
|
-
composed: true,
|
|
3034
|
-
detail: { url, name: tile.getAttribute("title") ?? "", type: tile.dataset["type"] ?? "" }
|
|
3035
|
-
}));
|
|
3064
|
+
dispatchChatEvent(this, "aparte-attachment-preview", { url, name: tile.getAttribute("title") ?? "", type: tile.dataset["type"] ?? "" });
|
|
3036
3065
|
};
|
|
3037
3066
|
tile.addEventListener("click", open);
|
|
3038
3067
|
tile.addEventListener("keydown", (e) => {
|
|
@@ -3091,11 +3120,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3091
3120
|
const messageId = this.getAttribute("message-id");
|
|
3092
3121
|
if (!messageId) return;
|
|
3093
3122
|
const detail = { messageId, direction };
|
|
3094
|
-
this
|
|
3095
|
-
bubbles: true,
|
|
3096
|
-
composed: true,
|
|
3097
|
-
detail
|
|
3098
|
-
}));
|
|
3123
|
+
dispatchChatEvent(this, "aparte-branch-navigate", detail);
|
|
3099
3124
|
};
|
|
3100
3125
|
/**
|
|
3101
3126
|
* A link the MODEL wrote is about to be followed. Announced as a cancelable event
|
|
@@ -3116,12 +3141,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3116
3141
|
anchor,
|
|
3117
3142
|
messageId: this.getAttribute("message-id")
|
|
3118
3143
|
};
|
|
3119
|
-
const announced = this
|
|
3120
|
-
bubbles: true,
|
|
3121
|
-
composed: true,
|
|
3122
|
-
cancelable: true,
|
|
3123
|
-
detail
|
|
3124
|
-
}));
|
|
3144
|
+
const announced = dispatchChatEvent(this, "aparte-link-click", detail, { cancelable: true });
|
|
3125
3145
|
if (!announced) event.preventDefault();
|
|
3126
3146
|
};
|
|
3127
3147
|
/**
|
|
@@ -3382,11 +3402,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3382
3402
|
role: this._role,
|
|
3383
3403
|
targetId: this._resolveTargetId()
|
|
3384
3404
|
};
|
|
3385
|
-
this
|
|
3386
|
-
bubbles: true,
|
|
3387
|
-
composed: true,
|
|
3388
|
-
detail
|
|
3389
|
-
}));
|
|
3405
|
+
dispatchChatEvent(this, "aparte-action", detail);
|
|
3390
3406
|
this._cfg.getActions("bubble").find((x) => x.id === actionId)?.onClick?.(e);
|
|
3391
3407
|
return;
|
|
3392
3408
|
}
|
|
@@ -3442,11 +3458,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3442
3458
|
const value = action2 === "feedback-positive" ? "positive" : "negative";
|
|
3443
3459
|
btn.setAttribute("data-submitted", "");
|
|
3444
3460
|
const detail = { messageId, value };
|
|
3445
|
-
this
|
|
3446
|
-
bubbles: true,
|
|
3447
|
-
composed: true,
|
|
3448
|
-
detail
|
|
3449
|
-
}));
|
|
3461
|
+
dispatchChatEvent(this, "aparte-feedback", detail);
|
|
3450
3462
|
if (value === "negative") this._askFeedbackReason(messageId);
|
|
3451
3463
|
else this.querySelector(".aparte-feedback-reasons")?.remove();
|
|
3452
3464
|
break;
|
|
@@ -3457,11 +3469,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3457
3469
|
messageId,
|
|
3458
3470
|
usage: this._usage ?? void 0
|
|
3459
3471
|
};
|
|
3460
|
-
this
|
|
3461
|
-
bubbles: true,
|
|
3462
|
-
composed: true,
|
|
3463
|
-
detail
|
|
3464
|
-
}));
|
|
3472
|
+
dispatchChatEvent(this, "aparte-message-info", detail);
|
|
3465
3473
|
break;
|
|
3466
3474
|
}
|
|
3467
3475
|
}
|
|
@@ -3542,14 +3550,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3542
3550
|
}
|
|
3543
3551
|
}
|
|
3544
3552
|
_resolveTargetId() {
|
|
3545
|
-
|
|
3546
|
-
while (el2) {
|
|
3547
|
-
const tag = el2.tagName?.toLowerCase();
|
|
3548
|
-
const isHost = tag === "aparte-chat" || el2.hasAttribute?.("data-aparte-chat");
|
|
3549
|
-
if (isHost && el2.id) return el2.id;
|
|
3550
|
-
el2 = el2.parentElement;
|
|
3551
|
-
}
|
|
3552
|
-
return void 0;
|
|
3553
|
+
return chatIdOf(this);
|
|
3553
3554
|
}
|
|
3554
3555
|
// ─────────────────────────────────────────────────────────────────────────
|
|
3555
3556
|
// Utilities
|
|
@@ -3788,11 +3789,11 @@ function markDerivedSegments(message) {
|
|
|
3788
3789
|
function hasDerivedSegments(message) {
|
|
3789
3790
|
return message[APARTE_DERIVED_SEGMENTS] === true;
|
|
3790
3791
|
}
|
|
3791
|
-
function longDate(
|
|
3792
|
+
function longDate(at2, tag) {
|
|
3792
3793
|
try {
|
|
3793
|
-
return new Intl.DateTimeFormat(tag || void 0, { dateStyle: "long" }).format(
|
|
3794
|
+
return new Intl.DateTimeFormat(tag || void 0, { dateStyle: "long" }).format(at2);
|
|
3794
3795
|
} catch {
|
|
3795
|
-
return
|
|
3796
|
+
return at2.toDateString();
|
|
3796
3797
|
}
|
|
3797
3798
|
}
|
|
3798
3799
|
class AparteChatViewport extends HTMLElement {
|
|
@@ -4039,6 +4040,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4039
4040
|
else container.removeAttribute("dir");
|
|
4040
4041
|
}
|
|
4041
4042
|
disconnectedCallback() {
|
|
4043
|
+
this._chatId = void 0;
|
|
4042
4044
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
4043
4045
|
if (this._boundResetHandler) {
|
|
4044
4046
|
window.removeEventListener("aparte-reset", this._boundResetHandler);
|
|
@@ -4121,14 +4123,17 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4121
4123
|
...stampSegmentActivity(segment)
|
|
4122
4124
|
};
|
|
4123
4125
|
}
|
|
4124
|
-
this.
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
detail: { messageId, segmentId, content: chunk, append: true }
|
|
4128
|
-
}));
|
|
4126
|
+
const targetId = this._chatIdOnce();
|
|
4127
|
+
const detail = targetId === void 0 ? { messageId, segmentId, content: chunk, append: true } : { messageId, segmentId, content: chunk, append: true, targetId };
|
|
4128
|
+
this.dispatchEvent(new CustomEvent("aparte-segment-update", { bubbles: true, composed: true, detail }));
|
|
4129
4129
|
this._notifyBubble(messageId, "appendToSegment", chunk, segmentId);
|
|
4130
4130
|
this._autoScroll();
|
|
4131
4131
|
}
|
|
4132
|
+
/** The chat this viewport is in, while it stays connected — see `appendToSegment`. */
|
|
4133
|
+
_chatId;
|
|
4134
|
+
_chatIdOnce() {
|
|
4135
|
+
return this._chatId ??= chatIdOf(this);
|
|
4136
|
+
}
|
|
4132
4137
|
/**
|
|
4133
4138
|
* The active (head) message id — the target of `AparteClient`'s 1-argument
|
|
4134
4139
|
* streaming convention (`addSegment(segment)`, `updateSegment(segmentId,
|
|
@@ -4723,21 +4728,21 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4723
4728
|
const on = cfg.getDateSeparators();
|
|
4724
4729
|
if (!on && !this.querySelector("aparte-chat-bubble[data-date]")) return;
|
|
4725
4730
|
const now = /* @__PURE__ */ new Date();
|
|
4726
|
-
const dayOf = (
|
|
4731
|
+
const dayOf = (at2) => new Date(at2.getFullYear(), at2.getMonth(), at2.getDate()).getTime();
|
|
4727
4732
|
const today = dayOf(now);
|
|
4728
4733
|
let previous = null;
|
|
4729
4734
|
this.querySelectorAll("aparte-chat-bubble").forEach((bubble) => {
|
|
4730
4735
|
const raw = Number(bubble.getAttribute("timestamp"));
|
|
4731
|
-
const
|
|
4732
|
-
const day =
|
|
4733
|
-
const starts = on &&
|
|
4736
|
+
const at2 = raw ? new Date(raw) : null;
|
|
4737
|
+
const day = at2 ? dayOf(at2) : null;
|
|
4738
|
+
const starts = on && at2 && day !== previous;
|
|
4734
4739
|
if (day !== null) previous = day;
|
|
4735
|
-
if (!starts || !
|
|
4740
|
+
if (!starts || !at2) {
|
|
4736
4741
|
if (bubble.hasAttribute("data-date")) bubble.removeAttribute("data-date");
|
|
4737
4742
|
return;
|
|
4738
4743
|
}
|
|
4739
4744
|
const elapsed = Math.round((today - day) / 864e5);
|
|
4740
|
-
const label = elapsed === 0 ? cfg.t("conversationGroupToday") : elapsed === 1 ? cfg.t("conversationGroupYesterday") : longDate(
|
|
4745
|
+
const label = elapsed === 0 ? cfg.t("conversationGroupToday") : elapsed === 1 ? cfg.t("conversationGroupYesterday") : longDate(at2, cfg.getLocale().tag);
|
|
4741
4746
|
if (bubble.getAttribute("data-date") !== label) bubble.setAttribute("data-date", label);
|
|
4742
4747
|
});
|
|
4743
4748
|
}
|
|
@@ -4787,11 +4792,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4787
4792
|
}
|
|
4788
4793
|
_dispatchPathChanged(messages, siblings) {
|
|
4789
4794
|
const detail = { messages, siblings };
|
|
4790
|
-
this
|
|
4791
|
-
bubbles: true,
|
|
4792
|
-
composed: true,
|
|
4793
|
-
detail
|
|
4794
|
-
}));
|
|
4795
|
+
dispatchChatEvent(this, "aparte-path-changed", detail);
|
|
4795
4796
|
}
|
|
4796
4797
|
_autoScroll() {
|
|
4797
4798
|
if (this._isAutoScrollEnabled) {
|
|
@@ -5638,6 +5639,7 @@ class AparteComposer extends HTMLElement {
|
|
|
5638
5639
|
this._offTypeToFocus = null;
|
|
5639
5640
|
}
|
|
5640
5641
|
attributeChangedCallback(name, _old, value) {
|
|
5642
|
+
if (_old === value) return;
|
|
5641
5643
|
if (name === "disabled") {
|
|
5642
5644
|
this._emit("disabled-change", { disabled: value !== null });
|
|
5643
5645
|
}
|
|
@@ -6001,11 +6003,7 @@ class AparteComposer extends HTMLElement {
|
|
|
6001
6003
|
_emit(event, payload) {
|
|
6002
6004
|
this._listeners.get(event)?.forEach((cb) => cb(payload));
|
|
6003
6005
|
if (AparteComposer._STATE_EVENTS.has(event)) {
|
|
6004
|
-
this
|
|
6005
|
-
bubbles: true,
|
|
6006
|
-
composed: true,
|
|
6007
|
-
detail: { state: this.getState(), composer: this }
|
|
6008
|
-
}));
|
|
6006
|
+
dispatchChatEvent(this, "aparte-composer-change", { state: this.getState(), composer: this });
|
|
6009
6007
|
}
|
|
6010
6008
|
}
|
|
6011
6009
|
/** @internal The composer parts' own bus. From outside, listen for `aparte-composer-change`. */
|
|
@@ -6048,16 +6046,7 @@ class AparteComposer extends HTMLElement {
|
|
|
6048
6046
|
console.warn(`[aparte-composer] this composer belongs to no chat while the page has several: give it target="<chat id>" or place it under a chat host with an id, or it will answer to every chat's events.`);
|
|
6049
6047
|
}
|
|
6050
6048
|
_ownTargetId() {
|
|
6051
|
-
|
|
6052
|
-
if (attr) return attr;
|
|
6053
|
-
let el2 = this.parentElement;
|
|
6054
|
-
while (el2) {
|
|
6055
|
-
const tag = el2.tagName?.toLowerCase();
|
|
6056
|
-
const isHost = tag === "aparte-chat" || el2.hasAttribute?.("data-aparte-chat");
|
|
6057
|
-
if (isHost && el2.id) return el2.id;
|
|
6058
|
-
el2 = el2.parentElement;
|
|
6059
|
-
}
|
|
6060
|
-
return void 0;
|
|
6049
|
+
return chatIdOf(this);
|
|
6061
6050
|
}
|
|
6062
6051
|
/**
|
|
6063
6052
|
* The message this composer's turn is writing, when the event that started it said.
|
|
@@ -6232,6 +6221,7 @@ class AparteComposerInput extends HTMLElement {
|
|
|
6232
6221
|
this._unsubscribes = [];
|
|
6233
6222
|
}
|
|
6234
6223
|
attributeChangedCallback(name, _old, value) {
|
|
6224
|
+
if (_old === value) return;
|
|
6235
6225
|
if (name === "placeholder") this._updatePlaceholder();
|
|
6236
6226
|
if (name === "max-height") this._maxHeight = parseInt(value || "200", 10);
|
|
6237
6227
|
if (name === "min-height") this._minHeight = parseInt(value || "44", 10);
|
|
@@ -6844,11 +6834,7 @@ class AparteComposerAttachments extends HTMLElement {
|
|
|
6844
6834
|
img.setAttribute("tabindex", "0");
|
|
6845
6835
|
img.setAttribute("aria-label", images[i2]?.name ?? "");
|
|
6846
6836
|
const open = () => {
|
|
6847
|
-
this
|
|
6848
|
-
bubbles: true,
|
|
6849
|
-
composed: true,
|
|
6850
|
-
detail: { url: img.src, name: images[i2]?.name ?? "", type: images[i2]?.type ?? "" }
|
|
6851
|
-
}));
|
|
6837
|
+
dispatchChatEvent(this, "aparte-attachment-preview", { url: img.src, name: images[i2]?.name ?? "", type: images[i2]?.type ?? "" });
|
|
6852
6838
|
};
|
|
6853
6839
|
img.addEventListener("click", open);
|
|
6854
6840
|
img.addEventListener("keydown", (e) => {
|
|
@@ -6893,6 +6879,7 @@ class AparteComposerAddAttachment extends HTMLElement {
|
|
|
6893
6879
|
this._unsubscribes = [];
|
|
6894
6880
|
}
|
|
6895
6881
|
attributeChangedCallback(name, _old, value) {
|
|
6882
|
+
if (_old === value) return;
|
|
6896
6883
|
if (name === "disabled" && this._button) {
|
|
6897
6884
|
this._button.disabled = value !== null;
|
|
6898
6885
|
}
|
|
@@ -7024,6 +7011,7 @@ class AparteComposerAction extends HTMLElement {
|
|
|
7024
7011
|
this._unsubscribes = [];
|
|
7025
7012
|
}
|
|
7026
7013
|
attributeChangedCallback(name, _old, value) {
|
|
7014
|
+
if (_old === value) return;
|
|
7027
7015
|
if (!this._button) return;
|
|
7028
7016
|
if (name === "disabled") {
|
|
7029
7017
|
this._button.disabled = value !== null;
|
|
@@ -7068,11 +7056,7 @@ class AparteComposerAction extends HTMLElement {
|
|
|
7068
7056
|
);
|
|
7069
7057
|
}
|
|
7070
7058
|
_handleClick(_e) {
|
|
7071
|
-
this
|
|
7072
|
-
bubbles: true,
|
|
7073
|
-
composed: true,
|
|
7074
|
-
detail: { actionId: this.getAttribute("action-id") ?? "", composer: this._getRoot() }
|
|
7075
|
-
}));
|
|
7059
|
+
dispatchChatEvent(this, "aparte-action-click", { actionId: this.getAttribute("action-id") ?? "", composer: this._getRoot() });
|
|
7076
7060
|
}
|
|
7077
7061
|
_resolveIcon(icon) {
|
|
7078
7062
|
if (!icon) return "";
|
|
@@ -7285,14 +7269,77 @@ class AparteConversationList extends HTMLElement {
|
|
|
7285
7269
|
if (status === "waiting") return this._t("conversationWaiting");
|
|
7286
7270
|
return "";
|
|
7287
7271
|
}
|
|
7288
|
-
/**
|
|
7272
|
+
/**
|
|
7273
|
+
* Set the list of conversations to display. Triggers a re-render — held while a row's menu is
|
|
7274
|
+
* open or a title is being renamed, and run when that ends.
|
|
7275
|
+
*
|
|
7276
|
+
* A host assigns this on every manager change, and a wrapper on every render of the app around
|
|
7277
|
+
* it, often the very array the list holds (mutated in place, so it is drawn again rather than
|
|
7278
|
+
* skipped). A render replaces the rows, and with them the open menu and the field being typed
|
|
7279
|
+
* in: those are the reader's, so the rows wait for them, as they wait for a press to land.
|
|
7280
|
+
*/
|
|
7289
7281
|
set conversations(items) {
|
|
7290
7282
|
this._conversations = Array.isArray(items) ? items : [];
|
|
7283
|
+
this._renderUnlessHeld();
|
|
7284
|
+
}
|
|
7285
|
+
/** A render held by an open menu or a rename (see `conversations`): run once it is over. */
|
|
7286
|
+
_renderAfterMenu = false;
|
|
7287
|
+
/**
|
|
7288
|
+
* The one way a render asked from outside runs: held while a row menu is open or a title is
|
|
7289
|
+
* being renamed, drawn once that ends. A press's deferred render goes through it too, so a
|
|
7290
|
+
* rename started by the click that closed a menu is not wiped by the render that menu held.
|
|
7291
|
+
*/
|
|
7292
|
+
_renderUnlessHeld() {
|
|
7293
|
+
if (this._renaming && !this._renaming.done || this.querySelector("[data-menu-for]")) {
|
|
7294
|
+
this._renderAfterMenu = true;
|
|
7295
|
+
return;
|
|
7296
|
+
}
|
|
7297
|
+
this._render();
|
|
7298
|
+
}
|
|
7299
|
+
_renderHeld() {
|
|
7300
|
+
if (!this._renderAfterMenu || !this.isConnected) return;
|
|
7301
|
+
this._renderAfterMenu = false;
|
|
7291
7302
|
this._render();
|
|
7292
7303
|
}
|
|
7293
7304
|
get conversations() {
|
|
7294
7305
|
return this._conversations;
|
|
7295
7306
|
}
|
|
7307
|
+
_renderMeta = null;
|
|
7308
|
+
/**
|
|
7309
|
+
* Draws something of the app's after a row's title — a shared mark, a count, a status
|
|
7310
|
+
* pill — and returns `null` for a row with nothing to say. An element goes in as it is;
|
|
7311
|
+
* a string is text, never markup. It sits BESIDE the title button, not inside it, so it
|
|
7312
|
+
* may hold a button or a link of its own, with its own accessible name. Setting it draws
|
|
7313
|
+
* the rows again, held like `conversations` while a menu is open or a title is being
|
|
7314
|
+
* renamed; the same function handed again draws nothing. It is read on every render after that.
|
|
7315
|
+
*/
|
|
7316
|
+
set renderMeta(fn) {
|
|
7317
|
+
const next = typeof fn === "function" ? fn : null;
|
|
7318
|
+
if (next === this._renderMeta) return;
|
|
7319
|
+
this._renderMeta = next;
|
|
7320
|
+
this._renderUnlessHeld();
|
|
7321
|
+
}
|
|
7322
|
+
get renderMeta() {
|
|
7323
|
+
return this._renderMeta;
|
|
7324
|
+
}
|
|
7325
|
+
/** Puts what `renderMeta` returns after each row's title. Rows are strings, so this runs on the built DOM. */
|
|
7326
|
+
_applyMeta() {
|
|
7327
|
+
const draw2 = this._renderMeta;
|
|
7328
|
+
if (!draw2) return;
|
|
7329
|
+
const byId = new Map(this._conversations.map((c2) => [c2.id, c2]));
|
|
7330
|
+
for (const row of this.querySelectorAll("[data-conv-id]")) {
|
|
7331
|
+
const item = byId.get(row.dataset["convId"] ?? "");
|
|
7332
|
+
const select = row.querySelector(".aparte-conv-item__select");
|
|
7333
|
+
if (!item || !select) continue;
|
|
7334
|
+
const made = draw2(item);
|
|
7335
|
+
if (made === null || made === void 0 || made === "") continue;
|
|
7336
|
+
const slot = document.createElement("span");
|
|
7337
|
+
slot.className = "aparte-conv-item__meta";
|
|
7338
|
+
if (typeof made === "string") slot.textContent = made;
|
|
7339
|
+
else slot.append(made);
|
|
7340
|
+
select.after(slot);
|
|
7341
|
+
}
|
|
7342
|
+
}
|
|
7296
7343
|
// ─── Rendering ────────────────────────────────────────────────────────
|
|
7297
7344
|
/**
|
|
7298
7345
|
* A press holds every render until its click has landed. The host re-assigns
|
|
@@ -7319,7 +7366,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7319
7366
|
this._pressed = false;
|
|
7320
7367
|
if (!this._renderAfterPress) return;
|
|
7321
7368
|
this._renderAfterPress = false;
|
|
7322
|
-
if (this.isConnected) this.
|
|
7369
|
+
if (this.isConnected) this._renderUnlessHeld();
|
|
7323
7370
|
}, 0);
|
|
7324
7371
|
};
|
|
7325
7372
|
/** The name this element last wrote, so one the app wrote — before or after connect — is left alone. */
|
|
@@ -7334,6 +7381,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7334
7381
|
this._renderAfterPress = true;
|
|
7335
7382
|
return;
|
|
7336
7383
|
}
|
|
7384
|
+
this._renderAfterMenu = false;
|
|
7337
7385
|
this._releaseMenus();
|
|
7338
7386
|
this._renaming = null;
|
|
7339
7387
|
const focused2 = activeElementIn(this);
|
|
@@ -7364,6 +7412,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7364
7412
|
} else {
|
|
7365
7413
|
this.innerHTML = groups;
|
|
7366
7414
|
}
|
|
7415
|
+
this._applyMeta();
|
|
7367
7416
|
this._applyFilter();
|
|
7368
7417
|
this._wireMenus();
|
|
7369
7418
|
if (!restore) return;
|
|
@@ -7431,7 +7480,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7431
7480
|
*/
|
|
7432
7481
|
_groups() {
|
|
7433
7482
|
const items = this._conversations;
|
|
7434
|
-
if (this.hasAttribute("flat") || !items.some((c2) => typeof c2.updatedAt === "number")) {
|
|
7483
|
+
if (this.hasAttribute("flat") || !items.some((c2) => typeof c2.updatedAt === "number" || c2.group)) {
|
|
7435
7484
|
return [{ key: "all", label: null, items }];
|
|
7436
7485
|
}
|
|
7437
7486
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -7446,22 +7495,32 @@ class AparteConversationList extends HTMLElement {
|
|
|
7446
7495
|
}
|
|
7447
7496
|
g.items.push(item);
|
|
7448
7497
|
};
|
|
7498
|
+
const named = /* @__PURE__ */ new Map();
|
|
7449
7499
|
for (const c2 of items) {
|
|
7500
|
+
if (c2.group) {
|
|
7501
|
+
let g = named.get(c2.group.key);
|
|
7502
|
+
if (!g) {
|
|
7503
|
+
g = { key: c2.group.key, label: c2.group.label, items: [] };
|
|
7504
|
+
named.set(c2.group.key, g);
|
|
7505
|
+
}
|
|
7506
|
+
g.items.push(c2);
|
|
7507
|
+
continue;
|
|
7508
|
+
}
|
|
7450
7509
|
if (c2.pinnedAt) {
|
|
7451
7510
|
push("pinned", this._t("conversationGroupPinned"), c2);
|
|
7452
7511
|
continue;
|
|
7453
7512
|
}
|
|
7454
|
-
const
|
|
7455
|
-
if (typeof
|
|
7513
|
+
const at2 = c2.updatedAt;
|
|
7514
|
+
if (typeof at2 !== "number") {
|
|
7456
7515
|
push("undated", null, c2);
|
|
7457
7516
|
continue;
|
|
7458
7517
|
}
|
|
7459
|
-
if (
|
|
7460
|
-
else if (
|
|
7461
|
-
else if (
|
|
7462
|
-
else if (
|
|
7518
|
+
if (at2 >= today) push("today", this._t("conversationGroupToday"), c2);
|
|
7519
|
+
else if (at2 >= today - DAY) push("yesterday", this._t("conversationGroupYesterday"), c2);
|
|
7520
|
+
else if (at2 >= today - 7 * DAY) push("week", this._t("conversationGroupWeek"), c2);
|
|
7521
|
+
else if (at2 >= today - 30 * DAY) push("month", this._t("conversationGroupMonth"), c2);
|
|
7463
7522
|
else {
|
|
7464
|
-
const d2 = new Date(
|
|
7523
|
+
const d2 = new Date(at2);
|
|
7465
7524
|
const sameYear = d2.getFullYear() === now.getFullYear();
|
|
7466
7525
|
const raw = new Intl.DateTimeFormat(tag, sameYear ? { month: "long" } : { month: "long", year: "numeric" }).format(d2);
|
|
7467
7526
|
const label = raw.charAt(0).toLocaleUpperCase(tag) + raw.slice(1);
|
|
@@ -7471,7 +7530,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
7471
7530
|
const fixed = ["pinned", "today", "yesterday", "week", "month"].map((k2) => buckets.get(k2)).filter((g) => !!g);
|
|
7472
7531
|
const months = [...buckets.keys()].filter((k2) => k2.startsWith("m-")).sort((a2, b3) => b3.localeCompare(a2)).map((k2) => buckets.get(k2));
|
|
7473
7532
|
const undated = buckets.get("undated");
|
|
7474
|
-
return [...fixed, ...months, ...undated ? [undated] : []];
|
|
7533
|
+
return [...named.values(), ...fixed, ...months, ...undated ? [undated] : []];
|
|
7475
7534
|
}
|
|
7476
7535
|
_renderGroup(group) {
|
|
7477
7536
|
const rows = group.items.map((conv) => this._renderItem(conv)).join("");
|
|
@@ -7596,7 +7655,10 @@ class AparteConversationList extends HTMLElement {
|
|
|
7596
7655
|
margin: VIEWPORT_MARGIN,
|
|
7597
7656
|
align: "end",
|
|
7598
7657
|
onOpen: () => this._fillMenu(row, menu),
|
|
7599
|
-
onClose: () =>
|
|
7658
|
+
onClose: () => {
|
|
7659
|
+
menu.remove();
|
|
7660
|
+
this._renderHeld();
|
|
7661
|
+
}
|
|
7600
7662
|
}));
|
|
7601
7663
|
}
|
|
7602
7664
|
const context = this._contextMenu ??= this._newMenu();
|
|
@@ -7608,7 +7670,10 @@ class AparteConversationList extends HTMLElement {
|
|
|
7608
7670
|
if (!row || !this.contains(row) || target.closest("[data-rename-id], [data-menu-for]")) return false;
|
|
7609
7671
|
return this._fillMenu(row, context);
|
|
7610
7672
|
},
|
|
7611
|
-
onClose: () =>
|
|
7673
|
+
onClose: () => {
|
|
7674
|
+
context.remove();
|
|
7675
|
+
this._renderHeld();
|
|
7676
|
+
}
|
|
7612
7677
|
}));
|
|
7613
7678
|
}
|
|
7614
7679
|
/** Closes whichever menu is open, without moving the focus, and stops them all. */
|
|
@@ -7962,7 +8027,8 @@ class AparteSuggestions extends HTMLElement {
|
|
|
7962
8027
|
this._stopHolding();
|
|
7963
8028
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
7964
8029
|
}
|
|
7965
|
-
attributeChangedCallback(name) {
|
|
8030
|
+
attributeChangedCallback(name, previous, value) {
|
|
8031
|
+
if (previous === value) return;
|
|
7966
8032
|
if (!this.isConnected) return;
|
|
7967
8033
|
if (name === "suggestions") {
|
|
7968
8034
|
this._readAttribute();
|
|
@@ -8088,6 +8154,11 @@ class AparteSuggestions extends HTMLElement {
|
|
|
8088
8154
|
}
|
|
8089
8155
|
}
|
|
8090
8156
|
_render() {
|
|
8157
|
+
const was = this.querySelector(".aparte-suggestions");
|
|
8158
|
+
const chips = was ? [...was.querySelectorAll(".aparte-suggestion")] : [];
|
|
8159
|
+
const focused2 = chips.findIndex((chip) => chip === document.activeElement);
|
|
8160
|
+
const focusedText = focused2 >= 0 ? chips[focused2].textContent : null;
|
|
8161
|
+
const scroll = was?.scrollLeft ?? 0;
|
|
8091
8162
|
this.replaceChildren();
|
|
8092
8163
|
if (this._suggestions.length === 0) {
|
|
8093
8164
|
this.setAttribute("data-empty", "");
|
|
@@ -8109,6 +8180,10 @@ class AparteSuggestions extends HTMLElement {
|
|
|
8109
8180
|
row.appendChild(button2);
|
|
8110
8181
|
}
|
|
8111
8182
|
this.appendChild(row);
|
|
8183
|
+
row.scrollLeft = scroll;
|
|
8184
|
+
if (focused2 < 0) return;
|
|
8185
|
+
const next = [...row.children];
|
|
8186
|
+
(next.find((chip) => chip.textContent === focusedText) ?? next[Math.min(focused2, next.length - 1)])?.focus();
|
|
8112
8187
|
}
|
|
8113
8188
|
_sending = false;
|
|
8114
8189
|
_sendingTimer;
|
|
@@ -8129,13 +8204,7 @@ class AparteSuggestions extends HTMLElement {
|
|
|
8129
8204
|
};
|
|
8130
8205
|
/** The chat the sending composer belongs to: its `target`, else the id of the chat host above it. */
|
|
8131
8206
|
_ownChatId() {
|
|
8132
|
-
|
|
8133
|
-
const attr = composer?.getAttribute("target");
|
|
8134
|
-
if (attr) return attr;
|
|
8135
|
-
for (let el2 = composer?.parentElement ?? null; el2; el2 = el2.parentElement) {
|
|
8136
|
-
if ((el2.tagName.toLowerCase() === "aparte-chat" || el2.hasAttribute("data-aparte-chat")) && el2.id) return el2.id;
|
|
8137
|
-
}
|
|
8138
|
-
return void 0;
|
|
8207
|
+
return chatIdOf(this._composer);
|
|
8139
8208
|
}
|
|
8140
8209
|
/** A chip sent: no other chip sends until the turn has started, or a second has passed without one. */
|
|
8141
8210
|
_holdUntilStreaming() {
|
|
@@ -8146,12 +8215,7 @@ class AparteSuggestions extends HTMLElement {
|
|
|
8146
8215
|
}
|
|
8147
8216
|
_activate(suggestion) {
|
|
8148
8217
|
const detail = { label: labelOf(suggestion), prompt: promptOf(suggestion) };
|
|
8149
|
-
const proceed = this
|
|
8150
|
-
detail,
|
|
8151
|
-
bubbles: true,
|
|
8152
|
-
composed: true,
|
|
8153
|
-
cancelable: true
|
|
8154
|
-
}));
|
|
8218
|
+
const proceed = dispatchChatEvent(this, "aparte-suggestion", detail, { cancelable: true });
|
|
8155
8219
|
if (!proceed) return;
|
|
8156
8220
|
const composer = this._composer ?? this._resolveComposer();
|
|
8157
8221
|
if (!composer) {
|
|
@@ -8419,7 +8483,8 @@ class AparteContext extends HTMLElement {
|
|
|
8419
8483
|
this.removeEventListener("keydown", this._onKeydown);
|
|
8420
8484
|
this._stopListeningWhileOpen();
|
|
8421
8485
|
}
|
|
8422
|
-
attributeChangedCallback(name) {
|
|
8486
|
+
attributeChangedCallback(name, previous, value) {
|
|
8487
|
+
if (previous === value) return;
|
|
8423
8488
|
if (name === "used") {
|
|
8424
8489
|
const n2 = Number(this.getAttribute("used"));
|
|
8425
8490
|
this._used = this.hasAttribute("used") && Number.isFinite(n2) && n2 >= 0 ? n2 : null;
|
|
@@ -8445,15 +8510,7 @@ class AparteContext extends HTMLElement {
|
|
|
8445
8510
|
}
|
|
8446
8511
|
/** The chat this gauge watches: `target`, else the chat host above it — the composer's rule. */
|
|
8447
8512
|
_ownTargetId() {
|
|
8448
|
-
|
|
8449
|
-
if (attr) return attr;
|
|
8450
|
-
let node = this.parentElement;
|
|
8451
|
-
while (node) {
|
|
8452
|
-
const isHost = node.tagName.toLowerCase() === "aparte-chat" || node.hasAttribute("data-aparte-chat");
|
|
8453
|
-
if (isHost && node.id) return node.id;
|
|
8454
|
-
node = node.parentElement;
|
|
8455
|
-
}
|
|
8456
|
-
return void 0;
|
|
8513
|
+
return chatIdOf(this);
|
|
8457
8514
|
}
|
|
8458
8515
|
_isMine(targetId) {
|
|
8459
8516
|
const own = this._ownTargetId();
|
|
@@ -8874,7 +8931,8 @@ class AparteScrollRail extends HTMLElement {
|
|
|
8874
8931
|
this.removeEventListener("focusout", this._onFocusOut);
|
|
8875
8932
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
8876
8933
|
}
|
|
8877
|
-
attributeChangedCallback(name) {
|
|
8934
|
+
attributeChangedCallback(name, previous, value) {
|
|
8935
|
+
if (previous === value) return;
|
|
8878
8936
|
if (!this.isConnected) return;
|
|
8879
8937
|
if (name === "target") this._attach();
|
|
8880
8938
|
else this._rebuild();
|
|
@@ -8909,8 +8967,8 @@ class AparteScrollRail extends HTMLElement {
|
|
|
8909
8967
|
}
|
|
8910
8968
|
continue;
|
|
8911
8969
|
}
|
|
8912
|
-
const
|
|
8913
|
-
const owner =
|
|
8970
|
+
const at2 = record.target instanceof Element ? record.target : record.target.parentElement;
|
|
8971
|
+
const owner = at2?.closest("aparte-chat-bubble");
|
|
8914
8972
|
if (owner) {
|
|
8915
8973
|
this._excerpts.delete(owner);
|
|
8916
8974
|
if (this._ticked(owner)) this._queueRelabel(owner);
|
|
@@ -9069,7 +9127,7 @@ class AparteScrollRail extends HTMLElement {
|
|
|
9069
9127
|
item.remove();
|
|
9070
9128
|
existing.delete(id);
|
|
9071
9129
|
}
|
|
9072
|
-
let
|
|
9130
|
+
let at2 = list.firstElementChild;
|
|
9073
9131
|
for (const bubble of bubbles) {
|
|
9074
9132
|
const id = bubble.getAttribute("message-id");
|
|
9075
9133
|
let item = existing.get(id);
|
|
@@ -9093,8 +9151,8 @@ class AparteScrollRail extends HTMLElement {
|
|
|
9093
9151
|
} else {
|
|
9094
9152
|
tick.removeAttribute("aria-current");
|
|
9095
9153
|
}
|
|
9096
|
-
if (item ===
|
|
9097
|
-
else list.insertBefore(item,
|
|
9154
|
+
if (item === at2) at2 = at2.nextElementSibling;
|
|
9155
|
+
else list.insertBefore(item, at2);
|
|
9098
9156
|
}
|
|
9099
9157
|
const dropped = this._currentId !== null && !known.has(this._currentId);
|
|
9100
9158
|
if (dropped) this._currentId = null;
|
|
@@ -9495,6 +9553,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9495
9553
|
/** The control that last opened the drawer, to hand the focus back to. */
|
|
9496
9554
|
_opener = null;
|
|
9497
9555
|
_lastCollapsed = null;
|
|
9556
|
+
_lastRail = false;
|
|
9498
9557
|
/**
|
|
9499
9558
|
* `connectedCallback` has run and the element knows what its markup asked for.
|
|
9500
9559
|
*
|
|
@@ -9543,6 +9602,14 @@ class AparteSidebar extends HTMLElement {
|
|
|
9543
9602
|
set collapsed(value) {
|
|
9544
9603
|
this.toggleAttribute("collapsed", presenceOn(value));
|
|
9545
9604
|
}
|
|
9605
|
+
/**
|
|
9606
|
+
* A rail is a column folded to `--aparte-sidebar-rail-width` that stays in the flow and
|
|
9607
|
+
* stays usable (`collapsed="rail"`). Only in the flow: a drawer is open or closed, and a
|
|
9608
|
+
* closed one is off-screen whatever its attribute says.
|
|
9609
|
+
*/
|
|
9610
|
+
_rail() {
|
|
9611
|
+
return this.getAttribute("collapsed") === "rail" && !this.drawer;
|
|
9612
|
+
}
|
|
9546
9613
|
/** True while the sidebar is a drawer: the window is under the breakpoint, or it is in a floating chat's card. */
|
|
9547
9614
|
get drawer() {
|
|
9548
9615
|
return this.hasAttribute("data-drawer");
|
|
@@ -9573,6 +9640,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9573
9640
|
this._watchBreakpoint();
|
|
9574
9641
|
this._syncHidden();
|
|
9575
9642
|
this._lastCollapsed = this.collapsed;
|
|
9643
|
+
this._lastRail = this._rail();
|
|
9576
9644
|
if (!this.id) this.id = `aparte-sidebar-${++sidebarIdSeq}`;
|
|
9577
9645
|
this._syncToggles();
|
|
9578
9646
|
this._ready = true;
|
|
@@ -9660,7 +9728,15 @@ class AparteSidebar extends HTMLElement {
|
|
|
9660
9728
|
}
|
|
9661
9729
|
if (name !== "collapsed") return;
|
|
9662
9730
|
const collapsed = this.collapsed;
|
|
9663
|
-
|
|
9731
|
+
const rail = this._rail();
|
|
9732
|
+
if (collapsed === this._lastCollapsed && rail === this._lastRail) {
|
|
9733
|
+
return;
|
|
9734
|
+
}
|
|
9735
|
+
this._lastRail = rail;
|
|
9736
|
+
if (collapsed === this._lastCollapsed) {
|
|
9737
|
+
this._syncHidden();
|
|
9738
|
+
return;
|
|
9739
|
+
}
|
|
9664
9740
|
this._lastCollapsed = collapsed;
|
|
9665
9741
|
if (!this._auto && !this.drawer) this._closedByHost = collapsed;
|
|
9666
9742
|
this._syncScrim();
|
|
@@ -9753,7 +9829,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9753
9829
|
* `<aparte-sidebar inert={busy}>` out of existence. The class docblock says it in prose.
|
|
9754
9830
|
*/
|
|
9755
9831
|
_syncHidden() {
|
|
9756
|
-
if (this.collapsed) {
|
|
9832
|
+
if (this.collapsed && !this._rail()) {
|
|
9757
9833
|
this.toggleAttribute("inert", true);
|
|
9758
9834
|
this.setAttribute("aria-hidden", "true");
|
|
9759
9835
|
this._ownHidden = true;
|
|
@@ -10142,7 +10218,8 @@ class AparteSplit extends HTMLElement {
|
|
|
10142
10218
|
this._keying = false;
|
|
10143
10219
|
this._ready = false;
|
|
10144
10220
|
}
|
|
10145
|
-
attributeChangedCallback(name) {
|
|
10221
|
+
attributeChangedCallback(name, previous, value) {
|
|
10222
|
+
if (previous === value) return;
|
|
10146
10223
|
if (!this._ready) return;
|
|
10147
10224
|
switch (name) {
|
|
10148
10225
|
case "position": {
|
|
@@ -10897,6 +10974,7 @@ class AparteLauncher extends HTMLElement {
|
|
|
10897
10974
|
this._ready = false;
|
|
10898
10975
|
}
|
|
10899
10976
|
attributeChangedCallback(name, previous, value) {
|
|
10977
|
+
if (previous === value) return;
|
|
10900
10978
|
if (!this._ready) return;
|
|
10901
10979
|
if (name === "breakpoint") {
|
|
10902
10980
|
this._watchBreakpoint();
|
|
@@ -11431,68 +11509,71 @@ export {
|
|
|
11431
11509
|
v as attachConfig,
|
|
11432
11510
|
buildApprovalPanel,
|
|
11433
11511
|
buildElicitationPanel,
|
|
11434
|
-
|
|
11435
|
-
z as
|
|
11436
|
-
B as
|
|
11512
|
+
chatIdOf,
|
|
11513
|
+
z as collectRendererStyles,
|
|
11514
|
+
B as contentToText,
|
|
11515
|
+
C as contextConfig,
|
|
11437
11516
|
copyText,
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11517
|
+
E as createAgentStreamRunner,
|
|
11518
|
+
F as createAparteAgentHandler,
|
|
11519
|
+
G as createAparteChatHandler,
|
|
11520
|
+
H as createSegmentList,
|
|
11521
|
+
I as createStreamAdapter,
|
|
11443
11522
|
cssEscape,
|
|
11444
|
-
|
|
11445
|
-
|
|
11523
|
+
J as declineDefaultRenderers,
|
|
11524
|
+
K as defaultSanitizer,
|
|
11446
11525
|
deferHydrationOf,
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11526
|
+
M as defineMountedSegmentRenderer,
|
|
11527
|
+
N as defineMountedToolRenderer,
|
|
11528
|
+
O as detachConfig,
|
|
11529
|
+
dispatchChatEvent,
|
|
11450
11530
|
enhanceContextMenu,
|
|
11451
11531
|
enhanceMenu,
|
|
11452
11532
|
b2 as enhanceTabs,
|
|
11453
11533
|
escapeAttr,
|
|
11454
11534
|
escapeHtml,
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11535
|
+
T as estimateTokens,
|
|
11536
|
+
U as estimateWireTokens,
|
|
11537
|
+
V as filesToAttachments,
|
|
11458
11538
|
formatDuration,
|
|
11459
|
-
|
|
11539
|
+
X as getAllRenderers,
|
|
11460
11540
|
getSegmentRenderer,
|
|
11461
|
-
|
|
11541
|
+
Z as historyFromCheckpoint,
|
|
11462
11542
|
installDefaultRenderersOnce,
|
|
11463
11543
|
installDialogTriggersOnce,
|
|
11464
11544
|
isAwaitingReply,
|
|
11465
|
-
|
|
11545
|
+
a1 as isFormatAdapter,
|
|
11466
11546
|
isSafeUrl,
|
|
11467
11547
|
isSegmentSettled,
|
|
11468
11548
|
measureContext,
|
|
11469
11549
|
onRenderersChange,
|
|
11470
|
-
|
|
11471
|
-
|
|
11550
|
+
a6 as overrideSegmentRenderer,
|
|
11551
|
+
a7 as parseAparteEventStream,
|
|
11472
11552
|
parseMarkdownToSegments,
|
|
11473
11553
|
placeFloating,
|
|
11474
11554
|
pluralize,
|
|
11475
11555
|
populateBubbleFromMessage,
|
|
11476
|
-
|
|
11556
|
+
ab as readableToAsyncIterable,
|
|
11477
11557
|
registerAllComponents,
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11558
|
+
ac as registerDefaultRenderers,
|
|
11559
|
+
ad as registerSegmentRenderer,
|
|
11560
|
+
ae as releaseDeferredHydration,
|
|
11561
|
+
af as renderCitations,
|
|
11562
|
+
ag as renderCodeLanguages,
|
|
11563
|
+
ah as requestUserInput,
|
|
11484
11564
|
resolveConfig,
|
|
11485
11565
|
revokeAttachmentUrls,
|
|
11486
|
-
|
|
11566
|
+
ak as runSubAgent,
|
|
11487
11567
|
runWithConfig,
|
|
11488
|
-
|
|
11568
|
+
am as segmentDuration,
|
|
11489
11569
|
segmentTiming,
|
|
11490
|
-
|
|
11491
|
-
|
|
11570
|
+
ao as setupSuggestionBlocks,
|
|
11571
|
+
ap as startSubAgent,
|
|
11492
11572
|
subscribeConfigChange,
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
uuid
|
|
11573
|
+
ar as toToolCallView,
|
|
11574
|
+
as as toolRefusal,
|
|
11575
|
+
at as unregisterSegmentRenderer,
|
|
11576
|
+
uuid,
|
|
11577
|
+
av as withoutAbandonedTurns
|
|
11497
11578
|
};
|
|
11498
11579
|
//# sourceMappingURL=index.js.map
|