oc-flight-deck 0.10.1 → 0.10.3
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 -0
- package/package.json +1 -1
- package/src/tui/clipboard.ts +135 -30
- package/src/tui/host-clipboard.ts +9 -0
- package/src/tui/index.tsx +24 -17
- package/src/tui/rows.ts +22 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ 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.3] - 2026-10-02
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- The `ses` row no longer bleeds past the rail. It again draws a short-pruned preview of the session id - width-aware, with an ellipsis, so it reads as a preview of a longer value - instead of the full 30-character id wrapping out of bounds. The click still copies the **full** id; only the display is pruned.
|
|
13
|
+
- A successful copy is now silent. The success toast is gone, since the copied value is already on the clipboard when the gesture works. A copy that could **not** be confirmed still shows its failure toast - a silent no-op must never masquerade as a success.
|
|
14
|
+
|
|
15
|
+
## [0.10.2] - 2026-10-02
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- 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.
|
|
20
|
+
|
|
8
21
|
## [0.10.1] - 2026-10-02
|
|
9
22
|
|
|
10
23
|
### Fixed
|
|
@@ -17,5 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
17
30
|
|
|
18
31
|
- 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.
|
|
19
32
|
|
|
33
|
+
[0.10.3]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.2...v0.10.3
|
|
34
|
+
[0.10.2]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.1...v0.10.2
|
|
20
35
|
[0.10.1]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.0...v0.10.1
|
|
21
36
|
[0.10.0]: https://github.com/nathwn12/oc-flight-deck/compare/v0.9.0...v0.10.0
|
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);
|
|
@@ -36,28 +67,102 @@ export function copyToClipboard(renderer: unknown, text: string): boolean {
|
|
|
36
67
|
}
|
|
37
68
|
}
|
|
38
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
|
+
|
|
39
128
|
/**
|
|
40
129
|
* The confirmation for a copy gesture, as a host-toast description.
|
|
41
130
|
*
|
|
42
|
-
* Split from {@link copyToClipboard} so the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* guaranteed. The failure text names the terminal's inability and carries no id
|
|
49
|
-
* at all, because nothing was copied, so a silent no-op can never masquerade as
|
|
50
|
-
* a success.
|
|
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.
|
|
51
137
|
*/
|
|
52
138
|
export function copyFeedback(
|
|
53
|
-
|
|
139
|
+
result: CopyResult,
|
|
54
140
|
id: string,
|
|
55
141
|
): {
|
|
56
142
|
readonly ok: boolean;
|
|
57
143
|
readonly variant: "success" | "error";
|
|
58
144
|
readonly message: string;
|
|
59
145
|
} {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
}
|
|
63
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
|
@@ -101,28 +101,35 @@ export default Plugin.define({
|
|
|
101
101
|
// the full session id. The handler wraps the line in a box so it fires
|
|
102
102
|
// wherever the row is clicked (mouse events bubble up, never down), and
|
|
103
103
|
// it closes over the id from THIS render - see `snapshot` for why the id
|
|
104
|
-
// is never cached.
|
|
105
|
-
// a
|
|
106
|
-
//
|
|
107
|
-
//
|
|
104
|
+
// is never cached. A verified copy is silent: the owner objects to the
|
|
105
|
+
// noise of a toast confirming a gesture that plainly worked, so the only
|
|
106
|
+
// host-reactive surface (`./ticker.ts`) is reserved for a genuine failure,
|
|
107
|
+
// where the honesty rail requires that a no-op can never pass as a
|
|
108
|
+
// success. The call is wrapped so a failure in it can never throw out of
|
|
108
109
|
// the mouse handler.
|
|
109
110
|
if (copyId === undefined) return text;
|
|
110
111
|
return (
|
|
111
112
|
<box
|
|
112
113
|
onMouseUp={() => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
void (async () => {
|
|
115
|
+
// Everything, the copy included, sits inside the try: a backend
|
|
116
|
+
// that throws or rejects must degrade to a failure result, never
|
|
117
|
+
// an exception out of the mouse handler.
|
|
118
|
+
try {
|
|
119
|
+
const result = await copyToClipboard(context.renderer, copyId);
|
|
120
|
+
const fb = copyFeedback(result, copyId);
|
|
121
|
+
if (fb.ok) return;
|
|
122
|
+
context.ui.toast.show({
|
|
123
|
+
title: "Flight Deck",
|
|
124
|
+
message: fb.message,
|
|
125
|
+
variant: fb.variant,
|
|
126
|
+
duration: 1500,
|
|
127
|
+
});
|
|
128
|
+
} catch {
|
|
129
|
+
// A confirmation must never be able to break the click that
|
|
130
|
+
// produced it, nor the panel it confirms.
|
|
131
|
+
}
|
|
132
|
+
})();
|
|
126
133
|
}}
|
|
127
134
|
>
|
|
128
135
|
{text}
|
package/src/tui/rows.ts
CHANGED
|
@@ -23,6 +23,17 @@ import {
|
|
|
23
23
|
/** Braille frames, advanced by the ticker, shown only while the session runs. */
|
|
24
24
|
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Value-column budget for the `ses` row's preview, in cells.
|
|
28
|
+
*
|
|
29
|
+
* Same width the `perms` row clips its resource to, because that is the column
|
|
30
|
+
* this roughly thirty-odd-column rail was designed to fit: the label column
|
|
31
|
+
* plus a value of this length stays inside the panel. A full 30-character
|
|
32
|
+
* session id is always shortened at this budget and gets the ellipsis appended
|
|
33
|
+
* - the row reads as a preview of a longer value, never as the value.
|
|
34
|
+
*/
|
|
35
|
+
const SES_PREVIEW_WIDTH = 18;
|
|
36
|
+
|
|
26
37
|
/**
|
|
27
38
|
* Flatten control characters in anything about to be drawn.
|
|
28
39
|
*
|
|
@@ -385,9 +396,17 @@ export function statLine(
|
|
|
385
396
|
}
|
|
386
397
|
case "ses": {
|
|
387
398
|
const id = asText(source.sessionId);
|
|
388
|
-
//
|
|
389
|
-
//
|
|
390
|
-
|
|
399
|
+
// A short preview, never the full id: the rail is roughly thirty-odd
|
|
400
|
+
// columns wide and the label already costs its column, so the 30-character
|
|
401
|
+
// id runs past the panel. `clip` shortens width-aware and appends the
|
|
402
|
+
// ellipsis that tells the reader this is a preview, not the value. The
|
|
403
|
+
// full id still lives on `source.sessionId`, which is what the row's click
|
|
404
|
+
// gesture copies - the display and the copy are separate values.
|
|
405
|
+
//
|
|
406
|
+
// Budget `SES_PREVIEW_WIDTH` (18), matching the `perms` row's clip width:
|
|
407
|
+
// that is the column this rail was designed to fit, so a preview of that
|
|
408
|
+
// length sits inside it beside the label.
|
|
409
|
+
return id === undefined ? undefined : row("ses", clip(id, SES_PREVIEW_WIDTH));
|
|
391
410
|
}
|
|
392
411
|
case "go": {
|
|
393
412
|
// The plain string is the exact join of the coloured segments, so the
|