@copilotkit/web-inspector 1.62.1 → 1.62.2

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 CHANGED
@@ -428,6 +428,8 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
428
428
  this._stateError = null;
429
429
  this._expandedTools = /* @__PURE__ */ new Set();
430
430
  this._expandedMessages = /* @__PURE__ */ new Set();
431
+ this._expandedTimelineDetails = /* @__PURE__ */ new Set();
432
+ this._expandedRawEvents = /* @__PURE__ */ new Set();
431
433
  this._showDetailPanel = false;
432
434
  this._detailPanelWidth = 250;
433
435
  this._eventsNotAvailable = false;
@@ -493,6 +495,8 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
493
495
  _stateError: { state: true },
494
496
  _expandedTools: { state: true },
495
497
  _expandedMessages: { state: true },
498
+ _expandedTimelineDetails: { state: true },
499
+ _expandedRawEvents: { state: true },
496
500
  _showDetailPanel: { state: true },
497
501
  _detailPanelWidth: { state: true },
498
502
  _eventsNotAvailable: { state: true },
@@ -707,6 +711,7 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
707
711
 
708
712
  .cpk-td__metadata-strip {
709
713
  display: flex;
714
+ align-items: center;
710
715
  gap: 6px;
711
716
  flex-wrap: wrap;
712
717
  padding: 10px 16px;
@@ -715,6 +720,14 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
715
720
  flex-shrink: 0;
716
721
  }
717
722
 
723
+ .cpk-td__metadata-pills {
724
+ display: flex;
725
+ gap: 6px;
726
+ flex: 1;
727
+ flex-wrap: wrap;
728
+ min-width: 0;
729
+ }
730
+
718
731
  .cpk-td__metadata-pill {
719
732
  display: inline-flex;
720
733
  align-items: center;
@@ -1009,13 +1022,44 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1009
1022
  }
1010
1023
 
1011
1024
  .cpk-td__timeline-body {
1012
- padding: 9px 10px;
1025
+ margin: 0;
1026
+ padding: 0 10px 9px;
1013
1027
  font-size: 12px;
1014
1028
  line-height: 1.55;
1015
1029
  color: #57575b;
1016
1030
  white-space: pre-wrap;
1017
1031
  word-break: break-word;
1018
- border-top: 1px solid #e9e9ef;
1032
+ }
1033
+
1034
+ .cpk-td__timeline-toolbar {
1035
+ display: flex;
1036
+ gap: 6px;
1037
+ margin-left: auto;
1038
+ }
1039
+
1040
+ .cpk-td__timeline-bulk-toggle {
1041
+ margin: 0;
1042
+ padding: 4px 8px;
1043
+ border: 1px solid #dcdce8;
1044
+ border-radius: 6px;
1045
+ background: #ffffff;
1046
+ color: #36363a;
1047
+ cursor: pointer;
1048
+ font-family: "Inter", sans-serif;
1049
+ font-size: 11px;
1050
+ font-weight: 600;
1051
+ line-height: 1.2;
1052
+ }
1053
+
1054
+ .cpk-td__timeline-bulk-toggle:hover {
1055
+ border-color: rgba(85, 88, 178, 0.38);
1056
+ background: #f7f7ff;
1057
+ color: #010507;
1058
+ }
1059
+
1060
+ .cpk-td__timeline-bulk-toggle:disabled {
1061
+ cursor: not-allowed;
1062
+ opacity: 0.45;
1019
1063
  }
1020
1064
 
1021
1065
  .cpk-td__source-link {
@@ -1036,6 +1080,34 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1036
1080
  color: #010507;
1037
1081
  }
1038
1082
 
1083
+ .cpk-td__timeline-details-toggle {
1084
+ margin: 0;
1085
+ padding: 5px 10px;
1086
+ border: none;
1087
+ background: #ffffff;
1088
+ color: #5558b2;
1089
+ cursor: pointer;
1090
+ display: inline-flex;
1091
+ align-items: center;
1092
+ gap: 5px;
1093
+ font-family: "Inter", sans-serif;
1094
+ font-size: 12px;
1095
+ font-weight: 600;
1096
+ line-height: 1.2;
1097
+ width: 100%;
1098
+ }
1099
+
1100
+ .cpk-td__timeline-details-toggle:hover {
1101
+ background: #f7f7ff;
1102
+ color: #010507;
1103
+ }
1104
+
1105
+ .cpk-td__timeline-details-toggle svg {
1106
+ width: 12px;
1107
+ height: 12px;
1108
+ stroke-width: 2;
1109
+ }
1110
+
1039
1111
  /* ── Generative UI ──────────────────────────────────────────────── */
1040
1112
  @keyframes cpk-genui-enter {
1041
1113
  from {
@@ -1293,6 +1365,8 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1293
1365
  this._liveEventsWithSourceIndexCache = null;
1294
1366
  this._expandedTools = /* @__PURE__ */ new Set();
1295
1367
  this._expandedMessages = /* @__PURE__ */ new Set();
1368
+ this._expandedTimelineDetails = /* @__PURE__ */ new Set();
1369
+ this._expandedRawEvents = /* @__PURE__ */ new Set();
1296
1370
  this._metadataAbort?.abort();
1297
1371
  this._metadataAbort = null;
1298
1372
  this._messagesAbort?.abort();
@@ -1821,6 +1895,37 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1821
1895
  else next.add(id);
1822
1896
  this._expandedMessages = next;
1823
1897
  }
1898
+ toggleTimelineDetails(id) {
1899
+ const next = new Set(this._expandedTimelineDetails);
1900
+ if (next.has(id)) next.delete(id);
1901
+ else next.add(id);
1902
+ this._expandedTimelineDetails = next;
1903
+ }
1904
+ expandTimelineDetails(ids) {
1905
+ this._expandedTimelineDetails = new Set([...this._expandedTimelineDetails, ...ids]);
1906
+ }
1907
+ collapseTimelineDetails(ids) {
1908
+ const next = new Set(this._expandedTimelineDetails);
1909
+ for (const id of ids) next.delete(id);
1910
+ this._expandedTimelineDetails = next;
1911
+ }
1912
+ toggleRawEventDetails(id) {
1913
+ const next = new Set(this._expandedRawEvents);
1914
+ if (next.has(id)) next.delete(id);
1915
+ else next.add(id);
1916
+ this._expandedRawEvents = next;
1917
+ }
1918
+ expandRawEventDetails(ids) {
1919
+ this._expandedRawEvents = new Set([...this._expandedRawEvents, ...ids]);
1920
+ }
1921
+ collapseRawEventDetails(ids) {
1922
+ const next = new Set(this._expandedRawEvents);
1923
+ for (const id of ids) next.delete(id);
1924
+ this._expandedRawEvents = next;
1925
+ }
1926
+ rawEventId(event) {
1927
+ return `raw-event-${event.sourceIndex ?? event.timestamp ?? event.type}`;
1928
+ }
1824
1929
  get activeEvents() {
1825
1930
  if (this._eventsNotAvailable) return [];
1826
1931
  const events = this._fetchedEvents ?? this.agentEventsInput ?? [];
@@ -1944,19 +2049,70 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1944
2049
  value: metadata?.status
1945
2050
  }
1946
2051
  ].filter((pill) => pill.value != null && pill.value !== "");
1947
- if (pills.length === 0) return lit.nothing;
2052
+ const bulkControls = this.renderActiveBulkControls();
2053
+ if (pills.length === 0 && bulkControls === lit.nothing) return lit.nothing;
1948
2054
  return lit.html`
1949
2055
  <div class="cpk-td__metadata-strip" aria-label="Thread metadata">
1950
- ${pills.map((pill) => lit.html`
1951
- <span class="cpk-td__metadata-pill" title=${pill.value ?? ""}>
1952
- <span class="cpk-td__metadata-label">${pill.label}</span>
1953
- <span class="cpk-td__metadata-value"
1954
- >${this.shortId(pill.value)}</span
1955
- >
1956
- </span>
1957
- `)}
2056
+ <div class="cpk-td__metadata-pills">
2057
+ ${pills.map((pill) => lit.html`
2058
+ <span class="cpk-td__metadata-pill" title=${pill.value ?? ""}>
2059
+ <span class="cpk-td__metadata-label">${pill.label}</span>
2060
+ <span class="cpk-td__metadata-value"
2061
+ >${this.shortId(pill.value)}</span
2062
+ >
2063
+ </span>
2064
+ `)}
2065
+ </div>
2066
+ ${bulkControls}
1958
2067
  </div>
1959
2068
  `;
2069
+ }
2070
+ renderActiveBulkControls() {
2071
+ if (this._eventsNotAvailable) return lit.nothing;
2072
+ if (this._tab === "raw-events") return this.renderRawEventBulkControls();
2073
+ if (this._tab !== "timeline") return lit.nothing;
2074
+ const detailIds = this.timelineItemsForEvents(this.activeEvents).filter((item) => item.details).map((item) => item.id);
2075
+ if (detailIds.length <= 1) return lit.nothing;
2076
+ return lit.html`<div class="cpk-td__timeline-toolbar">
2077
+ <button
2078
+ type="button"
2079
+ class="cpk-td__timeline-bulk-toggle"
2080
+ ?disabled=${detailIds.every((id) => this._expandedTimelineDetails.has(id))}
2081
+ @click=${() => this.expandTimelineDetails(detailIds)}
2082
+ >
2083
+ Expand all
2084
+ </button>
2085
+ <button
2086
+ type="button"
2087
+ class="cpk-td__timeline-bulk-toggle"
2088
+ ?disabled=${detailIds.every((id) => !this._expandedTimelineDetails.has(id))}
2089
+ @click=${() => this.collapseTimelineDetails(detailIds)}
2090
+ >
2091
+ Collapse all
2092
+ </button>
2093
+ </div>`;
2094
+ }
2095
+ renderRawEventBulkControls() {
2096
+ const eventIds = this.activeEvents.map((event) => this.rawEventId(event));
2097
+ if (eventIds.length <= 1) return lit.nothing;
2098
+ return lit.html`<div class="cpk-td__timeline-toolbar">
2099
+ <button
2100
+ type="button"
2101
+ class="cpk-td__timeline-bulk-toggle"
2102
+ ?disabled=${eventIds.every((id) => this._expandedRawEvents.has(id))}
2103
+ @click=${() => this.expandRawEventDetails(eventIds)}
2104
+ >
2105
+ Expand all
2106
+ </button>
2107
+ <button
2108
+ type="button"
2109
+ class="cpk-td__timeline-bulk-toggle"
2110
+ ?disabled=${eventIds.every((id) => !this._expandedRawEvents.has(id))}
2111
+ @click=${() => this.collapseRawEventDetails(eventIds)}
2112
+ >
2113
+ Collapse all
2114
+ </button>
2115
+ </div>`;
1960
2116
  }
1961
2117
  revealSourceEvent(sourceIndex) {
1962
2118
  this._activatedTabs = new Set([...this._activatedTabs, "raw-events"]);
@@ -1987,7 +2143,7 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1987
2143
  `;
1988
2144
  }
1989
2145
  const events = this.activeEvents;
1990
- const cachedTimeline = this.getCachedPanelTpl("timeline", [events]);
2146
+ const cachedTimeline = this.getCachedPanelTpl("timeline", [events, this._expandedTimelineDetails]);
1991
2147
  if (cachedTimeline) return cachedTimeline;
1992
2148
  const timelineItems = this.timelineItemsForEvents(events);
1993
2149
  if (timelineItems.length === 0) {
@@ -2003,14 +2159,14 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
2003
2159
  </div>
2004
2160
  `;
2005
2161
  }
2006
- return this.cachedPanelTpl("timeline", [events], () => {
2007
- return lit.html`${timelineItems.map((item) => this.renderTimelineItem(item))}`;
2008
- });
2162
+ return this.cachedPanelTpl("timeline", [events, this._expandedTimelineDetails], () => lit.html`${timelineItems.map((item) => this.renderTimelineItem(item))}`);
2009
2163
  }
2010
2164
  renderTimelineItem(item) {
2165
+ const isWarning = item.kind === "warning";
2166
+ const detailsExpanded = this._expandedTimelineDetails.has(item.id);
2011
2167
  return lit.html`
2012
2168
  <div
2013
- class="cpk-td__timeline-item ${item.kind === "warning" ? "cpk-td__timeline-item--warning" : ""}"
2169
+ class="cpk-td__timeline-item ${isWarning ? "cpk-td__timeline-item--warning" : ""}"
2014
2170
  >
2015
2171
  <div class="cpk-td__timeline-header">
2016
2172
  <span class="cpk-td__timeline-kind"
@@ -2028,9 +2184,39 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
2028
2184
  >${formatTimestamp(item.timestamp)}</span
2029
2185
  >
2030
2186
  </div>
2031
- ${item.body ? lit.html`<div class="cpk-td__timeline-body">${item.body}</div>` : item.details ? lit.html`<pre class="cpk-td__timeline-body">
2032
- ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.details))}</pre
2033
- >` : lit.nothing}
2187
+ ${item.details ? lit.html`<button
2188
+ type="button"
2189
+ class="cpk-td__timeline-details-toggle"
2190
+ aria-expanded=${detailsExpanded ? "true" : "false"}
2191
+ @click=${() => this.toggleTimelineDetails(item.id)}
2192
+ >
2193
+ ${detailsExpanded ? lit.html`
2194
+ <svg
2195
+ aria-hidden="true"
2196
+ viewBox="0 0 24 24"
2197
+ fill="none"
2198
+ stroke="currentColor"
2199
+ stroke-linecap="round"
2200
+ stroke-linejoin="round"
2201
+ >
2202
+ <path d="m6 9 6 6 6-6" />
2203
+ </svg>
2204
+ ` : lit.html`
2205
+ <svg
2206
+ aria-hidden="true"
2207
+ viewBox="0 0 24 24"
2208
+ fill="none"
2209
+ stroke="currentColor"
2210
+ stroke-linecap="round"
2211
+ stroke-linejoin="round"
2212
+ >
2213
+ <path d="m9 18 6-6-6-6" />
2214
+ </svg>
2215
+ `}
2216
+ <span>${detailsExpanded ? "Hide details" : "Show details"}</span>
2217
+ </button>` : lit.nothing}
2218
+ ${item.body ? lit.html`<div class="cpk-td__timeline-body">${item.body}</div>` : lit.nothing}
2219
+ ${item.details && detailsExpanded ? lit.html`<pre class="cpk-td__timeline-body">${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.details))}</pre>` : lit.nothing}
2034
2220
  </div>
2035
2221
  `;
2036
2222
  }
@@ -2287,9 +2473,11 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
2287
2473
  >
2288
2474
  </div>
2289
2475
  `;
2290
- return this.cachedPanelTpl("raw-events", [events], () => {
2476
+ return this.cachedPanelTpl("raw-events", [events, this._expandedRawEvents], () => {
2291
2477
  return lit.html`${events.map((event) => {
2292
2478
  const { bg, fg } = eventColors(event.type);
2479
+ const eventId = this.rawEventId(event);
2480
+ const detailsExpanded = this._expandedRawEvents.has(eventId);
2293
2481
  return lit.html`
2294
2482
  <div class="cpk-td__event" data-source-index=${event.sourceIndex}>
2295
2483
  <div class="cpk-td__event-header" style="background:${bg}">
@@ -2300,9 +2488,38 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
2300
2488
  >${formatTimestamp(event.timestamp)}</span
2301
2489
  >
2302
2490
  </div>
2303
- <pre class="cpk-td__event-payload">
2304
- ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.rawEvent ?? event))}</pre
2491
+ <button
2492
+ type="button"
2493
+ class="cpk-td__timeline-details-toggle"
2494
+ aria-expanded=${detailsExpanded ? "true" : "false"}
2495
+ @click=${() => this.toggleRawEventDetails(eventId)}
2305
2496
  >
2497
+ ${detailsExpanded ? lit.html`
2498
+ <svg
2499
+ aria-hidden="true"
2500
+ viewBox="0 0 24 24"
2501
+ fill="none"
2502
+ stroke="currentColor"
2503
+ stroke-linecap="round"
2504
+ stroke-linejoin="round"
2505
+ >
2506
+ <path d="m6 9 6 6 6-6" />
2507
+ </svg>
2508
+ ` : lit.html`
2509
+ <svg
2510
+ aria-hidden="true"
2511
+ viewBox="0 0 24 24"
2512
+ fill="none"
2513
+ stroke="currentColor"
2514
+ stroke-linecap="round"
2515
+ stroke-linejoin="round"
2516
+ >
2517
+ <path d="m9 18 6-6-6-6" />
2518
+ </svg>
2519
+ `}
2520
+ <span>${detailsExpanded ? "Hide details" : "Show details"}</span>
2521
+ </button>
2522
+ ${detailsExpanded ? lit.html`<pre class="cpk-td__event-payload">${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.rawEvent ?? event))}</pre>` : lit.nothing}
2306
2523
  </div>
2307
2524
  `;
2308
2525
  })}`;