oc-flight-deck 0.19.2 → 0.20.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/CHANGELOG.md +33 -0
- package/README.md +181 -75
- package/dist/tui/index.js +445 -110
- package/flight-deck.example.jsonc +52 -12
- package/flight-deck.schema.json +39 -5
- package/package.json +8 -7
- package/src/tui/clipboard.ts +99 -28
- package/src/tui/config.ts +104 -7
- package/src/tui/format.ts +23 -6
- package/src/tui/host-clipboard.ts +50 -12
- package/src/tui/index.tsx +20 -2
- package/src/tui/notify.ts +21 -0
- package/src/tui/presentation.ts +3 -0
- package/src/tui/realtime-tps.ts +433 -0
- package/src/tui/rows.ts +41 -9
- package/src/tui/session-tps.ts +133 -101
- package/src/tui/stat-fields.ts +25 -6
- package/src/tui/stats.ts +9 -3
- package/src/tui/throughput.ts +20 -110
|
@@ -144,11 +144,13 @@
|
|
|
144
144
|
// same value instead of resetting, it cannot step backwards
|
|
145
145
|
// while the host still reports those turns, and it is NOT
|
|
146
146
|
// wall-clock since the session began
|
|
147
|
-
// tps
|
|
148
|
-
// tokens (output + reasoning) over
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
147
|
+
// tps mean speed over `sidebar.tps.scope` below: generation
|
|
148
|
+
// tokens (output + reasoning) over the settled turns' own
|
|
149
|
+
// generating time. Draws the average by default — an idle
|
|
150
|
+
// gap reads as a steady figure rather than zero. `rt`
|
|
151
|
+
// below draws the realtime estimate from the host's
|
|
152
|
+
// streaming events instead (zero while nothing generates);
|
|
153
|
+
// `both` draws both on one line
|
|
152
154
|
// spark recent turn sizes as a sparkline
|
|
153
155
|
// reasoning reasoning tokens, when the model emits them, in the same
|
|
154
156
|
// family scope as `cost`
|
|
@@ -196,16 +198,33 @@
|
|
|
196
198
|
// ,"ses" - session id preview (labelled `session`); click to copy the full id
|
|
197
199
|
],
|
|
198
200
|
|
|
199
|
-
// Which sessions the `tps` row paces
|
|
200
|
-
//
|
|
201
|
-
//
|
|
201
|
+
// Which sessions the `tps` row paces, and which figure it draws.
|
|
202
|
+
// `"scope"` is who counts. `"family"` (the default) paces the open
|
|
203
|
+
// session plus its subagent sessions: generation tokens summed across
|
|
204
|
+
// the whole family over the union of all their streaming spans.
|
|
202
205
|
// Concurrent decoders share wall clock, so overlapping spans merge
|
|
203
206
|
// instead of adding — a root that is idle while its child decodes still
|
|
204
207
|
// reads live. `"session"` restores the per-session figure: the open
|
|
205
|
-
// session's own tokens over its own spans
|
|
206
|
-
// idle even when a child is still running. An unknown value
|
|
207
|
-
// to `"family"` and is reported.
|
|
208
|
-
|
|
208
|
+
// session's own tokens over its own spans (the `rt` figure reading zero
|
|
209
|
+
// while it is idle even when a child is still running). An unknown value
|
|
210
|
+
// falls back to `"family"` and is reported.
|
|
211
|
+
//
|
|
212
|
+
// `"display"` is what draws. `"avg"` (the default) is the settled-turn
|
|
213
|
+
// average: generation tokens over assistant turns that recorded
|
|
214
|
+
// `streamed`, divided by the union of their `streamed - created` spans —
|
|
215
|
+
// in-flight turns excluded, idle gaps never billed. `"rt"` is the
|
|
216
|
+
// realtime estimate from the host's streaming delta events, reading
|
|
217
|
+
// `0 tok/s` whenever the scope is not generating (idle, between turns,
|
|
218
|
+
// or before the first delta). `"both"` draws both on one line
|
|
219
|
+
// (`106 rt · 41 avg`), plus the mean time to first token over settled
|
|
220
|
+
// steps (`83 rt · 38 avg · 1.2s ttft`): per step, the earliest
|
|
221
|
+
// text/reasoning delta's event time minus the step's `started` dispatch
|
|
222
|
+
// stamp (request dispatch time, before waiting for provider output),
|
|
223
|
+
// pushed into the scope's ring when the step ends. The mean covers the
|
|
224
|
+
// most recent finalized steps observed while the plugin ran — in-memory,
|
|
225
|
+
// so a restart forgets them. An unknown value falls back to `"avg"` and
|
|
226
|
+
// is reported.
|
|
227
|
+
"tps": { "scope": "family", "display": "avg" },
|
|
209
228
|
|
|
210
229
|
// Every named row renders persistently: with no data yet it draws its
|
|
211
230
|
// zero skeleton (a real-looking zero, never a placeholder symbol), in the
|
|
@@ -286,6 +305,27 @@
|
|
|
286
305
|
"toast": false
|
|
287
306
|
},
|
|
288
307
|
|
|
308
|
+
// -- Notifications ---------------------------------------------------------
|
|
309
|
+
// The silencing layer over every toast the plugin can raise: the
|
|
310
|
+
// invalid-config warning, the copy outcome, and the opt-in caution toast
|
|
311
|
+
// above. Every flag is on by default and only ever silences — a verified
|
|
312
|
+
// copy is silent regardless.
|
|
313
|
+
//
|
|
314
|
+
// The one-line silence switch (commented, so copying this file keeps the
|
|
315
|
+
// defaults):
|
|
316
|
+
//
|
|
317
|
+
// "notifications": { "enabled": false }
|
|
318
|
+
"notifications": {
|
|
319
|
+
// false silences every toast with one key.
|
|
320
|
+
"enabled": true,
|
|
321
|
+
// The one-time warning naming an invalid config key.
|
|
322
|
+
"config": true,
|
|
323
|
+
// The copy-outcome toast when a copy could not be verified.
|
|
324
|
+
"copy": true,
|
|
325
|
+
// The opt-in caution toast (still needs `caution.enabled` + `caution.toast`).
|
|
326
|
+
"caution": true
|
|
327
|
+
},
|
|
328
|
+
|
|
289
329
|
// -- Layout ----------------------------------------------------------------
|
|
290
330
|
// Row geometry and wording. Change these when your terminal is unusually
|
|
291
331
|
// narrow or wide, or when you want a row called something else.
|
package/flight-deck.schema.json
CHANGED
|
@@ -148,26 +148,32 @@
|
|
|
148
148
|
"items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go", "ses", "session"] },
|
|
149
149
|
"default": ["status", "agent", "model", "cost", "project", "tokens", "cache", "context", "perms", "elapsed", "tps"],
|
|
150
150
|
"maxItems": 24,
|
|
151
|
-
"description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data; with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row
|
|
151
|
+
"description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data; with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row copies the full id to the OS clipboard: a host write reporting `written` or an exact clipboard read-back after the OSC52 dispatch verifies it, only a verified copy counts as success, a verified copy stays silent, and an unverified or failed outcome surfaces a toast gated by `notifications.copy`. `session` is accepted as an alias for `ses` and is normalized to it."
|
|
152
152
|
},
|
|
153
153
|
"tps": {
|
|
154
154
|
"type": "object",
|
|
155
155
|
"additionalProperties": false,
|
|
156
|
-
"default": { "scope": "family" },
|
|
157
|
-
"description": "
|
|
156
|
+
"default": { "scope": "family", "display": "avg" },
|
|
157
|
+
"description": "The `tps` row: which sessions it paces (`scope`) and which figure it draws (`display`). By default it shows the settled-turn average over the whole family: on hosts that record turn timestamps, generation tokens (output plus reasoning) over assistant turns that recorded `streamed`, divided by the union of their `streamed − created` spans — in-flight turns excluded, idle gaps never billed; on hosts without turn timestamps, generation tokens over the borrowed active clock instead. `display: \"rt\"` draws the realtime figure from the host's streaming events instead — an estimate from delta bytes while a turn streams, reading zero while nothing generates; `\"both\"` draws both figures on one line, plus the mean time to first token over settled steps (`1.2s ttft`) — per step, the earliest delta's event time minus the step's `started` dispatch stamp, pushed into the scope's ring when the step ends and kept in memory for the plugin's lifetime.",
|
|
158
158
|
"properties": {
|
|
159
159
|
"scope": {
|
|
160
160
|
"type": "string",
|
|
161
161
|
"enum": ["family", "session"],
|
|
162
162
|
"default": "family",
|
|
163
|
-
"description": "The `tps` row's scope. `family` sums generation tokens (output plus reasoning) across the open session and its subagent sessions over the union of their streaming spans, so a root that is idle while its child decodes still reads
|
|
163
|
+
"description": "The `tps` row's scope. `family` sums generation tokens (output plus reasoning) across the open session and its subagent sessions over the union of their streaming spans, so a root that is idle while its child decodes still reads realtime. `session` restores the per-session figure: the open session's own tokens over its own spans — under `display: \"rt\"` reading zero while it is idle even when a child is still running. An unknown value falls back to `family` and is reported."
|
|
164
|
+
},
|
|
165
|
+
"display": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"enum": ["avg", "rt", "both"],
|
|
168
|
+
"default": "avg",
|
|
169
|
+
"description": "Which figure the `tps` row draws. `avg` (the default) is the settled-turn average: on hosts that record turn timestamps, generation tokens over assistant turns with `streamed` recorded, divided by the union of their `streamed - created` spans, in the row's scope; on hosts without them, generation tokens over the borrowed active clock. `rt` is the realtime figure from the host's streaming events — an estimate from delta bytes while a turn streams, reading zero while nothing generates. `both` draws `rt` and `avg` on one line (`106 rt · 41 avg`), plus the mean time to first token over settled steps (`83 rt · 38 avg · 1.2s ttft`): per step, the earliest text/reasoning delta's event time minus the step's `started` dispatch stamp (request dispatch time, before waiting for provider output), pushed into the scope's ring when the step ends — the mean covers the most recent finalized steps observed while the plugin ran (in-memory; a restart forgets them). An unknown value falls back to `avg` and is reported."
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
172
|
},
|
|
167
173
|
"persist": {
|
|
168
174
|
"type": "boolean",
|
|
169
175
|
"default": true,
|
|
170
|
-
"description": "Render every field named in `sidebar.rows` as a persistent row, drawing its zero skeleton when the host has no data yet (`$0.000` for money rows, `0 in · 0 out` for tokens, `0 tok/s` for tps
|
|
176
|
+
"description": "Render every field named in `sidebar.rows` as a persistent row, drawing its zero skeleton when the host has no data yet (`$0.000` for money rows, `0 in · 0 out` for tokens, `0 tok/s` for tps — `0 live · 0 avg` when `sidebar.tps.display` is `both` — and so on; `caution` is the one row that never draws a skeleton and stays silent until it has something to announce). True keeps the rail a stable shape that fills in as the session produces data; false restores the old behavior of omitting rows with no data."
|
|
171
177
|
},
|
|
172
178
|
"placeholder": {
|
|
173
179
|
"type": "string",
|
|
@@ -256,6 +262,34 @@
|
|
|
256
262
|
}
|
|
257
263
|
},
|
|
258
264
|
|
|
265
|
+
"notifications": {
|
|
266
|
+
"type": "object",
|
|
267
|
+
"additionalProperties": false,
|
|
268
|
+
"description": "The silencing layer over every toast the plugin can raise: the invalid-config warning, the copy outcome, and the opt-in caution toast. Every flag is on by default and only ever silences — a verified copy is silent regardless and never reaches this gate.",
|
|
269
|
+
"properties": {
|
|
270
|
+
"enabled": {
|
|
271
|
+
"type": "boolean",
|
|
272
|
+
"default": true,
|
|
273
|
+
"description": "Master switch: false silences every toast with one key. True leaves each per-kind flag to decide."
|
|
274
|
+
},
|
|
275
|
+
"config": {
|
|
276
|
+
"type": "boolean",
|
|
277
|
+
"default": true,
|
|
278
|
+
"description": "Show the one-time warning naming an invalid config key. False ignores bad values silently, restoring defaults."
|
|
279
|
+
},
|
|
280
|
+
"copy": {
|
|
281
|
+
"type": "boolean",
|
|
282
|
+
"default": true,
|
|
283
|
+
"description": "Show the copy-outcome toast when a copy could not be verified. False keeps failures silent too; verified copies are always silent."
|
|
284
|
+
},
|
|
285
|
+
"caution": {
|
|
286
|
+
"type": "boolean",
|
|
287
|
+
"default": true,
|
|
288
|
+
"description": "Allow the opt-in caution toast. False suppresses it even when `caution.enabled` and `caution.toast` are both true."
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
|
|
259
293
|
"layout": {
|
|
260
294
|
"type": "object",
|
|
261
295
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-flight-deck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Live OpenCode V2 session telemetry — agent, model, branch, cost, tokens, cache hit rate and context usage in your sidebar.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -51,25 +51,26 @@
|
|
|
51
51
|
"test": "bun test",
|
|
52
52
|
"compile": "bun scripts/build.ts",
|
|
53
53
|
"check": "bun run typecheck && bun test",
|
|
54
|
-
"
|
|
54
|
+
"check:dist": "bun run compile && git diff --exit-code -- dist",
|
|
55
|
+
"prepublishOnly": "bun run check && bun run compile"
|
|
55
56
|
},
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@opencode/plugin": "2.
|
|
61
|
+
"@opencode/plugin": "2.1.1"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@opentui/core": "0.
|
|
64
|
-
"@opentui/solid": "0.
|
|
64
|
+
"@opentui/core": "0.6.6",
|
|
65
|
+
"@opentui/solid": "0.6.6",
|
|
65
66
|
"@types/bun": "^1.4.2",
|
|
66
67
|
"solid-js": "1.9.12",
|
|
67
68
|
"string-width": "7.2.0",
|
|
68
69
|
"typescript": "^5.9.3"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"@opentui/core": ">=0.
|
|
72
|
-
"@opentui/solid": ">=0.
|
|
72
|
+
"@opentui/core": ">=0.6.6",
|
|
73
|
+
"@opentui/solid": ">=0.6.6",
|
|
73
74
|
"solid-js": ">=1.9.0"
|
|
74
75
|
}
|
|
75
76
|
}
|
package/src/tui/clipboard.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
// The one clipboard write in the plugin: a session id, copied on a gesture.
|
|
2
2
|
//
|
|
3
|
-
// Two transports are available, and
|
|
3
|
+
// Two transports are available, and only a verified one may be reported as a
|
|
4
|
+
// success:
|
|
4
5
|
//
|
|
5
6
|
// 1. The process host clipboard (`createHostClipboard`). This is a real write
|
|
6
7
|
// through the OS clipboard, it resolves asynchronously, and it can report
|
|
7
|
-
// `written` - a status that means the platform completed the copy. Only
|
|
8
|
-
//
|
|
8
|
+
// `written` - a status that means the platform completed the copy. Only a
|
|
9
|
+
// verified copy may ever be reported to the user as a success.
|
|
9
10
|
// 2. OSC52 through the host renderer. This is a fire-and-forget escape
|
|
10
11
|
// sequence emitted on the terminal's wire. Its dispatch confirms only that
|
|
11
|
-
// a local call was issued - the terminal is free to ignore it
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
12
|
+
// a local call was issued - the terminal is free to ignore it. It is kept
|
|
13
|
+
// as a best-effort fallback and is verified by READING the OS clipboard
|
|
14
|
+
// back through the same host service: when the bytes read back match the
|
|
15
|
+
// text exactly, the dispatch demonstrably landed, whatever the terminal
|
|
16
|
+
// claims. A dispatch that cannot be confirmed is NEVER reported as a copy.
|
|
17
|
+
//
|
|
18
|
+
// Verification therefore means one thing throughout: the text was confirmed on
|
|
19
|
+
// the OS clipboard, either by the host write reporting `written` or by an
|
|
20
|
+
// exact read-back after an OSC52 dispatch.
|
|
15
21
|
//
|
|
16
22
|
// The renderer is read structurally, never value-imported: the plugin consumes
|
|
17
23
|
// the host's own renderer through the plugin context (`context.renderer`), so
|
|
18
|
-
// no `@opentui/*` copy may ship with or be imported by this module.
|
|
24
|
+
// no `@opentui/*` copy may ship with or be imported by this module. The host
|
|
25
|
+
// clipboard arrives through `./host-clipboard.js`, which is the one seam the
|
|
26
|
+
// render tests replace.
|
|
19
27
|
//
|
|
20
28
|
// The gesture is still the one and only trigger: there is no render-time,
|
|
21
29
|
// background, or automatic write, ever. And nothing here may throw out of the
|
|
@@ -42,16 +50,19 @@ interface RendererOsc52Boundary {
|
|
|
42
50
|
/**
|
|
43
51
|
* The outcome of a copy gesture.
|
|
44
52
|
*
|
|
45
|
-
* `verified` is true only when the
|
|
46
|
-
*
|
|
47
|
-
*
|
|
53
|
+
* `verified` is true only when the text was confirmed on the OS clipboard: by
|
|
54
|
+
* the host backend reporting `written`, or by an exact read-back after an
|
|
55
|
+
* OSC52 dispatch (`osc52-confirmed`). Every other value - including an OSC52
|
|
56
|
+
* dispatch that was merely issued - is false, so the caller can never
|
|
57
|
+
* accidentally treat a best-effort attempt as a real copy.
|
|
48
58
|
*/
|
|
49
59
|
export interface CopyResult {
|
|
50
|
-
/** True only for a verified
|
|
60
|
+
/** True only for a verified copy. */
|
|
51
61
|
readonly verified: boolean;
|
|
52
62
|
/** How the copy was carried, or why it was not. */
|
|
53
63
|
readonly outcome:
|
|
54
64
|
| "written"
|
|
65
|
+
| "osc52-confirmed"
|
|
55
66
|
| "unsupported"
|
|
56
67
|
| "cancelled"
|
|
57
68
|
| "timed-out"
|
|
@@ -63,6 +74,10 @@ export interface CopyResult {
|
|
|
63
74
|
/** The subset of the host clipboard service this path uses. */
|
|
64
75
|
interface HostClipboardLike {
|
|
65
76
|
writeText(text: string): Promise<{ readonly status: string }>;
|
|
77
|
+
read?(options: {
|
|
78
|
+
readonly preferredTypes: readonly [string, ...string[]];
|
|
79
|
+
readonly selection?: "clipboard" | "primary";
|
|
80
|
+
}): Promise<{ readonly status: string; readonly representation?: { readonly bytes: Uint8Array } }>;
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
/** A factory for the host clipboard; injectable so tests can stand in a fake. */
|
|
@@ -89,15 +104,67 @@ function dispatchOsc52(renderer: unknown, text: string): boolean {
|
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
|
|
107
|
+
/** Read-back attempts for one OSC52 dispatch: enough for the terminal to land it. */
|
|
108
|
+
const READ_BACK_ATTEMPTS = 5;
|
|
109
|
+
/** Milliseconds between read-back attempts. */
|
|
110
|
+
const READ_BACK_INTERVAL_MS = 60;
|
|
111
|
+
|
|
112
|
+
function delay(ms: number): Promise<void> {
|
|
113
|
+
return new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Confirm `text` is on the OS clipboard by reading it back through the same
|
|
118
|
+
* host service that carried (or could have carried) the write. This verifies
|
|
119
|
+
* either transport, because it reads the real clipboard rather than either
|
|
120
|
+
* transport's promise: whatever put the bytes there, an exact match proves the
|
|
121
|
+
* copy landed.
|
|
122
|
+
*
|
|
123
|
+
* Polls up to `READ_BACK_ATTEMPTS` times, `READ_BACK_INTERVAL_MS` apart. Never
|
|
124
|
+
* throws and never reports: `false` means "unconfirmed", and the caller keeps
|
|
125
|
+
* the advisory `osc52-dispatched` wording. Skipped (returning `false`) when
|
|
126
|
+
* there is no host service or it offers no read.
|
|
127
|
+
*/
|
|
128
|
+
async function readBackMatches(host: HostClipboardLike | undefined, text: string): Promise<boolean> {
|
|
129
|
+
const read = host?.read;
|
|
130
|
+
if (host === undefined || read === undefined) return false;
|
|
131
|
+
for (let attempt = 0; attempt < READ_BACK_ATTEMPTS; attempt += 1) {
|
|
132
|
+
if (attempt > 0) await delay(READ_BACK_INTERVAL_MS);
|
|
133
|
+
let current: { readonly status: string; readonly representation?: { readonly bytes: Uint8Array } };
|
|
134
|
+
try {
|
|
135
|
+
// `.call` keeps `host` as the receiver for the real service.
|
|
136
|
+
current = await read.call(host, { preferredTypes: ["text/plain"], selection: "clipboard" });
|
|
137
|
+
} catch {
|
|
138
|
+
// The read itself failed: the clipboard cannot confirm anything.
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (current.status !== "read") continue;
|
|
142
|
+
const bytes = current.representation?.bytes;
|
|
143
|
+
if (bytes === undefined) continue;
|
|
144
|
+
let decoded: string;
|
|
145
|
+
try {
|
|
146
|
+
decoded = new TextDecoder().decode(bytes);
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (decoded === text) return true;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
92
155
|
/**
|
|
93
156
|
* Write `text` to the clipboard, preferring the verified host backend.
|
|
94
157
|
*
|
|
95
158
|
* Resolution:
|
|
96
159
|
* 1. Try the host clipboard write and await it. `written` -> `verified: true`.
|
|
97
|
-
* 2.
|
|
98
|
-
* the
|
|
99
|
-
*
|
|
100
|
-
*
|
|
160
|
+
* 2. Otherwise issue the OSC52 fallback and verify it by reading the OS
|
|
161
|
+
* clipboard back through the same host service (up to 5 attempts, 60ms
|
|
162
|
+
* apart). An exact match -> `verified: true` as `osc52-confirmed`; a
|
|
163
|
+
* dispatch that cannot be confirmed -> `verified: false` as
|
|
164
|
+
* `osc52-dispatched`, exactly as before. The read-back is skipped when no
|
|
165
|
+
* host service exists or it offers no read.
|
|
166
|
+
* 3. If neither transport can take the write, report `no-backend` when the
|
|
167
|
+
* host was unreachable, else the host's own reason.
|
|
101
168
|
*
|
|
102
169
|
* Never throws: a backend that rejects, is missing, or throws a synchronous
|
|
103
170
|
* error collapses into a definite non-success result.
|
|
@@ -113,8 +180,6 @@ export async function copyToClipboard(
|
|
|
113
180
|
createHost: HostClipboardFactory = createHostClipboard,
|
|
114
181
|
): Promise<CopyResult> {
|
|
115
182
|
// 1. The verified path: a real host write that can report back `written`.
|
|
116
|
-
// The production backend is explicitly absent (`undefined`), so this step
|
|
117
|
-
// is skipped outside tests that inject a fake.
|
|
118
183
|
let hostReached = true;
|
|
119
184
|
let hostStatus: string = "failed";
|
|
120
185
|
let host: HostClipboardLike | undefined;
|
|
@@ -138,8 +203,12 @@ export async function copyToClipboard(
|
|
|
138
203
|
}
|
|
139
204
|
if (hostStatus === "written") return { verified: true, outcome: "written" };
|
|
140
205
|
|
|
141
|
-
// 2. Best-effort fallback: dispatch OSC52
|
|
142
|
-
|
|
206
|
+
// 2. Best-effort fallback: dispatch OSC52, then confirm it landed by reading
|
|
207
|
+
// the real clipboard back. Only an exact match is a verified copy.
|
|
208
|
+
if (dispatchOsc52(renderer, text)) {
|
|
209
|
+
if (await readBackMatches(host, text)) return { verified: true, outcome: "osc52-confirmed" };
|
|
210
|
+
return { verified: false, outcome: "osc52-dispatched" };
|
|
211
|
+
}
|
|
143
212
|
|
|
144
213
|
// 3. No transport took the write. Report it plainly by the host's own reason
|
|
145
214
|
// when the host was reachable, otherwise that there was no backend at all.
|
|
@@ -158,18 +227,20 @@ export async function copyToClipboard(
|
|
|
158
227
|
* The confirmation for a copy gesture, as a host-toast description.
|
|
159
228
|
*
|
|
160
229
|
* Split from {@link copyToClipboard} so the wordings are pure and tested
|
|
161
|
-
* directly. Success is claimed ONLY for a verified
|
|
162
|
-
* does the message name the full `id`.
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
230
|
+
* directly. Success is claimed ONLY for a verified copy (`written` or
|
|
231
|
+
* `osc52-confirmed`), and only then does the message name the full `id`. An
|
|
232
|
+
* unconfirmed OSC52 dispatch is advisory (`warning`): the bytes were sent but
|
|
233
|
+
* no backend could confirm the copy landed, so paste to verify. Every other
|
|
234
|
+
* outcome is a genuine failure (`error`). No non-success claims the id is on
|
|
235
|
+
* the clipboard: it is better to say the copy could not be confirmed than to
|
|
236
|
+
* imply one that was never verified.
|
|
166
237
|
*/
|
|
167
238
|
export function copyFeedback(
|
|
168
239
|
result: CopyResult,
|
|
169
240
|
id: string,
|
|
170
241
|
): {
|
|
171
242
|
readonly ok: boolean;
|
|
172
|
-
readonly variant: "success" | "error";
|
|
243
|
+
readonly variant: "success" | "warning" | "error";
|
|
173
244
|
readonly message: string;
|
|
174
245
|
} {
|
|
175
246
|
if (result.verified) {
|
|
@@ -179,8 +250,8 @@ export function copyFeedback(
|
|
|
179
250
|
case "osc52-dispatched":
|
|
180
251
|
return {
|
|
181
252
|
ok: false,
|
|
182
|
-
variant: "
|
|
183
|
-
message: "Sent the session id to the terminal
|
|
253
|
+
variant: "warning",
|
|
254
|
+
message: "Sent the session id to the terminal; the terminal does not confirm copies, so paste to verify.",
|
|
184
255
|
};
|
|
185
256
|
case "unsupported":
|
|
186
257
|
return { ok: false, variant: "error", message: "This terminal cannot copy to the clipboard." };
|
package/src/tui/config.ts
CHANGED
|
@@ -33,7 +33,7 @@ interface SidebarConfig {
|
|
|
33
33
|
readonly footer: SidebarFooterConfig;
|
|
34
34
|
/** Live session fields to render, top to bottom. Default `DEFAULT_SIDEBAR_ROWS`. */
|
|
35
35
|
readonly rows: readonly string[];
|
|
36
|
-
/** Which sessions the `tps` row paces. Default `{ scope: DEFAULT_TPS_SCOPE }`. */
|
|
36
|
+
/** Which sessions the `tps` row paces, and which figure it draws. Default `{ scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY }`. */
|
|
37
37
|
readonly tps: TpsConfig;
|
|
38
38
|
/**
|
|
39
39
|
* Render every named row even when the host has no data for it, using
|
|
@@ -130,20 +130,45 @@ export const DEFAULT_GO_PANEL_LOOK: GoPanelLook = {
|
|
|
130
130
|
*/
|
|
131
131
|
export type TpsScope = "family" | "session";
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Which figure the `tps` row draws.
|
|
135
|
+
*
|
|
136
|
+
* `"avg"` is the settled-turn average: generation tokens over assistant
|
|
137
|
+
* turns that recorded `streamed`, divided by the union of their
|
|
138
|
+
* `streamed - created` spans. `"rt"` is the realtime estimate from the
|
|
139
|
+
* host's streaming delta events, reading zero while nothing streams.
|
|
140
|
+
* `"both"` draws both on one line.
|
|
141
|
+
*/
|
|
142
|
+
export type TpsDisplay = "avg" | "rt" | "both";
|
|
143
|
+
|
|
133
144
|
/**
|
|
134
145
|
* The shipped `tps` scope: `"family"`.
|
|
135
146
|
*
|
|
136
147
|
* The one default for this knob, so flipping the shipped behaviour is one
|
|
137
148
|
* line here. Family ships because the visible work in a delegation-heavy
|
|
138
149
|
* session happens in its subagents: a root that has gone idle while its child
|
|
139
|
-
* is still decoding must still read
|
|
140
|
-
* tree up. Set it to `"session"` for the previous per-session figure.
|
|
150
|
+
* is still decoding must still read realtime, the way `cost` already rolls
|
|
151
|
+
* the tree up. Set it to `"session"` for the previous per-session figure.
|
|
141
152
|
*/
|
|
142
153
|
export const DEFAULT_TPS_SCOPE: TpsScope = "family";
|
|
143
154
|
|
|
155
|
+
/**
|
|
156
|
+
* The shipped `tps` figure: `"avg"`.
|
|
157
|
+
*
|
|
158
|
+
* The one default for this knob, so flipping the shipped behaviour is one
|
|
159
|
+
* line here. The average ships because it answers the question the row is
|
|
160
|
+
* really asked — how fast is this session producing — instead of what the
|
|
161
|
+
* decoder is doing in this exact poll: an idle gap between turns reads as a
|
|
162
|
+
* steady figure rather than as zero, while `rt` stays one edit away for
|
|
163
|
+
* the moment-to-moment view.
|
|
164
|
+
*/
|
|
165
|
+
export const DEFAULT_TPS_DISPLAY: TpsDisplay = "avg";
|
|
166
|
+
|
|
144
167
|
interface TpsConfig {
|
|
145
168
|
/** Which sessions the `tps` row paces. Default `DEFAULT_TPS_SCOPE`. */
|
|
146
169
|
readonly scope: TpsScope;
|
|
170
|
+
/** Which figure the `tps` row draws. Default `DEFAULT_TPS_DISPLAY`. */
|
|
171
|
+
readonly display: TpsDisplay;
|
|
147
172
|
}
|
|
148
173
|
|
|
149
174
|
interface SidebarFooterConfig {
|
|
@@ -228,6 +253,12 @@ export interface FlightDeckConfig {
|
|
|
228
253
|
* it is opt-in, so an install that never asks for it spends no timer on it.
|
|
229
254
|
*/
|
|
230
255
|
readonly caution: CautionConfig;
|
|
256
|
+
/**
|
|
257
|
+
* The silencing layer over every toast the plugin can raise: the
|
|
258
|
+
* invalid-config warning, the copy outcome, and the opt-in caution toast.
|
|
259
|
+
* All on by default; `enabled: false` silences everything with one key.
|
|
260
|
+
*/
|
|
261
|
+
readonly notifications: NotificationsConfig;
|
|
231
262
|
/** Geometry and wording of a row. Every value has a sane default. */
|
|
232
263
|
readonly layout: LayoutConfig;
|
|
233
264
|
/** How values are written on the rail, e.g. the `elapsed` duration style. */
|
|
@@ -328,6 +359,34 @@ const DEFAULT_GLYPHS: GlyphConfig = {
|
|
|
328
359
|
clear: "○",
|
|
329
360
|
};
|
|
330
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Which toasts the plugin may raise.
|
|
364
|
+
*
|
|
365
|
+
* The silencing layer, not a feature switch: every kind is on by default, and
|
|
366
|
+
* each flag only ever silences. `enabled` is the one-line master switch;
|
|
367
|
+
* `config`, `copy`, and `caution` silence the invalid-config warning, the copy
|
|
368
|
+
* outcome, and the opt-in caution toast respectively. A verified copy is
|
|
369
|
+
* silent regardless and never reaches this gate.
|
|
370
|
+
*/
|
|
371
|
+
export interface NotificationsConfig {
|
|
372
|
+
/** Master switch: `false` silences every toast. Default `true`. */
|
|
373
|
+
readonly enabled: boolean;
|
|
374
|
+
/** The invalid-config warning toast. Default `true`. */
|
|
375
|
+
readonly config: boolean;
|
|
376
|
+
/** The copy-outcome toast (failures only; verified copies are silent). Default `true`. */
|
|
377
|
+
readonly copy: boolean;
|
|
378
|
+
/** The opt-in caution toast (still also requires `caution.enabled` and `caution.toast`). Default `true`. */
|
|
379
|
+
readonly caution: boolean;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** All toasts on: silencing is always an explicit edit. */
|
|
383
|
+
export const DEFAULT_NOTIFICATIONS: NotificationsConfig = {
|
|
384
|
+
enabled: true,
|
|
385
|
+
config: true,
|
|
386
|
+
copy: true,
|
|
387
|
+
caution: true,
|
|
388
|
+
};
|
|
389
|
+
|
|
331
390
|
const DEFAULT_CAUTION: CautionConfig = {
|
|
332
391
|
enabled: false,
|
|
333
392
|
toolWatchSeconds: 180,
|
|
@@ -426,13 +485,14 @@ export const DEFAULT_CONFIG: FlightDeckConfig = {
|
|
|
426
485
|
lines: DEFAULT_SIDEBAR_LINES,
|
|
427
486
|
footer: { lines: DEFAULT_SIDEBAR_FOOTER_LINES, go: false },
|
|
428
487
|
rows: DEFAULT_SIDEBAR_ROWS,
|
|
429
|
-
tps: { scope: DEFAULT_TPS_SCOPE },
|
|
488
|
+
tps: { scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY },
|
|
430
489
|
persist: true,
|
|
431
490
|
placeholder: DEFAULT_PLACEHOLDER,
|
|
432
491
|
maxLines: MAX_LINES,
|
|
433
492
|
},
|
|
434
493
|
footer: { enabled: false, text: DEFAULT_FOOTER_TEXT },
|
|
435
494
|
caution: DEFAULT_CAUTION,
|
|
495
|
+
notifications: DEFAULT_NOTIFICATIONS,
|
|
436
496
|
layout: DEFAULT_LAYOUT,
|
|
437
497
|
format: DEFAULT_FORMAT,
|
|
438
498
|
glyphs: DEFAULT_GLYPHS,
|
|
@@ -719,6 +779,20 @@ function readTpsScope(value: unknown, issues: string[]): TpsScope {
|
|
|
719
779
|
return DEFAULT_TPS_SCOPE;
|
|
720
780
|
}
|
|
721
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Which figure the `tps` row draws, as one of a fixed trio of strings.
|
|
784
|
+
*
|
|
785
|
+
* Like the scope, there is no sensible repair for a misspelled display: the
|
|
786
|
+
* default comes back and the key is named, like every other invalid option.
|
|
787
|
+
* An absent key falls back silently.
|
|
788
|
+
*/
|
|
789
|
+
function readTpsDisplay(value: unknown, issues: string[]): TpsDisplay {
|
|
790
|
+
if (value === undefined) return DEFAULT_TPS_DISPLAY;
|
|
791
|
+
if (value === "avg" || value === "rt" || value === "both") return value;
|
|
792
|
+
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "avg"`);
|
|
793
|
+
return DEFAULT_TPS_DISPLAY;
|
|
794
|
+
}
|
|
795
|
+
|
|
722
796
|
/**
|
|
723
797
|
* Which sessions the `tps` row paces.
|
|
724
798
|
*
|
|
@@ -730,10 +804,10 @@ function readTps(section: Record<string, unknown>, issues: string[]): TpsConfig
|
|
|
730
804
|
const raw = section["tps"];
|
|
731
805
|
if (raw !== undefined && !isRecord(raw)) {
|
|
732
806
|
issues.push("sidebar.tps must be an object; using defaults");
|
|
733
|
-
return { scope: DEFAULT_TPS_SCOPE };
|
|
807
|
+
return { scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY };
|
|
734
808
|
}
|
|
735
809
|
const tps = isRecord(raw) ? raw : {};
|
|
736
|
-
return { scope: readTpsScope(tps["scope"], issues) };
|
|
810
|
+
return { scope: readTpsScope(tps["scope"], issues), display: readTpsDisplay(tps["display"], issues) };
|
|
737
811
|
}
|
|
738
812
|
|
|
739
813
|
/**
|
|
@@ -747,7 +821,7 @@ function readMaxLines(value: unknown, issues: string[]): number {
|
|
|
747
821
|
}
|
|
748
822
|
|
|
749
823
|
/** Every config section that can be set from the file and overridden by the host. */
|
|
750
|
-
type SectionKey = "sidebar" | "footer" | "caution" | "layout" | "format" | "glyphs" | "style";
|
|
824
|
+
type SectionKey = "sidebar" | "footer" | "caution" | "notifications" | "layout" | "format" | "glyphs" | "style";
|
|
751
825
|
|
|
752
826
|
function sectionOf(options: Record<string, unknown>, key: SectionKey): Record<string, unknown> {
|
|
753
827
|
const value = options[key];
|
|
@@ -827,6 +901,7 @@ export function mergeOptions(fileOptions: unknown, hostOptions: unknown): Record
|
|
|
827
901
|
sidebar: mergeSection(file, host, "sidebar"),
|
|
828
902
|
footer: mergeSection(file, host, "footer"),
|
|
829
903
|
caution: mergeSection(file, host, "caution"),
|
|
904
|
+
notifications: mergeSection(file, host, "notifications"),
|
|
830
905
|
layout: mergeSection(file, host, "layout"),
|
|
831
906
|
format: mergeSection(file, host, "format"),
|
|
832
907
|
glyphs: mergeSection(file, host, "glyphs"),
|
|
@@ -1085,6 +1160,22 @@ function readToolNames(value: unknown, issues: string[]): readonly string[] {
|
|
|
1085
1160
|
return names;
|
|
1086
1161
|
}
|
|
1087
1162
|
|
|
1163
|
+
/**
|
|
1164
|
+
* The notification silencing layer.
|
|
1165
|
+
*
|
|
1166
|
+
* Every flag falls back independently through the existing `readBoolean`
|
|
1167
|
+
* idiom: absent means on, malformed is reported and means on. Silencing is
|
|
1168
|
+
* always an explicit `false`, never a typo.
|
|
1169
|
+
*/
|
|
1170
|
+
function readNotifications(section: Record<string, unknown>, issues: string[]): NotificationsConfig {
|
|
1171
|
+
return {
|
|
1172
|
+
enabled: readBoolean(section["enabled"], DEFAULT_NOTIFICATIONS.enabled, "notifications.enabled", issues),
|
|
1173
|
+
config: readBoolean(section["config"], DEFAULT_NOTIFICATIONS.config, "notifications.config", issues),
|
|
1174
|
+
copy: readBoolean(section["copy"], DEFAULT_NOTIFICATIONS.copy, "notifications.copy", issues),
|
|
1175
|
+
caution: readBoolean(section["caution"], DEFAULT_NOTIFICATIONS.caution, "notifications.caution", issues),
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1088
1179
|
function readCaution(section: Record<string, unknown>, issues: string[]): CautionConfig {
|
|
1089
1180
|
const toolWatchSeconds = readNumber(
|
|
1090
1181
|
section["toolWatchSeconds"],
|
|
@@ -1166,6 +1257,7 @@ export function resolveConfig(options: unknown): ConfigResolution {
|
|
|
1166
1257
|
const rawSidebar = options.sidebar;
|
|
1167
1258
|
const rawFooter = options.footer;
|
|
1168
1259
|
const rawCaution = options.caution;
|
|
1260
|
+
const rawNotifications = options.notifications;
|
|
1169
1261
|
const rawFormat = options.format;
|
|
1170
1262
|
const rawStyle = options.style;
|
|
1171
1263
|
if (rawSidebar !== undefined && !isRecord(rawSidebar)) {
|
|
@@ -1177,6 +1269,9 @@ export function resolveConfig(options: unknown): ConfigResolution {
|
|
|
1177
1269
|
if (rawCaution !== undefined && !isRecord(rawCaution)) {
|
|
1178
1270
|
issues.push("caution must be an object; using defaults");
|
|
1179
1271
|
}
|
|
1272
|
+
if (rawNotifications !== undefined && !isRecord(rawNotifications)) {
|
|
1273
|
+
issues.push("notifications must be an object; using defaults");
|
|
1274
|
+
}
|
|
1180
1275
|
if (rawFormat !== undefined && !isRecord(rawFormat)) {
|
|
1181
1276
|
issues.push("format must be an object; using defaults");
|
|
1182
1277
|
}
|
|
@@ -1187,6 +1282,7 @@ export function resolveConfig(options: unknown): ConfigResolution {
|
|
|
1187
1282
|
const sidebar = isRecord(rawSidebar) ? rawSidebar : {};
|
|
1188
1283
|
const footer = isRecord(rawFooter) ? rawFooter : {};
|
|
1189
1284
|
const caution = isRecord(rawCaution) ? rawCaution : {};
|
|
1285
|
+
const notifications = isRecord(rawNotifications) ? rawNotifications : {};
|
|
1190
1286
|
const layout = isRecord(options.layout) ? options.layout : {};
|
|
1191
1287
|
const format = isRecord(rawFormat) ? rawFormat : {};
|
|
1192
1288
|
const glyphs = isRecord(options.glyphs) ? options.glyphs : {};
|
|
@@ -1248,6 +1344,7 @@ export function resolveConfig(options: unknown): ConfigResolution {
|
|
|
1248
1344
|
text: readText(footer.text, DEFAULT_CONFIG.footer.text, "footer.text", issues),
|
|
1249
1345
|
},
|
|
1250
1346
|
caution: readCaution(caution, issues),
|
|
1347
|
+
notifications: readNotifications(notifications, issues),
|
|
1251
1348
|
layout: readLayout(layout, issues),
|
|
1252
1349
|
format: readFormat(format, issues),
|
|
1253
1350
|
glyphs: readGlyphs(glyphs, issues),
|