@copilotkit/web-inspector 1.79.1-canary.1792091124 → 1.79.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/index.cjs +43 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +43 -6
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +46 -12
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1391,6 +1391,9 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
1391
1391
|
this._lastSeenLiveMessageVersion = 0;
|
|
1392
1392
|
this._metadataAbort = null;
|
|
1393
1393
|
this._messagesAbort = null;
|
|
1394
|
+
this._messagesRefreshTimer = null;
|
|
1395
|
+
this._messagesRefreshPending = false;
|
|
1396
|
+
this._lastMessagesFetchAt = 0;
|
|
1394
1397
|
this._eventsAbort = null;
|
|
1395
1398
|
this._stateAbort = null;
|
|
1396
1399
|
this._hasConnectedOnce = false;
|
|
@@ -1486,6 +1489,9 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
1486
1489
|
static {
|
|
1487
1490
|
this.COLLAPSE_THRESHOLD = 800;
|
|
1488
1491
|
}
|
|
1492
|
+
static {
|
|
1493
|
+
this.MESSAGE_REFRESH_INTERVAL_MS = 1e3;
|
|
1494
|
+
}
|
|
1489
1495
|
static {
|
|
1490
1496
|
this.TAB_LIST = [
|
|
1491
1497
|
{
|
|
@@ -2970,9 +2976,8 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
2970
2976
|
}
|
|
2971
2977
|
} else if (this.threadId && this.liveMessageVersion !== this._lastSeenLiveMessageVersion) {
|
|
2972
2978
|
this._lastSeenLiveMessageVersion = this.liveMessageVersion;
|
|
2973
|
-
this.
|
|
2974
|
-
this.
|
|
2975
|
-
this.fetchMessages(this.threadId, true);
|
|
2979
|
+
this._messagesRefreshPending = true;
|
|
2980
|
+
this.scheduleMessagesRefresh();
|
|
2976
2981
|
}
|
|
2977
2982
|
const focusedContentChanged = _changed.has("_fetchedEvents") || _changed.has("agentEventsInput") || _changed.has("agentMessagesInput") || _changed.has("_conversation");
|
|
2978
2983
|
if (this.focusMessageId && (this.focusRequestId > this._scrolledFocusRequestId || focusedContentChanged)) {
|
|
@@ -3029,6 +3034,12 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3029
3034
|
].join("||");
|
|
3030
3035
|
}
|
|
3031
3036
|
resetLoadedThreadData() {
|
|
3037
|
+
if (this._messagesRefreshTimer !== null) {
|
|
3038
|
+
clearTimeout(this._messagesRefreshTimer);
|
|
3039
|
+
this._messagesRefreshTimer = null;
|
|
3040
|
+
}
|
|
3041
|
+
this._messagesRefreshPending = false;
|
|
3042
|
+
this._lastMessagesFetchAt = 0;
|
|
3032
3043
|
this._tab = "timeline";
|
|
3033
3044
|
this._activatedTabs = new Set(["timeline"]);
|
|
3034
3045
|
this._panelTplCache = /* @__PURE__ */ new Map();
|
|
@@ -3077,6 +3088,19 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3077
3088
|
this._fetchedMetadata = null;
|
|
3078
3089
|
}
|
|
3079
3090
|
}
|
|
3091
|
+
/** Coalesces live updates without overlapping requests or starving the final update. */
|
|
3092
|
+
scheduleMessagesRefresh() {
|
|
3093
|
+
if (!this._messagesRefreshPending || this._messagesRefreshTimer !== null || this._messagesAbort || !this.isConnected || !this.threadId || !this.canFetchMessages()) return;
|
|
3094
|
+
const threadId = this.threadId;
|
|
3095
|
+
const loadKey = this.currentLoadKey();
|
|
3096
|
+
if (loadKey !== this._lastLoadKey) return;
|
|
3097
|
+
const delay = Math.max(0, CpkThreadInspector.MESSAGE_REFRESH_INTERVAL_MS - (Date.now() - this._lastMessagesFetchAt));
|
|
3098
|
+
this._messagesRefreshTimer = setTimeout(() => {
|
|
3099
|
+
this._messagesRefreshTimer = null;
|
|
3100
|
+
if (!this.isConnected || this.currentLoadKey() !== loadKey || this._lastLoadKey !== loadKey || this._messagesAbort) return;
|
|
3101
|
+
this.fetchMessages(threadId, true);
|
|
3102
|
+
}, delay);
|
|
3103
|
+
}
|
|
3080
3104
|
/**
|
|
3081
3105
|
* Fetch the canonical conversation for `threadId` from the runtime.
|
|
3082
3106
|
*
|
|
@@ -3092,8 +3116,15 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3092
3116
|
if (!silent) this._conversation = [];
|
|
3093
3117
|
return;
|
|
3094
3118
|
}
|
|
3119
|
+
if (this._messagesRefreshTimer !== null) {
|
|
3120
|
+
clearTimeout(this._messagesRefreshTimer);
|
|
3121
|
+
this._messagesRefreshTimer = null;
|
|
3122
|
+
}
|
|
3123
|
+
this._messagesRefreshPending = false;
|
|
3124
|
+
this._lastMessagesFetchAt = Date.now();
|
|
3095
3125
|
this._messagesAbort?.abort();
|
|
3096
3126
|
const controller = new AbortController();
|
|
3127
|
+
const loadKey = this.currentLoadKey();
|
|
3097
3128
|
this._messagesAbort = controller;
|
|
3098
3129
|
if (!silent) {
|
|
3099
3130
|
this._loadingMessages = true;
|
|
@@ -3102,19 +3133,25 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3102
3133
|
}
|
|
3103
3134
|
try {
|
|
3104
3135
|
const messages = this.provider?.getMessages ? await this.provider.getMessages(threadId, { signal: controller.signal }) : await this.fetchRuntimeMessages(threadId, controller.signal);
|
|
3105
|
-
if (controller.signal.aborted || this.
|
|
3136
|
+
if (controller.signal.aborted || this.currentLoadKey() !== loadKey) return;
|
|
3106
3137
|
this._conversation = this.mapMessages(messages);
|
|
3107
3138
|
this._messagesError = null;
|
|
3108
3139
|
this._messageRefreshError = null;
|
|
3109
3140
|
} catch (err) {
|
|
3110
|
-
if (controller.signal.aborted || this.
|
|
3141
|
+
if (controller.signal.aborted || this.currentLoadKey() !== loadKey) return;
|
|
3111
3142
|
if (err instanceof Error && err.name === "AbortError") return;
|
|
3112
3143
|
if (!silent || this._conversation.length === 0) {
|
|
3113
3144
|
this._messagesError = err instanceof Error ? err.message : "Failed to load messages";
|
|
3114
3145
|
this._conversation = [];
|
|
3115
3146
|
} else this._messageRefreshError = "Could not refresh messages. Showing the last loaded conversation.";
|
|
3116
3147
|
} finally {
|
|
3117
|
-
if (
|
|
3148
|
+
if (this._messagesAbort === controller) {
|
|
3149
|
+
this._messagesAbort = null;
|
|
3150
|
+
if (!controller.signal.aborted && this.currentLoadKey() === loadKey) {
|
|
3151
|
+
this._loadingMessages = false;
|
|
3152
|
+
this.scheduleMessagesRefresh();
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3118
3155
|
}
|
|
3119
3156
|
}
|
|
3120
3157
|
async fetchEvents(threadId) {
|