@kodaris/krubble-app-components 1.0.165 → 1.0.167

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.
@@ -3677,6 +3677,28 @@
3677
3677
  this._inputValue = payload.message;
3678
3678
  this._handleSubmit();
3679
3679
  }
3680
+ /**
3681
+ * Open the panel and place `payload.message` in the composer, selected, without sending it.
3682
+ *
3683
+ * For a host app that wants to suggest an opening message rather than send one (e.g. a site
3684
+ * editor deep link): Enter sends it as is, typing replaces it. Nothing is persisted beyond the
3685
+ * composer draft state any typed text gets.
3686
+ */
3687
+ draft(payload) {
3688
+ this.open();
3689
+ this._inputValue = payload.message;
3690
+ this._saveState();
3691
+ // Same delay as the open-focus in `updated`: the panel has to finish showing before the
3692
+ // textarea can take focus, and this has to run after that focus so the selection sticks.
3693
+ this.updateComplete.then(() => {
3694
+ setTimeout(() => {
3695
+ if (this._inputEl) {
3696
+ this._inputEl.focus();
3697
+ this._inputEl.select();
3698
+ }
3699
+ }, 200);
3700
+ });
3701
+ }
3680
3702
  // --- Private methods ---
3681
3703
  /**
3682
3704
  * Shows a full-viewport transparent overlay during drag/resize operations.
@@ -6367,6 +6389,19 @@
6367
6389
  }
6368
6390
  return '~$' + n.toFixed(4);
6369
6391
  }
6392
+ _fmtPrice(n) {
6393
+ if (n == null || isNaN(n)) {
6394
+ return '—';
6395
+ }
6396
+ return '$' + n.toFixed(2);
6397
+ }
6398
+ _getCustomerPriceLabel() {
6399
+ const rate = this._telemetry?.customerPricePerThousandTokens;
6400
+ if (rate == null || isNaN(rate)) {
6401
+ return 'Customer price';
6402
+ }
6403
+ return `Customer price ($${rate}/1K)`;
6404
+ }
6370
6405
  /**
6371
6406
  * INTERNAL-ONLY debug telemetry panel. Rendered only in the inline variant
6372
6407
  * (guarded by the caller) and only when the user has toggled it open. Shows
@@ -6747,8 +6782,14 @@
6747
6782
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnCacheReadTokens)}</span>
6748
6783
  <span class="debug-metrics__key">Hit rate</span>
6749
6784
  <span class="debug-metrics__val">${this._telemetry.turnHitRate ?? '—'}%</span>
6785
+ <span class="debug-metrics__key">Total tokens</span>
6786
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnTotalTokens)}</span>
6787
+ <span class="debug-metrics__key">Reported total</span>
6788
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnReportedTotalTokens)}</span>
6750
6789
  <span class="debug-metrics__key">Cost</span>
6751
6790
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.turnCostUsd)}</span>
6791
+ <span class="debug-metrics__key">${this._getCustomerPriceLabel()}</span>
6792
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.turnCustomerUsd)}</span>
6752
6793
  </div>
6753
6794
  </div>
6754
6795
 
@@ -6763,8 +6804,12 @@
6763
6804
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheReadTokens)}</span>
6764
6805
  <span class="debug-metrics__key">Cache write</span>
6765
6806
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheWriteTokens)}</span>
6807
+ <span class="debug-metrics__key">Total tokens</span>
6808
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationTotalTokens)}</span>
6766
6809
  <span class="debug-metrics__key">Cost so far</span>
6767
6810
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.conversationCostUsd)}</span>
6811
+ <span class="debug-metrics__key">${this._getCustomerPriceLabel()} so far</span>
6812
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.conversationCustomerUsd)}</span>
6768
6813
  </div>
6769
6814
  </div>
6770
6815
  ` : b `
@@ -6784,7 +6829,10 @@
6784
6829
  <th>Cache R</th>
6785
6830
  <th>Cache W</th>
6786
6831
  <th>Hit</th>
6832
+ <th>Total</th>
6833
+ <th>Reported</th>
6787
6834
  <th>Cost</th>
6835
+ <th>Price</th>
6788
6836
  <th>Ckpt</th>
6789
6837
  </tr>
6790
6838
  </thead>
@@ -6799,7 +6847,10 @@
6799
6847
  <td>${this._fmtTokens(it.iterationCacheRead)}</td>
6800
6848
  <td>${this._fmtTokens(it.iterationCacheWrite)}</td>
6801
6849
  <td>${it.iterationHitRate ?? '—'}%</td>
6850
+ <td>${this._fmtTokens(it.iterationTotalTokens)}</td>
6851
+ <td>${this._fmtTokens(it.reportedTotalTokens)}</td>
6802
6852
  <td class="debug-cost">${this._fmtCost(it.iterationCostUsd)}</td>
6853
+ <td class="debug-cost">${this._fmtPrice(it.iterationCustomerUsd)}</td>
6803
6854
  <td>${ckpt ? ckpt.mode : '—'}</td>
6804
6855
  </tr>
6805
6856
  `;