@awebai/oats 0.66.0 → 0.68.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/bin/oats.mjs +166 -17
- package/docs/capabilities.md +58 -9
- package/docs/capability-manifest.schema.json +5 -1
- package/docs/design/2026-10-22-module-upgrade.md +192 -0
- package/docs/design/README.md +4 -0
- package/docs/desktop-cli-api.md +463 -13
- package/docs/desktop.md +363 -67
- package/docs/first-team.md +5 -3
- package/docs/implementation.md +46 -6
- package/docs/integrations.md +16 -4
- package/docs/knowledge.md +44 -27
- package/docs/layers.md +2 -2
- package/docs/official-catalog.md +5 -5
- package/docs/packages.md +14 -14
- package/docs/release-lane.md +16 -0
- package/docs/release-notes/v0.67.0.md +366 -0
- package/docs/release-notes/v0.67.1.md +64 -0
- package/docs/release-notes/v0.68.0.md +504 -0
- package/docs/servers.md +8 -2
- package/docs/souls-and-instances.md +58 -6
- package/docs/tui.md +1033 -237
- package/docs/upgrading.md +164 -26
- package/docs/workspaces.md +2 -2
- package/lib/capability-contract.mjs +8 -7
- package/lib/core.mjs +331 -75
- package/lib/instance-color.mjs +58 -0
- package/lib/instance-events.mjs +1 -1
- package/lib/instance-inspect.mjs +107 -23
- package/lib/instance-lifecycle.mjs +21 -1
- package/lib/instance-naming.mjs +187 -0
- package/lib/instance-resolution.mjs +10 -6
- package/lib/instance-upgrade.mjs +1445 -0
- package/lib/materialize.mjs +287 -89
- package/lib/servers.mjs +24 -11
- package/lib/soul-composition.mjs +7 -3
- package/lib/upgrade-state.mjs +101 -0
- package/lib/workspace.mjs +4 -1
- package/lib/worktree.mjs +103 -12
- package/package-catalog.json +5 -4
- package/package.json +1 -1
- package/packages/client/cli-adapter.mjs +52 -6
- package/packages/client/cli-locator.mjs +2 -2
- package/packages/client/composed-gate.mjs +10 -2
- package/packages/client/deployment-data.mjs +5 -0
- package/packages/client/deployment-identity.mjs +40 -0
- package/packages/client/deployment-panel.mjs +9 -3
- package/packages/client/inspect-boundary.mjs +11 -7
- package/packages/client/inspect-cache.mjs +2 -2
- package/packages/client/instance-name.mjs +28 -0
- package/packages/client/instance-presentation.mjs +11 -0
- package/packages/client/keymap.mjs +133 -28
- package/packages/client/keys-file.mjs +126 -0
- package/packages/client/own-codes.mjs +4 -2
- package/packages/client/panel-views.mjs +78 -12
- package/packages/client/spawn-naming.mjs +32 -0
- package/packages/client/spawn-preview-cli.mjs +58 -7
- package/packages/client/spawn-preview-contract.mjs +59 -0
- package/packages/client/spawn-preview-facts.mjs +8 -4
- package/packages/client/spawn-preview.mjs +81 -3
- package/packages/client/team-members.mjs +4 -1
- package/packages/client/workspace-step.mjs +25 -0
- package/packages/tui/README.md +7 -7
- package/packages/tui/lib/actions.mjs +92 -25
- package/packages/tui/lib/client.mjs +9 -4
- package/packages/tui/lib/config.mjs +50 -9
- package/packages/tui/lib/main.mjs +65 -24
- package/packages/tui/lib/model.mjs +292 -75
- package/packages/tui/lib/read.mjs +53 -1
- package/packages/tui/lib/store.mjs +469 -100
- package/packages/tui/lib/term/keys.mjs +22 -6
- package/packages/tui/lib/term/kitty.mjs +54 -11
- package/packages/tui/lib/term/screen.mjs +15 -6
- package/packages/tui/lib/term/through.mjs +66 -28
- package/packages/tui/lib/views/frame.mjs +223 -165
- package/packages/tui/lib/views/help.mjs +134 -29
- package/packages/tui/lib/views/instances.mjs +63 -22
- package/packages/tui/lib/views/palette.mjs +14 -4
- package/packages/tui/lib/views/souls.mjs +2 -2
- package/packages/tui/lib/views/switcher.mjs +6 -1
- package/packages/tui/lib/views/workspaces.mjs +55 -0
- package/skills/oats-getting-started/SKILL.md +96 -42
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
// whole width, and the detail and every overlay are a page over the whole screen. There is no
|
|
11
11
|
// header and no footer. The TUI's own words are lit(); everything else is shown(). Meaning never
|
|
12
12
|
// rests on colour alone: what is dim or bold also says what it is in words or by a mark.
|
|
13
|
-
import { LEADER, backKeyLabel, keyLabel } from "../actions.mjs";
|
|
13
|
+
import { LEADER, backKeyLabel, keyLabel, keysTogether } from "../actions.mjs";
|
|
14
14
|
import { lit, ownEllipsis, shown, shownLines, textOf } from "../term/text.mjs";
|
|
15
15
|
import { style } from "../term/style.mjs";
|
|
16
16
|
import { act } from "./act.mjs";
|
|
17
17
|
import { detail } from "./detail.mjs";
|
|
18
|
-
import { help, keyText } from "./help.mjs";
|
|
18
|
+
import { help, keyText, paletteGroupKeys } from "./help.mjs";
|
|
19
19
|
import { instances, measured } from "./instances.mjs";
|
|
20
20
|
import { textWidth } from "../term/width.mjs";
|
|
21
21
|
import { palette } from "./palette.mjs";
|
|
@@ -24,6 +24,7 @@ import { capabilitiesList, capabilitiesListed, capabilityDetail } from "./capabi
|
|
|
24
24
|
import { spawn } from "./spawn.mjs";
|
|
25
25
|
import { splitFits, splitRegions } from "./split.mjs";
|
|
26
26
|
import { switcher } from "./switcher.mjs";
|
|
27
|
+
import { workspaceRows } from "./workspaces.mjs";
|
|
27
28
|
|
|
28
29
|
/** The frame is drawn from this size up (docs/tui.md); the design size is 80x24. */
|
|
29
30
|
export const MIN_SIZE = Object.freeze({ cols: 60, rows: 15 });
|
|
@@ -53,11 +54,6 @@ const LIST_LEAST = 3;
|
|
|
53
54
|
const SOUL_WORD = "soul";
|
|
54
55
|
/** What the title says in the workspace's place while the switcher is shown. */
|
|
55
56
|
const WORKSPACES = "workspaces";
|
|
56
|
-
/** The TUI's word before the one machine of a view that holds no deployment of this machine. */
|
|
57
|
-
const ON = "on";
|
|
58
|
-
/** The cells the workspace's name keeps (all of them, when it is shorter) before the title says
|
|
59
|
-
* how many other machines it is on: under that the name comes first. */
|
|
60
|
-
const NAME_MIN = 8;
|
|
61
57
|
|
|
62
58
|
const BOLD = style({ bold: true });
|
|
63
59
|
const DIM = style({ dim: true });
|
|
@@ -65,7 +61,7 @@ const FOCUSED = style({ bold: true, reverse: true });
|
|
|
65
61
|
|
|
66
62
|
const clamp = (n, low, high) => Math.min(Math.max(n, low), high);
|
|
67
63
|
const tooSmall = (size) => size.cols < MIN_SIZE.cols || size.rows < MIN_SIZE.rows;
|
|
68
|
-
/** The leader's label, spelt for people (`Alt+O
|
|
64
|
+
/** The leader's label, spelt for people (`Ctrl+X` by default, `Alt+O`): tui.json's open.detachKey is the
|
|
69
65
|
* user's, so it is text from outside. */
|
|
70
66
|
const leaderText = (m) => keyText(backKeyLabel(m.detachKey));
|
|
71
67
|
|
|
@@ -143,7 +139,11 @@ function openOf(m) {
|
|
|
143
139
|
* layout first, because the model's window is as tall (`page`), and the sentences in its list as
|
|
144
140
|
* wide, as this gives. The answer's `note` is the note's rows and `outcome` the line's: its
|
|
145
141
|
* sentence and each text under it (what the viewer printed, what the kernel said) set as a reason
|
|
146
|
-
* is, on as many rows as a reason may take; `above` is how many of those rows stand.
|
|
142
|
+
* is, on as many rows as a reason may take; `above` is how many of those rows stand. A line that
|
|
143
|
+
* passes at the next key (`once`: the end of the list of workspaces) and takes one row stands
|
|
144
|
+
* instead in the empty row under what stands above (`passing`), so nothing moves while it shows:
|
|
145
|
+
* it takes no row of `above`, and `page` is a row shorter, so that empty row is always drawn. A
|
|
146
|
+
* list that fills the sidebar has no such row: it moves a row down, giving up its last. `open` is the
|
|
147
147
|
* accordion's open view (null while the switcher is shown): the title, the three views' rows and
|
|
148
148
|
* the rules between the sidebar's parts take what they need, what stands above gives way to keep
|
|
149
149
|
* the list LIST_LEAST rows and the leader's, and `room` is what is left for the empty row under
|
|
@@ -153,7 +153,7 @@ function openOf(m) {
|
|
|
153
153
|
* While a terminal is open (`terminal`) the sidebar keeps LIST_BESIDE cells at most, whether the
|
|
154
154
|
* terminal or the detail stands beside it, so the agent's screen keeps one size; a name longer
|
|
155
155
|
* than its row is cut there. */
|
|
156
|
-
export function layout(notice, size, { note = null, ascii = false, outcome = null, terminal = false, open = "instances" } = {}) {
|
|
156
|
+
export function layout(notice, size, { note = null, ascii = false, outcome = null, terminal = false, open = "instances", list = 1 } = {}) {
|
|
157
157
|
const wide = size.cols >= WIDE;
|
|
158
158
|
const listCols = !wide ? size.cols : terminal ? LIST_BESIDE : clamp(Math.floor(size.cols * 0.48), 36, 60);
|
|
159
159
|
const across = Math.max(1, listCols - 2 * MARGIN);
|
|
@@ -164,55 +164,34 @@ export function layout(notice, size, { note = null, ascii = false, outcome = nul
|
|
|
164
164
|
...partRows(outcome.said, across, reasonRows, { ascii }),
|
|
165
165
|
...outcome.under.flatMap((text) => shownLines(text, across, reasonRows, { ascii }).map((line) => [{ col: 0, text: line, width: across }])),
|
|
166
166
|
] : [];
|
|
167
|
+
const passing = outcome?.once === true && after.length === 1 ? after[0] : null;
|
|
167
168
|
// The title, a row per view, and the rules: one before the cheat sheet, one between the open
|
|
168
169
|
// view's list and the views after it, and one between the views before it and its heading.
|
|
169
170
|
const at = VIEWS.findIndex((view) => view.id === open);
|
|
170
171
|
const rules = 1 + (at < 0 ? 0 : (at > 0 ? 1 : 0) + (at < VIEWS.length - 1 ? 1 : 0));
|
|
171
|
-
const fixed =
|
|
172
|
-
const
|
|
172
|
+
const fixed = list + VIEWS.length + rules;
|
|
173
|
+
const standing = passing === null ? after : [];
|
|
174
|
+
const said = (notice ? 1 + reason.length : 0) + noted.length + standing.length;
|
|
173
175
|
const above = Math.min(said, Math.max(0, size.rows - fixed - 1 - LIST_LEAST));
|
|
174
176
|
const room = Math.max(0, size.rows - fixed - above);
|
|
175
|
-
return { wide, listCols, reason, note: noted, outcome:
|
|
177
|
+
return { wide, listCols, reason, note: noted, outcome: standing, passing, above, open: at < 0 ? null : open, room, page: Math.max(1, room - 1 - (passing === null ? 0 : 1)), body: size.rows };
|
|
176
178
|
}
|
|
177
179
|
/** The layout the frame draws a model by. */
|
|
178
|
-
const layoutOf = (m, size, given = {}) => layout(m.notice, size, { note: m.note, ascii: m.ascii, outcome: m.outcome, terminal: panelOpen(m), open: openOf(m), ...given });
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* `N machines` two or more of them and no deployment of this machine.
|
|
186
|
-
* Whether a deployment is this machine's is the shared entries' word (the model's `here`), and
|
|
187
|
-
* the machine's name is theirs. What stands after the name gives way before the name is cut
|
|
188
|
-
* short of NAME_MIN cells, and a machine's name is cut before the workspace's. While the
|
|
189
|
-
* switcher is shown no workspace is named: the title says what is listed instead. */
|
|
180
|
+
const layoutOf = (m, size, given = {}) => layout(m.notice, size, { note: m.note, ascii: m.ascii, outcome: m.outcome, terminal: panelOpen(m), open: openOf(m), list: listRows(m), ...given });
|
|
181
|
+
/** The rows the top of the sidebar takes: the list of workspaces' (views/workspaces.mjs), else the title's. */
|
|
182
|
+
const listRows = (m) => (m.workspaces ? Math.max(1, m.workspaces.lines.length + (m.workspaces.more > 0 ? 1 : 0)) : 1);
|
|
183
|
+
|
|
184
|
+
/** The title, from `col` on in `room` cells, where the list of workspaces does not stand (nothing
|
|
185
|
+
* is open, or the switcher is shown): the workspace's name, else what is listed. Its machines are
|
|
186
|
+
* the workspace's own pages' to say (the list of instances' sections). */
|
|
190
187
|
function nameSpans(m, col, room) {
|
|
191
188
|
if (room <= 0) return [];
|
|
192
189
|
if (m.under === "switcher") return [{ col, text: lit(WORKSPACES), width: room }];
|
|
193
|
-
|
|
194
|
-
if (!(m.machines > 0)) return alone;
|
|
195
|
-
const least = Math.min(name.width, NAME_MIN);
|
|
196
|
-
// Two cells between the name and what follows it.
|
|
197
|
-
const after = (width) => col + width + (width ? 2 : 0);
|
|
198
|
-
if (!m.here && m.machine !== null) {
|
|
199
|
-
const where = measured(m.machine), left = room - 2 - ON.length - 1;
|
|
200
|
-
// The machine's name is cut first, down to the cells that still say something: the
|
|
201
|
-
// workspace's name has what that leaves.
|
|
202
|
-
const kept = Math.min(where.width, NAME_MIN);
|
|
203
|
-
if (left - least < kept) return alone;
|
|
204
|
-
const width = Math.min(name.width, left - kept), at = after(width);
|
|
205
|
-
return [...(width ? [{ col, text: name.text, width }] : []), { col: at, text: lit(ON), style: DIM, width: ON.length }, { col: at + ON.length + 1, text: where.text, style: DIM, width: Math.min(where.width, left - width) }];
|
|
206
|
-
}
|
|
207
|
-
const more = `${m.here ? "+" : ""}${m.machines} ${m.machines === 1 ? "machine" : "machines"}`;
|
|
208
|
-
const left = room - 2 - more.length;
|
|
209
|
-
if (left < least) return alone;
|
|
210
|
-
const width = Math.min(name.width, left);
|
|
211
|
-
return [...(width ? [{ col, text: name.text, width }] : []), { col: after(width), text: lit(more), style: DIM, width: more.length }];
|
|
190
|
+
return [{ col, text: measured(m.workspace).text, width: room }];
|
|
212
191
|
}
|
|
213
192
|
|
|
214
|
-
/** The title, the sidebar's first row: the workspace's name in bold
|
|
215
|
-
*
|
|
193
|
+
/** The title, the sidebar's first row where the list does not stand: the workspace's name in bold,
|
|
194
|
+
* or `workspaces` while the switcher is shown (nameSpans). */
|
|
216
195
|
function titleRow(m, cols) {
|
|
217
196
|
return nameSpans(m, MARGIN, cols - 2 * MARGIN).map((span) => (span.style ? span : { ...span, style: BOLD }));
|
|
218
197
|
}
|
|
@@ -280,27 +259,35 @@ function types(m) {
|
|
|
280
259
|
}
|
|
281
260
|
|
|
282
261
|
/** THE CHEAT SHEET (docs/tui.md, "The cheat sheet"): the keys that apply now, one per row, the
|
|
283
|
-
* leader first in every focus (`
|
|
284
|
-
* the leader waits for its key it is the
|
|
285
|
-
* the
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
262
|
+
* leader first in every focus (`Ctrl+X commands`), then the palette, `help` and `quit` last. While
|
|
263
|
+
* the leader waits for its key it is the same: nothing is drawn for the wait, and the help lists
|
|
264
|
+
* the leader's table (views/help.mjs). While what is typed goes to
|
|
265
|
+
* the agent the TUI reads the leader and the chords only: the leader then Esc gives the list the
|
|
266
|
+
* focus, and the leader twice types the leader into the terminal; while the terminal confirms the
|
|
267
|
+
* kitty keyboard protocol, or in the Alt family, whose chords all come without it, the chords lead
|
|
268
|
+
* there (docs/tui.md, "Chords"; chordHints), the leader's hints after them, and the leader is the
|
|
269
|
+
* last given up; else the leader's lead, and the arrows, the chords that come then, follow them
|
|
270
|
+
* (the first given up). In the palette
|
|
271
|
+
* (its group keys last, where the TUI has them, so the first given up: paletteGroups), the spawn prompt
|
|
272
|
+
* (spawnHints), a confirmation, the filter field, the help and the switcher, how to work them: the
|
|
273
|
+
* keys they read are their own, so they are the TUI's words, but for the confirmation's close key and the
|
|
289
274
|
* field's clear, which are the user's. Else it is small: a view's list or its detail names what
|
|
290
|
-
* Enter does now, and the rest stays the leader's
|
|
275
|
+
* Enter does now, and the rest stays the leader's, the palette's and the help's. In the list
|
|
291
276
|
* of instances Enter is `open` while it would open the selected agent's terminal and `focus
|
|
292
277
|
* terminal` on the row whose terminal is open; while another machine is asked first, the key that
|
|
293
278
|
* gives the open up (`stop opening`) stands in its place. In the Souls view Enter is the detail
|
|
294
279
|
* from the list and the soul's instances from the detail; in the Capabilities view the detail,
|
|
295
280
|
* and from it the marked soul. With the detail's focus the key that goes back to the list
|
|
296
281
|
* (`Tab back`) comes before it, and `spawn` after it where it spawns (the list of instances, the
|
|
297
|
-
* Souls view of a workspace of this machine)
|
|
298
|
-
*
|
|
282
|
+
* Souls view of a workspace of this machine), then in the Instances view `workspaces` (the
|
|
283
|
+
* list of workspaces' focus). With that focus: the open action's key opens, the up and down
|
|
284
|
+
* actions' move, the close action's goes back, and `workspaces` again is the switcher (`all
|
|
285
|
+
* workspaces`), each by its first key as tui.json binds it. An action with no key (tui.json may unbind one) has no hint. The views have no
|
|
286
|
+
* hint: the accordion names their keys. When rows are short the sheet
|
|
299
287
|
* gives up rows from its end (keptHints), down to the leader alone. */
|
|
300
288
|
function cheatSheet(m) {
|
|
301
289
|
const action = (id) => (m.actions ?? []).find((a) => a.id === id && a.keys.length);
|
|
302
290
|
const hint = (id, label) => { const a = action(id); return a ? made(id, keyText(keyLabel(a.keys[0])), label ?? a.label) : null; };
|
|
303
|
-
if (m.leader) return leaderHints(m);
|
|
304
291
|
const led = (list) => [made("leader", leaderText(m), "commands"), ...list.filter(Boolean)];
|
|
305
292
|
const soul = m.view === "souls" && m.souls ? m.souls : null;
|
|
306
293
|
const capability = m.view === "capabilities" && m.capabilities ? m.capabilities : null;
|
|
@@ -309,9 +296,10 @@ function cheatSheet(m) {
|
|
|
309
296
|
const listing = !["help", "switcher", "souls", "capabilities"].includes(m.view);
|
|
310
297
|
if (listing && m.terminal?.focus === "terminal" && !m.palette && !m.spawn) {
|
|
311
298
|
const label = backKeyLabel(m.detachKey), list = keyLabel(LEADER.find((entry) => entry.does === "list").keys[0]);
|
|
312
|
-
|
|
299
|
+
const leader = [made("list", keyText(`${label} ${list}`), "the list"), made("again", keyText(`${label} ${label}`), types(m))];
|
|
300
|
+
return m.chordsLead ? [...chordHints(m), ...led(leader)] : [...led(leader), ...chordHints(m)];
|
|
313
301
|
}
|
|
314
|
-
if (m.palette) return led([own("run", "Enter", "run"), own("move", "Up/Down", "move"), own("close", "Esc", "close")]);
|
|
302
|
+
if (m.palette) return led([own("run", "Enter", "run"), own("move", "Up/Down", "move"), own("close", "Esc", "close"), paletteGroups(m)]);
|
|
315
303
|
if (m.spawn) return led(spawnHints(m.spawn, m.ascii));
|
|
316
304
|
if (m.view !== "help" && filter?.editing) return led([own("keep", "Enter", "keep"), hint("close", "clear")]);
|
|
317
305
|
if (m.view === "act" && m.act) {
|
|
@@ -324,6 +312,13 @@ function cheatSheet(m) {
|
|
|
324
312
|
// Esc closes the switcher only onto a view, and there is none before a workspace is opened.
|
|
325
313
|
// Remove stands on a row of this computer's deployments list only, after the keys that move about.
|
|
326
314
|
if (m.view === "switcher") return led([hint("palette"), ...["open", "filter", ...(m.filter?.query ? ["close", "refresh"] : ["refresh", ...(m.open ? ["close"] : [])]), ...(m.switcher?.removable ? ["remove"] : [])].map((id) => hint(id)), hint("help"), hint("quit")]);
|
|
315
|
+
// The list of workspaces with the focus: its keys, and `w` again for the switcher.
|
|
316
|
+
// The keys are the actions' as tui.json binds them: an action with no key has no hint.
|
|
317
|
+
if (listing && m.workspaces?.focused) {
|
|
318
|
+
const moves = [action("up"), action("down")].filter(Boolean);
|
|
319
|
+
const move = moves.length ? made("move", keyText(keysTogether(moves.map((a) => a.keys[0]))), "move") : null;
|
|
320
|
+
return led([hint("open", "open"), move, hint("close", "back"), hint("workspaces", "all workspaces"), hint("help"), hint("quit")]);
|
|
321
|
+
}
|
|
327
322
|
// A view's list or its detail: a small sheet; the rest is the leader's, the palette's and the help's.
|
|
328
323
|
const asking = listing && m.opening?.phase === "preflight";
|
|
329
324
|
const enter = asking ? [hint("close", "stop opening")] : listing && m.onTerminal ? [hint("open", "focus terminal")] : listing && m.openable ? [hint("open")]
|
|
@@ -331,7 +326,35 @@ function cheatSheet(m) {
|
|
|
331
326
|
: capability?.detail ? (capability.focus !== "detail" ? [hint("open", "detail")] : capability.mark >= 0 ? [hint("open", "soul")] : []) : [];
|
|
332
327
|
const detailed = soul ? soul.focus === "detail" && Boolean(soul.detail) : capability ? capability.focus === "detail" && Boolean(capability.detail) : listing && m.focus === "detail";
|
|
333
328
|
const spawns = listing || (soul && soul.local !== false);
|
|
334
|
-
return led([hint("palette"), ...(detailed ? [hint("detail", "back")] : []), ...enter, ...(spawns ? [hint("spawn")] : []), hint("help"), hint("quit")]);
|
|
329
|
+
return led([hint("palette"), ...(detailed ? [hint("detail", "back")] : []), ...enter, ...(spawns ? [hint("spawn")] : []), ...(listing ? [hint("workspaces")] : []), hint("help"), hint("quit")]);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** The palette's own keys as one hint (docs/tui.md, "The palette"): the first row of the group
|
|
333
|
+
* before and of the next, `Alt+Shift+Up/Down group` (keysTogether), from the model's
|
|
334
|
+
* `paletteKeys` (views/help.mjs paletteGroupKeys); null where the TUI has none (macOS). */
|
|
335
|
+
function paletteGroups(m) {
|
|
336
|
+
const pair = paletteGroupKeys(m.paletteKeys);
|
|
337
|
+
return pair === null ? null : own("group", keysTogether(pair), "group");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** The chords a terminal's cheat sheet names while they lead it (chordHints), in this order, a
|
|
341
|
+
* pair as one hint, each with the TUI's word: what is reached most from a terminal. */
|
|
342
|
+
const SHEET_CHORDS = Object.freeze([
|
|
343
|
+
Object.freeze([["palette"], "palette"]),
|
|
344
|
+
Object.freeze([["previous", "next"], "agent"]),
|
|
345
|
+
Object.freeze([["tab-previous", "tab-next"], "tab"]),
|
|
346
|
+
Object.freeze([["close-terminal"], "close"]),
|
|
347
|
+
Object.freeze([["zoom"], "zoom"]),
|
|
348
|
+
]);
|
|
349
|
+
/** The chord hints of a terminal's focus (docs/tui.md, "Chords"): those of SHEET_CHORDS read now
|
|
350
|
+
* (the model's `chords`: tui.json may have taken a key; outside the Alt family, without the
|
|
351
|
+
* protocol, the arrows alone), the tabs' only
|
|
352
|
+
* with two tabs or more, as the leader's table has them. A pair's keys share their modifiers:
|
|
353
|
+
* `Alt+Shift+Up/Down` (keysTogether). They stand in a block of their own (cheatRows). */
|
|
354
|
+
function chordHints(m) {
|
|
355
|
+
const keyOf = new Map((m.chords ?? []).map(([key, does]) => [does, key]));
|
|
356
|
+
return SHEET_CHORDS.filter(([list]) => list.every((does) => keyOf.has(does)) && (list[0] !== "tab-previous" || (m.tabs?.length ?? 0) > 1))
|
|
357
|
+
.map(([list, word]) => ({ ...made(`chord-${list[0]}`, keyText(keysTogether(list.map((does) => keyOf.get(does)))), word), block: "chords" }));
|
|
335
358
|
}
|
|
336
359
|
|
|
337
360
|
/** The spawn prompt's hints (docs/tui.md, "Spawning an agent"): the keys the prompt reads are its
|
|
@@ -343,61 +366,52 @@ function spawnHints(s, ascii) {
|
|
|
343
366
|
: [...(s.enter ? [own("enter", "Enter", ownEllipsis(s.enter, ascii))] : []), own("next", "Tab", "next"), own("back", "Shift+Tab", "back"), own("esc", "Esc", "back")];
|
|
344
367
|
}
|
|
345
368
|
|
|
346
|
-
/** The
|
|
347
|
-
|
|
348
|
-
* that need a terminal are named only while one is open, the tabs' only with two or more, and the
|
|
349
|
-
* split's only where they apply; while what is typed goes to the agent, the leader again, which
|
|
350
|
-
* types it there. The last, the list's, is never given up. */
|
|
351
|
-
function leaderHints(m) {
|
|
352
|
-
const by = (does) => LEADER.find((entry) => entry.does === does);
|
|
353
|
-
const one = (does) => { const entry = by(does); return own(does, keyLabel(entry.keys[0]), entry.label); };
|
|
354
|
-
const keysOf = (list) => list.map((does) => keyLabel(by(does).keys[0])).join("/");
|
|
355
|
-
const views = keysOf(["instances", "souls", "capabilities"]);
|
|
356
|
-
const typing = m.terminal?.focus === "terminal" && m.view === "instances" && !m.palette && !m.spawn;
|
|
357
|
-
return [
|
|
358
|
-
made("leader", leaderText(m), "then"),
|
|
359
|
-
own("palette", keyLabel(by("palette").keys[0]), "palette"),
|
|
360
|
-
own("views", views === "1/2/3" ? "1-3" : views, "views"),
|
|
361
|
-
own("instance", keysOf(["previous", "next"]), "instance"),
|
|
362
|
-
...(m.terminal ? [one("zoom"), one("close-terminal")] : []),
|
|
363
|
-
// With two tabs or more, the keys that move between them.
|
|
364
|
-
...((m.tabs?.length ?? 0) > 1 ? [own("tabs", keysOf(["tab-previous", "tab-next"]), "tab")] : []),
|
|
365
|
-
// The split's (docs/tui.md, "Splits"): to split while there is one group; with two, the next
|
|
366
|
-
// group, and the move of the shown tab, or the close of the focused group while it is empty.
|
|
367
|
-
...(m.panelOpen && !m.split ? [own("split", keysOf(["split-right", "split-down"]), "split")] : []),
|
|
368
|
-
...(m.split ? [one("group-next"), ...(m.terminal ? [one("tab-move")] : [one("group-close")])] : []),
|
|
369
|
-
own("acts", keysOf(["stop", "restart", "start", "retire"]), "acts"),
|
|
370
|
-
one("filter"), one("workspaces"), one("help"),
|
|
371
|
-
...(typing ? [made("again", leaderText(m), types(m))] : []),
|
|
372
|
-
one("list"),
|
|
373
|
-
];
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/** The hints that stand in `count` rows: given up from the end, down to the leader alone; the
|
|
377
|
-
* leader's hint keeps its last, the list's, while it has two rows. */
|
|
378
|
-
function keptHints(m, hints, count) {
|
|
369
|
+
/** The hints that stand in `count` rows: given up from the end, down to the leader alone (givenUp). */
|
|
370
|
+
function keptHints(hints, count) {
|
|
379
371
|
if (count >= hints.length) return hints;
|
|
380
|
-
|
|
381
|
-
|
|
372
|
+
let kept = hints;
|
|
373
|
+
while (kept.length > Math.max(1, count)) kept = givenUp(kept);
|
|
374
|
+
return kept;
|
|
375
|
+
}
|
|
376
|
+
/** `hints` with one given up: the last but the leader's (`commands`), which goes last of all. In a
|
|
377
|
+
* sheet that leads with the leader that is the last; in one that leads with the chords (a
|
|
378
|
+
* terminal's, under the kitty keyboard protocol) the leader stays after them. */
|
|
379
|
+
function givenUp(hints) {
|
|
380
|
+
const at = hints.findLastIndex((h) => h.id !== "leader");
|
|
381
|
+
return at < 0 ? hints.slice(0, -1) : [...hints.slice(0, at), ...hints.slice(at + 1)];
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/** The cheat sheet's rows, `cols` wide: each hint's key in bold from the margin, and what it does
|
|
385
|
-
* in a column of its own after the widest key; a word is cut at the edge.
|
|
385
|
+
* in a column of its own after the widest key; a word is cut at the edge. The hints of a `block`
|
|
386
|
+
* (the chords') have a column of their own, after their own widest key, and as far left as
|
|
387
|
+
* leaves their words whole: those words are the TUI's own and short, where their keys are long
|
|
388
|
+
* (`Alt+Shift+Left/Right` in the 30 cells beside a terminal). */
|
|
386
389
|
function cheatRows(hints, cols) {
|
|
387
390
|
const edge = cols - MARGIN;
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{
|
|
392
|
-
|
|
393
|
-
|
|
391
|
+
const columns = new Map();
|
|
392
|
+
for (const h of hints) {
|
|
393
|
+
const c = columns.get(h.block) ?? { widest: 0, word: 6 };
|
|
394
|
+
columns.set(h.block, { widest: Math.max(c.widest, h.key.width), word: h.block === undefined ? c.word : Math.max(c.word, h.word.width) });
|
|
395
|
+
}
|
|
396
|
+
return hints.map((h) => {
|
|
397
|
+
const c = columns.get(h.block), wordCol = Math.min(MARGIN + c.widest + GAP, Math.max(MARGIN + 1, edge - c.word));
|
|
398
|
+
return [
|
|
399
|
+
{ col: MARGIN, text: h.key.text, style: BOLD, width: Math.max(0, Math.min(h.key.width, wordCol - 1 - MARGIN)) },
|
|
400
|
+
...h.word.spans.map((span) => ({ ...span, col: wordCol + span.col, width: Math.max(0, Math.min(span.width, edge - wordCol - span.col)) })),
|
|
401
|
+
].filter((span) => span.width > 0);
|
|
402
|
+
});
|
|
394
403
|
}
|
|
395
404
|
|
|
405
|
+
/** The cheat sheet a title row carries (withKeys): where only some chords are read (no kitty
|
|
406
|
+
* keyboard protocol, a family other than Alt) the arrows follow the leader's hints in the sheet's
|
|
407
|
+
* rows, but a title row keeps to the leader's; where all are, the chords lead there as in the rows. */
|
|
408
|
+
const titleSheet = (m) => cheatSheet(m).filter((h) => m.chordsLead || h.block !== "chords");
|
|
409
|
+
|
|
396
410
|
/** An overlay's or a detail page's first row on a narrow terminal, where it has the whole screen:
|
|
397
411
|
* its essential keys (the cheat sheet's, but for the leader, the palette, help and quit) at the
|
|
398
412
|
* right, dim, as many as fit after what the row holds, given up from the end. With `first`, the
|
|
399
413
|
* first key always stands (a detail page's way back): what the row holds is cut to leave it room. */
|
|
400
|
-
function withKeys(given, hints, cols, { skip = ["leader", "palette", "help", "quit"],
|
|
414
|
+
function withKeys(given, hints, cols, { skip = ["leader", "palette", "help", "quit"], first = false } = {}) {
|
|
401
415
|
const keys = hints.filter((h) => !skip.includes(h.id));
|
|
402
416
|
const widthOf = (list) => list.reduce((sum, h) => sum + h.key.width + 1 + h.word.width, 0) + Math.max(0, list.length - 1) * GAP;
|
|
403
417
|
const limit = first && keys.length ? cols - MARGIN - widthOf(keys.slice(0, 1)) - GAP : Infinity;
|
|
@@ -406,8 +420,8 @@ function withKeys(given, hints, cols, { skip = ["leader", "palette", "help", "qu
|
|
|
406
420
|
// What the row holds ends where its text does: a span may be given more cells than its text takes.
|
|
407
421
|
const end = row.reduce((most, span) => (span.text !== undefined ? Math.max(most, span.col + Math.min(span.width ?? Infinity, textWidth(textOf(span.text)))) : most), 0);
|
|
408
422
|
let kept = keys;
|
|
409
|
-
// Given up from the end
|
|
410
|
-
while (kept.length && end + GAP + widthOf(kept) > cols - MARGIN) kept =
|
|
423
|
+
// Given up from the end, the leader last (givenUp).
|
|
424
|
+
while (kept.length && end + GAP + widthOf(kept) > cols - MARGIN) kept = givenUp(kept);
|
|
411
425
|
const spans = [];
|
|
412
426
|
let col = cols - MARGIN - widthOf(kept);
|
|
413
427
|
for (const h of kept) {
|
|
@@ -428,7 +442,8 @@ function listOf(m, g) {
|
|
|
428
442
|
}
|
|
429
443
|
|
|
430
444
|
/** The sidebar (docs/tui.md, "What it shows") in `rows`, from column 0 in the sidebar's width:
|
|
431
|
-
* the title; what stands under it (sayings); an empty row
|
|
445
|
+
* the title; what stands under it (sayings); an empty row, which a passing line takes (layout's
|
|
446
|
+
* `passing`); the views, the open one's heading
|
|
432
447
|
* with its list (`list`, trailing empty rows left out) under it and a rule between the views
|
|
433
448
|
* before it and its heading, and between its list and the views after it; a rule, then the
|
|
434
449
|
* cheat sheet. It flows from the top. The list keeps its rows ahead of the cheat sheet: when both
|
|
@@ -438,12 +453,14 @@ function sidebar(m, g, rows, list) {
|
|
|
438
453
|
const cols = g.listCols;
|
|
439
454
|
let r = 0;
|
|
440
455
|
const put = (spans) => { if (r < rows.length) rows[r] = spans; r += 1; };
|
|
441
|
-
|
|
456
|
+
if (m.workspaces) workspaceRows(m.workspaces, cols, { ascii: m.ascii, colour: m.colour }).forEach(put);
|
|
457
|
+
else put(titleRow(m, cols));
|
|
442
458
|
sayings(m, g).forEach(put);
|
|
443
459
|
let n = list.length;
|
|
444
460
|
while (n > 0 && list[n - 1].length === 0) n -= 1;
|
|
445
461
|
const hints = cheatSheet(m), room = g.room;
|
|
446
462
|
const [empty, count, shownRows] = n + 1 + hints.length <= room ? [1, hints.length, n] : n + 2 <= room ? [1, room - 1 - n, n] : [0, 1, Math.min(n, room - 1)];
|
|
463
|
+
if (empty && g.passing) rows[r] = placed(g.passing, MARGIN);
|
|
447
464
|
r += empty;
|
|
448
465
|
const at = VIEWS.findIndex((view) => view.id === g.open);
|
|
449
466
|
VIEWS.forEach((view, i) => {
|
|
@@ -454,7 +471,7 @@ function sidebar(m, g, rows, list) {
|
|
|
454
471
|
if (i < VIEWS.length - 1) put(rule(cols, m.ascii));
|
|
455
472
|
});
|
|
456
473
|
put(rule(cols, m.ascii));
|
|
457
|
-
cheatRows(keptHints(
|
|
474
|
+
cheatRows(keptHints(hints, count), cols).forEach(put);
|
|
458
475
|
}
|
|
459
476
|
|
|
460
477
|
/** The rule between the sidebar and the main area, over the whole height. */
|
|
@@ -514,7 +531,7 @@ function framed(m, size) {
|
|
|
514
531
|
const overlay = (drawn) => {
|
|
515
532
|
if (g.wide) { sidebar(m, g, rows, listOf(m, g)); barred(m, rows, g.listCols); }
|
|
516
533
|
drawn.forEach((spans, i) => { if (i < size.rows) rows[i] = [...rows[i], ...placed(spans, main.col)]; });
|
|
517
|
-
if (!g.wide) rows[0] = withKeys(rows[0],
|
|
534
|
+
if (!g.wide) rows[0] = withKeys(rows[0], titleSheet(m), cols);
|
|
518
535
|
};
|
|
519
536
|
|
|
520
537
|
// The palette, whatever is under it.
|
|
@@ -539,7 +556,7 @@ function framed(m, size) {
|
|
|
539
556
|
}
|
|
540
557
|
// The help, under its top row (readRow).
|
|
541
558
|
if (m.view === "help") {
|
|
542
|
-
const drawn = help(m.actions, { cols: main.cols, rows: size.rows - 1 }, { top: m.helpTop, ascii: m.ascii, detachKey: m.detachKey, chords: m.chords ?? null });
|
|
559
|
+
const drawn = help(m.actions, { cols: main.cols, rows: size.rows - 1 }, { top: m.helpTop, ascii: m.ascii, detachKey: m.detachKey, chords: m.chords ?? null, chordsLead: m.chordsLead === true, paletteKeys: m.paletteKeys ?? null, keys: m.keys ?? null });
|
|
543
560
|
overlay([readRow(m), ...drawn.rows]);
|
|
544
561
|
return { rows, page: Math.max(1, g.page), extent: drawn.extent, room: Math.max(1, size.rows - 1) };
|
|
545
562
|
}
|
|
@@ -582,9 +599,9 @@ function framed(m, size) {
|
|
|
582
599
|
if (paged) rows[0] = withKeys(rows[0], cheatSheet(m), cols, { first: true });
|
|
583
600
|
}
|
|
584
601
|
// Over the whole screen no cheat sheet is drawn: the terminal's title row, the TUI's own, carries
|
|
585
|
-
// its keys at the right instead (the leader, then Esc for the list),
|
|
586
|
-
//
|
|
587
|
-
if (zoomed) rows[area.title] =
|
|
602
|
+
// its keys at the right instead (the leader, then Esc for the list), the same while the leader
|
|
603
|
+
// waits.
|
|
604
|
+
if (zoomed) rows[area.title] = withKeys(rows[area.title], titleSheet(m), cols, { skip: ["again"] });
|
|
588
605
|
// The focused group's terminal, when it shows one: the agent's cursor, where the agent has it,
|
|
589
606
|
// while what is typed goes to the agent.
|
|
590
607
|
const shownArea = area !== null && area.id !== null && m.terminal ? { title: area.title, top: area.top, col: area.col, cols: area.cols, rows: area.rows, whole: area.whole } : null;
|
|
@@ -679,25 +696,57 @@ function terminalAt(m, size, g) {
|
|
|
679
696
|
|
|
680
697
|
/** A hidden tab's mark for output since it was last shown (docs/tui.md, "Tabs"). */
|
|
681
698
|
const ACTIVITY = "\u2022";
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
699
|
+
/** What stands between a tab's agent and its machine, another machine's: ` · ` (` - ` in ASCII). */
|
|
700
|
+
const tabDot = (ascii) => (ascii ? "-" : "\u00b7");
|
|
701
|
+
/** The divider between two tabs: one dim cell. */
|
|
702
|
+
const tabDivider = (ascii) => (ascii ? "|" : "\u2502");
|
|
703
|
+
/** The shown tab's own mark, which no style is needed to read: brackets in place of its side cells. */
|
|
704
|
+
const SHOWN_SIDES = Object.freeze(["[", "]"]);
|
|
705
|
+
/** A hidden tab's look: dim. Its activity mark is not: it is what a glance looks for. */
|
|
706
|
+
const HIDDEN = DIM;
|
|
707
|
+
/** The machine and the number of the shown tab while what is typed goes to it: dim, in the tab's
|
|
708
|
+
* reverse video. */
|
|
709
|
+
const FOCUSED_DIM = style({ dim: true, reverse: true });
|
|
710
|
+
|
|
711
|
+
/** A tab's number at `index` in a strip of `count` tabs (docs/tui.md, "Tabs"): the N whose tab-N
|
|
712
|
+
* chord shows it (store.mjs TAB_PICKS). The first eight are 1 to 8, the last of nine or more is 9,
|
|
713
|
+
* and any other past the eighth has none (null). */
|
|
714
|
+
export const tabNumber = (index, count) => (index < 8 ? index + 1 : index === count - 1 ? 9 : null);
|
|
715
|
+
|
|
716
|
+
/** THE TAB BAR (docs/tui.md, "Tabs"), the top row of a group's region whenever it shows a tab, one
|
|
717
|
+
* or many, as a terminal's own tabs read: each tab in order, a dim `│` (`|` in ASCII) between two.
|
|
718
|
+
* A tab is its agent's name with a cell on each side, `•` (`*` in ASCII) after the name of a hidden
|
|
719
|
+
* one whose agent wrote since it was shown, and ` · <machine>` dim (` - ` in ASCII) inside it for
|
|
720
|
+
* another machine's agent. The shown tab reads as the front one: `[` and `]` stand in its side
|
|
721
|
+
* cells (a mark no style is needed for: it holds under NO_COLOR and in ASCII), its name is bold,
|
|
722
|
+
* and the whole tab is in reverse video while what is typed goes to it; a hidden tab is dim.
|
|
723
|
+
* Each tab ends with its number in its group's strip (tabNumber), after a blank cell and before
|
|
724
|
+
* its closing side, dim (dim in the reverse video of the focused shown tab): a position, the same
|
|
725
|
+
* in every chord family, drawn while a chord shows the Nth tab (`numbers`, the model's
|
|
726
|
+
* `tabNumbers`: never on macOS, where none reaches the TUI). The numbers are drawn only while every tab fits
|
|
727
|
+
* whole with them, its name and its machine; else no tab has one, and the row is cut as follows.
|
|
728
|
+
* What does not fit is cut in this order: the hidden tabs' machines, then their names, each to an
|
|
729
|
+
* equal share of what the shown tab leaves with `…`, then the shown tab's machine, then the hidden
|
|
730
|
+
* tabs farthest from the shown one are left out (each takes its divider with it). The shown tab's
|
|
731
|
+
* name stays whole while the row can hold it, and is cut last. */
|
|
732
|
+
function stripRow(given, area, { focused, ascii, numbers = true }) {
|
|
733
|
+
const mark = ascii ? "*" : ACTIVITY, dot = tabDot(ascii);
|
|
734
|
+
const tabs = given.map((tab, i) => ({ ...tab, name: measured(tab.name), machine: tab.machine ? measured(tab.machine) : null, mark: !tab.shown && tab.activity === true, number: tabNumber(i, given.length) }));
|
|
735
|
+
const machineCells = (tab) => (tab.machine ? 3 + tab.machine.width : 0);
|
|
736
|
+
// The numbers, while drawn: a blank cell and the digit.
|
|
737
|
+
let numbered = numbers;
|
|
738
|
+
const numberCells = (tab) => (numbered && tab.number !== null ? 2 : 0);
|
|
739
|
+
const cellsOf = (tab, { machine, name = tab.name.width, dropped = false }) => (dropped ? 0 : 1 + name + (tab.mark ? 1 : 0) + (machine ? machineCells(tab) : 0) + numberCells(tab) + 1);
|
|
696
740
|
const plan = tabs.map((tab) => ({ machine: true, name: tab.name.width, dropped: false }));
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
741
|
+
// Each drawn tab after the first has its divider before it.
|
|
742
|
+
const total = () => tabs.reduce((sum, tab, i) => sum + cellsOf(tab, plan[i]), 0) + Math.max(0, plan.filter((p) => !p.dropped).length - 1);
|
|
743
|
+
const fits = () => total() <= area.cols;
|
|
744
|
+
// The numbers go first and all together: every tab whole with them, or none has one.
|
|
745
|
+
if (!fits()) numbered = false;
|
|
746
|
+
const shown = Math.max(0, tabs.findIndex((tab) => tab.shown));
|
|
747
|
+
// The least a hidden tab is drawn in: a cell of its name (the cut mark), its mark, a cell each
|
|
748
|
+
// side, and its divider.
|
|
749
|
+
const least = (tab) => 4 + (tab.mark ? 1 : 0);
|
|
701
750
|
// The shown tab's cells are taken first; the hidden ones share the rest equally. Those that do
|
|
702
751
|
// not get even their least are left out, the farthest from the shown tab first.
|
|
703
752
|
const share = () => {
|
|
@@ -705,42 +754,60 @@ function stripRow(given, area, { focused, ascii }) {
|
|
|
705
754
|
const near = tabs.map((tab, i) => i).filter((i) => i !== shown).sort((a, b) => Math.abs(a - shown) - Math.abs(b - shown) || a - b);
|
|
706
755
|
const kept = [];
|
|
707
756
|
for (const i of near) { plan[i].dropped = left - least(tabs[i]) < 0; if (!plan[i].dropped) { kept.push(i); left -= least(tabs[i]); } }
|
|
708
|
-
const room = area.cols - cellsOf(tabs[shown], plan[shown]), each = Math.floor(room / Math.max(1, kept.length));
|
|
757
|
+
const room = area.cols - cellsOf(tabs[shown], plan[shown]) - kept.length, each = Math.floor(room / Math.max(1, kept.length));
|
|
709
758
|
for (const i of kept) plan[i].name = Math.max(1, Math.min(tabs[i].name.width, each - 2 - (tabs[i].mark ? 1 : 0)));
|
|
710
759
|
while (!fits() && kept.length) plan[kept.pop()].dropped = true;
|
|
711
760
|
};
|
|
712
761
|
if (!fits()) tabs.forEach((tab, i) => { if (i !== shown) plan[i].machine = false; });
|
|
713
762
|
if (!fits()) share();
|
|
714
|
-
if (plan.some((p) => p.dropped) && plan[shown].machine && tabs[shown].machine) { plan[shown].machine = false; plan.forEach((p) => { p.dropped = false; }); share(); }
|
|
763
|
+
if ((!fits() || plan.some((p) => p.dropped)) && plan[shown].machine && tabs[shown].machine) { plan[shown].machine = false; plan.forEach((p) => { p.dropped = false; }); share(); }
|
|
764
|
+
// A shown name wider than the row itself: cut, its brackets kept.
|
|
765
|
+
if (cellsOf(tabs[shown], plan[shown]) > area.cols) plan[shown].name = Math.max(1, area.cols - 2);
|
|
766
|
+
const cut = (tab, p) => (p.name < tab.name.width ? shownLines(textOf(tab.name.text), p.name, 1, { ascii })[0] ?? lit("") : tab.name.text);
|
|
715
767
|
const row = [];
|
|
716
|
-
let col = area.col;
|
|
717
768
|
const end = area.col + area.cols;
|
|
769
|
+
let col = area.col, first = true;
|
|
770
|
+
// `text` null is a blank cell (a hidden tab's side): its cells are passed over.
|
|
771
|
+
const put = (text, width, look) => {
|
|
772
|
+
const w = Math.max(0, Math.min(width, end - col));
|
|
773
|
+
if (w > 0 && text !== null) row.push({ col, text, width: w, ...(look ? { style: look } : {}) });
|
|
774
|
+
col += width;
|
|
775
|
+
};
|
|
718
776
|
tabs.forEach((tab, i) => {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
777
|
+
const p = plan[i];
|
|
778
|
+
if (p.dropped || col >= end) return;
|
|
779
|
+
if (!first) put(lit(tabDivider(ascii)), 1, DIM);
|
|
780
|
+
first = false;
|
|
781
|
+
if (col >= end) return;
|
|
782
|
+
const front = tab.shown, reversed = front && focused;
|
|
783
|
+
const look = front ? (reversed ? FOCUSED : BOLD) : HIDDEN;
|
|
784
|
+
// In reverse while what is typed goes to it: the whole tab, its sides and machine included.
|
|
785
|
+
if (reversed) row.push({ col, width: Math.max(0, Math.min(cellsOf(tab, p), end - col)), style: FOCUSED });
|
|
786
|
+
const [left, right] = front ? SHOWN_SIDES.map((side) => lit(side)) : [null, null];
|
|
787
|
+
put(left, 1, look);
|
|
788
|
+
const name = cut(tab, p);
|
|
789
|
+
put(name, Math.min(p.name, textWidth(textOf(name))), look);
|
|
790
|
+
if (tab.mark) put(lit(mark), 1, null);
|
|
791
|
+
if (p.machine && tab.machine) {
|
|
792
|
+
const machineLook = reversed ? FOCUSED_DIM : DIM;
|
|
793
|
+
put(null, 1, null);
|
|
794
|
+
put(lit(dot), 1, machineLook);
|
|
795
|
+
put(null, 1, null);
|
|
796
|
+
put(tab.machine.text, tab.machine.width, machineLook);
|
|
732
797
|
}
|
|
733
|
-
|
|
798
|
+
if (numberCells(tab)) {
|
|
799
|
+
put(null, 1, null);
|
|
800
|
+
put(lit(String(tab.number)), 1, reversed ? FOCUSED_DIM : DIM);
|
|
801
|
+
}
|
|
802
|
+
put(right, 1, look);
|
|
734
803
|
});
|
|
735
804
|
return row;
|
|
736
805
|
}
|
|
737
806
|
|
|
738
|
-
/** The open terminal's rows from its
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
|
|
742
|
-
* first column and kept inside its cells. */
|
|
743
|
-
/** What an empty group shows (docs/tui.md, "Splits"), under an empty strip row: that Enter on an
|
|
807
|
+
/** The open terminal's rows from its top row: the tab bar (stripRow), then the shown agent's
|
|
808
|
+
* screen as the last capture made it (lib/panel.mjs, term/capture.mjs: spans of the agent's own
|
|
809
|
+
* text and styles), each row placed at the terminal's first column and kept inside its cells. */
|
|
810
|
+
/** What an empty group shows (docs/tui.md, "Splits"), under an empty tab bar row: that Enter on an
|
|
744
811
|
* agent in the list opens it here, in reverse while it is the focused group, then the leader's
|
|
745
812
|
* keys for the groups. */
|
|
746
813
|
const EMPTY_HINT = "Enter on an agent opens it here";
|
|
@@ -764,18 +831,9 @@ function regionRows(m, area) {
|
|
|
764
831
|
// The focused group's shown tab is in reverse while what is typed goes to it; the other group's
|
|
765
832
|
// is bold, never in reverse, so one terminal at a time reads as focused (T3).
|
|
766
833
|
const focused = area.focused && m.terminal?.focus === "terminal";
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
if (group.tabs.length > 1) title = stripRow(group.tabs, area, { focused, ascii: m.ascii });
|
|
771
|
-
else {
|
|
772
|
-
if (focused) title.push({ col: area.col, width: Math.min(area.cols, name.width + 2), style: FOCUSED });
|
|
773
|
-
title.push({ col: area.col + 1, text: name.text, style: focused ? FOCUSED : BOLD, width: Math.max(0, Math.min(name.width, area.cols - 2)) });
|
|
774
|
-
if (tab.machine) {
|
|
775
|
-
const where = measured(tab.machine), at = area.col + name.width + 3;
|
|
776
|
-
if (at + ON.length + 1 < area.col + area.cols) title.push({ col: at, text: lit(ON), style: DIM, width: ON.length }, { col: at + ON.length + 1, text: where.text, style: DIM, width: Math.max(0, area.col + area.cols - (at + ON.length + 1)) });
|
|
777
|
-
}
|
|
778
|
-
}
|
|
834
|
+
// A model made by hand may name its terminal and no tabs: its one tab is that terminal.
|
|
835
|
+
const tabs = group.tabs.length ? group.tabs : [{ name: m.terminal?.name, machine: m.terminal?.routed ? m.terminal.machine : null, shown: true, activity: false }];
|
|
836
|
+
const title = stripRow(tabs, area, { focused, ascii: m.ascii, numbers: m.tabNumbers !== false });
|
|
779
837
|
const screenOf = area.focused ? m.screen : m.screens?.get(group.shown) ?? null;
|
|
780
838
|
const lines = screenOf?.lines ?? [];
|
|
781
839
|
const body = Array.from({ length: area.rows }, (_, r) => (lines[r] ?? [])
|