oc-flight-deck 0.10.0 → 0.10.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 +15 -1
- package/README.md +1 -1
- package/flight-deck.example.jsonc +4 -4
- package/flight-deck.schema.json +1 -1
- package/package.json +1 -1
- package/src/tui/clipboard.ts +148 -17
- package/src/tui/host-clipboard.ts +9 -0
- package/src/tui/index.tsx +44 -5
- package/src/tui/rows.ts +3 -4
- package/src/tui/stat-fields.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,24 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.10.2] - 2026-10-02
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- The `ses` row's click-to-copy now actually copies. It previously treated the renderer's OSC52 `attempted` status as success and reported "Sent the full session id ... to the clipboard" - but `attempted` only proves a local dispatch was issued, and the terminal may never act on it (verified: the bytes are emitted and the clipboard is left unchanged). The copy now prefers the host clipboard backend and reports success only when that write is confirmed (`written`); the OSC52 path is a best-effort dispatch that is never reported as a copy. Every non-confirmed outcome states plainly that the id was not copied.
|
|
13
|
+
|
|
14
|
+
## [0.10.1] - 2026-10-02
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- The opt-in `ses` row is now usable as an identifier. It draws the full session id (the rail wraps it) instead of only its first 8 characters, and a click reports the outcome instead of copying silently: a confirmation naming the id when the copy was sent, and a distinct failure message when the terminal cannot take it.
|
|
19
|
+
|
|
8
20
|
## [0.10.0] - 2026-10-02
|
|
9
21
|
|
|
10
22
|
### Added
|
|
11
23
|
|
|
12
|
-
- Opt-in `ses` sidebar row: shows the session id
|
|
24
|
+
- Opt-in `ses` sidebar row: shows the full session id (the rail wraps it), and a mouse click copies that same full id and reports the outcome - a confirmation naming the id when the copy was sent, a distinct failure message when the terminal cannot take it. Off by default, and degrades gracefully when the terminal cannot copy.
|
|
13
25
|
|
|
26
|
+
[0.10.2]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.1...v0.10.2
|
|
27
|
+
[0.10.1]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.0...v0.10.1
|
|
14
28
|
[0.10.0]: https://github.com/nathwn12/oc-flight-deck/compare/v0.9.0...v0.10.0
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ The panel's only fixed text — `▸ FLIGHT DECK` over a separator — is **opt-
|
|
|
64
64
|
| `turns` | How many prompts you've sent this session · **off by default** |
|
|
65
65
|
| `guard` | Harness status from oc-harness-guard · **off by default** |
|
|
66
66
|
| `go` | Zen Go account usage — a dial and a whole-number percent for the **5h**, **1w**, and **1m** windows, in that fixed order; a window at 90% or more turns its dial and number red, and the reset hint appears only then · **off by default** |
|
|
67
|
-
| `ses` | The open session id,
|
|
67
|
+
| `ses` | The open session id, which the rail wraps; **click the row** to copy the full id to the terminal clipboard · **off by default** (requires the host's mouse) |
|
|
68
68
|
|
|
69
69
|
`project` matches on the host's **project id**, not on a directory, so a worktree counts as part of the same project. A host that reports no project id leaves nothing to match on, and the row then totals every session that host knows about.
|
|
70
70
|
|
|
@@ -120,9 +120,9 @@
|
|
|
120
120
|
// go Zen Go account usage for the 5h / 1w / 1m windows: a dial and
|
|
121
121
|
// a percent each, turning red as a window approaches its limit.
|
|
122
122
|
// Reads OPENCODE_GO_API_KEY. Available, off by default.
|
|
123
|
-
// ses the
|
|
124
|
-
//
|
|
125
|
-
//
|
|
123
|
+
// ses the full session id (the rail wraps it). A mouse click on the
|
|
124
|
+
// row copies the full id to the terminal clipboard. Off by
|
|
125
|
+
// default; needs the host's mouse enabled.
|
|
126
126
|
//
|
|
127
127
|
// Every named row renders persistently, so the rail keeps a stable shape:
|
|
128
128
|
// a row with no data yet shows the placeholder below, in the same label
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
// ,"go" — Zen Go account usage (needs OPENCODE_GO_API_KEY)
|
|
144
144
|
// ,"caution" — the annunciator
|
|
145
145
|
// ,"branch" — current git branch
|
|
146
|
-
// ,"ses"
|
|
146
|
+
// ,"ses" - current session id (full, wrapped); click to copy the full id
|
|
147
147
|
],
|
|
148
148
|
|
|
149
149
|
// Every named row renders persistently: with no data yet it shows the
|
package/flight-deck.schema.json
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go", "ses"] },
|
|
56
56
|
"default": ["status", "agent", "model", "cost", "project", "tokens", "cache", "context", "perms", "elapsed", "tps"],
|
|
57
57
|
"maxItems": 24,
|
|
58
|
-
"description": "Which live fields to draw, top to bottom. Any subset, any order
|
|
58
|
+
"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, using `sidebar.placeholder` 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 the full session id (the rail wraps it); a mouse click on that row copies the full id to the terminal clipboard."
|
|
59
59
|
},
|
|
60
60
|
"persist": {
|
|
61
61
|
"type": "boolean",
|
package/package.json
CHANGED
package/src/tui/clipboard.ts
CHANGED
|
@@ -1,32 +1,63 @@
|
|
|
1
1
|
// The one clipboard write in the plugin: a session id, copied on a gesture.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// renderer OpenTUI already hands the plugin and writes OSC52 directly. That is
|
|
5
|
-
// not a sanctioned plugin API, so it is kept to a single narrow function and
|
|
6
|
-
// two rules hold it in place:
|
|
3
|
+
// Two transports are available, and they are not equals:
|
|
7
4
|
//
|
|
8
|
-
// 1.
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
5
|
+
// 1. The process host clipboard (`createHostClipboard`). This is a real write
|
|
6
|
+
// through the OS clipboard, it resolves asynchronously, and it can report
|
|
7
|
+
// `written` - a status that means the platform completed the copy. Only
|
|
8
|
+
// this transport may ever be reported to the user as a success.
|
|
9
|
+
// 2. OSC52 through the renderer (`createRendererClipboardAdapter`). This is a
|
|
10
|
+
// fire-and-forget escape sequence emitted on the terminal's wire. Its
|
|
11
|
+
// `attempted` status confirms only that a local dispatch was issued - the
|
|
12
|
+
// terminal is free to ignore it, and on this machine's Windows Terminal it
|
|
13
|
+
// does, so an independent read still sees the old clipboard. It is kept as
|
|
14
|
+
// a best-effort fallback and is NEVER reported as a verified copy.
|
|
12
15
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
16
|
+
// The gesture is still the one and only trigger: there is no render-time,
|
|
17
|
+
// background, or automatic write, ever. And nothing here may throw out of the
|
|
18
|
+
// caller's mouse handler: every backend call is wrapped, and a backend that is
|
|
19
|
+
// missing, refuses, or throws degrades to a definite non-success result.
|
|
17
20
|
|
|
18
21
|
import { createRendererClipboardAdapter } from "@opentui/core";
|
|
22
|
+
import { createHostClipboard } from "./host-clipboard.js";
|
|
19
23
|
|
|
20
24
|
type RendererBoundary = Parameters<typeof createRendererClipboardAdapter>[0];
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
27
|
+
* The outcome of a copy gesture.
|
|
24
28
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
29
|
+
* `verified` is true only when the host backend reported `written`. Every other
|
|
30
|
+
* value - including an OSC52 dispatch that was merely issued - is false, so the
|
|
31
|
+
* caller can never accidentally treat a best-effort attempt as a real copy.
|
|
28
32
|
*/
|
|
29
|
-
export
|
|
33
|
+
export interface CopyResult {
|
|
34
|
+
/** True only for a verified host write. */
|
|
35
|
+
readonly verified: boolean;
|
|
36
|
+
/** How the copy was carried, or why it was not. */
|
|
37
|
+
readonly outcome:
|
|
38
|
+
| "written"
|
|
39
|
+
| "unsupported"
|
|
40
|
+
| "cancelled"
|
|
41
|
+
| "timed-out"
|
|
42
|
+
| "failed"
|
|
43
|
+
| "osc52-dispatched"
|
|
44
|
+
| "no-backend";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The subset of the host clipboard service this path uses. */
|
|
48
|
+
interface HostClipboardLike {
|
|
49
|
+
writeText(text: string): Promise<{ readonly status: string }>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A factory for the host clipboard; injectable so tests can stand in a fake. */
|
|
53
|
+
type HostClipboardFactory = () => HostClipboardLike;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Determine the OSC52 dispatch outcome for `text`, or `false` when the
|
|
57
|
+
* renderer cannot take it. Kept separate so the renderer type can stay
|
|
58
|
+
* `unknown` at the public boundary.
|
|
59
|
+
*/
|
|
60
|
+
function dispatchOsc52(renderer: unknown, text: string): boolean {
|
|
30
61
|
if (renderer === undefined || renderer === null) return false;
|
|
31
62
|
try {
|
|
32
63
|
const terminal = createRendererClipboardAdapter(renderer as RendererBoundary);
|
|
@@ -35,3 +66,103 @@ export function copyToClipboard(renderer: unknown, text: string): boolean {
|
|
|
35
66
|
return false;
|
|
36
67
|
}
|
|
37
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Write `text` to the clipboard, preferring the verified host backend.
|
|
72
|
+
*
|
|
73
|
+
* Resolution:
|
|
74
|
+
* 1. Try the host clipboard write and await it. `written` -> `verified: true`.
|
|
75
|
+
* 2. If the host is unavailable or reports anything other than `written`, issue
|
|
76
|
+
* the OSC52 fallback and report `osc52-dispatched`. That is a best-effort
|
|
77
|
+
* dispatch, NOT a verified copy, so `verified` stays false.
|
|
78
|
+
* 3. If neither transport can take the write, report `no-backend`.
|
|
79
|
+
*
|
|
80
|
+
* Never throws: a backend that rejects, is missing, or throws a synchronous
|
|
81
|
+
* error collapses into a definite non-success result.
|
|
82
|
+
*
|
|
83
|
+
* @param renderer The host renderer, or `undefined` when the host gave none.
|
|
84
|
+
* @param text The text to copy. Empty text is rejected by the host backend and
|
|
85
|
+
* degrades to the fallback rather than throwing.
|
|
86
|
+
* @param createHost Optional factory for the host clipboard, for tests.
|
|
87
|
+
*/
|
|
88
|
+
export async function copyToClipboard(
|
|
89
|
+
renderer: unknown,
|
|
90
|
+
text: string,
|
|
91
|
+
createHost: HostClipboardFactory = createHostClipboard,
|
|
92
|
+
): Promise<CopyResult> {
|
|
93
|
+
// 1. The verified path: a real host write that can report back `written`.
|
|
94
|
+
let hostReached = true;
|
|
95
|
+
let hostStatus: string = "failed";
|
|
96
|
+
try {
|
|
97
|
+
const host = createHost();
|
|
98
|
+
try {
|
|
99
|
+
const result = await host.writeText(text);
|
|
100
|
+
hostStatus = result.status;
|
|
101
|
+
} catch {
|
|
102
|
+
// The service exists but the write itself failed or rejected: a definite
|
|
103
|
+
// host failure, never an exception out of this call.
|
|
104
|
+
hostStatus = "failed";
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// The factory itself threw: there is no host service at all.
|
|
108
|
+
hostReached = false;
|
|
109
|
+
}
|
|
110
|
+
if (hostStatus === "written") return { verified: true, outcome: "written" };
|
|
111
|
+
|
|
112
|
+
// 2. Best-effort fallback: dispatch OSC52 and never call it a verified copy.
|
|
113
|
+
if (dispatchOsc52(renderer, text)) return { verified: false, outcome: "osc52-dispatched" };
|
|
114
|
+
|
|
115
|
+
// 3. No transport took the write. Report it plainly by the host's own reason
|
|
116
|
+
// when the host was reachable, otherwise that there was no backend at all.
|
|
117
|
+
if (!hostReached) return { verified: false, outcome: "no-backend" };
|
|
118
|
+
const outcome =
|
|
119
|
+
hostStatus === "unsupported" ||
|
|
120
|
+
hostStatus === "cancelled" ||
|
|
121
|
+
hostStatus === "timed-out" ||
|
|
122
|
+
hostStatus === "failed"
|
|
123
|
+
? hostStatus
|
|
124
|
+
: "failed";
|
|
125
|
+
return { verified: false, outcome };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The confirmation for a copy gesture, as a host-toast description.
|
|
130
|
+
*
|
|
131
|
+
* Split from {@link copyToClipboard} so the wordings are pure and tested
|
|
132
|
+
* directly. Success is claimed ONLY for a verified host write, and only then
|
|
133
|
+
* does the message name the full `id`. Every other outcome - an OSC52 dispatch
|
|
134
|
+
* included - is a distinct non-success that does not claim the id is on the
|
|
135
|
+
* clipboard: it is better to say the copy could not be confirmed than to imply
|
|
136
|
+
* one that was never verified.
|
|
137
|
+
*/
|
|
138
|
+
export function copyFeedback(
|
|
139
|
+
result: CopyResult,
|
|
140
|
+
id: string,
|
|
141
|
+
): {
|
|
142
|
+
readonly ok: boolean;
|
|
143
|
+
readonly variant: "success" | "error";
|
|
144
|
+
readonly message: string;
|
|
145
|
+
} {
|
|
146
|
+
if (result.verified) {
|
|
147
|
+
return { ok: true, variant: "success", message: `Copied the full session id ${id} to the clipboard.` };
|
|
148
|
+
}
|
|
149
|
+
switch (result.outcome) {
|
|
150
|
+
case "osc52-dispatched":
|
|
151
|
+
return {
|
|
152
|
+
ok: false,
|
|
153
|
+
variant: "error",
|
|
154
|
+
message: "Sent the session id to the terminal, but could not confirm it was copied.",
|
|
155
|
+
};
|
|
156
|
+
case "unsupported":
|
|
157
|
+
return { ok: false, variant: "error", message: "This terminal cannot copy to the clipboard." };
|
|
158
|
+
case "cancelled":
|
|
159
|
+
return { ok: false, variant: "error", message: "The clipboard copy was cancelled." };
|
|
160
|
+
case "timed-out":
|
|
161
|
+
return { ok: false, variant: "error", message: "The clipboard copy timed out." };
|
|
162
|
+
case "failed":
|
|
163
|
+
return { ok: false, variant: "error", message: "Could not copy the session id to the clipboard." };
|
|
164
|
+
case "no-backend":
|
|
165
|
+
default:
|
|
166
|
+
return { ok: false, variant: "error", message: "No clipboard is available to copy the session id." };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The host-clipboard seam, split from `./clipboard.ts` for one reason: the
|
|
2
|
+
// render tests mount the real JSX in a real headless renderer, where mocking
|
|
3
|
+
// all of `@opentui/core` would break the renderer itself. This module is the
|
|
4
|
+
// only thing those tests replace, so they can stand in a fake host write while
|
|
5
|
+
// the renderer and the OSC52 adapter stay real.
|
|
6
|
+
//
|
|
7
|
+
// Production always resolves to the real process host clipboard.
|
|
8
|
+
|
|
9
|
+
export { createHostClipboard } from "@opentui/core";
|
package/src/tui/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
import { Plugin } from "@opencode/plugin/tui";
|
|
3
3
|
import { cautionDetail, cautionText, detectCautions, worstCaution, type Caution } from "./caution.js";
|
|
4
|
-
import { copyToClipboard } from "./clipboard.js";
|
|
4
|
+
import { copyFeedback, copyToClipboard } from "./clipboard.js";
|
|
5
5
|
import { cautionThresholds, mergeOptions, resolveConfig } from "./config.js";
|
|
6
6
|
import { loadConfigFile } from "./file-config.js";
|
|
7
7
|
import { footerLine, railLineSpans, railLines, railLineStyle, type RailLine } from "./presentation.js";
|
|
@@ -79,7 +79,17 @@ export default Plugin.define({
|
|
|
79
79
|
// window is red" decision is tested directly. All this renderer does is
|
|
80
80
|
// resolve each role to a theme colour and pass `fg`, never ANSI.
|
|
81
81
|
const text = (
|
|
82
|
-
<text
|
|
82
|
+
<text
|
|
83
|
+
fg={lineFg}
|
|
84
|
+
attributes={attributeMask(style.attributes) ?? 0}
|
|
85
|
+
// Only the `ses` row breaks on character boundaries. Its value is one
|
|
86
|
+
// unbroken 30-character id with no word boundary; pinning `char`
|
|
87
|
+
// guarantees that token breaks deterministically at a character
|
|
88
|
+
// boundary, rather than depending on how the renderer's word-break
|
|
89
|
+
// handles a token it cannot break. Every other line keeps the
|
|
90
|
+
// renderer's own `word` default.
|
|
91
|
+
wrapMode={line.field === "ses" ? "char" : undefined}
|
|
92
|
+
>
|
|
83
93
|
{railLineSpans(line, style).map((span) => (
|
|
84
94
|
<span style={{ fg: themeColor(span.color, context.theme) as string | undefined }}>
|
|
85
95
|
{span.text}
|
|
@@ -90,10 +100,39 @@ export default Plugin.define({
|
|
|
90
100
|
// The `ses` row is the one live row with a second gesture: a click copies
|
|
91
101
|
// the full session id. The handler wraps the line in a box so it fires
|
|
92
102
|
// wherever the row is clicked (mouse events bubble up, never down), and
|
|
93
|
-
// it closes over the id from THIS render
|
|
94
|
-
// is never cached.
|
|
103
|
+
// it closes over the id from THIS render - see `snapshot` for why the id
|
|
104
|
+
// is never cached. The confirmation is a host toast, not an on-row glyph:
|
|
105
|
+
// a signal from this plugin's own Solid is invisible to the host's
|
|
106
|
+
// renderer (`./ticker.ts`), so the one host-reactive surface is used
|
|
107
|
+
// instead. The toast is wrapped so a failure in it can never throw out of
|
|
108
|
+
// the mouse handler.
|
|
95
109
|
if (copyId === undefined) return text;
|
|
96
|
-
return
|
|
110
|
+
return (
|
|
111
|
+
<box
|
|
112
|
+
onMouseUp={() => {
|
|
113
|
+
void (async () => {
|
|
114
|
+
// Everything, the copy included, sits inside the try: a backend
|
|
115
|
+
// that throws or rejects must degrade to a failure result, never
|
|
116
|
+
// an exception out of the mouse handler.
|
|
117
|
+
try {
|
|
118
|
+
const result = await copyToClipboard(context.renderer, copyId);
|
|
119
|
+
const fb = copyFeedback(result, copyId);
|
|
120
|
+
context.ui.toast.show({
|
|
121
|
+
title: "Flight Deck",
|
|
122
|
+
message: fb.message,
|
|
123
|
+
variant: fb.variant,
|
|
124
|
+
duration: 1500,
|
|
125
|
+
});
|
|
126
|
+
} catch {
|
|
127
|
+
// A confirmation must never be able to break the click that
|
|
128
|
+
// produced it, nor the panel it confirms.
|
|
129
|
+
}
|
|
130
|
+
})();
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{text}
|
|
134
|
+
</box>
|
|
135
|
+
);
|
|
97
136
|
};
|
|
98
137
|
|
|
99
138
|
// Bound a bankable window to a few ticks: `min(60s, max(5s, 4 * refreshMs))`,
|
package/src/tui/rows.ts
CHANGED
|
@@ -385,10 +385,9 @@ export function statLine(
|
|
|
385
385
|
}
|
|
386
386
|
case "ses": {
|
|
387
387
|
const id = asText(source.sessionId);
|
|
388
|
-
//
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
return id === undefined ? undefined : row("ses", id.slice(0, 8));
|
|
388
|
+
// The full id is drawn: it is the only usable form of the value, and the
|
|
389
|
+
// rail wraps it on character boundaries rather than clipping it.
|
|
390
|
+
return id === undefined ? undefined : row("ses", id);
|
|
392
391
|
}
|
|
393
392
|
case "go": {
|
|
394
393
|
// The plain string is the exact join of the coloured segments, so the
|
package/src/tui/stat-fields.ts
CHANGED
|
@@ -24,8 +24,8 @@ export interface StatSource {
|
|
|
24
24
|
readonly branch?: unknown;
|
|
25
25
|
/**
|
|
26
26
|
* The open session id, straight from the slot render props. Untrusted like
|
|
27
|
-
* every other field: the `ses` row draws
|
|
28
|
-
*
|
|
27
|
+
* every other field: the `ses` row draws the FULL id (the rail wraps it), and
|
|
28
|
+
* that same full value is what the row's copy gesture writes.
|
|
29
29
|
*/
|
|
30
30
|
readonly sessionId?: unknown;
|
|
31
31
|
readonly tree?: unknown;
|