oc-flight-deck 0.9.0 → 0.10.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 ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.10.1] - 2026-10-02
9
+
10
+ ### Fixed
11
+
12
+ - 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.
13
+
14
+ ## [0.10.0] - 2026-10-02
15
+
16
+ ### Added
17
+
18
+ - 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
+
20
+ [0.10.1]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.0...v0.10.1
21
+ [0.10.0]: https://github.com/nathwn12/oc-flight-deck/compare/v0.9.0...v0.10.0
package/README.md CHANGED
@@ -64,10 +64,11 @@ 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, which the rail wraps; **click the row** to copy the full id to the terminal clipboard · **off by default** (requires the host's mouse) |
67
68
 
68
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.
69
70
 
70
- The rows marked **off by default** — `caution`, `branch`, `total`, `spark`, `reasoning`, `turns`, `guard`, and `go` — are available but not in the default rail: add any of them to `sidebar.rows`. `caution` also needs `caution.enabled: true`; `go` needs `OPENCODE_GO_API_KEY` in the environment.
71
+ The rows marked **off by default** — `caution`, `branch`, `total`, `spark`, `reasoning`, `turns`, `guard`, `go`, and `ses` — are available but not in the default rail: add any of them to `sidebar.rows`. `caution` also needs `caution.enabled: true`; `go` needs `OPENCODE_GO_API_KEY` in the environment; `ses` needs the host's mouse enabled to click-copy.
71
72
 
72
73
  Every field named in `sidebar.rows` renders exactly one row, in order. With `sidebar.persist` (the default), a row with no data yet shows the `sidebar.placeholder` value (default `—`) in the same label column as a live row — so the rail keeps a stable shape instead of growing rows as the session produces data. Set `"persist": false` to restore omission: rows with no data are left out entirely.
73
74
 
@@ -154,10 +155,12 @@ Everything else lives in the example file, documented inline - a typo is never f
154
155
 
155
156
  ---
156
157
 
157
- ## 🔒 It reads. It writes one number — two with `guard` on.
158
+ ## 🔒 It reads. It writes almost nothing.
158
159
 
159
160
  Flight Deck shows what OpenCode already knows.
160
161
 
162
+ - **One clipboard write, and only on a click.** With the opt-in `ses` row on the rail, a mouse click on that row copies the full session id to the terminal clipboard. Nothing is copied on render, in the background, or without that gesture; a terminal that cannot take the write simply does nothing.
163
+
161
164
  - **No network calls while the opt-in `guard` row stays off.** Nothing is fetched, nothing is sent. With `guard` enabled, the panel polls the local guard RPC — same machine, no telemetry — about every ten seconds, plus right away when the rendered session changes.
162
165
  - **No telemetry.** Nothing is collected or phoned home.
163
166
  - **Nothing on disk.** The one thing it normally writes is an animation counter in the host's in-memory plugin state, so the spinner and a running `elapsed` clock keep moving between host events. It is scoped to this plugin and dies with the TUI; it is never persisted, and `"refresh": 0` removes even that. With `"refresh": 0` the rail re-reads only on host events, so a busy stretch that produces few events can undercount `elapsed` — no unobserved gap bills beyond its bound, and a longer gap banks nothing. With `guard` enabled there is a second in-memory write — that row's polled status — and `"refresh": 0` does not remove it; dropping `guard` from `sidebar.rows` does.
@@ -204,7 +207,7 @@ Built on the official [OpenCode V2 CLI plugin API](https://opencode.ai/v2/docs/b
204
207
  | Built against | `@opencode/plugin` `2.0.19` — pin a host version you've tested |
205
208
  | Host | OpenCode V2 (`opencode2`) |
206
209
  | Building from source | Node ≥ 22 or Bun ≥ 1.4 |
207
- | Writes | In-memory counters only — the animation tick, plus the `guard` row's polled status when `guard` is on; nothing to disk |
210
+ | Writes | In-memory counters only — the animation tick, plus the `guard` row's polled status when `guard` is on; with the opt-in `ses` row, a click copies the id to the terminal clipboard (never automatic); nothing to disk |
208
211
 
209
212
  ---
210
213
 
@@ -120,6 +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 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.
123
126
  //
124
127
  // Every named row renders persistently, so the rail keeps a stable shape:
125
128
  // a row with no data yet shows the placeholder below, in the same label
@@ -140,6 +143,7 @@
140
143
  // ,"go" — Zen Go account usage (needs OPENCODE_GO_API_KEY)
141
144
  // ,"caution" — the annunciator
142
145
  // ,"branch" — current git branch
146
+ // ,"ses" - current session id (full, wrapped); click to copy the full id
143
147
  ],
144
148
 
145
149
  // Every named row renders persistently: with no data yet it shows the
@@ -52,10 +52,10 @@
52
52
  },
53
53
  "rows": {
54
54
  "type": "array",
55
- "items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go"] },
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 — 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."
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",
@@ -268,7 +268,7 @@
268
268
  }
269
269
  },
270
270
  "propertyNames": {
271
- "enum": ["*", "caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go"]
271
+ "enum": ["*", "caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go", "ses"]
272
272
  },
273
273
  "default": { "*": { "color": "subdued", "attributes": [] } },
274
274
  "description": "Style all live rows under `*`, then optionally override any known row name such as `cost`. A row can change one field and inherit the other from `*`; unknown row names are reported and ignored."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-flight-deck",
3
- "version": "0.9.0",
3
+ "version": "0.10.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",
@@ -38,7 +38,8 @@
38
38
  "flight-deck.example.jsonc",
39
39
  "flight-deck.schema.json",
40
40
  "README.md",
41
- "LICENSE"
41
+ "LICENSE",
42
+ "CHANGELOG.md"
42
43
  ],
43
44
  "engines": {
44
45
  "node": ">=22",
@@ -47,7 +48,8 @@
47
48
  "scripts": {
48
49
  "typecheck": "tsc --noEmit",
49
50
  "test": "bun test",
50
- "check": "bun run typecheck && bun test"
51
+ "check": "bun run typecheck && bun test",
52
+ "prepublishOnly": "bun run check"
51
53
  },
52
54
  "publishConfig": {
53
55
  "access": "public"
@@ -0,0 +1,63 @@
1
+ // The one clipboard write in the plugin: a session id, copied on a gesture.
2
+ //
3
+ // The plugin Context exposes no clipboard member, so this reaches through the
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:
7
+ //
8
+ // 1. It is called only from an explicit mouse gesture on the `ses` row. There
9
+ // is no render-time, background, or automatic write, ever.
10
+ // 2. A renderer that cannot take the write degrades to a no-op. A copy that
11
+ // did not happen must never take the panel (or the click) down with it.
12
+ //
13
+ // `createRendererClipboardAdapter` is the OSC52 boundary: it reads the
14
+ // renderer's terminal capabilities and, unless OSC52 is reported unsupported,
15
+ // calls `renderer.copyToClipboardOSC52`. Wrapping it here keeps the rest of the
16
+ // rail from knowing the clipboard exists.
17
+
18
+ import { createRendererClipboardAdapter } from "@opentui/core";
19
+
20
+ type RendererBoundary = Parameters<typeof createRendererClipboardAdapter>[0];
21
+
22
+ /**
23
+ * Write `text` to the terminal clipboard, or do nothing.
24
+ *
25
+ * Returns true only when the adapter attempted the write. An absent renderer, a
26
+ * terminal without OSC52, or a renderer missing the OSC52 method all return
27
+ * false without throwing.
28
+ */
29
+ export function copyToClipboard(renderer: unknown, text: string): boolean {
30
+ if (renderer === undefined || renderer === null) return false;
31
+ try {
32
+ const terminal = createRendererClipboardAdapter(renderer as RendererBoundary);
33
+ return terminal.writeText(text, "clipboard").status === "attempted";
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ /**
40
+ * The confirmation for a copy gesture, as a host-toast description.
41
+ *
42
+ * Split from {@link copyToClipboard} so the success and failure wordings are
43
+ * pure and tested directly: a click must always report what actually happened,
44
+ * and the two outcomes must never read alike. `ok` mirrors the attempted write.
45
+ * The success text names the full `id` and says the copy was *sent* - an
46
+ * `attempted` status only confirms the local dispatch to the terminal, not that
47
+ * the terminal then copied - so a message never claims a write that was not
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.
51
+ */
52
+ export function copyFeedback(
53
+ attempted: boolean,
54
+ id: string,
55
+ ): {
56
+ readonly ok: boolean;
57
+ readonly variant: "success" | "error";
58
+ readonly message: string;
59
+ } {
60
+ return attempted
61
+ ? { ok: true, variant: "success", message: `Sent the full session id ${id} to the clipboard.` }
62
+ : { ok: false, variant: "error", message: "This terminal cannot copy to the clipboard." };
63
+ }
package/src/tui/index.tsx CHANGED
@@ -1,6 +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 { copyFeedback, copyToClipboard } from "./clipboard.js";
4
5
  import { cautionThresholds, mergeOptions, resolveConfig } from "./config.js";
5
6
  import { loadConfigFile } from "./file-config.js";
6
7
  import { footerLine, railLineSpans, railLines, railLineStyle, type RailLine } from "./presentation.js";
@@ -70,15 +71,25 @@ export default Plugin.define({
70
71
  // instead of assigning `undefined` over it, so the shipped config draws
71
72
  // exactly what it always drew. Shared with the sidebar footer slot so both
72
73
  // rails stay one styling path.
73
- const themedLine = (line: RailLine) => {
74
+ const themedLine = (line: RailLine, copyId?: string) => {
74
75
  const style = railLineStyle(config.style, line);
75
76
  const lineFg = themeColor(style.color, context.theme) as string | undefined;
76
77
  // The span mapping — which run inherits the line's colour and which
77
78
  // takes its own tone — lives in a pure helper, so the "only the flagged
78
79
  // window is red" decision is tested directly. All this renderer does is
79
80
  // resolve each role to a theme colour and pass `fg`, never ANSI.
80
- return (
81
- <text fg={lineFg} attributes={attributeMask(style.attributes) ?? 0}>
81
+ const 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
+ >
82
93
  {railLineSpans(line, style).map((span) => (
83
94
  <span style={{ fg: themeColor(span.color, context.theme) as string | undefined }}>
84
95
  {span.text}
@@ -86,6 +97,37 @@ export default Plugin.define({
86
97
  ))}
87
98
  </text>
88
99
  );
100
+ // The `ses` row is the one live row with a second gesture: a click copies
101
+ // the full session id. The handler wraps the line in a box so it fires
102
+ // wherever the row is clicked (mouse events bubble up, never down), and
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.
109
+ if (copyId === undefined) return text;
110
+ return (
111
+ <box
112
+ onMouseUp={() => {
113
+ const attempted = copyToClipboard(context.renderer, copyId);
114
+ const fb = copyFeedback(attempted, copyId);
115
+ try {
116
+ context.ui.toast.show({
117
+ title: "Flight Deck",
118
+ message: fb.message,
119
+ variant: fb.variant,
120
+ duration: 1500,
121
+ });
122
+ } catch {
123
+ // A confirmation must never be able to break the click that
124
+ // produced it, nor the panel it confirms.
125
+ }
126
+ }}
127
+ >
128
+ {text}
129
+ </box>
130
+ );
89
131
  };
90
132
 
91
133
  // Bound a bankable window to a few ticks: `min(60s, max(5s, 4 * refreshMs))`,
@@ -222,6 +264,10 @@ export default Plugin.define({
222
264
  // Read the go store inside the render too, so a poll re-runs the rail
223
265
  // exactly as the guard read does.
224
266
  go: goBridge?.usage,
267
+ // The id comes from the slot render props, read fresh on every render
268
+ // rather than cached: the sidebar is not remounted on a session switch,
269
+ // so a signal or module variable here would copy a stale session.
270
+ sessionId: wants("ses") ? sessionID : undefined,
225
271
  // Read the tick inside the render so the host registers a dependency on
226
272
  // it; that read is what makes the rail re-run on the ticker's schedule.
227
273
  frame: ticker?.frame ?? 0,
@@ -287,7 +333,7 @@ export default Plugin.define({
287
333
  // No padding here: the host already lays out and pads the sidebar,
288
334
  // so adding our own would push the rows out of alignment with it.
289
335
  <box flexDirection="column">
290
- {lines.map(themedLine)}
336
+ {lines.map((line) => themedLine(line, line.field === "ses" ? sessionID : undefined))}
291
337
  </box>
292
338
  );
293
339
  },
package/src/tui/rows.ts CHANGED
@@ -383,6 +383,12 @@ export function statLine(
383
383
  const token = guardToken(source.guard);
384
384
  return token === undefined ? undefined : row("guard", token);
385
385
  }
386
+ case "ses": {
387
+ const id = asText(source.sessionId);
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);
391
+ }
386
392
  case "go": {
387
393
  // The plain string is the exact join of the coloured segments, so the
388
394
  // string view (tests, `sidebarTextLines`) and the JSX view agree
@@ -22,6 +22,12 @@ export interface StatSource {
22
22
  readonly cost?: unknown;
23
23
  readonly tokens?: unknown;
24
24
  readonly branch?: unknown;
25
+ /**
26
+ * The open session id, straight from the slot render props. Untrusted like
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
+ */
30
+ readonly sessionId?: unknown;
25
31
  readonly tree?: unknown;
26
32
  readonly context?: unknown;
27
33
  readonly project?: unknown;
@@ -76,6 +82,7 @@ export const STAT_FIELDS = [
76
82
  "turns",
77
83
  "guard",
78
84
  "go",
85
+ "ses",
79
86
  ] as const;
80
87
 
81
88
  type StatField = (typeof STAT_FIELDS)[number];