@jack-yang/opencode-tps-meter 1.0.0 → 1.0.2
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 -18
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.2",
|
|
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
|
|
|
@@ -190,9 +190,7 @@ function MeterDisplay(props: {
|
|
|
190
190
|
spinnerCells: () => { glyph: string; color: RGBA }[]
|
|
191
191
|
subscribe: (listener: Listener) => () => void
|
|
192
192
|
}) {
|
|
193
|
-
|
|
194
|
-
const spinRefs: (TextRenderable | undefined)[] = []
|
|
195
|
-
const [thinking, setThinking] = createSignal(false)
|
|
193
|
+
let particleRef: TextRenderable | undefined
|
|
196
194
|
let tpsRef: TextRenderable | undefined
|
|
197
195
|
let avgRef: TextRenderable | undefined
|
|
198
196
|
let ttftRef: TextRenderable | undefined
|
|
@@ -208,14 +206,13 @@ function MeterDisplay(props: {
|
|
|
208
206
|
const avg = stats && stats.totalDurationMs > 0 ? stats.totalOutputTokens / (stats.totalDurationMs / 1000) : undefined
|
|
209
207
|
const ttft = props.tracker.liveTtftBySession[props.sessionID]
|
|
210
208
|
const thinkingNow = props.tracker.thinkingBySession[props.sessionID] === true && props.config.spinner.enabled
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (cell) { ref.content = cell.glyph; ref.fg = cell.color }
|
|
209
|
+
if (particleRef) {
|
|
210
|
+
if (thinkingNow) {
|
|
211
|
+
const cells = props.spinnerCells()
|
|
212
|
+
particleRef.content = " " + cells.map((c) => c.glyph).join("")
|
|
213
|
+
particleRef.fg = cells[0]?.color ?? muted
|
|
214
|
+
} else {
|
|
215
|
+
particleRef.content = ""
|
|
219
216
|
}
|
|
220
217
|
}
|
|
221
218
|
if (tpsRef) {
|
|
@@ -244,12 +241,7 @@ function MeterDisplay(props: {
|
|
|
244
241
|
<text ref={(el: TextRenderable) => { avgRef = el; sync() }} fg={muted}>--</text>
|
|
245
242
|
<text fg={muted}> | TTFT </text>
|
|
246
243
|
<text ref={(el: TextRenderable) => { ttftRef = el; sync() }} fg={muted}>--</text>
|
|
247
|
-
<
|
|
248
|
-
<text fg={muted}> </text>
|
|
249
|
-
{Array.from({ length: cellCount }).map((_, i) => (
|
|
250
|
-
<text ref={(el: TextRenderable) => { spinRefs[i] = el; sync() }} fg={muted}></text>
|
|
251
|
-
))}
|
|
252
|
-
</Show>
|
|
244
|
+
<text ref={(el: TextRenderable) => { particleRef = el; sync() }} fg={muted}></text>
|
|
253
245
|
</box>
|
|
254
246
|
)
|
|
255
247
|
}
|