oc-flight-deck 0.25.0 → 0.25.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/CHANGELOG.md +7 -1
- package/README.md +13 -16
- package/assets/signature-glyph.svg +5 -0
- package/dist/tui/index.js +56 -12
- package/docs/GUIDE.md +3 -2
- package/flight-deck.example.jsonc +6 -4
- package/flight-deck.schema.json +8 -1
- package/package.json +8 -6
- package/src/tui/caution.ts +15 -6
- package/src/tui/config.ts +10 -6
- package/src/tui/index.tsx +10 -3
- package/src/tui/presentation.ts +1 -0
- package/src/tui/rows.ts +11 -5
- package/src/tui/session-reads.ts +55 -12
- package/src/tui/stat-fields.ts +4 -0
- package/assets/signature.svg +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [0.25.
|
|
10
|
+
## [0.25.2] - 2026-11-26
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
- npm metadata alignment: README wording and keywords refreshed (cosmetic).
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- The `caution` row no longer reports `no progress` for an idle session: silent-turn now needs an open turn, not just a stale host `running` flag. The `status` row reads idle on stale running, paused when a permission or a question tool waits, and running only with real evidence.
|
|
11
17
|
|
|
12
18
|
### Added
|
|
13
19
|
|
package/README.md
CHANGED
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">oc-flight-deck</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center"><strong>Live cost, token, cache and context telemetry for every OpenCode session
|
|
7
|
+
<p align="center"><strong>Live cost, token, cache and context telemetry for every OpenCode session in your sidebar.</strong></p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://www.npmjs.com/package/oc-flight-deck"><img src="https://img.shields.io/npm/v/oc-flight-deck" alt="npm version"
|
|
11
|
-
<img src="https://img.shields.io/badge/platform-windows--linux-2b3137" alt="
|
|
12
|
-
<a href="https://github.com/nathwn12/oc-collections/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT"
|
|
10
|
+
<a href="https://www.npmjs.com/package/oc-flight-deck"><img src="https://img.shields.io/npm/v/oc-flight-deck" alt="npm version" /></a>
|
|
11
|
+
<img src="https://img.shields.io/badge/platform-windows--linux-2b3137" alt="Windows and Linux" />
|
|
12
|
+
<a href="https://github.com/nathwn12/oc-collections/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT licence" /></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
|
-
## Why
|
|
16
|
-
|
|
17
|
-
Cost and context are easy to lose sight of during a long session. `oc-flight-deck` draws them beside the session, live, so you see the roll-up without leaving the run. A cache hit rate excludes writes from its denominator, because a write is not a lookup. Elapsed time is recomputed from the turn spans the host recorded, so it survives a restart and never steps backwards. Estimates carry a `~` and say so out loud.
|
|
18
|
-
|
|
19
|
-
Every setting lives in one global file, not per project.
|
|
20
|
-
|
|
21
15
|
## Install
|
|
22
16
|
|
|
23
17
|
Add the entry to the `plugins` array in your `opencode.jsonc`, then restart OpenCode:
|
|
@@ -26,9 +20,9 @@ Add the entry to the `plugins` array in your `opencode.jsonc`, then restart Open
|
|
|
26
20
|
{ "plugins": ["oc-flight-deck"] }
|
|
27
21
|
```
|
|
28
22
|
|
|
29
|
-
## Use
|
|
23
|
+
## Use it
|
|
30
24
|
|
|
31
|
-
The rail draws up to
|
|
25
|
+
The rail draws up to 22 named fields in the order you choose; `MAX_LINES` (24) caps fixed lines plus live rows together. Among the fields:
|
|
32
26
|
|
|
33
27
|
- **Honest zeros** — every numeric row draws a real zero when there is no data, never a dash or a blank.
|
|
34
28
|
- **Money** — the current model's spend for this session, and a durable lifetime total for the subagent tree. The old `cost` and `total` row names still work as aliases.
|
|
@@ -38,10 +32,11 @@ The rail draws up to 18 named rows in the order you choose. Among them are:
|
|
|
38
32
|
- **Caution annunciator** — an opt-in watchdog that stays silent until a tool or a turn stops moving, and reports what it saw without killing anything.
|
|
39
33
|
- **Quota and session rows** — the Go usage dials, and a session id row that copies the full id on click.
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
A cache hit rate excludes writes from its denominator, because a write is not a lookup. Elapsed time is recomputed from the turn spans the host recorded, so it survives a restart and never steps backwards. Estimates carry a `~` and say so out loud.
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
### Configure it
|
|
44
38
|
|
|
39
|
+
All settings live in one global file; there are no per-project files. Start from the [example config](https://github.com/nathwn12/oc-collections/blob/main/packages/oc-flight-deck/flight-deck.example.jsonc) and check the [schema](https://github.com/nathwn12/oc-collections/blob/main/packages/oc-flight-deck/flight-deck.schema.json) for each key and its default.
|
|
45
40
|
|
|
46
41
|
## Requirements
|
|
47
42
|
|
|
@@ -49,11 +44,13 @@ All settings live in one global file; there are no per-project files. Start from
|
|
|
49
44
|
- Node 22 or newer, or Bun 1.4 or newer.
|
|
50
45
|
- Any platform the host runs on.
|
|
51
46
|
|
|
47
|
+
## Status
|
|
48
|
+
|
|
49
|
+
**Unverified** — as-is, use at your own risk.
|
|
50
|
+
|
|
52
51
|
## Links
|
|
53
52
|
|
|
54
53
|
- [Issues](https://github.com/nathwn12/oc-collections/issues)
|
|
55
54
|
- [Releases](https://github.com/nathwn12/oc-collections/releases)
|
|
56
55
|
- [Guide](https://github.com/nathwn12/oc-collections/blob/main/packages/oc-flight-deck/docs/GUIDE.md)
|
|
57
56
|
- [MIT licence](https://github.com/nathwn12/oc-collections/blob/main/LICENSE)
|
|
58
|
-
|
|
59
|
-
<p align="center"><sub>Built by nathwn12</sub></p>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="120 148 300 252">
|
|
2
|
+
<!-- Glyph variant: strokes identical to the canonical signature.svg; ground tile removed, viewBox tightened to the glyph. Fits any background. -->
|
|
3
|
+
<path d="M136 384 L136 264 C136 196 180 164 234 164 C288 164 328 198 328 264 L328 384 L264 384 L264 270 C264 242 250 230 234 230 C218 230 200 242 200 270 L200 384 Z" fill="#EEF3F6"/>
|
|
4
|
+
<rect x="352" y="312" width="52" height="72" rx="8" fill="#4DD4E8"/>
|
|
5
|
+
</svg>
|
package/dist/tui/index.js
CHANGED
|
@@ -159,7 +159,7 @@ function detectCautions(input) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
const hasLiveWork = calls.some((call) => !SETTLED_TOOL.has(call.status)) || shells.some((raw) => asRecord(raw)?.["status"] === "running");
|
|
162
|
-
if (sessionRunning && !hasLiveWork) {
|
|
162
|
+
if (input.openTurn === true && sessionRunning && !hasLiveWork) {
|
|
163
163
|
const settledAt = newestActivity(calls) ?? input.lastMessageAt;
|
|
164
164
|
if (settledAt !== undefined) {
|
|
165
165
|
const elapsedMs = now - settledAt;
|
|
@@ -947,10 +947,14 @@ function statLine(field, source, layout = {}) {
|
|
|
947
947
|
}
|
|
948
948
|
case "status": {
|
|
949
949
|
const status = asText2(source.status);
|
|
950
|
-
|
|
950
|
+
const paused = source.paused === true;
|
|
951
|
+
if (status === undefined && source.busy === undefined && !paused)
|
|
951
952
|
return;
|
|
952
|
-
if (
|
|
953
|
+
if (paused)
|
|
954
|
+
return row("status", `${layout.pausedGlyph ?? "\u2016"} paused`);
|
|
955
|
+
if (source.busy === false || source.busy !== true && status !== "running") {
|
|
953
956
|
return row("status", "\u25CB idle");
|
|
957
|
+
}
|
|
954
958
|
const frame = Math.floor(asCount2(source.frame) ?? 0);
|
|
955
959
|
return row("status", `${SPINNER[frame % SPINNER.length]} running`);
|
|
956
960
|
}
|
|
@@ -1669,7 +1673,8 @@ var DEFAULT_FORMAT = {
|
|
|
1669
1673
|
var DEFAULT_GLYPHS = {
|
|
1670
1674
|
watch: "\u25B2",
|
|
1671
1675
|
caution: "\u25CF",
|
|
1672
|
-
clear: "\u25CB"
|
|
1676
|
+
clear: "\u25CB",
|
|
1677
|
+
paused: "\u2016"
|
|
1673
1678
|
};
|
|
1674
1679
|
var DEFAULT_NOTIFICATIONS = {
|
|
1675
1680
|
enabled: true,
|
|
@@ -2230,7 +2235,8 @@ function readGlyphs(section, issues) {
|
|
|
2230
2235
|
return {
|
|
2231
2236
|
watch: readGlyph(section["watch"], DEFAULT_GLYPHS.watch, "glyphs.watch", issues),
|
|
2232
2237
|
caution: readGlyph(section["caution"], DEFAULT_GLYPHS.caution, "glyphs.caution", issues),
|
|
2233
|
-
clear: readGlyph(section["clear"], DEFAULT_GLYPHS.clear, "glyphs.clear", issues)
|
|
2238
|
+
clear: readGlyph(section["clear"], DEFAULT_GLYPHS.clear, "glyphs.clear", issues),
|
|
2239
|
+
paused: readGlyph(section["paused"], DEFAULT_GLYPHS.paused, "glyphs.paused", issues)
|
|
2234
2240
|
};
|
|
2235
2241
|
}
|
|
2236
2242
|
function readStyleColor(value, fallback, path, issues) {
|
|
@@ -2572,6 +2578,7 @@ function railLines(config, source = {}) {
|
|
|
2572
2578
|
tpsDisplay: config.sidebar.tps.display,
|
|
2573
2579
|
tpsLabel: config.sidebar.tps.label,
|
|
2574
2580
|
tpsTtft: config.sidebar.tps.ttft,
|
|
2581
|
+
pausedGlyph: config.glyphs.paused,
|
|
2575
2582
|
hasLifetimeRow: config.sidebar.rows.some((field) => canonicalField(field) === "lifetime")
|
|
2576
2583
|
};
|
|
2577
2584
|
const lines = config.sidebar.lines.map((text) => ({ text }));
|
|
@@ -4433,10 +4440,42 @@ function createSessionReads(context) {
|
|
|
4433
4440
|
return;
|
|
4434
4441
|
}
|
|
4435
4442
|
};
|
|
4443
|
+
const openTurnOf = (sessionID) => {
|
|
4444
|
+
const messages = messagesOf(sessionID);
|
|
4445
|
+
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
4446
|
+
const message = asRecord2(messages[index]);
|
|
4447
|
+
const type = asText2(message?.["type"]);
|
|
4448
|
+
if (type !== "user" && type !== "assistant")
|
|
4449
|
+
continue;
|
|
4450
|
+
if (type === "user")
|
|
4451
|
+
return true;
|
|
4452
|
+
return asCount2(asRecord2(message?.["time"])?.["completed"]) === undefined;
|
|
4453
|
+
}
|
|
4454
|
+
return false;
|
|
4455
|
+
};
|
|
4456
|
+
const pausedOf = (sessionID) => {
|
|
4457
|
+
if (permsOf(sessionID) !== undefined)
|
|
4458
|
+
return true;
|
|
4459
|
+
for (const part of recentParts(sessionID)) {
|
|
4460
|
+
const call = readToolCall(part);
|
|
4461
|
+
if (call !== undefined && call.name === "question" && !SETTLED_TOOL.has(call.status))
|
|
4462
|
+
return true;
|
|
4463
|
+
}
|
|
4464
|
+
return false;
|
|
4465
|
+
};
|
|
4436
4466
|
const busy = (sessionID) => {
|
|
4437
4467
|
const status = statusOf(sessionID);
|
|
4438
|
-
|
|
4439
|
-
|
|
4468
|
+
try {
|
|
4469
|
+
for (const part of recentParts(sessionID)) {
|
|
4470
|
+
const call = readToolCall(part);
|
|
4471
|
+
if (call !== undefined && !SETTLED_TOOL.has(call.status))
|
|
4472
|
+
return true;
|
|
4473
|
+
}
|
|
4474
|
+
} catch {}
|
|
4475
|
+
try {
|
|
4476
|
+
if (shellsOf(sessionID).some((entry) => asRecord2(entry)?.["status"] === "running"))
|
|
4477
|
+
return true;
|
|
4478
|
+
} catch {}
|
|
4440
4479
|
try {
|
|
4441
4480
|
for (const id of context.data.session.family(sessionID) ?? []) {
|
|
4442
4481
|
if (id === sessionID)
|
|
@@ -4447,10 +4486,8 @@ function createSessionReads(context) {
|
|
|
4447
4486
|
} catch {}
|
|
4448
4487
|
}
|
|
4449
4488
|
} catch {}
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
return true;
|
|
4453
|
-
} catch {}
|
|
4489
|
+
if (openTurnOf(sessionID))
|
|
4490
|
+
return true;
|
|
4454
4491
|
return status === undefined ? undefined : false;
|
|
4455
4492
|
};
|
|
4456
4493
|
const spansOf = (sessionID, now) => {
|
|
@@ -4514,6 +4551,8 @@ function createSessionReads(context) {
|
|
|
4514
4551
|
shellsOf,
|
|
4515
4552
|
lastActivity,
|
|
4516
4553
|
permsOf,
|
|
4554
|
+
openTurnOf,
|
|
4555
|
+
pausedOf,
|
|
4517
4556
|
busy
|
|
4518
4557
|
};
|
|
4519
4558
|
}
|
|
@@ -4739,6 +4778,8 @@ var tui_default = Plugin.define({
|
|
|
4739
4778
|
shellsOf,
|
|
4740
4779
|
lastActivity,
|
|
4741
4780
|
permsOf,
|
|
4781
|
+
openTurnOf,
|
|
4782
|
+
pausedOf,
|
|
4742
4783
|
busy
|
|
4743
4784
|
} = reads;
|
|
4744
4785
|
const { projectTotals } = createProjectTotals(context);
|
|
@@ -4749,6 +4790,7 @@ var tui_default = Plugin.define({
|
|
|
4749
4790
|
shells: shellsOf(sessionID),
|
|
4750
4791
|
now,
|
|
4751
4792
|
sessionRunning: statusOf(sessionID) === "running",
|
|
4793
|
+
openTurn: openTurnOf(sessionID),
|
|
4752
4794
|
lastMessageAt: lastActivity(sessionID),
|
|
4753
4795
|
thresholds: cautionThreshold
|
|
4754
4796
|
});
|
|
@@ -4798,7 +4840,8 @@ var tui_default = Plugin.define({
|
|
|
4798
4840
|
const location = locationOf(context);
|
|
4799
4841
|
const session = context.data.session.get(sessionID);
|
|
4800
4842
|
const isBusy = busy(sessionID);
|
|
4801
|
-
|
|
4843
|
+
const paused = wants("status") ? pausedOf(sessionID) : false;
|
|
4844
|
+
spinnerNeeded = wants("status") && isBusy === true && !paused;
|
|
4802
4845
|
const turns = wants("turns") ? messagesOf(sessionID).filter((entry) => asRecord2(entry)?.["type"] === "user").length : undefined;
|
|
4803
4846
|
const wantsUsage = wants("spend") || wants("lifetime") || wants("tokens") || wants("cache") || wants("reasoning");
|
|
4804
4847
|
const ownCost = wantsUsage ? sessionCost(sessionID, session) : undefined;
|
|
@@ -4834,6 +4877,7 @@ var tui_default = Plugin.define({
|
|
|
4834
4877
|
project: wants("project") ? projectTotals(sessionID) : undefined,
|
|
4835
4878
|
status: wants("status") ? statusOf(sessionID) : undefined,
|
|
4836
4879
|
busy: isBusy,
|
|
4880
|
+
paused,
|
|
4837
4881
|
perms: wants("perms") ? permsOf(sessionID) : undefined,
|
|
4838
4882
|
tps: wants("tps") ? sessionTps(sessionID, session) : undefined,
|
|
4839
4883
|
spark: wants("spark") ? sparkValues(sessionID) : undefined,
|
package/docs/GUIDE.md
CHANGED
|
@@ -157,6 +157,7 @@ One global file: `~/.config/opencode/flight-deck.jsonc`. The `.json` name is als
|
|
|
157
157
|
| **`glyphs.watch`** | `"▲"` | The watch glyph, 1–2 chars. |
|
|
158
158
|
| **`glyphs.caution`** | `"●"` | The caution glyph, 1–2 chars. |
|
|
159
159
|
| **`glyphs.clear`** | `"○"` | Reserved, not drawn today. |
|
|
160
|
+
| **`glyphs.paused`** | `"‖"` | The status row's paused mark, 1–2 chars. Draws `‖ paused` when a permission or a question tool waits on the person. |
|
|
160
161
|
|
|
161
162
|
**Style**
|
|
162
163
|
|
|
@@ -172,7 +173,7 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
172
173
|
| Row | What it shows | Default |
|
|
173
174
|
| --- | --- | --- |
|
|
174
175
|
| `caution` | Annunciator, opt-in with `caution.enabled`. Silent unless a tool or turn stops moving. Reports observations, never verdicts (`shell running 8m41s`). Never aborts, kills, retries, or blocks. `▲` watch, `●` caution, `○` reserved and not drawn. | opt-in |
|
|
175
|
-
| `status` | `⠙ running`
|
|
176
|
+
| `status` | `‖ paused` when a permission or a `question` tool waits on the person; `⠙ running` with real evidence of work (a live tool, shell, child or open turn); `○ idle` otherwise. A stale host `running` flag with no evidence reads idle. | yes |
|
|
176
177
|
| `agent` | Active agent name. | yes |
|
|
177
178
|
| `model` | Model id, plus ` · variant` when one is present. | yes |
|
|
178
179
|
| `branch` | Current git branch. Costs a VCS call. | opt-in |
|
|
@@ -293,7 +294,7 @@ The shipped `flight-deck.example.jsonc` is a complete starting file, and `flight
|
|
|
293
294
|
|
|
294
295
|
<!-- nathwn12 house footer: identical in every repo. Do not edit. -->
|
|
295
296
|
<p align="center">
|
|
296
|
-
<a href="https://github.com/nathwn12"><img src="../assets/signature.svg" width="96" alt="nathwn12" /></a>
|
|
297
|
+
<a href="https://github.com/nathwn12"><img src="../assets/signature-glyph.svg" width="96" alt="nathwn12" /></a>
|
|
297
298
|
</p>
|
|
298
299
|
<p align="center">
|
|
299
300
|
<sub>Built by <a href="https://github.com/nathwn12">nathwn12</a> · <a href="https://github.com/nathwn12?tab=repositories">All projects</a></sub>
|
|
@@ -409,13 +409,15 @@
|
|
|
409
409
|
},
|
|
410
410
|
|
|
411
411
|
// -- Glyphs ----------------------------------------------------------------
|
|
412
|
-
// The
|
|
413
|
-
//
|
|
414
|
-
//
|
|
412
|
+
// The rail's status marks. Change these if your terminal renders a default
|
|
413
|
+
// as a box or at the wrong width - an ugly but readable panel beats an
|
|
414
|
+
// unreadable one. One or two characters each.
|
|
415
415
|
"glyphs": {
|
|
416
416
|
"watch": "▲",
|
|
417
417
|
"caution": "●",
|
|
418
|
-
"clear": "○"
|
|
418
|
+
"clear": "○",
|
|
419
|
+
// The status row's paused mark: one glyph plus the word `paused`.
|
|
420
|
+
"paused": "‖"
|
|
419
421
|
},
|
|
420
422
|
|
|
421
423
|
// -- Style -----------------------------------------------------------------
|
package/flight-deck.schema.json
CHANGED
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
"glyphs": {
|
|
395
395
|
"type": "object",
|
|
396
396
|
"additionalProperties": false,
|
|
397
|
-
"description": "The
|
|
397
|
+
"description": "The rail's status marks: one per annunciator severity, plus the paused mark for the status row. Change these when a terminal renders the defaults as a box, or at the wrong width — an ugly-but-readable panel beats an unreadable one. One or two characters each.",
|
|
398
398
|
"properties": {
|
|
399
399
|
"watch": {
|
|
400
400
|
"type": "string",
|
|
@@ -416,6 +416,13 @@
|
|
|
416
416
|
"maxLength": 2,
|
|
417
417
|
"default": "○",
|
|
418
418
|
"description": "Reserved for a future always-visible annunciator state. Not currently drawn: the row is absent when nothing is wrong."
|
|
419
|
+
},
|
|
420
|
+
"paused": {
|
|
421
|
+
"type": "string",
|
|
422
|
+
"minLength": 1,
|
|
423
|
+
"maxLength": 2,
|
|
424
|
+
"default": "‖",
|
|
425
|
+
"description": "Shown on the `status` row when a permission request is pending or a `question` tool is waiting on the person. One glyph plus one word: `‖ paused`."
|
|
419
426
|
}
|
|
420
427
|
}
|
|
421
428
|
},
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-flight-deck",
|
|
3
|
-
"version": "0.25.
|
|
4
|
-
"description": "Live
|
|
3
|
+
"version": "0.25.2",
|
|
4
|
+
"description": "Live cost, token, cache and context telemetry for every OpenCode session in your sidebar.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
7
7
|
"opencode-plugin",
|
|
8
|
-
"
|
|
8
|
+
"plugin",
|
|
9
9
|
"tui",
|
|
10
|
-
"cli",
|
|
11
|
-
"sidebar",
|
|
12
10
|
"telemetry",
|
|
13
|
-
"cost"
|
|
11
|
+
"cost",
|
|
12
|
+
"tokens",
|
|
13
|
+
"typescript",
|
|
14
|
+
"tooling",
|
|
15
|
+
"session"
|
|
14
16
|
],
|
|
15
17
|
"license": "MIT",
|
|
16
18
|
"author": "nathwn12",
|
package/src/tui/caution.ts
CHANGED
|
@@ -63,6 +63,12 @@ interface CautionInput {
|
|
|
63
63
|
readonly shells?: readonly unknown[];
|
|
64
64
|
readonly now: number;
|
|
65
65
|
readonly sessionRunning: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* True only while a turn is genuinely open: the newest message is a user
|
|
68
|
+
* message, or the newest assistant message has no `time.completed`. A stale
|
|
69
|
+
* host `running` flag with a closed turn must not drive the silent clock.
|
|
70
|
+
*/
|
|
71
|
+
readonly openTurn?: boolean;
|
|
66
72
|
readonly lastMessageAt?: number;
|
|
67
73
|
readonly thresholds: CautionThresholds;
|
|
68
74
|
}
|
|
@@ -88,7 +94,7 @@ function asText(value: unknown): string | undefined {
|
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
/** Statuses that mean a tool has stopped. Anything else counts as live. */
|
|
91
|
-
const SETTLED_TOOL = new Set(["completed", "error", "aborted", "cancelled"]);
|
|
97
|
+
export const SETTLED_TOOL = new Set(["completed", "error", "aborted", "cancelled"]);
|
|
92
98
|
|
|
93
99
|
interface ToolCall {
|
|
94
100
|
readonly name: string;
|
|
@@ -293,15 +299,18 @@ export function detectCautions(input: CautionInput): Caution[] {
|
|
|
293
299
|
}
|
|
294
300
|
}
|
|
295
301
|
|
|
296
|
-
// Rule 5 —
|
|
302
|
+
// Rule 5 — an OPEN turn that is not moving.
|
|
297
303
|
//
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
304
|
+
// The host's `running` flag alone is not enough: it goes stale when a turn
|
|
305
|
+
// closes without the host clearing it, and then the clock runs on an idle
|
|
306
|
+
// session. The newest message must still be open. A live tool or shell is
|
|
307
|
+
// progress and rules 1 and 2 own it, so this stays out of their way too —
|
|
308
|
+
// including an exempt one, because an exempt tool is usually waiting on a
|
|
309
|
+
// person.
|
|
301
310
|
const hasLiveWork =
|
|
302
311
|
calls.some((call) => !SETTLED_TOOL.has(call.status)) ||
|
|
303
312
|
shells.some((raw) => asRecord(raw)?.["status"] === "running");
|
|
304
|
-
if (sessionRunning && !hasLiveWork) {
|
|
313
|
+
if (input.openTurn === true && sessionRunning && !hasLiveWork) {
|
|
305
314
|
const settledAt = newestActivity(calls) ?? input.lastMessageAt;
|
|
306
315
|
if (settledAt !== undefined) {
|
|
307
316
|
const elapsedMs = now - settledAt;
|
package/src/tui/config.ts
CHANGED
|
@@ -333,18 +333,20 @@ interface LayoutConfig {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
/**
|
|
336
|
-
* The
|
|
336
|
+
* The rail's status marks: one per annunciator severity, plus the status row's
|
|
337
|
+
* paused mark.
|
|
337
338
|
*
|
|
338
|
-
* All
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
339
|
+
* All four are single-cell marks — `▲` watch, `●` caution, `○` clear, `‖`
|
|
340
|
+
* paused — so the rail lines up regardless of how the terminal classifies
|
|
341
|
+
* their East Asian width. Configurable because these have to read at a glance,
|
|
342
|
+
* and a terminal that draws one badly can be given a substitute without a
|
|
343
|
+
* rebuild.
|
|
343
344
|
*/
|
|
344
345
|
interface GlyphConfig {
|
|
345
346
|
readonly watch: string;
|
|
346
347
|
readonly caution: string;
|
|
347
348
|
readonly clear: string;
|
|
349
|
+
readonly paused: string;
|
|
348
350
|
}
|
|
349
351
|
|
|
350
352
|
/**
|
|
@@ -406,6 +408,7 @@ const DEFAULT_GLYPHS: GlyphConfig = {
|
|
|
406
408
|
watch: "▲",
|
|
407
409
|
caution: "●",
|
|
408
410
|
clear: "○",
|
|
411
|
+
paused: "‖",
|
|
409
412
|
};
|
|
410
413
|
|
|
411
414
|
/**
|
|
@@ -1318,6 +1321,7 @@ function readGlyphs(section: Record<string, unknown>, issues: string[]): GlyphCo
|
|
|
1318
1321
|
watch: readGlyph(section["watch"], DEFAULT_GLYPHS.watch, "glyphs.watch", issues),
|
|
1319
1322
|
caution: readGlyph(section["caution"], DEFAULT_GLYPHS.caution, "glyphs.caution", issues),
|
|
1320
1323
|
clear: readGlyph(section["clear"], DEFAULT_GLYPHS.clear, "glyphs.clear", issues),
|
|
1324
|
+
paused: readGlyph(section["paused"], DEFAULT_GLYPHS.paused, "glyphs.paused", issues),
|
|
1321
1325
|
};
|
|
1322
1326
|
}
|
|
1323
1327
|
|
package/src/tui/index.tsx
CHANGED
|
@@ -176,6 +176,8 @@ export default Plugin.define({
|
|
|
176
176
|
shellsOf,
|
|
177
177
|
lastActivity,
|
|
178
178
|
permsOf,
|
|
179
|
+
openTurnOf,
|
|
180
|
+
pausedOf,
|
|
179
181
|
busy,
|
|
180
182
|
} = reads;
|
|
181
183
|
|
|
@@ -193,6 +195,9 @@ export default Plugin.define({
|
|
|
193
195
|
shells: shellsOf(sessionID),
|
|
194
196
|
now,
|
|
195
197
|
sessionRunning: statusOf(sessionID) === "running",
|
|
198
|
+
// The host flag alone can go stale; only an open turn may drive the
|
|
199
|
+
// silent clock.
|
|
200
|
+
openTurn: openTurnOf(sessionID),
|
|
196
201
|
lastMessageAt: lastActivity(sessionID),
|
|
197
202
|
thresholds: cautionThreshold,
|
|
198
203
|
});
|
|
@@ -301,9 +306,10 @@ export default Plugin.define({
|
|
|
301
306
|
const location = locationOf(context);
|
|
302
307
|
const session = context.data.session.get(sessionID) as SessionLike | undefined;
|
|
303
308
|
const isBusy = busy(sessionID);
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
|
|
309
|
+
const paused = wants("status") ? pausedOf(sessionID) : false;
|
|
310
|
+
// The fast tick exists for the spinner, and the spinner is only drawn
|
|
311
|
+
// while something is moving and nobody is being asked a question.
|
|
312
|
+
spinnerNeeded = wants("status") && isBusy === true && !paused;
|
|
307
313
|
|
|
308
314
|
// A "turn" is one prompt and the work it caused. The host's message list
|
|
309
315
|
// also carries system, shell and switch records, so counting records
|
|
@@ -362,6 +368,7 @@ export default Plugin.define({
|
|
|
362
368
|
project: wants("project") ? projectTotals(sessionID) : undefined,
|
|
363
369
|
status: wants("status") ? statusOf(sessionID) : undefined,
|
|
364
370
|
busy: isBusy,
|
|
371
|
+
paused,
|
|
365
372
|
perms: wants("perms") ? permsOf(sessionID) : undefined,
|
|
366
373
|
tps: wants("tps") ? sessionTps(sessionID, session) : undefined,
|
|
367
374
|
spark: wants("spark") ? sparkValues(sessionID) : undefined,
|
package/src/tui/presentation.ts
CHANGED
|
@@ -58,6 +58,7 @@ export function railLines(config: FlightDeckConfig, source: StatSource = {}): re
|
|
|
58
58
|
tpsDisplay: config.sidebar.tps.display,
|
|
59
59
|
tpsLabel: config.sidebar.tps.label,
|
|
60
60
|
tpsTtft: config.sidebar.tps.ttft,
|
|
61
|
+
pausedGlyph: config.glyphs.paused,
|
|
61
62
|
// Decided from the whole row list, the way `statRows` decides it: `spend`
|
|
62
63
|
// folds the subagent total into itself only when no `lifetime` row (or its
|
|
63
64
|
// `total` alias) was asked for, even if the cap later drops that row.
|
package/src/tui/rows.ts
CHANGED
|
@@ -311,15 +311,21 @@ export function statLine(
|
|
|
311
311
|
}
|
|
312
312
|
case "status": {
|
|
313
313
|
const status = asText(source.status);
|
|
314
|
-
|
|
314
|
+
const paused = source.paused === true;
|
|
315
|
+
if (status === undefined && source.busy === undefined && !paused) return undefined;
|
|
316
|
+
// A person being asked something outranks the spinner: the session may
|
|
317
|
+
// still be busy underneath, but nothing moves until they answer.
|
|
318
|
+
if (paused) return row("status", `${layout.pausedGlyph ?? "‖"} paused`);
|
|
315
319
|
// The spinner lives here rather than in a row of its own: an animated
|
|
316
320
|
// glyph beside "running" says the same thing without spending a line.
|
|
317
321
|
//
|
|
318
322
|
// `busy` folds in work the session's own status misses — a subagent
|
|
319
|
-
// running in its own session,
|
|
320
|
-
// glyph only stops when there is
|
|
321
|
-
//
|
|
322
|
-
if (source.busy !== true && status !== "running")
|
|
323
|
+
// running in its own session, a shell command still going, a live tool,
|
|
324
|
+
// or an open turn — so the glyph only stops when there is real evidence
|
|
325
|
+
// of work. A stale host `running` with none of that reads idle.
|
|
326
|
+
if (source.busy === false || (source.busy !== true && status !== "running")) {
|
|
327
|
+
return row("status", "○ idle");
|
|
328
|
+
}
|
|
323
329
|
// Floored at the boundary: a fractional frame would index the frame list
|
|
324
330
|
// with a non-integer and render `undefined`.
|
|
325
331
|
const frame = Math.floor(asCount(source.frame) ?? 0);
|
package/src/tui/session-reads.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// Coercion of untrusted values happens through ./coerce.js.
|
|
9
9
|
|
|
10
10
|
import type { Plugin } from "@opencode/plugin/tui";
|
|
11
|
+
import { SETTLED_TOOL, readToolCall } from "./caution.js";
|
|
11
12
|
import { createActiveTime } from "./session-elapsed.js";
|
|
12
13
|
import { asCount, asRecord, asText, type SessionLike } from "./coerce.js";
|
|
13
14
|
import { turnKey, type ThroughputSpan } from "./stats.js";
|
|
@@ -487,13 +488,57 @@ export function createSessionReads(context: Plugin.Context) {
|
|
|
487
488
|
}
|
|
488
489
|
};
|
|
489
490
|
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
491
|
+
// A turn is open while a user prompt is waiting for its reply, or while the
|
|
492
|
+
// newest assistant message has not recorded a completion. This is the only
|
|
493
|
+
// honest clock for the silent-turn rule: the host's `running` flag can go
|
|
494
|
+
// stale, but an open turn cannot be mistaken for a closed one.
|
|
495
|
+
const openTurnOf = (sessionID: string): boolean => {
|
|
496
|
+
const messages = messagesOf(sessionID);
|
|
497
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
498
|
+
const message = asRecord(messages[index]);
|
|
499
|
+
const type = asText(message?.["type"]);
|
|
500
|
+
// System, shell and switch records are not turns; walk past them.
|
|
501
|
+
if (type !== "user" && type !== "assistant") continue;
|
|
502
|
+
if (type === "user") return true;
|
|
503
|
+
return asCount(asRecord(message?.["time"])?.["completed"]) === undefined;
|
|
504
|
+
}
|
|
505
|
+
return false;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
// A person is being asked something: a pending permission request, or a live
|
|
509
|
+
// `question` tool. Both outrank the spinner — the session cannot move until
|
|
510
|
+
// someone answers.
|
|
511
|
+
const pausedOf = (sessionID: string): boolean => {
|
|
512
|
+
if (permsOf(sessionID) !== undefined) return true;
|
|
513
|
+
for (const part of recentParts(sessionID)) {
|
|
514
|
+
const call = readToolCall(part);
|
|
515
|
+
if (call !== undefined && call.name === "question" && !SETTLED_TOOL.has(call.status)) return true;
|
|
516
|
+
}
|
|
517
|
+
return false;
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
// Real evidence of work: a live tool, a running shell, a running child, or an
|
|
521
|
+
// open turn. A `running` status on its own is not evidence — that flag goes
|
|
522
|
+
// stale when a turn closes without the host clearing it, and reading it as
|
|
523
|
+
// work kept the caution clock running on an idle session. Returns
|
|
524
|
+
// `undefined` only when the host said nothing at all and no evidence exists.
|
|
494
525
|
const busy = (sessionID: string): boolean | undefined => {
|
|
495
526
|
const status = statusOf(sessionID);
|
|
496
|
-
|
|
527
|
+
|
|
528
|
+
try {
|
|
529
|
+
for (const part of recentParts(sessionID)) {
|
|
530
|
+
const call = readToolCall(part);
|
|
531
|
+
if (call !== undefined && !SETTLED_TOOL.has(call.status)) return true;
|
|
532
|
+
}
|
|
533
|
+
} catch {
|
|
534
|
+
// Unreadable parts just mean no tool evidence.
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
try {
|
|
538
|
+
if (shellsOf(sessionID).some((entry) => asRecord(entry)?.["status"] === "running")) return true;
|
|
539
|
+
} catch {
|
|
540
|
+
// Unreadable shells just mean no shell signal.
|
|
541
|
+
}
|
|
497
542
|
|
|
498
543
|
try {
|
|
499
544
|
for (const id of context.data.session.family(sessionID) ?? []) {
|
|
@@ -505,15 +550,11 @@ export function createSessionReads(context: Plugin.Context) {
|
|
|
505
550
|
}
|
|
506
551
|
}
|
|
507
552
|
} catch {
|
|
508
|
-
// No subagent status on this host; the
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
try {
|
|
512
|
-
if (shellsOf(sessionID).some((entry) => asRecord(entry)?.["status"] === "running")) return true;
|
|
513
|
-
} catch {
|
|
514
|
-
// Unreadable shells just mean no shell signal.
|
|
553
|
+
// No subagent status on this host; the other signals still apply.
|
|
515
554
|
}
|
|
516
555
|
|
|
556
|
+
if (openTurnOf(sessionID)) return true;
|
|
557
|
+
// A stale `running` with no evidence reads idle, not busy.
|
|
517
558
|
return status === undefined ? undefined : false;
|
|
518
559
|
};
|
|
519
560
|
|
|
@@ -608,6 +649,8 @@ export function createSessionReads(context: Plugin.Context) {
|
|
|
608
649
|
shellsOf,
|
|
609
650
|
lastActivity,
|
|
610
651
|
permsOf,
|
|
652
|
+
openTurnOf,
|
|
653
|
+
pausedOf,
|
|
611
654
|
busy,
|
|
612
655
|
};
|
|
613
656
|
}
|
package/src/tui/stat-fields.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface StatSource {
|
|
|
50
50
|
readonly status?: unknown;
|
|
51
51
|
/** True when anything is working: this session, a subagent, or a shell. */
|
|
52
52
|
readonly busy?: unknown;
|
|
53
|
+
/** True when a permission or a question tool is waiting on the person. */
|
|
54
|
+
readonly paused?: unknown;
|
|
53
55
|
readonly perms?: unknown;
|
|
54
56
|
/**
|
|
55
57
|
* Session generation speed: the figures the reader hands over.
|
|
@@ -236,6 +238,8 @@ export interface LayoutHint {
|
|
|
236
238
|
* config's own type: this module must not import config.
|
|
237
239
|
*/
|
|
238
240
|
readonly tpsLabel?: string;
|
|
241
|
+
/** The status row's paused mark, from `glyphs.paused`. Default `‖`. */
|
|
242
|
+
readonly pausedGlyph?: string;
|
|
239
243
|
/**
|
|
240
244
|
* Whether the `tps` row may draw the observed mean time to first token
|
|
241
245
|
* (`1.2s ttft`). Off suppresses that segment in every display mode,
|
package/assets/signature.svg
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
2
|
-
<style>html,body{margin:0;padding:0}svg{display:block;width:100vw;height:100vh}</style>
|
|
3
|
-
<!-- Direction A: "cursor-n" — rounded lowercase n + terminal block cursor, near-black ground -->
|
|
4
|
-
<rect x="16" y="16" width="480" height="480" rx="112" fill="#0B0F14"/>
|
|
5
|
-
<path d="M136 384 L136 264 C136 196 180 164 234 164 C288 164 328 198 328 264 L328 384 L264 384 L264 270 C264 242 250 230 234 230 C218 230 200 242 200 270 L200 384 Z" fill="#EEF3F6"/>
|
|
6
|
-
<rect x="352" y="312" width="52" height="72" rx="8" fill="#4DD4E8"/>
|
|
7
|
-
</svg>
|