@copilotkit/web-components 2.0.0-rc.26 → 2.0.0-rc.27
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/index.umd.js +17 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.cjs +16 -17
- package/dist/threads-drawer/copilotkit-threads-drawer.cjs.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.d.cts.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.d.mts.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.mjs +16 -17
- package/dist/threads-drawer/copilotkit-threads-drawer.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -2212,6 +2212,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2212
2212
|
<circle cx="12" cy="19" r="1.6" />
|
|
2213
2213
|
</svg>
|
|
2214
2214
|
`;
|
|
2215
|
+
/**
|
|
2216
|
+
* Most recent first, by `lastRunAt`, then `updatedAt`, then `createdAt`,
|
|
2217
|
+
* compared as parsed instants. A timestamp that does not parse sorts last, and
|
|
2218
|
+
* ties keep their input order. This is the order of `sortThreadsByRecency` in
|
|
2219
|
+
* `@copilotkit/core` (`packages/core/src/threads.ts`), which sorts the
|
|
2220
|
+
* threads the framework drawers pass in, so the element keeps their order.
|
|
2221
|
+
* Keep the two in step: this package does not depend on core.
|
|
2222
|
+
*/
|
|
2223
|
+
function sortThreadsByRecency(threads) {
|
|
2224
|
+
return [...threads].sort((left, right) => recencyOf(right) - recencyOf(left));
|
|
2225
|
+
}
|
|
2226
|
+
function recencyOf(thread) {
|
|
2227
|
+
var _ref, _thread$lastRunAt;
|
|
2228
|
+
const time = Date.parse((_ref = (_thread$lastRunAt = thread.lastRunAt) !== null && _thread$lastRunAt !== void 0 ? _thread$lastRunAt : thread.updatedAt) !== null && _ref !== void 0 ? _ref : thread.createdAt);
|
|
2229
|
+
return Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;
|
|
2230
|
+
}
|
|
2215
2231
|
/**
|
|
2216
2232
|
* `<copilotkit-threads-drawer>` — a public, self-contained, controlled, framework-agnostic
|
|
2217
2233
|
* threads drawer rendered into a shadow root.
|
|
@@ -2454,24 +2470,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2454
2470
|
* threads; ordering is most-recent-first by `lastRunAt`/`updatedAt`.
|
|
2455
2471
|
*/
|
|
2456
2472
|
_visibleThreads() {
|
|
2457
|
-
|
|
2458
|
-
const ts = (t) => {
|
|
2459
|
-
var _ref, _t$lastRunAt;
|
|
2460
|
-
const raw = (_ref = (_t$lastRunAt = t.lastRunAt) !== null && _t$lastRunAt !== void 0 ? _t$lastRunAt : t.updatedAt) !== null && _ref !== void 0 ? _ref : t.createdAt;
|
|
2461
|
-
const parsed = Date.parse(raw);
|
|
2462
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
2463
|
-
};
|
|
2464
|
-
return [...filtered].map((thread, index) => ({
|
|
2465
|
-
thread,
|
|
2466
|
-
index,
|
|
2467
|
-
ts: ts(thread)
|
|
2468
|
-
})).sort((a, b) => {
|
|
2469
|
-
if (a.ts === null && b.ts === null) return a.index - b.index;
|
|
2470
|
-
if (a.ts === null) return 1;
|
|
2471
|
-
if (b.ts === null) return -1;
|
|
2472
|
-
if (a.ts !== b.ts) return b.ts - a.ts;
|
|
2473
|
-
return a.index - b.index;
|
|
2474
|
-
}).map((entry) => entry.thread);
|
|
2473
|
+
return sortThreadsByRecency(this._filter === "active" ? this.threads.filter((t) => !t.archived) : this.threads);
|
|
2475
2474
|
}
|
|
2476
2475
|
_emit(type, detail) {
|
|
2477
2476
|
this.dispatchEvent(new CustomEvent(type, {
|