@glaicer/supercode-token-usage-panel 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/usage-model.js +18 -4
- package/dist/usage-panel.js +3 -2
- package/package.json +1 -1
package/dist/usage-model.js
CHANGED
|
@@ -224,7 +224,21 @@ function addMetrics(target, source) {
|
|
|
224
224
|
addCalibration(target.calibrations, key, sourceCalibration.chars, sourceCalibration.tokens);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Whether the viewed session launched subagents: at least one other member of
|
|
230
|
+
* the family descends from it. Siblings and ancestors do not count, so the
|
|
231
|
+
* section title stays "Token Usage" unless the current session itself has
|
|
232
|
+
* descendants.
|
|
233
|
+
*/
|
|
234
|
+
function hasCurrentDescendant(viewedID, contributions) {
|
|
235
|
+
for (const id of contributions.keys()) {
|
|
236
|
+
if (id === viewedID) continue;
|
|
237
|
+
if (belongsToBranch(id, viewedID, contributions)) return true;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
function aggregateContributions(contributions, incompleteBranches = new Set(), viewedID) {
|
|
228
242
|
let totals;
|
|
229
243
|
const metrics = emptyMetrics();
|
|
230
244
|
for (const contribution of contributions.values()) {
|
|
@@ -239,7 +253,7 @@ function aggregateContributions(contributions, incompleteBranches = new Set()) {
|
|
|
239
253
|
return {
|
|
240
254
|
totals,
|
|
241
255
|
metrics,
|
|
242
|
-
hasDescendants: members.size > 1,
|
|
256
|
+
hasDescendants: viewedID ? hasCurrentDescendant(viewedID, contributions) : members.size > 1,
|
|
243
257
|
members,
|
|
244
258
|
contributions,
|
|
245
259
|
incompleteBranches
|
|
@@ -288,7 +302,7 @@ async function fetchBranch(client, root) {
|
|
|
288
302
|
incompleteBranches.add(session.id);
|
|
289
303
|
}
|
|
290
304
|
}
|
|
291
|
-
return aggregateContributions(contributions, incompleteBranches);
|
|
305
|
+
return aggregateContributions(contributions, incompleteBranches, root.id);
|
|
292
306
|
}
|
|
293
307
|
function walkParents(sessionID, contributions, matches) {
|
|
294
308
|
const visited = new Set();
|
|
@@ -380,7 +394,7 @@ export function createUsageModel(api, sessionId, solid) {
|
|
|
380
394
|
for (const id of ids) contributionRevisions.set(id, revision);
|
|
381
395
|
};
|
|
382
396
|
const publishFamily = (sessionID, contributions, incompleteBranches) => {
|
|
383
|
-
const aggregate = aggregateContributions(contributions, incompleteBranches);
|
|
397
|
+
const aggregate = aggregateContributions(contributions, incompleteBranches, sessionID);
|
|
384
398
|
members = aggregate.members;
|
|
385
399
|
return {
|
|
386
400
|
sessionID,
|
package/dist/usage-panel.js
CHANGED
|
@@ -10,8 +10,9 @@ import { createElement as _$createElement } from "@opentui/solid";
|
|
|
10
10
|
* Usage of the current session family: token totals, cache rate, completed
|
|
11
11
|
* step count, generation speed/TTFT, and provisional diagnostics for the
|
|
12
12
|
* visible stream.
|
|
13
|
-
* Family totals include all subagent descendants; when
|
|
14
|
-
*
|
|
13
|
+
* Family totals include all subagent descendants; when the current session
|
|
14
|
+
* itself has descendant sessions the section title becomes
|
|
15
|
+
* "Token Usage (including subagents)", otherwise it stays "Token Usage".
|
|
15
16
|
*
|
|
16
17
|
* This file is only the View plus slot registration: it computes no numbers
|
|
17
18
|
* and formats nothing — all logic lives in ./usage-model.ts (the tested seam).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@glaicer/supercode-token-usage-panel",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "OpenCode TUI sidebar section: cumulative token usage and cost of the current session family.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|