oc-flight-deck 0.9.0 → 0.10.0

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,14 @@
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.0] - 2026-10-02
9
+
10
+ ### Added
11
+
12
+ - Opt-in `ses` sidebar row: shows the session id shortened to its first 8 characters, and a mouse click copies the full id via the renderer's OSC52 clipboard path. Off by default, and degrades gracefully when the terminal cannot copy.
13
+
14
+ [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, shortened to its first **8 characters**; **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 open session id, shortened to its first 8 characters.
124
+ // A mouse click on the row copies the full id to the terminal
125
+ // clipboard. Off by 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 (first 8 chars); 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 open session id shortened to its first 8 characters; 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.0",
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,37 @@
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
+ }
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 { 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,14 +71,14 @@ 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
+ const text = (
81
82
  <text fg={lineFg} attributes={attributeMask(style.attributes) ?? 0}>
82
83
  {railLineSpans(line, style).map((span) => (
83
84
  <span style={{ fg: themeColor(span.color, context.theme) as string | undefined }}>
@@ -86,6 +87,13 @@ export default Plugin.define({
86
87
  ))}
87
88
  </text>
88
89
  );
90
+ // The `ses` row is the one live row with a second gesture: a click copies
91
+ // the full session id. The handler wraps the line in a box so it fires
92
+ // wherever the row is clicked (mouse events bubble up, never down), and
93
+ // it closes over the id from THIS render — see `snapshot` for why the id
94
+ // is never cached.
95
+ if (copyId === undefined) return text;
96
+ return <box onMouseUp={() => copyToClipboard(context.renderer, copyId)}>{text}</box>;
89
97
  };
90
98
 
91
99
  // Bound a bankable window to a few ticks: `min(60s, max(5s, 4 * refreshMs))`,
@@ -222,6 +230,10 @@ export default Plugin.define({
222
230
  // Read the go store inside the render too, so a poll re-runs the rail
223
231
  // exactly as the guard read does.
224
232
  go: goBridge?.usage,
233
+ // The id comes from the slot render props, read fresh on every render
234
+ // rather than cached: the sidebar is not remounted on a session switch,
235
+ // so a signal or module variable here would copy a stale session.
236
+ sessionId: wants("ses") ? sessionID : undefined,
225
237
  // Read the tick inside the render so the host registers a dependency on
226
238
  // it; that read is what makes the rail re-run on the ticker's schedule.
227
239
  frame: ticker?.frame ?? 0,
@@ -287,7 +299,7 @@ export default Plugin.define({
287
299
  // No padding here: the host already lays out and pads the sidebar,
288
300
  // so adding our own would push the rows out of alignment with it.
289
301
  <box flexDirection="column">
290
- {lines.map(themedLine)}
302
+ {lines.map((line) => themedLine(line, line.field === "ses" ? sessionID : undefined))}
291
303
  </box>
292
304
  );
293
305
  },
package/src/tui/rows.ts CHANGED
@@ -383,6 +383,13 @@ 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
+ // Only the first eight characters are drawn: a session id is longer than
389
+ // the rail and would wrap. The full id stays in the source so the row's
390
+ // copy gesture can write it.
391
+ return id === undefined ? undefined : row("ses", id.slice(0, 8));
392
+ }
386
393
  case "go": {
387
394
  // The plain string is the exact join of the coloured segments, so the
388
395
  // 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 only the first eight characters,
28
+ * while the full value is what that 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];