@jack-yang/opencode-tps-meter 1.0.0 → 1.0.1
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/package.json +1 -1
- package/tui.tsx +10 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@jack-yang/opencode-tps-meter",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "Live TPS/AVG/TTFT meter plugin for OpenCode TUI with color-coded speed tiers",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
package/tui.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { RGBA } from "@opentui/core"
|
|
|
3
3
|
import type { TextRenderable } from "@opentui/core"
|
|
4
4
|
import type { TuiPlugin, TuiPluginModule, TuiThemeCurrent } from "@opencode-ai/plugin/tui"
|
|
5
5
|
import type { PluginOptions } from "@opencode-ai/plugin"
|
|
6
|
-
import {
|
|
6
|
+
import { onCleanup } from "solid-js"
|
|
7
7
|
|
|
8
8
|
type DeltaSample = { at: number; rawTokens: number }
|
|
9
9
|
|
|
@@ -192,7 +192,7 @@ function MeterDisplay(props: {
|
|
|
192
192
|
}) {
|
|
193
193
|
const cellCount = props.config.spinner.enabled ? props.config.spinner.cells : 0
|
|
194
194
|
const spinRefs: (TextRenderable | undefined)[] = []
|
|
195
|
-
|
|
195
|
+
let sepRef: TextRenderable | undefined
|
|
196
196
|
let tpsRef: TextRenderable | undefined
|
|
197
197
|
let avgRef: TextRenderable | undefined
|
|
198
198
|
let ttftRef: TextRenderable | undefined
|
|
@@ -208,8 +208,8 @@ function MeterDisplay(props: {
|
|
|
208
208
|
const avg = stats && stats.totalDurationMs > 0 ? stats.totalOutputTokens / (stats.totalDurationMs / 1000) : undefined
|
|
209
209
|
const ttft = props.tracker.liveTtftBySession[props.sessionID]
|
|
210
210
|
const thinkingNow = props.tracker.thinkingBySession[props.sessionID] === true && props.config.spinner.enabled
|
|
211
|
-
setThinking(thinkingNow)
|
|
212
211
|
if (thinkingNow) {
|
|
212
|
+
if (sepRef) sepRef.content = " "
|
|
213
213
|
const cells = props.spinnerCells()
|
|
214
214
|
for (let i = 0; i < spinRefs.length; i++) {
|
|
215
215
|
const ref = spinRefs[i]
|
|
@@ -217,6 +217,9 @@ function MeterDisplay(props: {
|
|
|
217
217
|
const cell = cells[i]
|
|
218
218
|
if (cell) { ref.content = cell.glyph; ref.fg = cell.color }
|
|
219
219
|
}
|
|
220
|
+
} else {
|
|
221
|
+
if (sepRef) sepRef.content = ""
|
|
222
|
+
for (const ref of spinRefs) if (ref) ref.content = ""
|
|
220
223
|
}
|
|
221
224
|
if (tpsRef) {
|
|
222
225
|
tpsRef.content = live !== undefined ? formatTps(live) ?? "--" : "--"
|
|
@@ -244,12 +247,10 @@ function MeterDisplay(props: {
|
|
|
244
247
|
<text ref={(el: TextRenderable) => { avgRef = el; sync() }} fg={muted}>--</text>
|
|
245
248
|
<text fg={muted}> | TTFT </text>
|
|
246
249
|
<text ref={(el: TextRenderable) => { ttftRef = el; sync() }} fg={muted}>--</text>
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
{
|
|
250
|
-
|
|
251
|
-
))}
|
|
252
|
-
</Show>
|
|
250
|
+
<text ref={(el: TextRenderable) => { sepRef = el; sync() }} fg={muted}></text>
|
|
251
|
+
{Array.from({ length: cellCount }).map((_, i) => (
|
|
252
|
+
<text ref={(el: TextRenderable) => { spinRefs[i] = el; sync() }} fg={muted}></text>
|
|
253
|
+
))}
|
|
253
254
|
</box>
|
|
254
255
|
)
|
|
255
256
|
}
|