@mtayfur/opencode-cache-view 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -446,7 +446,7 @@ function createSpeedTracker(api) {
|
|
|
446
446
|
if (!start || start.sessionID !== event.properties.sessionID)
|
|
447
447
|
return;
|
|
448
448
|
clearStream(value.messageID);
|
|
449
|
-
const duration =
|
|
449
|
+
const duration = start.firstTokenTime === undefined || start.lastTokenTime === undefined ? 0 : start.lastTokenTime - start.firstTokenTime;
|
|
450
450
|
const tokens = value.tokens.output + value.tokens.reasoning;
|
|
451
451
|
if (value.reason === "tool-calls") {
|
|
452
452
|
pendingToolTurns.add(start.sessionID);
|
|
@@ -460,9 +460,14 @@ function createSpeedTracker(api) {
|
|
|
460
460
|
trends.set(start.sessionID, [...trends.get(start.sessionID) ?? [], speed].slice(-8));
|
|
461
461
|
});
|
|
462
462
|
const delta = api.event.on("message.part.delta", (event) => {
|
|
463
|
-
if (event.properties.field !== "text"
|
|
463
|
+
if (event.properties.field !== "text")
|
|
464
|
+
return;
|
|
465
|
+
const start = starts.get(event.properties.messageID);
|
|
466
|
+
if (!start)
|
|
464
467
|
return;
|
|
465
468
|
const now = Date.now();
|
|
469
|
+
start.firstTokenTime ??= now;
|
|
470
|
+
start.lastTokenTime = now;
|
|
466
471
|
const previous = streamParts.get(event.properties.partID) ?? {
|
|
467
472
|
messageID: event.properties.messageID,
|
|
468
473
|
units: 0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@mtayfur/opencode-cache-view",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Minimal OpenCode TUI sidebar for cache hit, estimated tokens, and generation speed.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|