@copilotkit/web-inspector 1.75.1 → 1.76.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/index.cjs CHANGED
@@ -267,8 +267,18 @@ const DRAG_THRESHOLD = 6;
267
267
  const MIN_WINDOW_WIDTH = 880;
268
268
  const MIN_WINDOW_WIDTH_DOCKED_LEFT = 640;
269
269
  const MIN_WINDOW_HEIGHT = 480;
270
+ /**
271
+ * A window minimum that gives way on screens smaller than it, so the window
272
+ * (and its close control) never runs past the viewport edge.
273
+ */
274
+ const viewportCappedMin = (px, unit) => `min(${px}px, calc(100${unit} - ${EDGE_MARGIN * 2}px))`;
275
+ /**
276
+ * The floating window zooms down with the screen, never below this, once the
277
+ * viewport can no longer hold the default window at full size.
278
+ */
279
+ const MIN_WINDOW_SCALE = .8;
270
280
  const INSPECTOR_STORAGE_KEY = "cpk:inspector:state";
271
- const LAUNCHER_MIN_SIZE = 51.84;
281
+ const LAUNCHER_MIN_SIZE = 34;
272
282
  const LAUNCHER_MAX_SIZE = 62.208;
273
283
  const DEFAULT_BUTTON_SIZE = {
274
284
  width: LAUNCHER_MIN_SIZE,
@@ -5547,7 +5557,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
5547
5557
  const sidebarBounds = sidebar.getBoundingClientRect();
5548
5558
  this.sidebarRailTooltip = {
5549
5559
  label,
5550
- top: targetBounds.top - sidebarBounds.top + targetBounds.height / 2
5560
+ top: (targetBounds.top - sidebarBounds.top + targetBounds.height / 2) / this.getWindowScale()
5551
5561
  };
5552
5562
  this.requestUpdate();
5553
5563
  };
@@ -7699,7 +7709,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
7699
7709
  is the button's sibling, can clear the mark by the same length. */
7700
7710
  --cpk-launcher-size: clamp(
7701
7711
  ${LAUNCHER_MIN_SIZE}px,
7702
- 7vw,
7712
+ calc(22px + 2.8vw),
7703
7713
  ${LAUNCHER_MAX_SIZE}px
7704
7714
  );
7705
7715
  }
@@ -11362,6 +11372,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
11362
11372
  const isPoppedOut = this.isPoppedOut;
11363
11373
  const isTransitioning = this.hasAttribute("data-transitioning");
11364
11374
  const disableDrag = isDocked || isPoppedOut;
11375
+ const scale = this.getWindowScale();
11365
11376
  const windowStyles = isPoppedOut ? {
11366
11377
  position: "fixed",
11367
11378
  inset: "0",
@@ -11375,17 +11386,18 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
11375
11386
  ...this.getDockedWindowStyles(),
11376
11387
  overflowX: "hidden"
11377
11388
  } : {
11378
- width: `${Math.round(windowState.size.width)}px`,
11379
- height: `${Math.round(windowState.size.height)}px`,
11380
- minWidth: `${MIN_WINDOW_WIDTH}px`,
11381
- minHeight: `${MIN_WINDOW_HEIGHT}px`,
11382
- overflowX: "hidden"
11389
+ width: `${Math.round(windowState.size.width / scale)}px`,
11390
+ height: `${Math.round(windowState.size.height / scale)}px`,
11391
+ minWidth: viewportCappedMin(MIN_WINDOW_WIDTH, "vw"),
11392
+ minHeight: viewportCappedMin(MIN_WINDOW_HEIGHT, "vh"),
11393
+ overflowX: "hidden",
11394
+ ...scale < 1 ? { zoom: String(scale) } : {}
11383
11395
  };
11384
11396
  const hasContextDropdown = this.contextOptions.some((option) => option.key !== "all-agents");
11385
11397
  const viewportWidth = isPoppedOut ? this.popOut?.win.innerWidth ?? windowState.size.width : typeof window === "undefined" ? windowState.size.width : window.innerWidth;
11386
11398
  const automaticallyCollapsed = require_inspector_nav.shouldUseIconRail({
11387
11399
  dockedLeft: this.dockMode === "docked-left",
11388
- width: viewportWidth
11400
+ width: viewportWidth / scale
11389
11401
  });
11390
11402
  const iconRail = this.sidebarCollapsed || automaticallyCollapsed;
11391
11403
  const contextDropdown = hasContextDropdown ? this.renderContextDropdown(iconRail) : lit.nothing;
@@ -11715,8 +11727,9 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
11715
11727
  getRenderedInspectorWindowSize() {
11716
11728
  const inspectorWindow = this.shadowRoot?.querySelector(".inspector-window");
11717
11729
  if (inspectorWindow) {
11718
- const width = Math.round(Number.parseFloat(inspectorWindow.style.width));
11719
- const height = Math.round(Number.parseFloat(inspectorWindow.style.height));
11730
+ const scale = this.getWindowScale();
11731
+ const width = Math.round(Number.parseFloat(inspectorWindow.style.width) * scale);
11732
+ const height = Math.round(Number.parseFloat(inspectorWindow.style.height) * scale);
11720
11733
  if (Number.isFinite(width) && Number.isFinite(height)) return {
11721
11734
  width,
11722
11735
  height
@@ -11801,6 +11814,16 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
11801
11814
  height: window.innerHeight
11802
11815
  };
11803
11816
  }
11817
+ /**
11818
+ * Zoom for the floating window: 1 while the viewport holds the default
11819
+ * window, then proportional to the screen down to MIN_WINDOW_SCALE, so a
11820
+ * small screen gets the same layout smaller rather than a cramped one.
11821
+ */
11822
+ getWindowScale() {
11823
+ if (typeof window === "undefined" || this.isPoppedOut || this.dockMode !== "floating") return 1;
11824
+ const fit = Math.min(window.innerWidth / (DEFAULT_WINDOW_SIZE.width + EDGE_MARGIN * 2), window.innerHeight / (DEFAULT_WINDOW_SIZE.height + EDGE_MARGIN * 2));
11825
+ return Math.min(1, Math.max(MIN_WINDOW_SCALE, Math.round(fit * 20) / 20));
11826
+ }
11804
11827
  persistState() {
11805
11828
  const state = {
11806
11829
  button: {
@@ -12106,14 +12129,14 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
12106
12129
  bottom: "0",
12107
12130
  width: `${Math.round(this.contextState.window.size.width)}px`,
12108
12131
  height: "auto",
12109
- minWidth: `${MIN_WINDOW_WIDTH_DOCKED_LEFT}px`,
12132
+ minWidth: viewportCappedMin(MIN_WINDOW_WIDTH_DOCKED_LEFT, "vw"),
12110
12133
  borderRadius: "0"
12111
12134
  };
12112
12135
  return {
12113
12136
  width: `${Math.round(this.contextState.window.size.width)}px`,
12114
12137
  height: `${Math.round(this.contextState.window.size.height)}px`,
12115
- minWidth: `${MIN_WINDOW_WIDTH}px`,
12116
- minHeight: `${MIN_WINDOW_HEIGHT}px`
12138
+ minWidth: viewportCappedMin(MIN_WINDOW_WIDTH, "vw"),
12139
+ minHeight: viewportCappedMin(MIN_WINDOW_HEIGHT, "vh")
12117
12140
  };
12118
12141
  }
12119
12142
  handleDockClick(mode) {
@@ -13949,7 +13972,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
13949
13972
  <div style="display:flex;min-height:0;flex:1;overflow:hidden;">
13950
13973
  <!-- Left sidebar: thread list -->
13951
13974
  <div
13952
- style="display:${this.threadListCollapsed ? "none" : "flex"};width:${this.threadListWidth}px;flex-shrink:0;overflow:hidden;flex-direction:column;border-right:1px solid #DBDBE5;"
13975
+ style="display:${this.threadListCollapsed ? "none" : "flex"};width:${this.threadListWidth}px;max-width:calc(100% - 160px);flex-shrink:0;overflow:hidden;flex-direction:column;border-right:1px solid #DBDBE5;"
13953
13976
  >
13954
13977
  ${ephemeral ? lit.html`
13955
13978
  <button type="button" class="cpk-ephemeral-threads-banner"