@aparte/core 0.16.9 → 0.16.11
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/README.md +2 -0
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts +89 -9
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +8 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +29 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/conversations/index.d.ts +1 -1
- package/dist/conversations/index.d.ts.map +1 -1
- package/dist/custom-elements.json +9012 -8633
- package/dist/{dialog-triggers-CApC7K1I.js → dialog-triggers-cYGTlfZf.js} +33 -5
- package/dist/dialog-triggers-cYGTlfZf.js.map +1 -0
- package/dist/index.css +56 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +292 -49
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +1 -1
- package/dist/index.node.js.map +1 -1
- package/package.json +2 -2
- package/dist/dialog-triggers-CApC7K1I.js.map +0 -1
|
@@ -3151,9 +3151,24 @@ class AparteConversationManager {
|
|
|
3151
3151
|
_listeners = /* @__PURE__ */ new Set();
|
|
3152
3152
|
_initialized = false;
|
|
3153
3153
|
_retention = null;
|
|
3154
|
+
_titleProvider = null;
|
|
3154
3155
|
constructor(adapter, options) {
|
|
3155
3156
|
this._adapter = adapter;
|
|
3156
3157
|
this._retention = options?.retention ?? null;
|
|
3158
|
+
this._titleProvider = options?.titleProvider ?? null;
|
|
3159
|
+
}
|
|
3160
|
+
// ─── Title provider ─────────────────────────────────────────────────────
|
|
3161
|
+
/**
|
|
3162
|
+
* Replace how a new conversation is titled from its first user message.
|
|
3163
|
+
* `null` restores the default (the message's text). The provider is consulted
|
|
3164
|
+
* once per conversation, on that first message; `updateTitle` is untouched.
|
|
3165
|
+
*/
|
|
3166
|
+
setTitleProvider(provider) {
|
|
3167
|
+
this._titleProvider = provider;
|
|
3168
|
+
}
|
|
3169
|
+
/** The registered title provider, or `null` when the default applies. */
|
|
3170
|
+
getTitleProvider() {
|
|
3171
|
+
return this._titleProvider;
|
|
3157
3172
|
}
|
|
3158
3173
|
// ─── Initialisation ────────────────────────────────────────────────────
|
|
3159
3174
|
/** Load all conversations from the adapter. Call once at app startup. */
|
|
@@ -3229,7 +3244,7 @@ class AparteConversationManager {
|
|
|
3229
3244
|
...conv,
|
|
3230
3245
|
messages: [...conv.messages, msg],
|
|
3231
3246
|
updatedAt: Date.now(),
|
|
3232
|
-
title: isFirstUserMsg ? this.
|
|
3247
|
+
title: isFirstUserMsg ? await this._title(msg) : conv.title
|
|
3233
3248
|
};
|
|
3234
3249
|
this._replace(updated);
|
|
3235
3250
|
await this._adapter.save(updated);
|
|
@@ -3362,10 +3377,23 @@ class AparteConversationManager {
|
|
|
3362
3377
|
}
|
|
3363
3378
|
});
|
|
3364
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* The title of a conversation, decided once, on its first user message: the
|
|
3382
|
+
* provider's answer when one is registered and answers, else the default.
|
|
3383
|
+
*/
|
|
3384
|
+
async _title(msg) {
|
|
3385
|
+
const fallback = this._autoTitle(msg);
|
|
3386
|
+
if (!this._titleProvider) return fallback;
|
|
3387
|
+
try {
|
|
3388
|
+
const title = (await this._titleProvider((msg.content ?? "").trim(), msg)).trim();
|
|
3389
|
+
return title || fallback;
|
|
3390
|
+
} catch (err) {
|
|
3391
|
+
console.warn("[AparteConversationManager] the title provider threw; the default title stands:", err);
|
|
3392
|
+
return fallback;
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3365
3395
|
_autoTitle(msg) {
|
|
3366
|
-
|
|
3367
|
-
const text = typeof raw === "string" ? raw : (raw ?? "").toString();
|
|
3368
|
-
return text.trim() || "New Chat";
|
|
3396
|
+
return (msg.content ?? "").trim() || "New Chat";
|
|
3369
3397
|
}
|
|
3370
3398
|
}
|
|
3371
3399
|
function filesToAttachments(files) {
|
|
@@ -6477,4 +6505,4 @@ export {
|
|
|
6477
6505
|
collectRendererStyles as y,
|
|
6478
6506
|
contentToText as z
|
|
6479
6507
|
};
|
|
6480
|
-
//# sourceMappingURL=dialog-triggers-
|
|
6508
|
+
//# sourceMappingURL=dialog-triggers-cYGTlfZf.js.map
|