@sunshaobei/dsh-balance-panel 3.0.7 → 3.0.8

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/lib/client.js CHANGED
@@ -37,6 +37,10 @@ window.__ModuleLoader__.load({
37
37
  // (from the host's modelDirectories service) into this tiny store;
38
38
  // the indicator component subscribes to it.
39
39
  var selStore = { sel: null, listeners: new Set() };
40
+ let clientLogQueue = Promise.resolve();
41
+ function clientLog(line) {
42
+ clientLogQueue = clientLogQueue.then(() => ctx.connection.rpc.call(CHANNEL, 'client-log', { line })).catch(() => { });
43
+ }
40
44
  function setSel(next) {
41
45
  var cur = selStore.sel;
42
46
  if (!cur && !next)
@@ -46,6 +50,7 @@ window.__ModuleLoader__.load({
46
50
  if (cur && next && cur.provider === next.provider && cur.model === next.model && cur.src === next.src)
47
51
  return;
48
52
  selStore.sel = next;
53
+ clientLog('setSel provider=' + JSON.stringify(next && next.provider) + ' model=' + JSON.stringify(next && next.model) + ' src=' + JSON.stringify(next && next.src));
49
54
  selStore.listeners.forEach(function (l) { l(next); });
50
55
  }
51
56
  /** Map a provider/model/spec string to a coarse provider family key. */
@@ -1148,6 +1153,8 @@ window.__ModuleLoader__.load({
1148
1153
  // expands the full card with EVERY provider.
1149
1154
  var RING_R = 7, RING_C = 2 * Math.PI * RING_R;
1150
1155
  var curSpec = matchSpec(specs, sel);
1156
+ if (specs && specs.rows)
1157
+ clientLog('capsule sel=' + JSON.stringify(sel) + ' rows=[' + specs.rows.map(function (r3x) { return r3x.id + ':' + r3x.kind; }).join(',') + '] matched=' + (curSpec ? curSpec.id : 'null'));
1151
1158
  var curView = curSpec ? views[curSpec.id] : null;
1152
1159
  // Compact window group: small ring first, tiny label beside it.
1153
1160
  var makeRing = function (key, pct, status, label) {
package/lib/index.js CHANGED
@@ -2001,8 +2001,24 @@ export function apply(ctx, config = {}) {
2001
2001
  catalog
2002
2002
  });
2003
2003
  if (endpoint === 'specs') {
2004
+ try {
2005
+ const fsp2 = await import('node:fs/promises');
2006
+ const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
2007
+ await fsp2.appendFile(dbg, new Date().toISOString() + ' specs rows=[' + rows.map(r2 => r2.id + ':' + r2.kind).join(',') + ']\n').catch(() => { });
2008
+ }
2009
+ catch { }
2004
2010
  return { ok: true, value: { rows: rows.map(rowSpec), refreshMs } };
2005
2011
  }
2012
+ if (endpoint === 'client-log') {
2013
+ try {
2014
+ const fsp2 = await import('node:fs/promises');
2015
+ const line = payload && typeof payload.line === 'string' ? payload.line : '';
2016
+ const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
2017
+ await fsp2.appendFile(dbg, new Date().toISOString() + ' client: ' + line + '\n').catch(() => { });
2018
+ }
2019
+ catch { }
2020
+ return { ok: true, value: { logged: true } };
2021
+ }
2006
2022
  if (endpoint === 'fetch-all') {
2007
2023
  const overrides = {};
2008
2024
  const overrideErrors = {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sunshaobei/dsh-balance-panel",
3
3
  "description": "Provider quota/balance widget for the dsh web surface: an inline sidebar card above the Settings row (collapsed glanceable row expanding into a Harness-native card with a settings panel), fed by a loopback Connection RPC channel whose host half proxies each provider with credentials that never reach the browser.",
4
- "version": "3.0.7",
4
+ "version": "3.0.8",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
package/src/client.ts CHANGED
@@ -39,6 +39,10 @@
39
39
  // (from the host's modelDirectories service) into this tiny store;
40
40
  // the indicator component subscribes to it.
41
41
  var selStore = { sel: null, listeners: new Set() };
42
+ let clientLogQueue = Promise.resolve();
43
+ function clientLog(line) {
44
+ clientLogQueue = clientLogQueue.then(() => ctx.connection.rpc.call(CHANNEL, 'client-log', { line })).catch(() => {});
45
+ }
42
46
  function setSel(next) {
43
47
  var cur = selStore.sel;
44
48
  if (!cur && !next) return;
@@ -46,6 +50,7 @@
46
50
  // republishes the same value on every tick).
47
51
  if (cur && next && cur.provider === next.provider && cur.model === next.model && cur.src === next.src) return;
48
52
  selStore.sel = next;
53
+ clientLog('setSel provider=' + JSON.stringify(next && next.provider) + ' model=' + JSON.stringify(next && next.model) + ' src=' + JSON.stringify(next && next.src));
49
54
  selStore.listeners.forEach(function (l) { l(next); });
50
55
  }
51
56
  /** Map a provider/model/spec string to a coarse provider family key. */
@@ -1149,6 +1154,7 @@
1149
1154
  // expands the full card with EVERY provider.
1150
1155
  var RING_R = 7, RING_C = 2 * Math.PI * RING_R;
1151
1156
  var curSpec = matchSpec(specs, sel);
1157
+ if (specs && specs.rows) clientLog('capsule sel=' + JSON.stringify(sel) + ' rows=[' + specs.rows.map(function (r3x) { return r3x.id + ':' + r3x.kind; }).join(',') + '] matched=' + (curSpec ? curSpec.id : 'null'));
1152
1158
  var curView = curSpec ? views[curSpec.id] : null;
1153
1159
  // Compact window group: small ring first, tiny label beside it.
1154
1160
  var makeRing = function (key, pct, status, label) {
package/src/index.ts CHANGED
@@ -1942,8 +1942,22 @@ export function apply(ctx, config: Record<string, any> = {}) {
1942
1942
  catalog
1943
1943
  });
1944
1944
  if (endpoint === 'specs') {
1945
+ try {
1946
+ const fsp2 = await import('node:fs/promises');
1947
+ const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
1948
+ await fsp2.appendFile(dbg, new Date().toISOString() + ' specs rows=[' + rows.map(r2 => r2.id + ':' + r2.kind).join(',') + ']\n').catch(() => {});
1949
+ } catch {}
1945
1950
  return { ok: true, value: { rows: rows.map(rowSpec), refreshMs } };
1946
1951
  }
1952
+ if (endpoint === 'client-log') {
1953
+ try {
1954
+ const fsp2 = await import('node:fs/promises');
1955
+ const line = payload && typeof payload.line === 'string' ? payload.line : '';
1956
+ const dbg = path.join(chatgptDshStoreDir(), 'debug.log');
1957
+ await fsp2.appendFile(dbg, new Date().toISOString() + ' client: ' + line + '\n').catch(() => {});
1958
+ } catch {}
1959
+ return { ok: true, value: { logged: true } };
1960
+ }
1947
1961
  if (endpoint === 'fetch-all') {
1948
1962
  const overrides = {};
1949
1963
  const overrideErrors = {};