@laoyuehanni/dsh-token-usage 0.4.14 → 0.4.16
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/README.md +2 -2
- package/README.zh.md +2 -2
- package/docs/DETAIL.md +18 -0
- package/docs/DETAIL.zh.md +18 -0
- package/lib/aux-request.d.ts +18 -13
- package/lib/aux-request.d.ts.map +1 -1
- package/lib/aux-request.js +32 -19
- package/lib/aux-request.js.map +1 -1
- package/lib/backup.d.ts +32 -0
- package/lib/backup.d.ts.map +1 -0
- package/lib/backup.js +114 -0
- package/lib/backup.js.map +1 -0
- package/lib/client/CostPill.d.ts +3 -4
- package/lib/client/CostPill.d.ts.map +1 -1
- package/lib/client/CostPill.js +50 -37
- package/lib/client/CostPill.js.map +1 -1
- package/lib/client/DashboardCards.d.ts +4 -2
- package/lib/client/DashboardCards.d.ts.map +1 -1
- package/lib/client/DashboardCards.js +2 -2
- package/lib/client/DashboardCards.js.map +1 -1
- package/lib/client/OverheadRows.d.ts +17 -12
- package/lib/client/OverheadRows.d.ts.map +1 -1
- package/lib/client/OverheadRows.js +32 -20
- package/lib/client/OverheadRows.js.map +1 -1
- package/lib/client/OverviewBoard.js +3 -3
- package/lib/client/OverviewBoard.js.map +1 -1
- package/lib/client/TokenUsageCard.d.ts.map +1 -1
- package/lib/client/TokenUsageCard.js +6 -0
- package/lib/client/TokenUsageCard.js.map +1 -1
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +11 -9
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/UsageRows.js +2 -2
- package/lib/client/UsageRows.js.map +1 -1
- package/lib/client/UsageView.d.ts +7 -6
- package/lib/client/UsageView.d.ts.map +1 -1
- package/lib/client/UsageView.js +100 -51
- package/lib/client/UsageView.js.map +1 -1
- package/lib/client/async-resource.d.ts +5 -2
- package/lib/client/async-resource.d.ts.map +1 -1
- package/lib/client/async-resource.js +14 -6
- package/lib/client/async-resource.js.map +1 -1
- package/lib/client/cost-inflate-motion.d.ts +0 -4
- package/lib/client/cost-inflate-motion.d.ts.map +1 -1
- package/lib/client/cost-inflate-motion.js +0 -19
- package/lib/client/cost-inflate-motion.js.map +1 -1
- package/lib/client/cost-inflate.d.ts +4 -6
- package/lib/client/cost-inflate.d.ts.map +1 -1
- package/lib/client/cost-inflate.js +3 -5
- package/lib/client/cost-inflate.js.map +1 -1
- package/lib/client/format.d.ts +11 -0
- package/lib/client/format.d.ts.map +1 -1
- package/lib/client/format.js +32 -3
- package/lib/client/format.js.map +1 -1
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +25 -1
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +50 -2
- package/lib/client/locales.js.map +1 -1
- package/lib/client/project-rows.d.ts +3 -2
- package/lib/client/project-rows.d.ts.map +1 -1
- package/lib/client/project-rows.js +3 -2
- package/lib/client/project-rows.js.map +1 -1
- package/lib/client/session-stats.d.ts +52 -10
- package/lib/client/session-stats.d.ts.map +1 -1
- package/lib/client/session-stats.js +88 -11
- package/lib/client/session-stats.js.map +1 -1
- package/lib/client/use-cost-inflate.d.ts +5 -15
- package/lib/client/use-cost-inflate.d.ts.map +1 -1
- package/lib/client/use-cost-inflate.js +11 -51
- package/lib/client/use-cost-inflate.js.map +1 -1
- package/lib/client.js +517 -319
- package/lib/client.js.map +1 -1
- package/lib/field-completion.d.ts.map +1 -1
- package/lib/field-completion.js +4 -1
- package/lib/field-completion.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +134 -22
- package/lib/index.js.map +1 -1
- package/lib/migrate.d.ts +7 -1
- package/lib/migrate.d.ts.map +1 -1
- package/lib/migrate.js +116 -9
- package/lib/migrate.js.map +1 -1
- package/lib/project-rows.d.ts +20 -4
- package/lib/project-rows.d.ts.map +1 -1
- package/lib/project-rows.js +33 -8
- package/lib/project-rows.js.map +1 -1
- package/lib/request-observe.d.ts +7 -5
- package/lib/request-observe.d.ts.map +1 -1
- package/lib/request-observe.js +19 -16
- package/lib/request-observe.js.map +1 -1
- package/lib/rollup.d.ts +6 -1
- package/lib/rollup.d.ts.map +1 -1
- package/lib/rollup.js +15 -1
- package/lib/rollup.js.map +1 -1
- package/lib/session-request-details.d.ts.map +1 -1
- package/lib/session-request-details.js +5 -1
- package/lib/session-request-details.js.map +1 -1
- package/lib/stats-route.d.ts.map +1 -1
- package/lib/stats-route.js +65 -8
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts +42 -1
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +240 -16
- package/lib/stats.js.map +1 -1
- package/lib/sync.d.ts +32 -0
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +286 -30
- package/lib/sync.js.map +1 -1
- package/lib/usage-log.d.ts +14 -9
- package/lib/usage-log.d.ts.map +1 -1
- package/lib/usage-log.js +190 -144
- package/lib/usage-log.js.map +1 -1
- package/lib/usage-record.d.ts +150 -27
- package/lib/usage-record.d.ts.map +1 -1
- package/lib/usage-record.js +221 -34
- package/lib/usage-record.js.map +1 -1
- package/lib/web-call.d.ts +55 -0
- package/lib/web-call.d.ts.map +1 -0
- package/lib/web-call.js +222 -0
- package/lib/web-call.js.map +1 -0
- package/lib/wire.d.ts +122 -11
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js +40 -7
- package/lib/wire.js.map +1 -1
- package/locale/en.json +5 -1
- package/locale/zh.json +2 -1
- package/package.json +3 -3
- package/lib/client/CostDeltaFlyLabel.d.ts +0 -8
- package/lib/client/CostDeltaFlyLabel.d.ts.map +0 -1
- package/lib/client/CostDeltaFlyLabel.js +0 -24
- package/lib/client/CostDeltaFlyLabel.js.map +0 -1
package/lib/client.js
CHANGED
|
@@ -15,6 +15,10 @@ window.__ModuleLoader__.load({
|
|
|
15
15
|
const PRICING_PATH = "/token-usage/pricing";
|
|
16
16
|
const PRICING_SYNC_PATH = "/token-usage/pricing-sync";
|
|
17
17
|
const ASSOCIATIONS_PATH = "/token-usage/pricing-associations";
|
|
18
|
+
/** Query key carrying the scope's root session id. */
|
|
19
|
+
const ROOT_PARAM = "root";
|
|
20
|
+
/** Query key carrying the scope kind; omitted means `self`. */
|
|
21
|
+
const SCOPE_PARAM = "scope";
|
|
18
22
|
/** Encode one repeated query key (`sessionId=a&sessionId=b`). Empty list yields ''. */
|
|
19
23
|
function encodeRepeatedParam(key, values) {
|
|
20
24
|
return values.map((value) => `${key}=${encodeURIComponent(value)}`).join("&");
|
|
@@ -25,14 +29,27 @@ window.__ModuleLoader__.load({
|
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Build the stats query string (including the leading `?`, or '' when
|
|
28
|
-
* unconstrained).
|
|
29
|
-
*
|
|
32
|
+
* unconstrained). A `root` request describes a RANGE RULE: the host expands
|
|
33
|
+
* `scope` from its session-metadata lineage index, so the URL never grows
|
|
34
|
+
* with the number of subagents — a subtree of 150+ sessions used to push the
|
|
35
|
+
* request line past Node's 16 KiB header limit (HTTP 431). `scope=self` is
|
|
36
|
+
* the default and is omitted from the wire.
|
|
37
|
+
*
|
|
38
|
+
* The explicit `sessionIds` / `childGroups` form is retained for legacy
|
|
39
|
+
* callers (older browser bundles, hand-written URLs and tests); new client
|
|
40
|
+
* code must use `root`, and the two forms are mutually exclusive.
|
|
41
|
+
* `fields: 'full'` is omitted — that is the default the settings page hits.
|
|
30
42
|
*/
|
|
31
43
|
function encodeStatsQuery(options) {
|
|
32
44
|
const parts = [];
|
|
33
|
-
if (options.
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
if (options.root !== void 0 && options.root !== "") {
|
|
46
|
+
parts.push(`${ROOT_PARAM}=${encodeURIComponent(options.root)}`);
|
|
47
|
+
if (options.scope === "subtree") parts.push(`${SCOPE_PARAM}=subtree`);
|
|
48
|
+
} else {
|
|
49
|
+
if (options.sessionIds !== void 0 && options.sessionIds.length > 0) parts.push(encodeRepeatedParam("sessionId", options.sessionIds));
|
|
50
|
+
const children = options.childGroups !== void 0 ? encodeChildGroups(options.childGroups) : "";
|
|
51
|
+
if (children !== "") parts.push(children);
|
|
52
|
+
}
|
|
36
53
|
if (options.fields !== void 0 && options.fields !== "full") parts.push(`fields=${options.fields}`);
|
|
37
54
|
return parts.length === 0 ? "" : `?${parts.join("&")}`;
|
|
38
55
|
}
|
|
@@ -415,23 +432,45 @@ window.__ModuleLoader__.load({
|
|
|
415
432
|
* Return a value that lags behind its source by `delayMs` — a debounced
|
|
416
433
|
* snapshot. The initial render already holds `value` (no null sentinel), so
|
|
417
434
|
* a consumer can fetch immediately on mount without a second shot when the
|
|
418
|
-
* first debounce window closes on the same value.
|
|
435
|
+
* first debounce window closes on the same value. When `resetKey` changes,
|
|
436
|
+
* the snapshot snaps to the current `value` immediately so a scope switch
|
|
437
|
+
* fires one fetch instead of a second delayed one when the old timer lands.
|
|
419
438
|
*
|
|
420
439
|
* @param value - the source value to debounce.
|
|
421
440
|
* @param delayMs - the lag window in milliseconds.
|
|
441
|
+
* @param resetKey - optional identity whose change bypasses the debounce lag.
|
|
422
442
|
* @returns the debounced value.
|
|
423
443
|
*/
|
|
424
|
-
function useDebouncedValue(value, delayMs) {
|
|
425
|
-
const [
|
|
444
|
+
function useDebouncedValue(value, delayMs, resetKey) {
|
|
445
|
+
const [state, setState] = (0, react.useState)({
|
|
446
|
+
value,
|
|
447
|
+
resetKey
|
|
448
|
+
});
|
|
449
|
+
const effective = Object.is(state.resetKey, resetKey) ? state.value : value;
|
|
426
450
|
(0, react.useEffect)(() => {
|
|
451
|
+
if (!Object.is(state.resetKey, resetKey)) {
|
|
452
|
+
setState({
|
|
453
|
+
value,
|
|
454
|
+
resetKey
|
|
455
|
+
});
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
427
458
|
const timer = setTimeout(() => {
|
|
428
|
-
|
|
459
|
+
setState({
|
|
460
|
+
value,
|
|
461
|
+
resetKey
|
|
462
|
+
});
|
|
429
463
|
}, delayMs);
|
|
430
464
|
return () => {
|
|
431
465
|
clearTimeout(timer);
|
|
432
466
|
};
|
|
433
|
-
}, [
|
|
434
|
-
|
|
467
|
+
}, [
|
|
468
|
+
value,
|
|
469
|
+
delayMs,
|
|
470
|
+
resetKey,
|
|
471
|
+
state.resetKey
|
|
472
|
+
]);
|
|
473
|
+
return effective;
|
|
435
474
|
}
|
|
436
475
|
// src/client/day.ts
|
|
437
476
|
/** Total tokens across the four buckets (billed input = input + cacheRead + cacheWrite). */
|
|
@@ -566,22 +605,38 @@ window.__ModuleLoader__.load({
|
|
|
566
605
|
* future code is not in this map and the tooltip renders it verbatim. */
|
|
567
606
|
const FAILURE_CODE_LABEL_KEYS = {
|
|
568
607
|
ABORTED: "fail.ABORTED",
|
|
608
|
+
ACCOUNT_QUOTA: "fail.ACCOUNT_QUOTA",
|
|
609
|
+
ACCOUNT_SIGN_IN_REQUIRED: "fail.ACCOUNT_SIGN_IN_REQUIRED",
|
|
610
|
+
ACCOUNT_TOKEN_INVALID: "fail.ACCOUNT_TOKEN_INVALID",
|
|
569
611
|
AUTH: "fail.AUTH",
|
|
612
|
+
CLIENT_UPGRADE_REQUIRED: "fail.CLIENT_UPGRADE_REQUIRED",
|
|
613
|
+
CONTENT_REFUSED: "fail.CONTENT_REFUSED",
|
|
570
614
|
CONTEXT_WINDOW_EXCEEDED: "fail.CONTEXT_WINDOW_EXCEEDED",
|
|
571
615
|
EMPTY_RESPONSE: "fail.EMPTY_RESPONSE",
|
|
572
616
|
FILES_API: "fail.FILES_API",
|
|
617
|
+
IMAGE_OFFLOAD_REQUIRED: "fail.IMAGE_OFFLOAD_REQUIRED",
|
|
573
618
|
INVALID_CREDENTIAL: "fail.INVALID_CREDENTIAL",
|
|
574
619
|
INVALID_REQUEST: "fail.INVALID_REQUEST",
|
|
620
|
+
INVALID_RESPONSE: "fail.INVALID_RESPONSE",
|
|
575
621
|
MALFORMED_RESPONSE: "fail.MALFORMED_RESPONSE",
|
|
576
622
|
MISSING_CREDENTIAL: "fail.MISSING_CREDENTIAL",
|
|
623
|
+
MODEL_SWITCH_COMPACTION_FAILED: "fail.MODEL_SWITCH_COMPACTION_FAILED",
|
|
624
|
+
MODEL_UNSUPPORTED: "fail.MODEL_UNSUPPORTED",
|
|
625
|
+
NO_ADAPTER: "fail.NO_ADAPTER",
|
|
626
|
+
PI_AI_ERROR: "fail.PI_AI_ERROR",
|
|
577
627
|
QUOTA: "fail.QUOTA",
|
|
578
628
|
RATE_LIMIT: "fail.RATE_LIMIT",
|
|
579
629
|
REQUEST_EXTENSION: "fail.REQUEST_EXTENSION",
|
|
630
|
+
REQUEST_HEADERS: "fail.REQUEST_HEADERS",
|
|
580
631
|
SERVER: "fail.SERVER",
|
|
581
632
|
STREAM_CLOSED: "fail.STREAM_CLOSED",
|
|
582
633
|
TIMEOUT: "fail.TIMEOUT",
|
|
583
634
|
TRANSPORT: "fail.TRANSPORT",
|
|
584
|
-
UNKNOWN: "fail.UNKNOWN"
|
|
635
|
+
UNKNOWN: "fail.UNKNOWN",
|
|
636
|
+
UNKNOWN_MODEL: "fail.UNKNOWN_MODEL",
|
|
637
|
+
UNSUPPORTED_CONTENT: "fail.UNSUPPORTED_CONTENT",
|
|
638
|
+
UNSUPPORTED_OPTION: "fail.UNSUPPORTED_OPTION",
|
|
639
|
+
UNSUPPORTED_REASONING_EFFORT: "fail.UNSUPPORTED_REASONING_EFFORT"
|
|
585
640
|
};
|
|
586
641
|
/** One decimal below 10, integer otherwise, trailing `.0` stripped. */
|
|
587
642
|
function scale(value) {
|
|
@@ -779,6 +834,19 @@ window.__ModuleLoader__.load({
|
|
|
779
834
|
}
|
|
780
835
|
/**
|
|
781
836
|
* The overhead pill's hover tooltip text: one `label ×count` line per
|
|
837
|
+
/**
|
|
838
|
+
* Total auxiliary (bypass) call count: completed requests plus recorded
|
|
839
|
+
* failures (for example `CONTENT_REFUSED` aux calls that billed before
|
|
840
|
+
* refusal). Kept shared so the overhead pill, card rows, tooltip and detail
|
|
841
|
+
* tab gate stay aligned.
|
|
842
|
+
* @param totals - the totals bucket (usually `aux.total` or a kind row's totals).
|
|
843
|
+
* @returns completed requests plus failures (treating absent failures as 0).
|
|
844
|
+
*/
|
|
845
|
+
function auxCallCount(totals) {
|
|
846
|
+
return totals.requests + (totals.failures ?? 0);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Multi-line tooltip text for the overview card's `OverheadPill`: one line per
|
|
782
850
|
* auxiliary kind, count descending, newline-joined — the same shape as
|
|
783
851
|
* {@link failuresTooltip}. An absent breakdown yields '' and the caller
|
|
784
852
|
* suppresses the tooltip (the pill itself still shows its count).
|
|
@@ -789,7 +857,7 @@ window.__ModuleLoader__.load({
|
|
|
789
857
|
*/
|
|
790
858
|
function overheadTooltip(byKind, t) {
|
|
791
859
|
if (byKind === void 0) return "";
|
|
792
|
-
return byKind.filter((row) => row.totals
|
|
860
|
+
return byKind.filter((row) => auxCallCount(row.totals) > 0).sort((left, right) => auxCallCount(right.totals) - auxCallCount(left.totals)).map((row) => `${t(`aux.kind.${row.auxKind}`)} ×${auxCallCount(row.totals).toLocaleString()}`).join("\n");
|
|
793
861
|
}
|
|
794
862
|
// src/client/PricingStatus.tsx
|
|
795
863
|
function costsAvailable(state) {
|
|
@@ -1766,17 +1834,19 @@ window.__ModuleLoader__.load({
|
|
|
1766
1834
|
return out;
|
|
1767
1835
|
}
|
|
1768
1836
|
/**
|
|
1769
|
-
* The immediate subagent parent of one session, when the record
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1837
|
+
* The immediate subagent parent of one session, when the record is tagged
|
|
1838
|
+
* `origin === 'subagent'` and names a parent. Ordinary forks — including
|
|
1839
|
+
* historical forks that retained `parentId` without `origin: 'subagent'` —
|
|
1840
|
+
* answer `undefined`, matching {@link buildChildIndex}.
|
|
1773
1841
|
* @param rows - the retained session-summary mirror.
|
|
1774
1842
|
* @param id - the current focus session id.
|
|
1775
|
-
* @returns the parent session id, or undefined when the record
|
|
1776
|
-
*
|
|
1843
|
+
* @returns the parent session id, or undefined when the record is not a
|
|
1844
|
+
* subagent child.
|
|
1777
1845
|
*/
|
|
1778
1846
|
function subagentParentOf(rows, id) {
|
|
1779
|
-
const
|
|
1847
|
+
const row = rows[id];
|
|
1848
|
+
if (row?.origin !== "subagent") return void 0;
|
|
1849
|
+
const parent = row.parentId;
|
|
1780
1850
|
return parent === void 0 || parent === id ? void 0 : parent;
|
|
1781
1851
|
}
|
|
1782
1852
|
/**
|
|
@@ -1826,17 +1896,79 @@ window.__ModuleLoader__.load({
|
|
|
1826
1896
|
].join(".");
|
|
1827
1897
|
}
|
|
1828
1898
|
/**
|
|
1829
|
-
*
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1899
|
+
* Compact fingerprint of one session's summary `tokenUsage` projection —
|
|
1900
|
+
* retained on `session.list` rows in DSH 0.2.2+ after `sessionStats` was
|
|
1901
|
+
* excluded from summaries, so subagent token progress still bumps freshness.
|
|
1902
|
+
*/
|
|
1903
|
+
function tokenUsageFingerprint(usage) {
|
|
1904
|
+
if (usage === void 0) return "-";
|
|
1905
|
+
return [
|
|
1906
|
+
usage.uncachedInputTokens,
|
|
1907
|
+
usage.outputTokens,
|
|
1908
|
+
usage.cacheReadTokens,
|
|
1909
|
+
usage.cacheWriteTokens
|
|
1910
|
+
].join(".");
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Build a debounce key from mirror `updatedAt`, summary `tokenUsage` churn
|
|
1914
|
+
* (for subagents in DSH 0.2.2+), and `sessionStats` churn (active session and
|
|
1915
|
+
* legacy hosts).
|
|
1832
1916
|
*/
|
|
1833
1917
|
function buildStatsFreshnessKey(ids, options) {
|
|
1834
1918
|
return ids.map((id) => {
|
|
1835
1919
|
const row = options.rows[id];
|
|
1920
|
+
const tokenUsage = id === options.activeSessionId ? options.liveTokenUsage ?? row?.projectionValues?.tokenUsage : row?.projectionValues?.tokenUsage;
|
|
1836
1921
|
const stats = id === options.activeSessionId ? options.liveSessionStats ?? row?.projectionValues?.sessionStats : row?.projectionValues?.sessionStats;
|
|
1837
|
-
return `${id}:${String(row?.updatedAt ?? 0)}:${sessionStatsFingerprint(stats)}`;
|
|
1922
|
+
return `${id}:${String(row?.updatedAt ?? 0)}:${tokenUsageFingerprint(tokenUsage)}:${sessionStatsFingerprint(stats)}`;
|
|
1838
1923
|
}).join(",");
|
|
1839
1924
|
}
|
|
1925
|
+
/** Aggregate retained `sessionStats` projections across `ids`, preferring the
|
|
1926
|
+
* live hook for `activeSessionId` and reading mirror rows for legacy hosts. */
|
|
1927
|
+
function aggregateScopedProjections(ids, rows, activeSessionId, liveSessionStats) {
|
|
1928
|
+
return aggregateProjections(ids.map((id) => {
|
|
1929
|
+
if (id === activeSessionId) return liveSessionStats ?? rows[id]?.projectionValues?.sessionStats;
|
|
1930
|
+
return rows[id]?.projectionValues?.sessionStats;
|
|
1931
|
+
}));
|
|
1932
|
+
}
|
|
1933
|
+
function timingFromBuckets(bucket) {
|
|
1934
|
+
if (bucket === void 0) return {};
|
|
1935
|
+
return {
|
|
1936
|
+
...bucket.ttftSteps > 0 ? { ttftMs: bucket.ttftMs / bucket.ttftSteps } : {},
|
|
1937
|
+
...bucket.decodeMs > 0 ? { tokensPerSec: bucket.decodeTokens / (bucket.decodeMs / 1e3) } : {}
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
function timingFromPerfTotals(totals) {
|
|
1941
|
+
const samples = totals?.perfStreamCount ?? 0;
|
|
1942
|
+
if (samples <= 0) return {};
|
|
1943
|
+
return {
|
|
1944
|
+
...totals?.perfStreamFirstMsSum !== void 0 ? { ttftMs: totals.perfStreamFirstMsSum / samples } : {},
|
|
1945
|
+
...totals?.perfStreamTpsSum !== void 0 ? { tokensPerSec: totals.perfStreamTpsSum / samples } : {}
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* Resolve header TTFT and decode throughput while keeping DSH's weighted
|
|
1950
|
+
* projection formula (`ttftMs / ttftSteps`, `decodeTokens / (decodeMs / 1_000)`):
|
|
1951
|
+
* - Solo active session: prefer live `sessionStats` projection (covers
|
|
1952
|
+
* unlogged pre-install history and per-step retries), then host `summary.timing`.
|
|
1953
|
+
* - Subtree or drilled subagent: prefer host-aggregated `summary.timing` (which
|
|
1954
|
+
* covers finished subagents even when `sessionStats` is excluded from
|
|
1955
|
+
* summaries in DSH 0.2.2+), then legacy mirror projections, then `perfStream*`
|
|
1956
|
+
* on `history-incomplete` rollup fallbacks.
|
|
1957
|
+
*/
|
|
1958
|
+
function resolveHeaderTiming(input) {
|
|
1959
|
+
const candidates = input.isSoloActive ? [
|
|
1960
|
+
timingFromBuckets(input.liveStats),
|
|
1961
|
+
timingFromBuckets(input.serverTiming),
|
|
1962
|
+
timingFromBuckets(input.mirrorAggregate),
|
|
1963
|
+
timingFromPerfTotals(input.totalPerf)
|
|
1964
|
+
] : [
|
|
1965
|
+
timingFromBuckets(input.serverTiming),
|
|
1966
|
+
timingFromBuckets(input.mirrorAggregate),
|
|
1967
|
+
timingFromPerfTotals(input.totalPerf)
|
|
1968
|
+
];
|
|
1969
|
+
for (const candidate of candidates) if (candidate.ttftMs !== void 0 || candidate.tokensPerSec !== void 0) return candidate;
|
|
1970
|
+
return {};
|
|
1971
|
+
}
|
|
1840
1972
|
// src/client/use-color-scheme.ts
|
|
1841
1973
|
/**
|
|
1842
1974
|
* Shared browser-half hook: mirror the shell's root `color-scheme` onto a
|
|
@@ -1953,88 +2085,6 @@ window.__ModuleLoader__.load({
|
|
|
1953
2085
|
easing: "cubic-bezier(0.25, 0.85, 0.35, 1)"
|
|
1954
2086
|
});
|
|
1955
2087
|
}
|
|
1956
|
-
/** +Δ label fall (`deltaFall`). Caller must position the element (absolute,
|
|
1957
|
-
* below the pill — the dock sits under the composer, so the label falls
|
|
1958
|
-
* away from the message scrollport rather than climbing into it). */
|
|
1959
|
-
function runDeltaFly(el, v) {
|
|
1960
|
-
if (!motionAllowed() || !waapiAvailable(el)) return null;
|
|
1961
|
-
return el.animate([
|
|
1962
|
-
{
|
|
1963
|
-
opacity: 0,
|
|
1964
|
-
transform: "translate(-50%, 20%)"
|
|
1965
|
-
},
|
|
1966
|
-
{
|
|
1967
|
-
opacity: 1,
|
|
1968
|
-
transform: "translate(-50%, 20%)",
|
|
1969
|
-
offset: .15
|
|
1970
|
-
},
|
|
1971
|
-
{
|
|
1972
|
-
opacity: 0,
|
|
1973
|
-
transform: `translate(calc(-50% + ${v.flyX}), calc(100% + ${v.flyY}))`
|
|
1974
|
-
}
|
|
1975
|
-
], {
|
|
1976
|
-
duration: v.inflateMs,
|
|
1977
|
-
easing: "cubic-bezier(0.22, 0.55, 0.25, 1)",
|
|
1978
|
-
fill: "both"
|
|
1979
|
-
});
|
|
1980
|
-
}
|
|
1981
|
-
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/CostPill.module.css.mjs
|
|
1982
|
-
const css$15 = ".T_i-_W_root{min-width:0;display:inline-flex;position:relative}.T_i-_W_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.T_i-_W_glyph{flex:none;width:14px;height:14px}button.T_i-_W_pill{cursor:pointer}button.T_i-_W_pill:hover,button.T_i-_W_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.T_i-_W_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.T_i-_W_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.T_i-_W_deltaFly{color:var(--dsw-alias-state-warn-primary);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;text-shadow:0 0 8px color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent);margin-top:2px;font-size:11px;font-weight:600;position:absolute;top:100%;left:50%}@media (prefers-reduced-motion:reduce){.T_i-_W_deltaFly{display:none}}.T_i-_W_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.T_i-_W_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.T_i-_W_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.T_i-_W_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.T_i-_W_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.T_i-_W_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.T_i-_W_dot{color:var(--dsw-alias-separator-primary)}.T_i-_W_rows{flex-direction:column;margin-top:8px;display:flex}.T_i-_W_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.T_i-_W_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.T_i-_W_rowValue{color:var(--dsw-alias-label-primary)}.T_i-_W_rowSub .T_i-_W_rowValue{color:var(--dsw-alias-label-secondary)}.T_i-_W_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.T_i-_W_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.T_i-_W_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.T_i-_W_unpriced .T_i-_W_rowLabel,.T_i-_W_unpriced .T_i-_W_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.T_i-_W_pending{color:var(--dsw-alias-label-tertiary)}";
|
|
1983
|
-
const tagId$15 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
|
|
1984
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$15) + "]") === null) {
|
|
1985
|
-
const tag = document.createElement("style");
|
|
1986
|
-
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1987
|
-
tag.dataset.pluginCss = tagId$15;
|
|
1988
|
-
tag.textContent = css$15;
|
|
1989
|
-
document.head.appendChild(tag);
|
|
1990
|
-
}
|
|
1991
|
-
var CostPill_module_css_default = {
|
|
1992
|
-
"cost": "T_i-_W_cost",
|
|
1993
|
-
"deltaFly": "T_i-_W_deltaFly",
|
|
1994
|
-
"deltaLayer": "T_i-_W_deltaLayer",
|
|
1995
|
-
"dot": "T_i-_W_dot",
|
|
1996
|
-
"glyph": "T_i-_W_glyph",
|
|
1997
|
-
"groupLabel": "T_i-_W_groupLabel",
|
|
1998
|
-
"panel": "T_i-_W_panel",
|
|
1999
|
-
"panelHead": "T_i-_W_panelHead",
|
|
2000
|
-
"panelTitle": "T_i-_W_panelTitle",
|
|
2001
|
-
"panelTotal": "T_i-_W_panelTotal",
|
|
2002
|
-
"pending": "T_i-_W_pending",
|
|
2003
|
-
"pill": "T_i-_W_pill",
|
|
2004
|
-
"requests": "T_i-_W_requests",
|
|
2005
|
-
"root": "T_i-_W_root",
|
|
2006
|
-
"row": "T_i-_W_row",
|
|
2007
|
-
"rowLabel": "T_i-_W_rowLabel",
|
|
2008
|
-
"rowSub": "T_i-_W_rowSub",
|
|
2009
|
-
"rowValue": "T_i-_W_rowValue",
|
|
2010
|
-
"rows": "T_i-_W_rows",
|
|
2011
|
-
"scopeTag": "T_i-_W_scopeTag",
|
|
2012
|
-
"tok": "T_i-_W_tok",
|
|
2013
|
-
"unpriced": "T_i-_W_unpriced",
|
|
2014
|
-
"usageLine": "T_i-_W_usageLine"
|
|
2015
|
-
};
|
|
2016
|
-
// src/client/CostDeltaFlyLabel.tsx
|
|
2017
|
-
/** One +Δ fly label; animation starts on mount via WAAPI. */
|
|
2018
|
-
function CostDeltaFlyLabel({ text, vars }) {
|
|
2019
|
-
const ref = (0, react.useRef)(null);
|
|
2020
|
-
(0, react.useLayoutEffect)(() => {
|
|
2021
|
-
const el = ref.current;
|
|
2022
|
-
if (el === null) return;
|
|
2023
|
-
const anim = runDeltaFly(el, vars);
|
|
2024
|
-
if (anim === null) {
|
|
2025
|
-
el.style.visibility = "hidden";
|
|
2026
|
-
return;
|
|
2027
|
-
}
|
|
2028
|
-
return () => {
|
|
2029
|
-
anim.cancel();
|
|
2030
|
-
};
|
|
2031
|
-
}, [vars]);
|
|
2032
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2033
|
-
ref,
|
|
2034
|
-
className: CostPill_module_css_default["deltaFly"],
|
|
2035
|
-
children: text
|
|
2036
|
-
});
|
|
2037
|
-
}
|
|
2038
2088
|
// src/client/cost-inflate.ts
|
|
2039
2089
|
const MISS_RATE_CAP = .55;
|
|
2040
2090
|
const OUT_CAP = 32e3;
|
|
@@ -2070,16 +2120,15 @@ window.__ModuleLoader__.load({
|
|
|
2070
2120
|
return {
|
|
2071
2121
|
inflateMs: Math.round(lerp(1e3, 1800, I)),
|
|
2072
2122
|
popScale: lerp(1.08, 1.32, I).toFixed(3),
|
|
2073
|
-
warnMix: `${Math.round(lerp(0, 55, I))}
|
|
2074
|
-
flyY: `${lerp(22, 38, I).toFixed(1)}px`,
|
|
2075
|
-
flyX: `${((Math.random() - .5) * 10).toFixed(1)}px`
|
|
2123
|
+
warnMix: `${Math.round(lerp(0, 55, I))}%`
|
|
2076
2124
|
};
|
|
2077
2125
|
}
|
|
2078
2126
|
// src/client/use-cost-inflate.ts
|
|
2079
2127
|
/**
|
|
2080
2128
|
* Request-driven cost-figure inflate animation for the composer-dock usage
|
|
2081
|
-
* pill: detects new usage from summary deltas and drives WAAPI motion on
|
|
2082
|
-
* the cost figure
|
|
2129
|
+
* pill: detects new usage from summary deltas and drives the WAAPI motion on
|
|
2130
|
+
* the cost figure (a scale + colour pop whose amplitude follows the step's
|
|
2131
|
+
* token intensity).
|
|
2083
2132
|
*
|
|
2084
2133
|
* @module token-usage/client/use-cost-inflate
|
|
2085
2134
|
*/
|
|
@@ -2091,44 +2140,23 @@ window.__ModuleLoader__.load({
|
|
|
2091
2140
|
return totalTokens$1(delta) > 0;
|
|
2092
2141
|
}
|
|
2093
2142
|
/**
|
|
2094
|
-
* Hook the pill uses to play costPop
|
|
2143
|
+
* Hook the pill uses to play the costPop on each new request.
|
|
2095
2144
|
* @param scopeKey - changes reset the diff baseline.
|
|
2096
2145
|
* @param costRef - the live cost figure span (WAAPI target).
|
|
2097
2146
|
*/
|
|
2098
2147
|
function useCostInflate(scopeKey, costRef) {
|
|
2099
2148
|
const prevRef = (0, react.useRef)(null);
|
|
2100
|
-
const flyIdRef = (0, react.useRef)(0);
|
|
2101
|
-
const timersRef = (0, react.useRef)([]);
|
|
2102
|
-
const flyCountRef = (0, react.useRef)(0);
|
|
2103
2149
|
const popAnimRef = (0, react.useRef)(null);
|
|
2104
|
-
const [flies, setFlies] = (0, react.useState)([]);
|
|
2105
|
-
const [flyOverflow, setFlyOverflow] = (0, react.useState)(false);
|
|
2106
|
-
const clearTimers = (0, react.useCallback)(() => {
|
|
2107
|
-
for (const id of timersRef.current) window.clearTimeout(id);
|
|
2108
|
-
timersRef.current = [];
|
|
2109
|
-
}, []);
|
|
2110
|
-
const schedule = (0, react.useCallback)((fn, ms) => {
|
|
2111
|
-
const id = window.setTimeout(fn, ms);
|
|
2112
|
-
timersRef.current.push(id);
|
|
2113
|
-
}, []);
|
|
2114
2150
|
const reset = (0, react.useCallback)(() => {
|
|
2115
|
-
clearTimers();
|
|
2116
2151
|
popAnimRef.current?.cancel();
|
|
2117
2152
|
popAnimRef.current = null;
|
|
2118
2153
|
prevRef.current = null;
|
|
2119
|
-
|
|
2120
|
-
flyCountRef.current = 0;
|
|
2121
|
-
setFlies([]);
|
|
2122
|
-
setFlyOverflow(false);
|
|
2123
|
-
}, [clearTimers]);
|
|
2154
|
+
}, []);
|
|
2124
2155
|
(0, react.useEffect)(() => {
|
|
2125
2156
|
reset();
|
|
2126
2157
|
}, [scopeKey, reset]);
|
|
2127
2158
|
(0, react.useEffect)(() => () => {
|
|
2128
|
-
|
|
2129
|
-
}, [clearTimers]);
|
|
2130
|
-
const maybeClearOverflow = (0, react.useCallback)(() => {
|
|
2131
|
-
if (flyCountRef.current <= 0) setFlyOverflow(false);
|
|
2159
|
+
popAnimRef.current?.cancel();
|
|
2132
2160
|
}, []);
|
|
2133
2161
|
const playCostPop = (0, react.useCallback)((v) => {
|
|
2134
2162
|
const el = costRef.current;
|
|
@@ -2137,8 +2165,6 @@ window.__ModuleLoader__.load({
|
|
|
2137
2165
|
popAnimRef.current = runCostPop(el, v);
|
|
2138
2166
|
}, [costRef]);
|
|
2139
2167
|
return {
|
|
2140
|
-
flies,
|
|
2141
|
-
flyOverflow,
|
|
2142
2168
|
onSummary: (0, react.useCallback)((summary) => {
|
|
2143
2169
|
if (!costsAvailable(summary.costState)) {
|
|
2144
2170
|
reset();
|
|
@@ -2154,36 +2180,46 @@ window.__ModuleLoader__.load({
|
|
|
2154
2180
|
if (!hasUsageChurn(prev, summary)) return;
|
|
2155
2181
|
if (!motionAllowed()) return;
|
|
2156
2182
|
const v = animVars(computeIntensityFromDelta(deltaTotals(prev.totals, summary.total)));
|
|
2157
|
-
setFlyOverflow(true);
|
|
2158
2183
|
window.requestAnimationFrame(() => {
|
|
2159
2184
|
playCostPop(v);
|
|
2160
2185
|
});
|
|
2161
|
-
|
|
2162
|
-
if (wireDeltaCost > MIN_WIRE_DELTA_COST) {
|
|
2163
|
-
const view = currencyViewOf(summary);
|
|
2164
|
-
const text = `+${(wireDeltaCost / view.rate).toFixed(2)}${view.symbol}`;
|
|
2165
|
-
const id = ++flyIdRef.current;
|
|
2166
|
-
flyCountRef.current += 1;
|
|
2167
|
-
setFlies((current) => [...current, {
|
|
2168
|
-
id,
|
|
2169
|
-
text,
|
|
2170
|
-
vars: v
|
|
2171
|
-
}]);
|
|
2172
|
-
schedule(() => {
|
|
2173
|
-
flyCountRef.current -= 1;
|
|
2174
|
-
setFlies((current) => current.filter((fly) => fly.id !== id));
|
|
2175
|
-
maybeClearOverflow();
|
|
2176
|
-
}, v.inflateMs + 40);
|
|
2177
|
-
} else schedule(maybeClearOverflow, v.inflateMs + 40);
|
|
2178
|
-
}, [
|
|
2179
|
-
maybeClearOverflow,
|
|
2180
|
-
playCostPop,
|
|
2181
|
-
schedule,
|
|
2182
|
-
reset
|
|
2183
|
-
]),
|
|
2186
|
+
}, [playCostPop, reset]),
|
|
2184
2187
|
reset
|
|
2185
2188
|
};
|
|
2186
2189
|
}
|
|
2190
|
+
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/CostPill.module.css.mjs
|
|
2191
|
+
const css$15 = ".T_i-_W_root{min-width:0;display:inline-flex;position:relative}.T_i-_W_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.T_i-_W_glyph{flex:none;width:14px;height:14px}button.T_i-_W_pill{cursor:pointer}button.T_i-_W_pill:hover,button.T_i-_W_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.T_i-_W_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.T_i-_W_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.T_i-_W_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.T_i-_W_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.T_i-_W_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.T_i-_W_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.T_i-_W_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.T_i-_W_dot{color:var(--dsw-alias-separator-primary)}.T_i-_W_rows{flex-direction:column;margin-top:8px;display:flex}.T_i-_W_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.T_i-_W_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.T_i-_W_rowValue{color:var(--dsw-alias-label-primary)}.T_i-_W_rowSub .T_i-_W_rowValue{color:var(--dsw-alias-label-secondary)}.T_i-_W_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.T_i-_W_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.T_i-_W_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.T_i-_W_unpriced .T_i-_W_rowLabel,.T_i-_W_unpriced .T_i-_W_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.T_i-_W_pending{color:var(--dsw-alias-label-tertiary)}";
|
|
2192
|
+
const tagId$15 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
|
|
2193
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$15) + "]") === null) {
|
|
2194
|
+
const tag = document.createElement("style");
|
|
2195
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2196
|
+
tag.dataset.pluginCss = tagId$15;
|
|
2197
|
+
tag.textContent = css$15;
|
|
2198
|
+
document.head.appendChild(tag);
|
|
2199
|
+
}
|
|
2200
|
+
var CostPill_module_css_default = {
|
|
2201
|
+
"cost": "T_i-_W_cost",
|
|
2202
|
+
"dot": "T_i-_W_dot",
|
|
2203
|
+
"glyph": "T_i-_W_glyph",
|
|
2204
|
+
"groupLabel": "T_i-_W_groupLabel",
|
|
2205
|
+
"panel": "T_i-_W_panel",
|
|
2206
|
+
"panelHead": "T_i-_W_panelHead",
|
|
2207
|
+
"panelTitle": "T_i-_W_panelTitle",
|
|
2208
|
+
"panelTotal": "T_i-_W_panelTotal",
|
|
2209
|
+
"pending": "T_i-_W_pending",
|
|
2210
|
+
"pill": "T_i-_W_pill",
|
|
2211
|
+
"requests": "T_i-_W_requests",
|
|
2212
|
+
"root": "T_i-_W_root",
|
|
2213
|
+
"row": "T_i-_W_row",
|
|
2214
|
+
"rowLabel": "T_i-_W_rowLabel",
|
|
2215
|
+
"rowSub": "T_i-_W_rowSub",
|
|
2216
|
+
"rowValue": "T_i-_W_rowValue",
|
|
2217
|
+
"rows": "T_i-_W_rows",
|
|
2218
|
+
"scopeTag": "T_i-_W_scopeTag",
|
|
2219
|
+
"tok": "T_i-_W_tok",
|
|
2220
|
+
"unpriced": "T_i-_W_unpriced",
|
|
2221
|
+
"usageLine": "T_i-_W_usageLine"
|
|
2222
|
+
};
|
|
2187
2223
|
// src/client/CostPill.tsx
|
|
2188
2224
|
/**
|
|
2189
2225
|
* Composer-dock usage pill (browser half): a cost trigger registered into
|
|
@@ -2208,10 +2244,9 @@ window.__ModuleLoader__.load({
|
|
|
2208
2244
|
* cadence, inherited whole): `sessionStats` projection churn plus mirror
|
|
2209
2245
|
* `updatedAt` is debounced 250 ms into one fetch, a failed FIRST fetch
|
|
2210
2246
|
* retries itself on a 3 s cadence, and later failures keep the prior
|
|
2211
|
-
* figures. When
|
|
2212
|
-
*
|
|
2213
|
-
*
|
|
2214
|
-
* Reduced-motion users get silent figure updates.
|
|
2247
|
+
* figures. When usage grows on a new request the figure plays `costPop` —
|
|
2248
|
+
* a scale + colour pop whose amplitude follows that step's token
|
|
2249
|
+
* intensity. Reduced-motion users get silent figure updates.
|
|
2215
2250
|
*
|
|
2216
2251
|
* Visibility contract: a session with no recorded requests renders
|
|
2217
2252
|
* nothing; a transient fetch miss keeps the previous render.
|
|
@@ -2267,19 +2302,41 @@ window.__ModuleLoader__.load({
|
|
|
2267
2302
|
childIndex
|
|
2268
2303
|
]);
|
|
2269
2304
|
const hasSubs = scopeIds.length > 1;
|
|
2270
|
-
const
|
|
2305
|
+
const liveStats = useProjection("sessionStats");
|
|
2306
|
+
const scopeIdsKey = scopeIds.join(",");
|
|
2307
|
+
const debouncedFreshnessKey = useDebouncedValue(buildStatsFreshnessKey(scopeIds, {
|
|
2271
2308
|
activeSessionId: sessionId,
|
|
2272
2309
|
rows: byId,
|
|
2273
|
-
liveSessionStats:
|
|
2274
|
-
});
|
|
2275
|
-
const
|
|
2276
|
-
const
|
|
2310
|
+
liveSessionStats: liveStats
|
|
2311
|
+
}), REFRESH_DEBOUNCE_MS$1, sessionId);
|
|
2312
|
+
const { onSummary } = useCostInflate(`${sessionId}:${scopeIds.length}`, costRef);
|
|
2313
|
+
const recentRef = (0, react.useRef)(void 0);
|
|
2277
2314
|
const [treeRes, retryTree] = useAsyncResource((signal) => {
|
|
2278
|
-
const
|
|
2279
|
-
|
|
2280
|
-
|
|
2315
|
+
const recent = recentRef.current;
|
|
2316
|
+
if (recent !== void 0 && !recent.coalesced && recent.sessionId === sessionId && recent.scopeIdsKey !== scopeIdsKey && recent.associationTick === associationTick && Date.now() - recent.at < 500 && recent !== void 0) {
|
|
2317
|
+
recentRef.current = {
|
|
2318
|
+
...recent,
|
|
2319
|
+
scopeIdsKey,
|
|
2320
|
+
at: Date.now(),
|
|
2321
|
+
coalesced: true
|
|
2322
|
+
};
|
|
2323
|
+
return Promise.resolve(recent.value);
|
|
2324
|
+
}
|
|
2325
|
+
return fetchSummary$1(sessionId, "subtree", "chip", signal).then((value) => {
|
|
2326
|
+
if (value !== null) recentRef.current = {
|
|
2327
|
+
sessionId,
|
|
2328
|
+
scopeIdsKey,
|
|
2329
|
+
associationTick,
|
|
2330
|
+
at: Date.now(),
|
|
2331
|
+
value,
|
|
2332
|
+
coalesced: false
|
|
2333
|
+
};
|
|
2334
|
+
return value;
|
|
2335
|
+
});
|
|
2336
|
+
}, [debouncedFreshnessKey, associationTick], {
|
|
2281
2337
|
silentAfterFirst: true,
|
|
2282
|
-
retryToken: 0
|
|
2338
|
+
retryToken: 0,
|
|
2339
|
+
scopeKey: sessionId
|
|
2283
2340
|
});
|
|
2284
2341
|
const summary = treeRes.status === "ready" ? treeRes.value : null;
|
|
2285
2342
|
(0, react.useEffect)(() => {
|
|
@@ -2292,29 +2349,24 @@ window.__ModuleLoader__.load({
|
|
|
2292
2349
|
window.clearTimeout(timer);
|
|
2293
2350
|
};
|
|
2294
2351
|
}, [treeRes, retryTree]);
|
|
2295
|
-
const [detailRes] = useAsyncResource((signal) =>
|
|
2296
|
-
if (!open) return Promise.resolve(null);
|
|
2297
|
-
const [idsPart] = debouncedKey.split("\n ");
|
|
2298
|
-
return fetchSummary$1((idsPart ?? "").split("\n").filter((id) => id !== ""), "session", signal);
|
|
2299
|
-
}, [
|
|
2352
|
+
const [detailRes] = useAsyncResource((signal) => open ? fetchSummary$1(sessionId, "subtree", "session", signal) : Promise.resolve(null), [
|
|
2300
2353
|
open,
|
|
2301
|
-
|
|
2354
|
+
debouncedFreshnessKey,
|
|
2302
2355
|
associationTick
|
|
2303
2356
|
], {
|
|
2304
2357
|
silentAfterFirst: true,
|
|
2305
|
-
retryToken: 0
|
|
2358
|
+
retryToken: 0,
|
|
2359
|
+
scopeKey: sessionId
|
|
2306
2360
|
});
|
|
2307
|
-
const [selfRes] = useAsyncResource((signal) =>
|
|
2308
|
-
if (!open || sessionId === "") return Promise.resolve(null);
|
|
2309
|
-
return fetchSummary$1([sessionId], "chip", signal);
|
|
2310
|
-
}, [
|
|
2361
|
+
const [selfRes] = useAsyncResource((signal) => open && sessionId !== "" ? fetchSummary$1(sessionId, "self", "chip", signal) : Promise.resolve(null), [
|
|
2311
2362
|
open,
|
|
2312
2363
|
sessionId,
|
|
2313
|
-
|
|
2364
|
+
debouncedFreshnessKey,
|
|
2314
2365
|
associationTick
|
|
2315
2366
|
], {
|
|
2316
2367
|
silentAfterFirst: true,
|
|
2317
|
-
retryToken: 0
|
|
2368
|
+
retryToken: 0,
|
|
2369
|
+
scopeKey: sessionId
|
|
2318
2370
|
});
|
|
2319
2371
|
(0, react.useEffect)(() => {
|
|
2320
2372
|
setOpen(false);
|
|
@@ -2381,41 +2433,30 @@ window.__ModuleLoader__.load({
|
|
|
2381
2433
|
onClick: () => {
|
|
2382
2434
|
setOpen(!open);
|
|
2383
2435
|
},
|
|
2384
|
-
children: [
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
children: costText
|
|
2409
|
-
}),
|
|
2410
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2411
|
-
className: CostPill_module_css_default.deltaLayer,
|
|
2412
|
-
"aria-hidden": "true",
|
|
2413
|
-
children: flies.map((fly) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostDeltaFlyLabel, {
|
|
2414
|
-
text: fly.text,
|
|
2415
|
-
vars: fly.vars
|
|
2416
|
-
}, fly.id))
|
|
2417
|
-
})
|
|
2418
|
-
]
|
|
2436
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
2437
|
+
className: CostPill_module_css_default.glyph,
|
|
2438
|
+
viewBox: "0 0 14 14",
|
|
2439
|
+
width: "14",
|
|
2440
|
+
height: "14",
|
|
2441
|
+
"aria-hidden": true,
|
|
2442
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
2443
|
+
cx: "7",
|
|
2444
|
+
cy: "7",
|
|
2445
|
+
r: "5.5",
|
|
2446
|
+
fill: "none",
|
|
2447
|
+
stroke: "currentColor",
|
|
2448
|
+
strokeWidth: "1.2"
|
|
2449
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
2450
|
+
d: "M4.8 4.5 L7 7.2 L9.2 4.5 M7 7.2 V10 M5.2 8 H8.8 M5.2 9.4 H8.8",
|
|
2451
|
+
fill: "none",
|
|
2452
|
+
stroke: "currentColor",
|
|
2453
|
+
strokeWidth: "1.2"
|
|
2454
|
+
})]
|
|
2455
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2456
|
+
ref: costRef,
|
|
2457
|
+
className: CostPill_module_css_default.cost,
|
|
2458
|
+
children: costText
|
|
2459
|
+
})]
|
|
2419
2460
|
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2420
2461
|
className: CostPill_module_css_default.panel,
|
|
2421
2462
|
role: "dialog",
|
|
@@ -2559,20 +2600,22 @@ window.__ModuleLoader__.load({
|
|
|
2559
2600
|
return typeof value === "object" && value !== null && typeof value.total === "object" && value.total !== null;
|
|
2560
2601
|
}
|
|
2561
2602
|
/**
|
|
2562
|
-
* Fetch one stats summary.
|
|
2563
|
-
*
|
|
2564
|
-
* the
|
|
2565
|
-
*
|
|
2566
|
-
*
|
|
2567
|
-
*
|
|
2568
|
-
* @param
|
|
2569
|
-
*
|
|
2603
|
+
* Fetch one stats summary. The request carries a RANGE RULE (root + scope),
|
|
2604
|
+
* never an enumerated subtree — the host expands it from its lineage index,
|
|
2605
|
+
* so the pill's chip/detail reads stay short even for hundreds of subagents.
|
|
2606
|
+
* Throws on transport failure (network, abort, non-2xx response, or a payload
|
|
2607
|
+
* that doesn't look like a stats summary) so the hook can keep the previous
|
|
2608
|
+
* render in place.
|
|
2609
|
+
* @param root - the scope's root session id; empty skips the fetch.
|
|
2610
|
+
* @param scope - `subtree` for the folded total, `self` for the split.
|
|
2611
|
+
* @param fields - `chip` for totals-only reads, `session` for byModel.
|
|
2570
2612
|
* @param signal - the cancellation signal from the hook.
|
|
2571
2613
|
*/
|
|
2572
|
-
async function fetchSummary$1(
|
|
2573
|
-
if (
|
|
2614
|
+
async function fetchSummary$1(root, scope, fields, signal) {
|
|
2615
|
+
if (root === "") return null;
|
|
2574
2616
|
const response = await fetch(STATS_PATH + encodeStatsQuery({
|
|
2575
|
-
|
|
2617
|
+
root,
|
|
2618
|
+
scope,
|
|
2576
2619
|
fields
|
|
2577
2620
|
}), {
|
|
2578
2621
|
headers: { accept: "application/json" },
|
|
@@ -3419,7 +3462,8 @@ window.__ModuleLoader__.load({
|
|
|
3419
3462
|
added: body.added,
|
|
3420
3463
|
skipped: body.skipped,
|
|
3421
3464
|
removed: typeof body.removed === "number" ? body.removed : 0,
|
|
3422
|
-
failedSessions: typeof body.failedSessions === "number" ? body.failedSessions : 0
|
|
3465
|
+
failedSessions: typeof body.failedSessions === "number" ? body.failedSessions : 0,
|
|
3466
|
+
...typeof body.ignoredImported === "number" && body.ignoredImported > 0 ? { ignoredImported: body.ignoredImported } : {}
|
|
3423
3467
|
};
|
|
3424
3468
|
return null;
|
|
3425
3469
|
}
|
|
@@ -3649,13 +3693,17 @@ window.__ModuleLoader__.load({
|
|
|
3649
3693
|
role: "status",
|
|
3650
3694
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3651
3695
|
className: TokenUsageCard_module_css_default.fullSyncProgressLabel,
|
|
3652
|
-
children: [
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3696
|
+
children: [
|
|
3697
|
+
t("card.fullSync.progress", {
|
|
3698
|
+
processed: String(fullSync.processed),
|
|
3699
|
+
total: String(fullSync.total),
|
|
3700
|
+
added: String(fullSync.added),
|
|
3701
|
+
skipped: String(fullSync.skipped),
|
|
3702
|
+
removed: String(fullSync.removed)
|
|
3703
|
+
}),
|
|
3704
|
+
fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : "",
|
|
3705
|
+
fullSync.ignoredImported !== void 0 ? t("card.fullSync.importedNote", { count: String(fullSync.ignoredImported) }) : ""
|
|
3706
|
+
]
|
|
3659
3707
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3660
3708
|
className: TokenUsageCard_module_css_default.fullSyncBar,
|
|
3661
3709
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -3667,11 +3715,15 @@ window.__ModuleLoader__.load({
|
|
|
3667
3715
|
fullSync.status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
3668
3716
|
className: TokenUsageCard_module_css_default.fullSyncResult,
|
|
3669
3717
|
role: "status",
|
|
3670
|
-
children: [
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3718
|
+
children: [
|
|
3719
|
+
t("card.fullSync.done", {
|
|
3720
|
+
added: String(fullSync.added),
|
|
3721
|
+
skipped: String(fullSync.skipped),
|
|
3722
|
+
removed: String(fullSync.removed)
|
|
3723
|
+
}),
|
|
3724
|
+
fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : "",
|
|
3725
|
+
fullSync.ignoredImported !== void 0 ? t("card.fullSync.importedNote", { count: String(fullSync.ignoredImported) }) : ""
|
|
3726
|
+
]
|
|
3675
3727
|
}) : null,
|
|
3676
3728
|
fullSync.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3677
3729
|
className: TokenUsageCard_module_css_default.fullSyncError,
|
|
@@ -4247,23 +4299,28 @@ window.__ModuleLoader__.load({
|
|
|
4247
4299
|
/**
|
|
4248
4300
|
* The runtime-overhead card's row shape (browser half): one expanded-by-
|
|
4249
4301
|
* default row per auxiliary kind — the row carries the kind's aggregate
|
|
4250
|
-
* (calls · cost · tokens) and discloses its per-model lines on toggle
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4302
|
+
* (calls · cost · tokens) and discloses its per-model lines on toggle — plus
|
|
4303
|
+
* one expanded-by-default web-tools row that carries the total call count and
|
|
4304
|
+
* discloses its per-tool lines (`web_search`, `web_fetch`) on toggle. The
|
|
4305
|
+
* total line beneath the list covers the auxiliary kinds only: web tools
|
|
4306
|
+
* never join it, and any tokens a search reported are billed with the
|
|
4307
|
+
* ordinary request totals.
|
|
4254
4308
|
*
|
|
4255
4309
|
* @module token-usage/client/OverheadRows
|
|
4256
4310
|
*/
|
|
4257
4311
|
/**
|
|
4258
|
-
* Render the overhead rows: one disclosure row per kind,
|
|
4259
|
-
*
|
|
4260
|
-
* payload with no `aux` field at all —
|
|
4261
|
-
* the
|
|
4262
|
-
*
|
|
4263
|
-
*
|
|
4312
|
+
* Render the overhead rows: one disclosure row per auxiliary kind, the
|
|
4313
|
+
* web-search row, then the auxiliary total line. A summary without auxiliary
|
|
4314
|
+
* requests — including an older host payload with no `aux` field at all —
|
|
4315
|
+
* renders the empty hint instead, unless the web-search layer has calls.
|
|
4316
|
+
* A web row renders one line: its call count.
|
|
4317
|
+
* @param props - the aux layer (possibly absent), the web-search layer
|
|
4318
|
+
* (absent on legacy payloads), the cost state, the display currency view,
|
|
4319
|
+
* and the locale translator.
|
|
4264
4320
|
*/
|
|
4265
|
-
function OverheadRows({ aux, costState, view, t }) {
|
|
4321
|
+
function OverheadRows({ aux, web, costState, view, t }) {
|
|
4266
4322
|
const [collapsedKinds, setCollapsedKinds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
4323
|
+
const [webCollapsed, setWebCollapsed] = (0, react.useState)(false);
|
|
4267
4324
|
const toggleKind = (auxKind) => {
|
|
4268
4325
|
setCollapsedKinds((previous) => {
|
|
4269
4326
|
const next = new Set(previous);
|
|
@@ -4272,7 +4329,9 @@ window.__ModuleLoader__.load({
|
|
|
4272
4329
|
return next;
|
|
4273
4330
|
});
|
|
4274
4331
|
};
|
|
4275
|
-
|
|
4332
|
+
const hasAux = aux !== void 0 && auxCallCount(aux.total) > 0;
|
|
4333
|
+
const hasWeb = web !== void 0 && web.calls > 0;
|
|
4334
|
+
if (!hasAux && !hasWeb) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4276
4335
|
className: OverheadRows_module_css_default["muted"],
|
|
4277
4336
|
children: t("aux.empty")
|
|
4278
4337
|
});
|
|
@@ -4291,11 +4350,11 @@ window.__ModuleLoader__.load({
|
|
|
4291
4350
|
formatTokens(tokens)
|
|
4292
4351
|
] })]
|
|
4293
4352
|
});
|
|
4294
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
4353
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4295
4354
|
className: UsageRows_module_css_default["rows"],
|
|
4296
4355
|
role: "list",
|
|
4297
4356
|
"aria-label": t("aux.tab"),
|
|
4298
|
-
children: (aux
|
|
4357
|
+
children: [(aux?.byKind ?? []).map((kindRow) => {
|
|
4299
4358
|
const expanded = !collapsedKinds.has(kindRow.auxKind);
|
|
4300
4359
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4301
4360
|
className: OverheadRows_module_css_default["orow"],
|
|
@@ -4315,7 +4374,7 @@ window.__ModuleLoader__.load({
|
|
|
4315
4374
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4316
4375
|
className: OverheadRows_module_css_default["onums"],
|
|
4317
4376
|
children: [
|
|
4318
|
-
t("aux.requestCount", { count: kindRow.totals.
|
|
4377
|
+
t("aux.requestCount", { count: auxCallCount(kindRow.totals).toLocaleString() }),
|
|
4319
4378
|
" · ",
|
|
4320
4379
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4321
4380
|
className: OverheadRows_module_css_default["onumsCost"],
|
|
@@ -4327,13 +4386,42 @@ window.__ModuleLoader__.load({
|
|
|
4327
4386
|
})]
|
|
4328
4387
|
}), expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4329
4388
|
className: OverheadRows_module_css_default["adetail"],
|
|
4330
|
-
children: (kindRow.byModel ?? []).map((modelRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: modelLine(modelRow.model, modelRow.totals
|
|
4389
|
+
children: (kindRow.byModel ?? []).map((modelRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: modelLine(modelRow.model, auxCallCount(modelRow.totals), modelRow.cost, totalTokens$1(modelRow.totals)) }, `${kindRow.auxKind}:${modelRow.model}`))
|
|
4331
4390
|
}) : null]
|
|
4332
4391
|
}, kindRow.auxKind);
|
|
4333
|
-
})
|
|
4334
|
-
|
|
4392
|
+
}), hasWeb ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4393
|
+
className: OverheadRows_module_css_default["orow"],
|
|
4394
|
+
role: "listitem",
|
|
4395
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4396
|
+
className: OverheadRows_module_css_default["orowTop"],
|
|
4397
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4398
|
+
type: "button",
|
|
4399
|
+
className: OverheadRows_module_css_default["kindToggle"],
|
|
4400
|
+
"aria-expanded": !webCollapsed,
|
|
4401
|
+
onClick: () => setWebCollapsed((previous) => !previous),
|
|
4402
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4403
|
+
className: OverheadRows_module_css_default["chevron"],
|
|
4404
|
+
"aria-hidden": "true",
|
|
4405
|
+
children: "▸"
|
|
4406
|
+
}), t("web.title")]
|
|
4407
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4408
|
+
className: OverheadRows_module_css_default["onums"],
|
|
4409
|
+
children: t("web.calls", { count: web.calls.toLocaleString() })
|
|
4410
|
+
})]
|
|
4411
|
+
}), !webCollapsed && (web.byTool?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4412
|
+
className: OverheadRows_module_css_default["adetail"],
|
|
4413
|
+
children: (web.byTool ?? []).map((toolRow) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4414
|
+
className: OverheadRows_module_css_default["dline"],
|
|
4415
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4416
|
+
className: OverheadRows_module_css_default["dmodelName"],
|
|
4417
|
+
children: t(`web.tool.${toolRow.tool}`)
|
|
4418
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("web.calls", { count: toolRow.calls.toLocaleString() }) })]
|
|
4419
|
+
}, `web:${toolRow.tool}`))
|
|
4420
|
+
}) : null]
|
|
4421
|
+
}, "web-tools") : null]
|
|
4422
|
+
}), hasAux ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4335
4423
|
className: OverheadRows_module_css_default["asum"],
|
|
4336
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("aux.totalCount", { count: aux.total.
|
|
4424
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("aux.totalCount", { count: auxCallCount(aux.total).toLocaleString() }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
4337
4425
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4338
4426
|
className: OverheadRows_module_css_default["onumsCost"],
|
|
4339
4427
|
children: costText(aux.cost)
|
|
@@ -4341,7 +4429,7 @@ window.__ModuleLoader__.load({
|
|
|
4341
4429
|
" · ",
|
|
4342
4430
|
formatTokens(totalTokens$1(aux.total))
|
|
4343
4431
|
] })]
|
|
4344
|
-
})] });
|
|
4432
|
+
}) : null] });
|
|
4345
4433
|
}
|
|
4346
4434
|
// src/project-rows.ts
|
|
4347
4435
|
function totalTokens(totals) {
|
|
@@ -4352,6 +4440,25 @@ window.__ModuleLoader__.load({
|
|
|
4352
4440
|
const parts = cwd.split(/[\\/]/u).filter((part) => part !== "");
|
|
4353
4441
|
return parts[parts.length - 1] ?? cwd;
|
|
4354
4442
|
}
|
|
4443
|
+
/** The dsh-worktree plugin's project-internal layout marker: a checkout
|
|
4444
|
+
* at `<repo>/.dsh/gitworktree/<branch>` belongs to `<repo>`. Matches the
|
|
4445
|
+
* branch segment (never the bare layout root) and everything under it,
|
|
4446
|
+
* on either separator. */
|
|
4447
|
+
const WORKTREE_LAYOUT = /[/\\]\.dsh[/\\]gitworktree[/\\][^/\\]+/u;
|
|
4448
|
+
/**
|
|
4449
|
+
* Map a session cwd onto the repository it belongs to for project
|
|
4450
|
+
* aggregation: a `<repo>/.dsh/gitworktree/<branch>` checkout (the
|
|
4451
|
+
* dsh-worktree plugin's project layout, deeper subdirectories included)
|
|
4452
|
+
* folds onto its repository root, so worktree sessions join the
|
|
4453
|
+
* repository's own project row instead of surfacing as a project of
|
|
4454
|
+
* their own. Any other path returns unchanged. Pure string work — the
|
|
4455
|
+
* host fold and the browser's older-host fallback must share one rule,
|
|
4456
|
+
* and neither can probe the disk.
|
|
4457
|
+
*/
|
|
4458
|
+
function belongedCwdOf(cwd) {
|
|
4459
|
+
const match = WORKTREE_LAYOUT.exec(cwd);
|
|
4460
|
+
return match === null ? cwd : cwd.slice(0, match.index);
|
|
4461
|
+
}
|
|
4355
4462
|
/** Element-wise totals sum: the counted fields add, the optional ones
|
|
4356
4463
|
* treat absence as 0 and stay absent only while both sides lack them. */
|
|
4357
4464
|
function addTotals(left, right) {
|
|
@@ -4385,28 +4492,32 @@ window.__ModuleLoader__.load({
|
|
|
4385
4492
|
* Fold session rows into one row per directory tail, token-descending (the
|
|
4386
4493
|
* dashboard's relative bars take the first row as their 100%). The tail is
|
|
4387
4494
|
* the bucket key — two different full paths ending in the same segment read
|
|
4388
|
-
* as one project here, matching the demo's semantics
|
|
4389
|
-
*
|
|
4390
|
-
*
|
|
4495
|
+
* as one project here, matching the demo's semantics — and a worktree
|
|
4496
|
+
* checkout (`<repo>/.dsh/gitworktree/<branch>`, see {@link belongedCwdOf})
|
|
4497
|
+
* folds onto its repository before the tail is taken, so its sessions join
|
|
4498
|
+
* the repository's project. Within a bucket the first-seen (belonged) cwd
|
|
4499
|
+
* rides along as the representative full path. The input order is preserved
|
|
4500
|
+
* inside a bucket (the served rows arrive cost-sorted).
|
|
4391
4501
|
* @param rows - subtree-folded root sessions; the host supplies the full
|
|
4392
4502
|
* set, not the truncated session list.
|
|
4393
4503
|
*/
|
|
4394
4504
|
function projectRowsOf(rows) {
|
|
4395
4505
|
const buckets = /* @__PURE__ */ new Map();
|
|
4396
4506
|
for (const row of rows) {
|
|
4397
|
-
const
|
|
4507
|
+
const owned = row.cwd === void 0 ? void 0 : belongedCwdOf(row.cwd);
|
|
4508
|
+
const name = owned === void 0 ? "" : dirTailOf(owned);
|
|
4398
4509
|
const bucket = buckets.get(name);
|
|
4399
4510
|
if (bucket === void 0) {
|
|
4400
4511
|
buckets.set(name, {
|
|
4401
4512
|
name,
|
|
4402
|
-
...
|
|
4513
|
+
...owned === void 0 ? {} : { cwd: owned },
|
|
4403
4514
|
sessionCount: 1,
|
|
4404
4515
|
totals: { ...row.totals },
|
|
4405
4516
|
cost: row.cost
|
|
4406
4517
|
});
|
|
4407
4518
|
continue;
|
|
4408
4519
|
}
|
|
4409
|
-
if (bucket.cwd === void 0 &&
|
|
4520
|
+
if (bucket.cwd === void 0 && owned !== void 0) bucket.cwd = owned;
|
|
4410
4521
|
bucket.sessionCount += 1;
|
|
4411
4522
|
bucket.totals = addTotals(bucket.totals, row.totals);
|
|
4412
4523
|
bucket.cost += row.cost;
|
|
@@ -4850,7 +4961,7 @@ window.__ModuleLoader__.load({
|
|
|
4850
4961
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4851
4962
|
className: UsageRows_module_css_default["rowSub"],
|
|
4852
4963
|
children: [
|
|
4853
|
-
session.cwd === void 0 ? t("session.untitledDir") : dirTailOf(session.cwd),
|
|
4964
|
+
session.cwd === void 0 ? t("session.untitledDir") : dirTailOf(belongedCwdOf(session.cwd)),
|
|
4854
4965
|
" · ",
|
|
4855
4966
|
relativeTimeOf(session.lastTime, t)
|
|
4856
4967
|
]
|
|
@@ -4897,7 +5008,7 @@ window.__ModuleLoader__.load({
|
|
|
4897
5008
|
* providers on the second, runtime overhead on the last. The lists cap
|
|
4898
5009
|
* their own height and scroll inside the cards.
|
|
4899
5010
|
*/
|
|
4900
|
-
function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, providerRows, providerNames, providerSort, onProviderSortChange, sessionSort, onSessionSortChange, aux, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
|
|
5011
|
+
function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, providerRows, providerNames, providerSort, onProviderSortChange, sessionSort, onSessionSortChange, aux, web, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
|
|
4901
5012
|
const namedProviderCount = providerRows.filter((row) => row.provider !== "").length;
|
|
4902
5013
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4903
5014
|
className: DashboardCards_module_css_default["grid2"],
|
|
@@ -5041,6 +5152,7 @@ window.__ModuleLoader__.load({
|
|
|
5041
5152
|
})
|
|
5042
5153
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverheadRows, {
|
|
5043
5154
|
aux,
|
|
5155
|
+
web,
|
|
5044
5156
|
costState,
|
|
5045
5157
|
view,
|
|
5046
5158
|
t
|
|
@@ -6069,14 +6181,14 @@ window.__ModuleLoader__.load({
|
|
|
6069
6181
|
failuresByCode: total.failuresByCode,
|
|
6070
6182
|
...compact ? {
|
|
6071
6183
|
labelExtra: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverheadPill, {
|
|
6072
|
-
requests: aux
|
|
6184
|
+
requests: aux !== void 0 ? auxCallCount(aux.total) : void 0,
|
|
6073
6185
|
byKind: aux?.byKind,
|
|
6074
6186
|
onActivate: onOverheadActivate,
|
|
6075
6187
|
t
|
|
6076
6188
|
}),
|
|
6077
6189
|
failureBare: true
|
|
6078
6190
|
} : {
|
|
6079
|
-
overheadRequests: aux
|
|
6191
|
+
overheadRequests: aux !== void 0 ? auxCallCount(aux.total) : void 0,
|
|
6080
6192
|
overheadByKind: aux?.byKind,
|
|
6081
6193
|
onOverheadActivate
|
|
6082
6194
|
},
|
|
@@ -7190,7 +7302,8 @@ window.__ModuleLoader__.load({
|
|
|
7190
7302
|
const { total } = state.value;
|
|
7191
7303
|
const view = currencyViewOf(state.value);
|
|
7192
7304
|
const projectRows = state.value.projectRows ?? projectRowsOf(state.value.sessionRows ?? []);
|
|
7193
|
-
const auxRequests = state.value.aux
|
|
7305
|
+
const auxRequests = state.value.aux !== void 0 ? auxCallCount(state.value.aux.total) : 0;
|
|
7306
|
+
const webCalls = state.value.web?.calls ?? 0;
|
|
7194
7307
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7195
7308
|
ref: rootRef,
|
|
7196
7309
|
className: rootClass,
|
|
@@ -7256,6 +7369,7 @@ window.__ModuleLoader__.load({
|
|
|
7256
7369
|
sessionSort,
|
|
7257
7370
|
onSessionSortChange: setSessionSort,
|
|
7258
7371
|
aux: state.value.aux,
|
|
7372
|
+
web: state.value.web,
|
|
7259
7373
|
pricing: state.value.pricing,
|
|
7260
7374
|
costState: state.value.costState,
|
|
7261
7375
|
view,
|
|
@@ -7268,7 +7382,7 @@ window.__ModuleLoader__.load({
|
|
|
7268
7382
|
onModelName: setDetailModel,
|
|
7269
7383
|
overheadCardRef,
|
|
7270
7384
|
overheadFlash
|
|
7271
|
-
}) : state.value.byModel.length > 0 || (state.value.sessionRows?.length ?? 0) > 0 || auxRequests > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
7385
|
+
}) : state.value.byModel.length > 0 || (state.value.sessionRows?.length ?? 0) > 0 || auxRequests > 0 || webCalls > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
7272
7386
|
className: TokenUsageSection_module_css_default["detailPanel"],
|
|
7273
7387
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7274
7388
|
className: TokenUsageSection_module_css_default["detailToolbar"],
|
|
@@ -7306,6 +7420,7 @@ window.__ModuleLoader__.load({
|
|
|
7306
7420
|
className: TokenUsageSection_module_css_default["detailBody"],
|
|
7307
7421
|
children: detailMode === "aux" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverheadRows, {
|
|
7308
7422
|
aux: state.value.aux,
|
|
7423
|
+
web: state.value.web,
|
|
7309
7424
|
costState: state.value.costState,
|
|
7310
7425
|
view,
|
|
7311
7426
|
t
|
|
@@ -7392,7 +7507,7 @@ window.__ModuleLoader__.load({
|
|
|
7392
7507
|
});
|
|
7393
7508
|
}
|
|
7394
7509
|
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/UsageView.module.css.mjs
|
|
7395
|
-
const css = ".PR9kTG_root{color:var(--dsw-alias-label-primary);box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);padding-bottom:calc(var(--dsh-composer-height,152px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;min-height:0;margin:0 auto;display:flex;overflow-y:auto;container:PR9kTG_usage/inline-size}.PR9kTG_root>*{flex-shrink:0}.PR9kTG_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.PR9kTG_headRight{align-items:center;gap:10px;display:flex}.PR9kTG_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}.PR9kTG_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.PR9kTG_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.PR9kTG_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}.PR9kTG_segBtn:hover:not(.PR9kTG_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.PR9kTG_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.PR9kTG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.PR9kTG_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.PR9kTG_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.PR9kTG_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}.PR9kTG_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}.PR9kTG_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}.PR9kTG_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}.PR9kTG_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}.PR9kTG_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}.PR9kTG_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}.PR9kTG_mid{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);align-items:start;gap:24px;display:grid}.PR9kTG_chartCol,.PR9kTG_modelCol,.PR9kTG_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}.PR9kTG_subagentsHead,.PR9kTG_chartHead{align-items:center;gap:8px;display:flex}.PR9kTG_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}.PR9kTG_tableWrap{overflow-x:auto}.PR9kTG_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}.PR9kTG_table th,.PR9kTG_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.PR9kTG_table tbody tr{transition:background-color .12s}.PR9kTG_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}.PR9kTG_table th{border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600}.PR9kTG_costCol{font-weight:600}.PR9kTG_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}.PR9kTG_table th:first-child,.PR9kTG_table td:first-child,.PR9kTG_modelHead{text-align:left}.PR9kTG_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}.PR9kTG_modelIdentity{align-items:center;gap:4px;max-width:180px;display:inline-flex}.PR9kTG_modelName{text-overflow:ellipsis;min-width:0;overflow:hidden}.PR9kTG_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}.PR9kTG_childLink:hover{text-decoration:underline}.PR9kTG_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}.PR9kTG_poolSection{flex-direction:column;gap:6px;min-width:0;margin-top:4px;display:flex}.PR9kTG_poolHead{flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:8px 12px;display:flex}.PR9kTG_poolContext{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px}.PR9kTG_poolEmpty{color:var(--dsw-alias-label-secondary);padding:12px 0;font-size:12px}.PR9kTG_latestPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0;padding:14px 16px}.PR9kTG_requestIdentity{flex-wrap:wrap;align-items:center;gap:6px 10px;min-width:0;display:flex}.PR9kTG_poolBadge{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:5px;flex:none;padding:1px 7px;font-size:11px}.PR9kTG_poolState{white-space:nowrap;font-size:11px}.PR9kTG_requestIdentity .PR9kTG_poolState{align-items:center;gap:5px;display:inline-flex}.PR9kTG_statusDot{background:currentColor;border-radius:50%;flex:none;width:5px;height:5px}.PR9kTG_latestPanel .PR9kTG_modelName{font-size:13px;font-weight:500}.PR9kTG_stateDone{color:var(--dsw-alias-state-success-primary,#16a34a)}.PR9kTG_stateFailed{color:var(--dsw-alias-state-error-primary,#dc2626)}.PR9kTG_statePending{color:light-dark(#b45309,#d9ac64)}.PR9kTG_stateStreaming{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary))}.PR9kTG_modelInline{white-space:nowrap;align-items:center;gap:6px;min-width:0;max-width:100%;display:inline-flex}.PR9kTG_cacheLoss{color:light-dark(#b45309,#d9ac64);white-space:nowrap;background:light-dark(#fff1d8,#352b1d);border-radius:4px;flex:none;align-items:center;gap:4px;padding:2px 6px;font-size:11px;display:inline-flex}.PR9kTG_cacheLoss svg{flex:none;width:12px;height:12px}.PR9kTG_auxKind{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:4px;flex:none;padding:2px 5px;font-size:10px}.PR9kTG_requestMetrics{grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;padding:13px 0;display:grid}.PR9kTG_metricValue{letter-spacing:-.25px;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:23px;font-weight:500}.PR9kTG_metricUnit{color:var(--dsw-alias-label-tertiary);letter-spacing:0;margin-left:4px;font-size:11px}.PR9kTG_metricLabel{color:var(--dsw-alias-label-tertiary);margin-top:2px;font-size:11px}.PR9kTG_requestFooter{border-top:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);flex-wrap:nowrap;justify-content:space-between;align-items:baseline;gap:8px 18px;padding-top:8px;font-size:11px;display:flex}.PR9kTG_requestBuckets{flex-wrap:wrap;flex:none;gap:8px 15px;display:flex}.PR9kTG_requestNote{white-space:nowrap;text-overflow:ellipsis;color:light-dark(#b45309,#d9ac64);flex:0 auto;min-width:0;margin:0;font-size:11px;overflow:hidden}.PR9kTG_requestNoteError{color:var(--dsw-alias-state-error-primary)}.PR9kTG_requestNoteNeutral{color:var(--dsw-alias-label-tertiary)}.PR9kTG_requestFooter b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-weight:400}.PR9kTG_poolNotice{color:light-dark(#b45309,#d9ac64);margin:4px 0 0;font-size:11px}.PR9kTG_poolTableWrap{overscroll-behavior:contain;max-height:196px;overflow:auto}.PR9kTG_poolTableWrap::-webkit-scrollbar{width:8px;height:8px}.PR9kTG_poolTableWrap::-webkit-scrollbar-track,.PR9kTG_poolTableWrap::-webkit-scrollbar-corner{background:0 0}.PR9kTG_poolTableWrap::-webkit-scrollbar-button{display:none}.PR9kTG_poolTableWrap::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.PR9kTG_poolTableWrap.PR9kTG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.PR9kTG_poolTableWrap:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:2px}.PR9kTG_poolTable{table-layout:fixed;border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;font-size:11px}.PR9kTG_poolTable th,.PR9kTG_poolTable td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:8px 6px;overflow:hidden}.PR9kTG_poolTable th{z-index:1;background:var(--dsw-alias-bg-base,var(--dsw-alias-bg-layer-1));color:var(--dsw-alias-label-secondary);border-bottom:1.5px solid var(--dsw-alias-border-l2);padding:6px;font-weight:400;position:sticky;top:0}.PR9kTG_poolTable th:nth-child(-n+4),.PR9kTG_poolTable td:nth-child(-n+4){text-align:left}.PR9kTG_poolOrigin,.PR9kTG_poolTime{color:var(--dsw-alias-label-secondary)}.PR9kTG_poolModel,.PR9kTG_poolModel .PR9kTG_modelInline{max-width:200px}.PR9kTG_poolModel .PR9kTG_modelName{text-overflow:ellipsis;min-width:0;overflow:hidden}.PR9kTG_poolModelHead{text-align:left}.PR9kTG_poolTable tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}@media (prefers-reduced-motion:no-preference){.PR9kTG_latestPanel{animation:.25s ease-out PR9kTG_pool-arrive}@keyframes PR9kTG_pool-arrive{0%{opacity:.4}to{opacity:1}}}@container PR9kTG_usage (width<=900px){.PR9kTG_requestMetrics{grid-template-columns:repeat(3,minmax(0,1fr))}.PR9kTG_poolTableWrap{max-height:230px}}@container PR9kTG_usage (width<=480px){.PR9kTG_poolTableWrap{max-height:240px}.PR9kTG_poolTable thead{display:none}.PR9kTG_poolTable,.PR9kTG_poolTable tbody{min-width:0;display:block}.PR9kTG_poolTable tbody tr{border-bottom:1px solid var(--dsw-alias-border-l1);grid-template-columns:repeat(3,minmax(0,1fr));gap:4px 9px;padding:9px 0;display:grid}.PR9kTG_poolTable td{border-bottom:none;text-align:left!important;padding:0!important}.PR9kTG_poolTable td:nth-child(4){grid-column:1/-1}.PR9kTG_poolTable td:before{content:attr(data-label) \" \";color:var(--dsw-alias-label-tertiary)}.PR9kTG_poolModel,.PR9kTG_poolModel .PR9kTG_modelInline{max-width:100%}.PR9kTG_metricValue{font-size:21px}}@container PR9kTG_usage (width<=900px){.PR9kTG_cards{grid-template-columns:repeat(3,minmax(0,1fr))}.PR9kTG_mid{grid-template-columns:1fr}}@media (width<=600px){.PR9kTG_root{padding-left:12px;padding-right:12px}}";
|
|
7510
|
+
const css = ".PR9kTG_root{color:var(--dsw-alias-label-primary);box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);padding-bottom:calc(var(--dsh-composer-height,152px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;min-height:0;margin:0 auto;display:flex;overflow-y:auto;container:PR9kTG_usage/inline-size}.PR9kTG_root>*{flex-shrink:0}.PR9kTG_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.PR9kTG_headRight{align-items:center;gap:10px;display:flex}.PR9kTG_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}.PR9kTG_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.PR9kTG_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.PR9kTG_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}.PR9kTG_segBtn:hover:not(.PR9kTG_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.PR9kTG_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.PR9kTG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.PR9kTG_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.PR9kTG_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.PR9kTG_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}.PR9kTG_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}.PR9kTG_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}.PR9kTG_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}.PR9kTG_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}.PR9kTG_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}.PR9kTG_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}.PR9kTG_mid{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);align-items:start;gap:24px;display:grid}.PR9kTG_chartCol,.PR9kTG_modelCol,.PR9kTG_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}.PR9kTG_subagentsHead,.PR9kTG_chartHead{align-items:center;gap:8px;display:flex}.PR9kTG_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}.PR9kTG_tableWrap{overflow-x:auto}.PR9kTG_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}.PR9kTG_table th,.PR9kTG_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.PR9kTG_table tbody tr{transition:background-color .12s}.PR9kTG_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}.PR9kTG_table th{border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600}.PR9kTG_subagentsWrap{--subagents-row-height:26px;max-height:calc(var(--subagents-row-height) * 16);overflow:hidden}.PR9kTG_subagentsWrap:focus-within{overflow:auto}.PR9kTG_subagentsWrap::-webkit-scrollbar{width:8px;height:8px}.PR9kTG_subagentsWrap::-webkit-scrollbar-track,.PR9kTG_subagentsWrap::-webkit-scrollbar-corner{background:0 0}.PR9kTG_subagentsWrap::-webkit-scrollbar-button{display:none}.PR9kTG_subagentsWrap::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.PR9kTG_subagentsWrap:focus-within::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.PR9kTG_subagentsWrap:focus-within.PR9kTG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 22%, transparent)}.PR9kTG_subagentsWrap:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:2px}.PR9kTG_subagentsWrap .PR9kTG_table thead tr,.PR9kTG_subagentsWrap .PR9kTG_table tbody tr{height:var(--subagents-row-height)}.PR9kTG_subagentsWrap .PR9kTG_table th{z-index:1;background:var(--dsw-alias-bg-base,var(--dsw-alias-bg-layer-1));position:sticky;top:0}.PR9kTG_costCol{font-weight:600}.PR9kTG_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}.PR9kTG_table th:first-child,.PR9kTG_table td:first-child,.PR9kTG_modelHead{text-align:left}.PR9kTG_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}.PR9kTG_modelIdentity{align-items:center;gap:4px;max-width:180px;display:inline-flex}.PR9kTG_modelName{text-overflow:ellipsis;min-width:0;overflow:hidden}.PR9kTG_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}.PR9kTG_childLink:hover{text-decoration:underline}.PR9kTG_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}.PR9kTG_poolSection{flex-direction:column;gap:6px;min-width:0;margin-top:4px;display:flex}.PR9kTG_poolHead{flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:8px 12px;display:flex}.PR9kTG_poolContext{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px}.PR9kTG_poolEmpty{color:var(--dsw-alias-label-secondary);padding:12px 0;font-size:12px}.PR9kTG_latestPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0;padding:14px 16px}.PR9kTG_requestIdentity{flex-wrap:wrap;align-items:center;gap:6px 10px;min-width:0;display:flex}.PR9kTG_poolBadge{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:5px;flex:none;padding:1px 7px;font-size:11px}.PR9kTG_poolState{white-space:nowrap;font-size:11px}.PR9kTG_requestIdentity .PR9kTG_poolState{align-items:center;gap:5px;display:inline-flex}.PR9kTG_statusDot{background:currentColor;border-radius:50%;flex:none;width:5px;height:5px}.PR9kTG_latestPanel .PR9kTG_modelName{font-size:13px;font-weight:500}.PR9kTG_stateDone{color:var(--dsw-alias-state-success-primary,#16a34a)}.PR9kTG_stateFailed{color:var(--dsw-alias-state-error-primary,#dc2626)}.PR9kTG_statePending{color:light-dark(#b45309,#d9ac64)}.PR9kTG_stateStreaming{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary))}.PR9kTG_modelInline{white-space:nowrap;align-items:center;gap:6px;min-width:0;max-width:100%;display:inline-flex}.PR9kTG_cacheLoss{color:light-dark(#b45309,#d9ac64);white-space:nowrap;background:light-dark(#fff1d8,#352b1d);border-radius:4px;flex:none;align-items:center;gap:4px;padding:2px 6px;font-size:11px;display:inline-flex}.PR9kTG_cacheLoss svg{flex:none;width:12px;height:12px}.PR9kTG_auxKind{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:4px;flex:none;padding:2px 5px;font-size:10px}.PR9kTG_requestMetrics{grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;padding:13px 0;display:grid}.PR9kTG_metricValue{letter-spacing:-.25px;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:23px;font-weight:500}.PR9kTG_metricUnit{color:var(--dsw-alias-label-tertiary);letter-spacing:0;margin-left:4px;font-size:11px}.PR9kTG_metricLabel{color:var(--dsw-alias-label-tertiary);margin-top:2px;font-size:11px}.PR9kTG_requestFooter{border-top:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);flex-wrap:nowrap;justify-content:space-between;align-items:baseline;gap:8px 18px;padding-top:8px;font-size:11px;display:flex}.PR9kTG_requestBuckets{flex-wrap:wrap;flex:none;gap:8px 15px;display:flex}.PR9kTG_requestNote{white-space:nowrap;text-overflow:ellipsis;color:light-dark(#b45309,#d9ac64);flex:0 auto;min-width:0;margin:0;font-size:11px;overflow:hidden}.PR9kTG_requestNoteError{color:var(--dsw-alias-state-error-primary)}.PR9kTG_requestNoteNeutral{color:var(--dsw-alias-label-tertiary)}.PR9kTG_requestFooter b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-weight:400}.PR9kTG_poolNotice{color:light-dark(#b45309,#d9ac64);margin:4px 0 0;font-size:11px}.PR9kTG_poolTableWrap{overscroll-behavior:contain;max-height:196px;overflow:auto}.PR9kTG_poolTableWrap::-webkit-scrollbar{width:8px;height:8px}.PR9kTG_poolTableWrap::-webkit-scrollbar-track,.PR9kTG_poolTableWrap::-webkit-scrollbar-corner{background:0 0}.PR9kTG_poolTableWrap::-webkit-scrollbar-button{display:none}.PR9kTG_poolTableWrap::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.PR9kTG_poolTableWrap.PR9kTG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.PR9kTG_poolTableWrap:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:2px}.PR9kTG_poolTable{table-layout:fixed;border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;font-size:11px}.PR9kTG_poolTable th,.PR9kTG_poolTable td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:8px 6px;overflow:hidden}.PR9kTG_poolTable th{z-index:1;background:var(--dsw-alias-bg-base,var(--dsw-alias-bg-layer-1));color:var(--dsw-alias-label-secondary);border-bottom:1.5px solid var(--dsw-alias-border-l2);padding:6px;font-weight:400;position:sticky;top:0}.PR9kTG_poolTable th:nth-child(-n+4),.PR9kTG_poolTable td:nth-child(-n+4){text-align:left}.PR9kTG_poolOrigin,.PR9kTG_poolTime{color:var(--dsw-alias-label-secondary)}.PR9kTG_poolModel,.PR9kTG_poolModel .PR9kTG_modelInline{max-width:200px}.PR9kTG_poolModel .PR9kTG_modelName{text-overflow:ellipsis;min-width:0;overflow:hidden}.PR9kTG_poolModelHead{text-align:left}.PR9kTG_poolTable tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}@media (prefers-reduced-motion:no-preference){.PR9kTG_latestPanel{animation:.25s ease-out PR9kTG_pool-arrive}@keyframes PR9kTG_pool-arrive{0%{opacity:.4}to{opacity:1}}}@container PR9kTG_usage (width<=900px){.PR9kTG_requestMetrics{grid-template-columns:repeat(3,minmax(0,1fr))}.PR9kTG_poolTableWrap{max-height:230px}}@container PR9kTG_usage (width<=480px){.PR9kTG_poolTableWrap{max-height:240px}.PR9kTG_poolTable thead{display:none}.PR9kTG_poolTable,.PR9kTG_poolTable tbody{min-width:0;display:block}.PR9kTG_poolTable tbody tr{border-bottom:1px solid var(--dsw-alias-border-l1);grid-template-columns:repeat(3,minmax(0,1fr));gap:4px 9px;padding:9px 0;display:grid}.PR9kTG_poolTable td{border-bottom:none;text-align:left!important;padding:0!important}.PR9kTG_poolTable td:nth-child(4){grid-column:1/-1}.PR9kTG_poolTable td:before{content:attr(data-label) \" \";color:var(--dsw-alias-label-tertiary)}.PR9kTG_poolModel,.PR9kTG_poolModel .PR9kTG_modelInline{max-width:100%}.PR9kTG_metricValue{font-size:21px}}@container PR9kTG_usage (width<=900px){.PR9kTG_cards{grid-template-columns:repeat(3,minmax(0,1fr))}.PR9kTG_mid{grid-template-columns:1fr}}@media (width<=600px){.PR9kTG_root{padding-left:12px;padding-right:12px}}";
|
|
7396
7511
|
const tagId = "@laoyuehanni/dsh-token-usage/UsageView.module.css";
|
|
7397
7512
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
7398
7513
|
const tag = document.createElement("style");
|
|
@@ -7462,6 +7577,7 @@ window.__ModuleLoader__.load({
|
|
|
7462
7577
|
"statusDot": "PR9kTG_statusDot",
|
|
7463
7578
|
"subagents": "PR9kTG_subagents",
|
|
7464
7579
|
"subagentsHead": "PR9kTG_subagentsHead",
|
|
7580
|
+
"subagentsWrap": "PR9kTG_subagentsWrap",
|
|
7465
7581
|
"subtitle": "PR9kTG_subtitle",
|
|
7466
7582
|
"table": "PR9kTG_table",
|
|
7467
7583
|
"tableWrap": "PR9kTG_tableWrap",
|
|
@@ -8081,15 +8197,16 @@ window.__ModuleLoader__.load({
|
|
|
8081
8197
|
* pill, 4 token buckets, cost, hit rate, TTFT average, decode throughput) with a
|
|
8082
8198
|
* scope switch between the session alone and its whole subagent subtree, a
|
|
8083
8199
|
* per-hour trend chart and the per-model table from the host stats route
|
|
8084
|
-
* (`
|
|
8200
|
+
* (`root` + `scope` scoped), and a subagent table below — each row drill-in
|
|
8085
8201
|
* switches the focus to that child.
|
|
8086
8202
|
*
|
|
8087
8203
|
* Data sources: token/cost figures come from the host route (the pricing
|
|
8088
|
-
* rule chain's authority)
|
|
8089
|
-
* retained `sessionStats` projection
|
|
8090
|
-
*
|
|
8091
|
-
*
|
|
8092
|
-
*
|
|
8204
|
+
* rule chain's authority). The header's TTFT and throughput come from the
|
|
8205
|
+
* framework's retained `sessionStats` projection (`useProjection`), which
|
|
8206
|
+
* covers history written before this plugin was installed; the SUBAGENT
|
|
8207
|
+
* table's two timing columns instead read `children[].timing`, folded by the
|
|
8208
|
+
* host from recorded requests (post-install, timed requests only). A
|
|
8209
|
+
* footnote states both scopes so the difference is not a surprise.
|
|
8093
8210
|
*
|
|
8094
8211
|
* The root declares `data-conversation-composer-overlay` — the same host
|
|
8095
8212
|
* opt-in Trajectory uses. ConversationRoot hides the chat-column width
|
|
@@ -8106,12 +8223,14 @@ window.__ModuleLoader__.load({
|
|
|
8106
8223
|
* full-bleed scroller set this so the chat-column width handles hide and
|
|
8107
8224
|
* the composer seat overlays instead of stealing clicks over the dashboard. */
|
|
8108
8225
|
const COMPOSER_OVERLAY = { "data-conversation-composer-overlay": "" };
|
|
8109
|
-
/** One fetch of the session-scoped summary from the host stats route
|
|
8110
|
-
*
|
|
8111
|
-
|
|
8226
|
+
/** One fetch of the session-scoped summary from the host stats route.
|
|
8227
|
+
* The request carries a RANGE RULE (root + scope), never the enumerated
|
|
8228
|
+
* subtree: the host expands it from its session-metadata lineage, so the URL
|
|
8229
|
+
* stays O(1) however many subagents the conversation has. */
|
|
8230
|
+
function fetchSessionSummary(root, scope, signal) {
|
|
8112
8231
|
return fetch(STATS_PATH + encodeStatsQuery({
|
|
8113
|
-
|
|
8114
|
-
|
|
8232
|
+
root,
|
|
8233
|
+
scope: scope === "tree" ? "subtree" : "self",
|
|
8115
8234
|
fields: "session"
|
|
8116
8235
|
}), { signal }).then((response) => {
|
|
8117
8236
|
if (!response.ok) throw new Error(`HTTP ${String(response.status)}`);
|
|
@@ -8142,6 +8261,19 @@ window.__ModuleLoader__.load({
|
|
|
8142
8261
|
setRetryToken((token) => token + 1);
|
|
8143
8262
|
};
|
|
8144
8263
|
usePricingAssociationRefresh(retry);
|
|
8264
|
+
const subagentsRef = (0, react.useRef)(null);
|
|
8265
|
+
const subagentsTimer = (0, react.useRef)(void 0);
|
|
8266
|
+
(0, react.useEffect)(() => () => window.clearTimeout(subagentsTimer.current), []);
|
|
8267
|
+
const handleSubagentsScroll = () => {
|
|
8268
|
+
const box = subagentsRef.current;
|
|
8269
|
+
const cls = UsageView_module_css_default["scrolling"];
|
|
8270
|
+
if (box === null || cls === void 0) return;
|
|
8271
|
+
box.classList.add(cls);
|
|
8272
|
+
window.clearTimeout(subagentsTimer.current);
|
|
8273
|
+
subagentsTimer.current = window.setTimeout(() => {
|
|
8274
|
+
box.classList.remove(cls);
|
|
8275
|
+
}, 800);
|
|
8276
|
+
};
|
|
8145
8277
|
const byId = useSessions((state) => state.byId);
|
|
8146
8278
|
const childIndex = (0, react.useMemo)(() => buildChildIndex(byId), [byId]);
|
|
8147
8279
|
const scopeIds = (0, react.useMemo)(() => scope === "tree" ? subtreeIds(byId, focusId, childIndex) : [focusId], [
|
|
@@ -8155,20 +8287,17 @@ window.__ModuleLoader__.load({
|
|
|
8155
8287
|
focusId,
|
|
8156
8288
|
childIndex
|
|
8157
8289
|
]);
|
|
8158
|
-
const childGroups = (0, react.useMemo)(() => children.map((id) => scope === "tree" ? subtreeIds(byId, id, childIndex) : [id]), [
|
|
8159
|
-
children,
|
|
8160
|
-
scope,
|
|
8161
|
-
byId,
|
|
8162
|
-
childIndex
|
|
8163
|
-
]);
|
|
8164
8290
|
const backParent = subagentParentOf(byId, focusId);
|
|
8165
8291
|
const liveStats = useProjection("sessionStats");
|
|
8166
|
-
const
|
|
8292
|
+
const scopedIds = [.../* @__PURE__ */ new Set([...scopeIds, ...children])];
|
|
8293
|
+
const scopeIdsKey = scopedIds.join(",");
|
|
8294
|
+
const freshnessKey = buildStatsFreshnessKey(scopedIds, {
|
|
8167
8295
|
activeSessionId: sessionId,
|
|
8168
8296
|
rows: byId,
|
|
8169
8297
|
liveSessionStats: liveStats
|
|
8170
8298
|
});
|
|
8171
|
-
const
|
|
8299
|
+
const scopeKey = `${focusId}\t${scope}`;
|
|
8300
|
+
const debouncedFreshnessKey = useDebouncedValue(freshnessKey, REFRESH_DEBOUNCE_MS, scopeKey);
|
|
8172
8301
|
const [pollTick, setPollTick] = (0, react.useState)(0);
|
|
8173
8302
|
const [pollSettle, setPollSettle] = (0, react.useState)(0);
|
|
8174
8303
|
const [staleAt, setStaleAt] = (0, react.useState)(void 0);
|
|
@@ -8176,19 +8305,33 @@ window.__ModuleLoader__.load({
|
|
|
8176
8305
|
const pollTimerRef = (0, react.useRef)(void 0);
|
|
8177
8306
|
const fetchingRef = (0, react.useRef)(false);
|
|
8178
8307
|
const fetchVersionRef = (0, react.useRef)(0);
|
|
8179
|
-
|
|
8308
|
+
/** The last successful read. A late session-mirror / sessionStats delivery
|
|
8309
|
+
* bumps the freshness key inside the first debounce window and reruns the
|
|
8310
|
+
* effect; coalescing that run avoids two identical GETs on opening the tab. */
|
|
8311
|
+
const recentRef = (0, react.useRef)(void 0);
|
|
8180
8312
|
const [summaryState] = useAsyncResource((signal) => {
|
|
8181
8313
|
clearTimeout(pollTimerRef.current);
|
|
8182
8314
|
fetchingRef.current = true;
|
|
8183
8315
|
const version = ++fetchVersionRef.current;
|
|
8184
|
-
const
|
|
8185
|
-
|
|
8316
|
+
const recent = recentRef.current;
|
|
8317
|
+
const canReuse = recent !== void 0 && !recent.coalesced && recent.idsKey !== scopeIdsKey && recent.scopeKey === scopeKey && recent.retryToken === retryToken && recent.pollTick === pollTick && Date.now() - recent.at < 500;
|
|
8318
|
+
const settle = (value) => {
|
|
8319
|
+
recentRef.current = {
|
|
8320
|
+
scopeKey,
|
|
8321
|
+
idsKey: scopeIdsKey,
|
|
8322
|
+
retryToken,
|
|
8323
|
+
pollTick,
|
|
8324
|
+
at: Date.now(),
|
|
8325
|
+
value,
|
|
8326
|
+
coalesced: canReuse
|
|
8327
|
+
};
|
|
8186
8328
|
if (!signal.aborted) {
|
|
8187
8329
|
lastOkAtRef.current = Date.now();
|
|
8188
8330
|
setStaleAt(void 0);
|
|
8189
8331
|
}
|
|
8190
8332
|
return value;
|
|
8191
|
-
}
|
|
8333
|
+
};
|
|
8334
|
+
return (canReuse && recent !== void 0 ? Promise.resolve(recent.value) : fetchSessionSummary(focusId, scope, signal)).then(settle).catch((error) => {
|
|
8192
8335
|
if (!signal.aborted && lastOkAtRef.current !== void 0) setStaleAt(lastOkAtRef.current);
|
|
8193
8336
|
throw error;
|
|
8194
8337
|
}).finally(() => {
|
|
@@ -8198,7 +8341,7 @@ window.__ModuleLoader__.load({
|
|
|
8198
8341
|
}
|
|
8199
8342
|
});
|
|
8200
8343
|
}, [
|
|
8201
|
-
|
|
8344
|
+
debouncedFreshnessKey,
|
|
8202
8345
|
retryToken,
|
|
8203
8346
|
pollTick
|
|
8204
8347
|
], {
|
|
@@ -8230,19 +8373,12 @@ window.__ModuleLoader__.load({
|
|
|
8230
8373
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
8231
8374
|
};
|
|
8232
8375
|
}, []);
|
|
8233
|
-
const
|
|
8234
|
-
return aggregateProjections(scopeIds.map((id) => {
|
|
8235
|
-
if (id === sessionId) return liveStats;
|
|
8236
|
-
return byId[id]?.projectionValues?.sessionStats;
|
|
8237
|
-
}));
|
|
8238
|
-
}, [
|
|
8376
|
+
const mirrorStats = (0, react.useMemo)(() => aggregateScopedProjections(scopeIds, byId, sessionId, liveStats), [
|
|
8239
8377
|
scopeIds,
|
|
8378
|
+
byId,
|
|
8240
8379
|
sessionId,
|
|
8241
|
-
liveStats
|
|
8242
|
-
byId
|
|
8380
|
+
liveStats
|
|
8243
8381
|
]);
|
|
8244
|
-
const ttftText = stats !== void 0 && stats.ttftSteps > 0 ? formatTtft(stats.ttftMs / stats.ttftSteps) : "—";
|
|
8245
|
-
const speedText = stats !== void 0 && stats.decodeMs > 0 ? formatSpeed(stats.decodeTokens / (stats.decodeMs / 1e3)) : "—";
|
|
8246
8382
|
const header = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
8247
8383
|
className: UsageView_module_css_default["head"],
|
|
8248
8384
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -8309,6 +8445,15 @@ window.__ModuleLoader__.load({
|
|
|
8309
8445
|
})
|
|
8310
8446
|
});
|
|
8311
8447
|
const summary = summaryState.value;
|
|
8448
|
+
const headerTiming = resolveHeaderTiming({
|
|
8449
|
+
isSoloActive: scope === "session" && focusId === sessionId,
|
|
8450
|
+
liveStats,
|
|
8451
|
+
mirrorAggregate: mirrorStats,
|
|
8452
|
+
serverTiming: summary.timing,
|
|
8453
|
+
totalPerf: summary.total
|
|
8454
|
+
});
|
|
8455
|
+
const ttftText = headerTiming.ttftMs !== void 0 ? formatTtft(headerTiming.ttftMs) : "—";
|
|
8456
|
+
const speedText = headerTiming.tokensPerSec !== void 0 ? formatSpeed(headerTiming.tokensPerSec) : "—";
|
|
8312
8457
|
const view = currencyViewOf(summary);
|
|
8313
8458
|
const { total } = summary;
|
|
8314
8459
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -8544,7 +8689,12 @@ window.__ModuleLoader__.load({
|
|
|
8544
8689
|
className: UsageView_module_css_default["muted"],
|
|
8545
8690
|
children: t("view.subagents.none")
|
|
8546
8691
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
8547
|
-
|
|
8692
|
+
ref: subagentsRef,
|
|
8693
|
+
onScroll: handleSubagentsScroll,
|
|
8694
|
+
className: UsageView_module_css_default["subagentsWrap"],
|
|
8695
|
+
tabIndex: 0,
|
|
8696
|
+
role: "region",
|
|
8697
|
+
"aria-label": t("view.subagents.scroll"),
|
|
8548
8698
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
8549
8699
|
className: UsageView_module_css_default["table"],
|
|
8550
8700
|
"aria-label": t("view.subagents.title", { count: String(children.length) }),
|
|
@@ -8562,7 +8712,7 @@ window.__ModuleLoader__.load({
|
|
|
8562
8712
|
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: children.map((id) => {
|
|
8563
8713
|
const child = byId[id];
|
|
8564
8714
|
const row = summary.children?.[id];
|
|
8565
|
-
const
|
|
8715
|
+
const timing = row?.timing;
|
|
8566
8716
|
const nestedCount = directSubagentIds(byId, id, childIndex).length;
|
|
8567
8717
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
8568
8718
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
@@ -8589,8 +8739,8 @@ window.__ModuleLoader__.load({
|
|
|
8589
8739
|
children: row !== void 0 && costsAvailable(summary.costState) && costsAvailable(row.costState) ? formatCost(row.totalCost, view) : "—"
|
|
8590
8740
|
}),
|
|
8591
8741
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.total }) : "—" }),
|
|
8592
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children:
|
|
8593
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children:
|
|
8742
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: timing !== void 0 && timing.ttftSteps > 0 ? formatTtft(timing.ttftMs / timing.ttftSteps) : "—" }),
|
|
8743
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: timing !== void 0 && timing.decodeMs > 0 ? `${formatSpeed(timing.decodeTokens / (timing.decodeMs / 1e3))} tok/s` : "—" })
|
|
8594
8744
|
] }, id);
|
|
8595
8745
|
}) })]
|
|
8596
8746
|
})
|
|
@@ -8696,15 +8846,31 @@ window.__ModuleLoader__.load({
|
|
|
8696
8846
|
"fail.TIMEOUT": "超时",
|
|
8697
8847
|
"fail.TRANSPORT": "网络异常",
|
|
8698
8848
|
"fail.EMPTY_RESPONSE": "空响应",
|
|
8849
|
+
"fail.CONTENT_REFUSED": "内容安全拒绝",
|
|
8699
8850
|
"fail.QUOTA": "配额耗尽",
|
|
8851
|
+
"fail.ACCOUNT_QUOTA": "账号余额不足",
|
|
8852
|
+
"fail.ACCOUNT_SIGN_IN_REQUIRED": "需要登录账号",
|
|
8853
|
+
"fail.ACCOUNT_TOKEN_INVALID": "账号凭证无效",
|
|
8854
|
+
"fail.CLIENT_UPGRADE_REQUIRED": "需要升级客户端",
|
|
8700
8855
|
"fail.CONTEXT_WINDOW_EXCEEDED": "上下文超限",
|
|
8701
8856
|
"fail.INVALID_CREDENTIAL": "凭证无效",
|
|
8702
8857
|
"fail.AUTH": "鉴权失败",
|
|
8703
8858
|
"fail.INVALID_REQUEST": "请求无效",
|
|
8859
|
+
"fail.INVALID_RESPONSE": "响应无效",
|
|
8704
8860
|
"fail.MISSING_CREDENTIAL": "缺少凭证",
|
|
8705
8861
|
"fail.ABORTED": "已中止",
|
|
8706
8862
|
"fail.REQUEST_EXTENSION": "请求扩展失败",
|
|
8863
|
+
"fail.REQUEST_HEADERS": "请求头异常",
|
|
8707
8864
|
"fail.FILES_API": "文件接口异常",
|
|
8865
|
+
"fail.IMAGE_OFFLOAD_REQUIRED": "图片需转存",
|
|
8866
|
+
"fail.MODEL_SWITCH_COMPACTION_FAILED": "切模型压缩失败",
|
|
8867
|
+
"fail.MODEL_UNSUPPORTED": "模型不支持",
|
|
8868
|
+
"fail.UNKNOWN_MODEL": "未知模型",
|
|
8869
|
+
"fail.NO_ADAPTER": "未注册适配器",
|
|
8870
|
+
"fail.PI_AI_ERROR": "适配器异常",
|
|
8871
|
+
"fail.UNSUPPORTED_CONTENT": "不支持的内容",
|
|
8872
|
+
"fail.UNSUPPORTED_OPTION": "不支持的参数",
|
|
8873
|
+
"fail.UNSUPPORTED_REASONING_EFFORT": "不支持的推理强度",
|
|
8708
8874
|
"fail.STREAM_CLOSED": "流中断",
|
|
8709
8875
|
"fail.MALFORMED_RESPONSE": "响应异常",
|
|
8710
8876
|
"fail.UNKNOWN": "未知错误",
|
|
@@ -8736,6 +8902,7 @@ window.__ModuleLoader__.load({
|
|
|
8736
8902
|
"aux.kind": "类别",
|
|
8737
8903
|
"aux.kind.auto-review": "自动审查",
|
|
8738
8904
|
"aux.kind.session-title": "标题生成",
|
|
8905
|
+
"aux.kind.timeline-report": "时间线报告",
|
|
8739
8906
|
"aux.kind.translation": "推理翻译",
|
|
8740
8907
|
"aux.kind.other": "其他",
|
|
8741
8908
|
"aux.requests": "次数",
|
|
@@ -8745,6 +8912,10 @@ window.__ModuleLoader__.load({
|
|
|
8745
8912
|
"aux.totalCount": "合计 · {count} 次",
|
|
8746
8913
|
"aux.requestCount": "{count} 次",
|
|
8747
8914
|
"aux.tooltipTotal": "运行开销 · 合计",
|
|
8915
|
+
"web.title": "联网工具",
|
|
8916
|
+
"web.tool.web_search": "联网搜索",
|
|
8917
|
+
"web.tool.web_fetch": "网页抓取",
|
|
8918
|
+
"web.calls": "{count} 次",
|
|
8748
8919
|
"board.projects": "项目",
|
|
8749
8920
|
"board.sessions": "会话",
|
|
8750
8921
|
"board.models": "模型",
|
|
@@ -8840,6 +9011,7 @@ window.__ModuleLoader__.load({
|
|
|
8840
9011
|
"card.fullSync.running": "扫描中…",
|
|
8841
9012
|
"card.fullSync.progress": "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条,删除 {removed} 条",
|
|
8842
9013
|
"card.fullSync.failuresNote": ",无法读取 {count} 个 session 已跳过",
|
|
9014
|
+
"card.fullSync.importedNote": ",忽略 {count} 条 DeepSeek chat 导入记录",
|
|
8843
9015
|
"card.fullSync.done": "扫描完成:新增 {added} 条,跳过 {skipped} 条,删除 {removed} 条",
|
|
8844
9016
|
"card.fullSync.failed": "扫描失败:{error}",
|
|
8845
9017
|
"loadFailed": "统计加载失败:{message}",
|
|
@@ -8869,7 +9041,8 @@ window.__ModuleLoader__.load({
|
|
|
8869
9041
|
"view.subagents.none": "无子会话",
|
|
8870
9042
|
"view.subagents.titleCol": "会话",
|
|
8871
9043
|
"view.subagents.nested": "含 {count} 个子会话",
|
|
8872
|
-
"view.
|
|
9044
|
+
"view.subagents.scroll": "子会话列表,点击后可在此滚动",
|
|
9045
|
+
"view.note": "注:token 与费用来自本插件请求记录;当前单会话顶部平均首token 与 token速度优先来自 DSH 会话投影(含无日志历史),含子会话、子会话详情及子会话表来自本插件有计时的请求记录。",
|
|
8873
9046
|
"pool.latest.title": "最新请求",
|
|
8874
9047
|
"pool.latest.context": "单次请求 · 非会话均值",
|
|
8875
9048
|
"pool.title": "实时请求",
|
|
@@ -8891,6 +9064,7 @@ window.__ModuleLoader__.load({
|
|
|
8891
9064
|
"pool.kind.compaction": "压缩",
|
|
8892
9065
|
"pool.kind.auto-review": "审查",
|
|
8893
9066
|
"pool.kind.session-title": "标题",
|
|
9067
|
+
"pool.kind.timeline-report": "时间线",
|
|
8894
9068
|
"pool.kind.translation": "翻译",
|
|
8895
9069
|
"pool.kind.other": "辅助",
|
|
8896
9070
|
"pool.attribution.prefix": "此请求发出前,宿主的压缩操作改写了上下文前缀,缓存表现可能受影响:",
|
|
@@ -9062,15 +9236,31 @@ window.__ModuleLoader__.load({
|
|
|
9062
9236
|
"fail.TIMEOUT": "Timed out",
|
|
9063
9237
|
"fail.TRANSPORT": "Network error",
|
|
9064
9238
|
"fail.EMPTY_RESPONSE": "Empty response",
|
|
9239
|
+
"fail.CONTENT_REFUSED": "Content refused",
|
|
9065
9240
|
"fail.QUOTA": "Quota exceeded",
|
|
9241
|
+
"fail.ACCOUNT_QUOTA": "Account quota exceeded",
|
|
9242
|
+
"fail.ACCOUNT_SIGN_IN_REQUIRED": "Sign-in required",
|
|
9243
|
+
"fail.ACCOUNT_TOKEN_INVALID": "Account token invalid",
|
|
9244
|
+
"fail.CLIENT_UPGRADE_REQUIRED": "Client upgrade required",
|
|
9066
9245
|
"fail.CONTEXT_WINDOW_EXCEEDED": "Context exceeded",
|
|
9067
9246
|
"fail.INVALID_CREDENTIAL": "Invalid credential",
|
|
9068
9247
|
"fail.AUTH": "Auth failed",
|
|
9069
9248
|
"fail.INVALID_REQUEST": "Invalid request",
|
|
9249
|
+
"fail.INVALID_RESPONSE": "Invalid response",
|
|
9070
9250
|
"fail.MISSING_CREDENTIAL": "Missing credential",
|
|
9071
9251
|
"fail.ABORTED": "Aborted",
|
|
9072
9252
|
"fail.REQUEST_EXTENSION": "Request extension failed",
|
|
9253
|
+
"fail.REQUEST_HEADERS": "Request headers error",
|
|
9073
9254
|
"fail.FILES_API": "Files API error",
|
|
9255
|
+
"fail.IMAGE_OFFLOAD_REQUIRED": "Image offload required",
|
|
9256
|
+
"fail.MODEL_SWITCH_COMPACTION_FAILED": "Model switch compaction failed",
|
|
9257
|
+
"fail.MODEL_UNSUPPORTED": "Model unsupported",
|
|
9258
|
+
"fail.UNKNOWN_MODEL": "Unknown model",
|
|
9259
|
+
"fail.NO_ADAPTER": "No adapter",
|
|
9260
|
+
"fail.PI_AI_ERROR": "Adapter error",
|
|
9261
|
+
"fail.UNSUPPORTED_CONTENT": "Unsupported content",
|
|
9262
|
+
"fail.UNSUPPORTED_OPTION": "Unsupported option",
|
|
9263
|
+
"fail.UNSUPPORTED_REASONING_EFFORT": "Unsupported reasoning effort",
|
|
9074
9264
|
"fail.STREAM_CLOSED": "Stream closed",
|
|
9075
9265
|
"fail.MALFORMED_RESPONSE": "Malformed response",
|
|
9076
9266
|
"fail.UNKNOWN": "Unknown error",
|
|
@@ -9102,6 +9292,7 @@ window.__ModuleLoader__.load({
|
|
|
9102
9292
|
"aux.kind": "Category",
|
|
9103
9293
|
"aux.kind.auto-review": "Auto review",
|
|
9104
9294
|
"aux.kind.session-title": "Session titles",
|
|
9295
|
+
"aux.kind.timeline-report": "Timeline reports",
|
|
9105
9296
|
"aux.kind.translation": "Translation",
|
|
9106
9297
|
"aux.kind.other": "Other",
|
|
9107
9298
|
"aux.requests": "Calls",
|
|
@@ -9111,6 +9302,10 @@ window.__ModuleLoader__.load({
|
|
|
9111
9302
|
"aux.totalCount": "Total · {count}",
|
|
9112
9303
|
"aux.requestCount": "{count} calls",
|
|
9113
9304
|
"aux.tooltipTotal": "Overhead · total",
|
|
9305
|
+
"web.title": "Web tools",
|
|
9306
|
+
"web.tool.web_search": "Web search",
|
|
9307
|
+
"web.tool.web_fetch": "Web fetch",
|
|
9308
|
+
"web.calls": "{count} calls",
|
|
9114
9309
|
"board.projects": "Projects",
|
|
9115
9310
|
"board.sessions": "Sessions",
|
|
9116
9311
|
"board.models": "Models",
|
|
@@ -9206,6 +9401,7 @@ window.__ModuleLoader__.load({
|
|
|
9206
9401
|
"card.fullSync.running": "Scanning…",
|
|
9207
9402
|
"card.fullSync.progress": "Processed {processed}/{total} sessions, added {added}, skipped {skipped}, removed {removed}",
|
|
9208
9403
|
"card.fullSync.failuresNote": ", {count} unreadable sessions skipped",
|
|
9404
|
+
"card.fullSync.importedNote": ", {count} DeepSeek chat imported records ignored",
|
|
9209
9405
|
"card.fullSync.done": "Scan complete: added {added}, skipped {skipped}, removed {removed}",
|
|
9210
9406
|
"card.fullSync.failed": "Scan failed: {error}",
|
|
9211
9407
|
"loadFailed": "Failed to load stats: {message}",
|
|
@@ -9235,7 +9431,8 @@ window.__ModuleLoader__.load({
|
|
|
9235
9431
|
"view.subagents.none": "No subagents",
|
|
9236
9432
|
"view.subagents.titleCol": "Session",
|
|
9237
9433
|
"view.subagents.nested": "With {count} subagents",
|
|
9238
|
-
"view.
|
|
9434
|
+
"view.subagents.scroll": "Subagent list — click it to scroll inside",
|
|
9435
|
+
"view.note": "Note: tokens and cost come from this plugin's request log; solo-session header TTFT and token speed prefer the DSH session projection (covers history without logs), while subtree, subagent, and subagent-table timing come from this plugin's timed request records.",
|
|
9239
9436
|
"pool.latest.title": "Latest request",
|
|
9240
9437
|
"pool.latest.context": "single request · not a session mean",
|
|
9241
9438
|
"pool.title": "Live requests",
|
|
@@ -9257,6 +9454,7 @@ window.__ModuleLoader__.load({
|
|
|
9257
9454
|
"pool.kind.compaction": "Compaction",
|
|
9258
9455
|
"pool.kind.auto-review": "Review",
|
|
9259
9456
|
"pool.kind.session-title": "Title",
|
|
9457
|
+
"pool.kind.timeline-report": "Timeline",
|
|
9260
9458
|
"pool.kind.translation": "Translation",
|
|
9261
9459
|
"pool.kind.other": "Auxiliary",
|
|
9262
9460
|
"pool.attribution.prefix": "Before this request, host compaction rewrote the context prefix; cache behaviour may be affected:",
|