@h-rig/cli 0.0.6-alpha.82 → 0.0.6-alpha.83
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/dist/bin/build-rig-binaries.js +40 -8
- package/dist/bin/rig.js +2798 -1440
- package/dist/src/app/board.js +62 -13
- package/dist/src/app-opentui/adapters/command.d.ts +2 -0
- package/dist/src/app-opentui/adapters/command.js +329 -0
- package/dist/src/app-opentui/adapters/common.js +2 -2
- package/dist/src/app-opentui/adapters/doctor.js +63 -14
- package/dist/src/app-opentui/adapters/fleet.js +84 -20
- package/dist/src/app-opentui/adapters/inbox.js +83 -19
- package/dist/src/app-opentui/adapters/init.js +87 -23
- package/dist/src/app-opentui/adapters/pi-attach.js +96 -34
- package/dist/src/app-opentui/adapters/run-detail.js +83 -19
- package/dist/src/app-opentui/adapters/server.js +100 -23
- package/dist/src/app-opentui/adapters/tasks.d.ts +11 -0
- package/dist/src/app-opentui/adapters/tasks.js +742 -94
- package/dist/src/app-opentui/bootstrap.d.ts +1 -6
- package/dist/src/app-opentui/bootstrap.js +13769 -12368
- package/dist/src/app-opentui/command-pty-host.d.ts +62 -0
- package/dist/src/app-opentui/command-pty-host.js +248 -0
- package/dist/src/app-opentui/events.js +1 -1
- package/dist/src/app-opentui/focus-manager.d.ts +14 -0
- package/dist/src/app-opentui/focus-manager.js +24 -0
- package/dist/src/app-opentui/index.js +3802 -2882
- package/dist/src/app-opentui/intent.js +154 -48
- package/dist/src/app-opentui/keymap.d.ts +20 -0
- package/dist/src/app-opentui/keymap.js +707 -0
- package/dist/src/app-opentui/launch-routing.d.ts +16 -0
- package/dist/src/app-opentui/launch-routing.js +55 -0
- package/dist/src/app-opentui/layout.js +2 -2
- package/dist/src/app-opentui/pi-host-child.js +66 -16
- package/dist/src/app-opentui/pi-pty-host.d.ts +9 -0
- package/dist/src/app-opentui/pi-pty-host.js +9 -11
- package/dist/src/app-opentui/registry.js +3231 -2403
- package/dist/src/app-opentui/render/ascii-fleet.d.ts +15 -0
- package/dist/src/app-opentui/render/ascii-fleet.js +82 -0
- package/dist/src/app-opentui/render/graphics.d.ts +1 -1
- package/dist/src/app-opentui/render/graphics.js +131 -16
- package/dist/src/app-opentui/render/image-visual-layer-worker.js +408 -957
- package/dist/src/app-opentui/render/image-visual-layer.d.ts +18 -10
- package/dist/src/app-opentui/render/image-visual-layer.js +386 -356
- package/dist/src/app-opentui/render/panel-layout.d.ts +38 -0
- package/dist/src/app-opentui/render/panel-layout.js +48 -0
- package/dist/src/app-opentui/render/panels.d.ts +2 -0
- package/dist/src/app-opentui/render/panels.js +62 -29
- package/dist/src/app-opentui/render/preloader.d.ts +10 -0
- package/dist/src/app-opentui/render/preloader.js +163 -0
- package/dist/src/app-opentui/render/scene.d.ts +3 -0
- package/dist/src/app-opentui/render/scene.js +12 -0
- package/dist/src/app-opentui/render/text.js +5 -1
- package/dist/src/app-opentui/render/type-bar.d.ts +2 -1
- package/dist/src/app-opentui/render/type-bar.js +51 -16
- package/dist/src/app-opentui/runtime-resources.d.ts +16 -0
- package/dist/src/app-opentui/runtime-resources.js +62 -0
- package/dist/src/app-opentui/runtime.js +2322 -1513
- package/dist/src/app-opentui/scenes/command.d.ts +3 -0
- package/dist/src/app-opentui/scenes/command.js +103 -0
- package/dist/src/app-opentui/scenes/doctor.d.ts +2 -1
- package/dist/src/app-opentui/scenes/doctor.js +53 -14
- package/dist/src/app-opentui/scenes/error.js +44 -14
- package/dist/src/app-opentui/scenes/fleet.js +40 -21
- package/dist/src/app-opentui/scenes/handoff.js +142 -27
- package/dist/src/app-opentui/scenes/help.js +63 -48
- package/dist/src/app-opentui/scenes/inbox.d.ts +2 -1
- package/dist/src/app-opentui/scenes/inbox.js +64 -17
- package/dist/src/app-opentui/scenes/init.d.ts +2 -1
- package/dist/src/app-opentui/scenes/init.js +62 -21
- package/dist/src/app-opentui/scenes/main.d.ts +2 -1
- package/dist/src/app-opentui/scenes/main.js +80 -24
- package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -1
- package/dist/src/app-opentui/scenes/run-detail.js +39 -25
- package/dist/src/app-opentui/scenes/server.d.ts +2 -1
- package/dist/src/app-opentui/scenes/server.js +71 -20
- package/dist/src/app-opentui/scenes/tasks.js +44 -22
- package/dist/src/app-opentui/state.js +70 -30
- package/dist/src/app-opentui/terminal-capabilities.d.ts +7 -0
- package/dist/src/app-opentui/terminal-capabilities.js +15 -0
- package/dist/src/app-opentui/types.d.ts +10 -2
- package/dist/src/commands/_doctor-checks.js +62 -13
- package/dist/src/commands/_operator-view.js +63 -13
- package/dist/src/commands/_pi-frontend.js +63 -13
- package/dist/src/commands/_preflight.js +64 -14
- package/dist/src/commands/_server-client.js +82 -18
- package/dist/src/commands/_snapshot-upload.js +62 -13
- package/dist/src/commands/connect.js +7 -1
- package/dist/src/commands/doctor.js +62 -13
- package/dist/src/commands/github.js +144 -23
- package/dist/src/commands/inbox.js +62 -13
- package/dist/src/commands/init.js +82 -18
- package/dist/src/commands/inspect.js +62 -13
- package/dist/src/commands/run.js +66 -13
- package/dist/src/commands/server.js +69 -14
- package/dist/src/commands/setup.js +62 -13
- package/dist/src/commands/stats.js +62 -13
- package/dist/src/commands/task-run-driver.js +62 -13
- package/dist/src/commands/task.js +65 -14
- package/dist/src/commands.js +227 -92
- package/dist/src/index.js +234 -99
- package/package.json +8 -9
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +0 -2
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +0 -1484
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type CommandPtyHostStatus = "starting" | "running" | "exited" | "failed";
|
|
2
|
+
export type CommandPtyHostSnapshot = {
|
|
3
|
+
readonly command: readonly string[];
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly status: CommandPtyHostStatus;
|
|
6
|
+
readonly cols: number;
|
|
7
|
+
readonly rows: number;
|
|
8
|
+
readonly lines: readonly string[];
|
|
9
|
+
readonly message?: string;
|
|
10
|
+
readonly exitCode?: number;
|
|
11
|
+
readonly signal?: string | null;
|
|
12
|
+
};
|
|
13
|
+
type CommandPtyInput = string | Uint8Array<ArrayBufferLike> | BufferSource;
|
|
14
|
+
export type CommandPtyHostOptions = {
|
|
15
|
+
readonly argv: readonly string[];
|
|
16
|
+
readonly projectRoot: string;
|
|
17
|
+
readonly cols: number;
|
|
18
|
+
readonly rows: number;
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
21
|
+
readonly onSnapshot?: (snapshot: CommandPtyHostSnapshot) => void;
|
|
22
|
+
readonly onExit?: (snapshot: CommandPtyHostSnapshot) => void;
|
|
23
|
+
readonly onError?: (error: unknown, snapshot: CommandPtyHostSnapshot) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare function getActiveCommandHost(): CommandPtyHost | null;
|
|
26
|
+
export declare function stopActiveCommandHost(reason?: string): void;
|
|
27
|
+
export declare function startCommandPtyHost(options: CommandPtyHostOptions): Promise<CommandPtyHost>;
|
|
28
|
+
export declare class CommandPtyHost {
|
|
29
|
+
private readonly argv;
|
|
30
|
+
private readonly projectRoot;
|
|
31
|
+
private readonly label;
|
|
32
|
+
private readonly env?;
|
|
33
|
+
private readonly onSnapshot?;
|
|
34
|
+
private readonly onExit?;
|
|
35
|
+
private readonly onError?;
|
|
36
|
+
private readonly terminal;
|
|
37
|
+
private readonly decoder;
|
|
38
|
+
private proc;
|
|
39
|
+
private pty;
|
|
40
|
+
private status;
|
|
41
|
+
private cols;
|
|
42
|
+
private rows;
|
|
43
|
+
private message;
|
|
44
|
+
private exitCode;
|
|
45
|
+
private signal;
|
|
46
|
+
private notifyTimer;
|
|
47
|
+
private _disposed;
|
|
48
|
+
constructor(options: CommandPtyHostOptions);
|
|
49
|
+
get disposed(): boolean;
|
|
50
|
+
get snapshot(): CommandPtyHostSnapshot;
|
|
51
|
+
start(): Promise<void>;
|
|
52
|
+
write(data: CommandPtyInput): void;
|
|
53
|
+
resize(cols: number, rows: number): void;
|
|
54
|
+
dispose(reason?: string, options?: {
|
|
55
|
+
readonly kill?: boolean;
|
|
56
|
+
readonly notify?: boolean;
|
|
57
|
+
}): void;
|
|
58
|
+
private handlePtyData;
|
|
59
|
+
private emitSnapshotSoon;
|
|
60
|
+
private createSnapshot;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/app-opentui/command-pty-host.ts
|
|
3
|
+
import { basename } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { Terminal as XtermTerminal } from "@xterm/headless";
|
|
6
|
+
var MIN_COLS = 40;
|
|
7
|
+
var MIN_ROWS = 10;
|
|
8
|
+
var MAX_ROWS = 300;
|
|
9
|
+
var MAX_SNAPSHOT_LINES = 420;
|
|
10
|
+
var SNAPSHOT_DELAY_MS = 80;
|
|
11
|
+
var fallbackCliScriptPath = fileURLToPath(new URL("../../bin/rig.ts", import.meta.url));
|
|
12
|
+
var activeHost = null;
|
|
13
|
+
function clampCols(cols) {
|
|
14
|
+
return Math.max(MIN_COLS, Math.trunc(cols || 120));
|
|
15
|
+
}
|
|
16
|
+
function clampRows(rows) {
|
|
17
|
+
return Math.max(MIN_ROWS, Math.min(MAX_ROWS, Math.trunc(rows || 36)));
|
|
18
|
+
}
|
|
19
|
+
function childCommandPrefix() {
|
|
20
|
+
const execName = basename(process.execPath).toLowerCase();
|
|
21
|
+
const currentEntry = process.argv[1];
|
|
22
|
+
if (execName === "bun" || execName === "bun.exe") {
|
|
23
|
+
return currentEntry ? [process.execPath, currentEntry] : [process.execPath, fallbackCliScriptPath];
|
|
24
|
+
}
|
|
25
|
+
return [process.execPath];
|
|
26
|
+
}
|
|
27
|
+
function withEnv(base) {
|
|
28
|
+
const env = {};
|
|
29
|
+
for (const [key, value] of Object.entries(base ?? process.env)) {
|
|
30
|
+
if (key === "NO_COLOR")
|
|
31
|
+
continue;
|
|
32
|
+
if (typeof value === "string")
|
|
33
|
+
env[key] = value;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
...env,
|
|
37
|
+
TERM: "xterm-256color",
|
|
38
|
+
COLORTERM: "truecolor",
|
|
39
|
+
FORCE_COLOR: env.FORCE_COLOR ?? "1",
|
|
40
|
+
RIG_PLAIN: "1",
|
|
41
|
+
RIG_OPENTUI_COMMAND_HOST: "1",
|
|
42
|
+
RIG_CLI_PLAIN_HELP: env.RIG_CLI_PLAIN_HELP ?? "1"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function commandLabel(argv, fallback) {
|
|
46
|
+
const command = argv.join(" ").trim();
|
|
47
|
+
return fallback?.trim() || (command ? `rig ${command}` : "rig");
|
|
48
|
+
}
|
|
49
|
+
function getActiveCommandHost() {
|
|
50
|
+
return activeHost && !activeHost.disposed ? activeHost : null;
|
|
51
|
+
}
|
|
52
|
+
function stopActiveCommandHost(reason = "detach") {
|
|
53
|
+
activeHost?.dispose(reason);
|
|
54
|
+
activeHost = null;
|
|
55
|
+
}
|
|
56
|
+
async function startCommandPtyHost(options) {
|
|
57
|
+
activeHost?.dispose("replace");
|
|
58
|
+
const host = new CommandPtyHost(options);
|
|
59
|
+
activeHost = host;
|
|
60
|
+
await host.start();
|
|
61
|
+
return host;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class CommandPtyHost {
|
|
65
|
+
argv;
|
|
66
|
+
projectRoot;
|
|
67
|
+
label;
|
|
68
|
+
env;
|
|
69
|
+
onSnapshot;
|
|
70
|
+
onExit;
|
|
71
|
+
onError;
|
|
72
|
+
terminal;
|
|
73
|
+
decoder = new TextDecoder("utf-8");
|
|
74
|
+
proc = null;
|
|
75
|
+
pty = null;
|
|
76
|
+
status = "starting";
|
|
77
|
+
cols;
|
|
78
|
+
rows;
|
|
79
|
+
message = "starting command";
|
|
80
|
+
exitCode;
|
|
81
|
+
signal;
|
|
82
|
+
notifyTimer = null;
|
|
83
|
+
_disposed = false;
|
|
84
|
+
constructor(options) {
|
|
85
|
+
this.argv = [...options.argv];
|
|
86
|
+
this.projectRoot = options.projectRoot;
|
|
87
|
+
this.label = commandLabel(options.argv, options.label);
|
|
88
|
+
this.env = options.env;
|
|
89
|
+
this.cols = clampCols(options.cols);
|
|
90
|
+
this.rows = clampRows(options.rows);
|
|
91
|
+
this.onSnapshot = options.onSnapshot;
|
|
92
|
+
this.onExit = options.onExit;
|
|
93
|
+
this.onError = options.onError;
|
|
94
|
+
this.terminal = new XtermTerminal({ allowProposedApi: true, cols: this.cols, rows: this.rows, scrollback: 2000 });
|
|
95
|
+
}
|
|
96
|
+
get disposed() {
|
|
97
|
+
return this._disposed;
|
|
98
|
+
}
|
|
99
|
+
get snapshot() {
|
|
100
|
+
return this.createSnapshot();
|
|
101
|
+
}
|
|
102
|
+
async start() {
|
|
103
|
+
if (this._disposed)
|
|
104
|
+
throw new Error("Command PTY host is disposed.");
|
|
105
|
+
if (typeof Bun.Terminal !== "function") {
|
|
106
|
+
throw new Error("Bun native PTY is unavailable in this runtime. Command host requires Bun.Terminal.");
|
|
107
|
+
}
|
|
108
|
+
const spawnOptions = {
|
|
109
|
+
cwd: this.projectRoot,
|
|
110
|
+
env: withEnv(this.env),
|
|
111
|
+
terminal: {
|
|
112
|
+
cols: this.cols,
|
|
113
|
+
rows: this.rows,
|
|
114
|
+
name: "xterm-256color",
|
|
115
|
+
data: (_terminal, data) => this.handlePtyData(data)
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const proc = Bun.spawn([...childCommandPrefix(), ...this.argv], spawnOptions);
|
|
119
|
+
if (!proc.terminal)
|
|
120
|
+
throw new Error("Bun did not attach a terminal to the command child process.");
|
|
121
|
+
this.proc = proc;
|
|
122
|
+
this.pty = proc.terminal;
|
|
123
|
+
this.status = "running";
|
|
124
|
+
this.message = "running";
|
|
125
|
+
this.emitSnapshotSoon(0);
|
|
126
|
+
proc.exited.then((exitCode) => {
|
|
127
|
+
if (this._disposed)
|
|
128
|
+
return;
|
|
129
|
+
this.status = exitCode === 0 ? "exited" : "failed";
|
|
130
|
+
this.exitCode = exitCode;
|
|
131
|
+
this.signal = null;
|
|
132
|
+
this.message = exitCode === 0 ? "completed" : `exited with code ${exitCode}`;
|
|
133
|
+
const snapshot = this.createSnapshot();
|
|
134
|
+
this.onSnapshot?.(snapshot);
|
|
135
|
+
this.onExit?.(snapshot);
|
|
136
|
+
if (activeHost === this)
|
|
137
|
+
activeHost = null;
|
|
138
|
+
this.dispose("exit", { kill: false, notify: false });
|
|
139
|
+
}).catch((error) => {
|
|
140
|
+
if (this._disposed)
|
|
141
|
+
return;
|
|
142
|
+
this.status = "failed";
|
|
143
|
+
this.message = error instanceof Error ? error.message : String(error);
|
|
144
|
+
const snapshot = this.createSnapshot();
|
|
145
|
+
this.onSnapshot?.(snapshot);
|
|
146
|
+
this.onError?.(error, snapshot);
|
|
147
|
+
if (activeHost === this)
|
|
148
|
+
activeHost = null;
|
|
149
|
+
this.dispose("error", { kill: false, notify: false });
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
write(data) {
|
|
153
|
+
if (this._disposed || !this.pty)
|
|
154
|
+
return;
|
|
155
|
+
try {
|
|
156
|
+
this.pty.write(data);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
this.status = "failed";
|
|
159
|
+
this.message = error instanceof Error ? error.message : String(error);
|
|
160
|
+
const snapshot = this.createSnapshot();
|
|
161
|
+
this.onSnapshot?.(snapshot);
|
|
162
|
+
this.onError?.(error, snapshot);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
resize(cols, rows) {
|
|
166
|
+
const nextCols = clampCols(cols);
|
|
167
|
+
const nextRows = clampRows(rows);
|
|
168
|
+
if (nextCols === this.cols && nextRows === this.rows)
|
|
169
|
+
return;
|
|
170
|
+
this.cols = nextCols;
|
|
171
|
+
this.rows = nextRows;
|
|
172
|
+
this.terminal.resize(nextCols, nextRows);
|
|
173
|
+
try {
|
|
174
|
+
this.pty?.resize(nextCols, nextRows);
|
|
175
|
+
} catch {}
|
|
176
|
+
this.emitSnapshotSoon(0);
|
|
177
|
+
}
|
|
178
|
+
dispose(reason = "dispose", options = {}) {
|
|
179
|
+
if (this._disposed)
|
|
180
|
+
return;
|
|
181
|
+
this._disposed = true;
|
|
182
|
+
if (this.notifyTimer)
|
|
183
|
+
clearTimeout(this.notifyTimer);
|
|
184
|
+
this.notifyTimer = null;
|
|
185
|
+
if (options.kill !== false) {
|
|
186
|
+
try {
|
|
187
|
+
this.proc?.kill("SIGTERM");
|
|
188
|
+
} catch {}
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
this.pty?.close();
|
|
192
|
+
} catch {}
|
|
193
|
+
try {
|
|
194
|
+
this.terminal.dispose();
|
|
195
|
+
} catch {}
|
|
196
|
+
if (activeHost === this)
|
|
197
|
+
activeHost = null;
|
|
198
|
+
if (options.notify) {
|
|
199
|
+
this.message = reason;
|
|
200
|
+
this.onSnapshot?.(this.createSnapshot(reason));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
handlePtyData(data) {
|
|
204
|
+
if (this._disposed)
|
|
205
|
+
return;
|
|
206
|
+
this.decoder.decode(data, { stream: true });
|
|
207
|
+
this.terminal.write(data, () => this.emitSnapshotSoon());
|
|
208
|
+
}
|
|
209
|
+
emitSnapshotSoon(delayMs = SNAPSHOT_DELAY_MS) {
|
|
210
|
+
if (this._disposed || this.notifyTimer)
|
|
211
|
+
return;
|
|
212
|
+
this.notifyTimer = setTimeout(() => {
|
|
213
|
+
this.notifyTimer = null;
|
|
214
|
+
if (this._disposed)
|
|
215
|
+
return;
|
|
216
|
+
this.onSnapshot?.(this.createSnapshot());
|
|
217
|
+
}, delayMs);
|
|
218
|
+
}
|
|
219
|
+
createSnapshot(message = this.message) {
|
|
220
|
+
const buffer = this.terminal.buffer.active;
|
|
221
|
+
const end = buffer.length;
|
|
222
|
+
const start = Math.max(0, end - MAX_SNAPSHOT_LINES);
|
|
223
|
+
const lines = [];
|
|
224
|
+
for (let row = start;row < end; row += 1) {
|
|
225
|
+
const line = buffer.getLine(row);
|
|
226
|
+
lines.push((line?.translateToString(false) ?? "").slice(0, this.cols));
|
|
227
|
+
}
|
|
228
|
+
while (lines.length < this.rows)
|
|
229
|
+
lines.push("");
|
|
230
|
+
return {
|
|
231
|
+
command: this.argv,
|
|
232
|
+
label: this.label,
|
|
233
|
+
status: this.status,
|
|
234
|
+
cols: this.cols,
|
|
235
|
+
rows: this.rows,
|
|
236
|
+
lines,
|
|
237
|
+
message,
|
|
238
|
+
...this.exitCode !== undefined ? { exitCode: this.exitCode } : {},
|
|
239
|
+
...this.signal !== undefined ? { signal: this.signal } : {}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
stopActiveCommandHost,
|
|
245
|
+
startCommandPtyHost,
|
|
246
|
+
getActiveCommandHost,
|
|
247
|
+
CommandPtyHost
|
|
248
|
+
};
|
|
@@ -17,7 +17,7 @@ function normalizeError(error) {
|
|
|
17
17
|
const message = error instanceof Error ? error.message : String(error);
|
|
18
18
|
const rawHint = error instanceof Error ? error.hint : undefined;
|
|
19
19
|
return {
|
|
20
|
-
message: message || "Unknown
|
|
20
|
+
message: message || "Unknown app error",
|
|
21
21
|
...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {},
|
|
22
22
|
cause: error
|
|
23
23
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TypeBarRenderables } from "./render/type-bar";
|
|
2
|
+
export type AppModalState = {
|
|
3
|
+
readonly active: boolean;
|
|
4
|
+
readonly owner?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class AppFocusManager {
|
|
7
|
+
private modalStack;
|
|
8
|
+
pushModal(owner: string): void;
|
|
9
|
+
popModal(owner: string): void;
|
|
10
|
+
get modal(): AppModalState;
|
|
11
|
+
restoreTypeBarFocus(typeBar: TypeBarRenderables | null, options?: {
|
|
12
|
+
readonly hidden?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/app-opentui/focus-manager.ts
|
|
3
|
+
class AppFocusManager {
|
|
4
|
+
modalStack = [];
|
|
5
|
+
pushModal(owner) {
|
|
6
|
+
this.modalStack = [...this.modalStack.filter((entry) => entry !== owner), owner];
|
|
7
|
+
}
|
|
8
|
+
popModal(owner) {
|
|
9
|
+
this.modalStack = this.modalStack.filter((entry) => entry !== owner);
|
|
10
|
+
}
|
|
11
|
+
get modal() {
|
|
12
|
+
const owner = this.modalStack[this.modalStack.length - 1];
|
|
13
|
+
return owner ? { active: true, owner } : { active: false };
|
|
14
|
+
}
|
|
15
|
+
restoreTypeBarFocus(typeBar, options = {}) {
|
|
16
|
+
if (options.hidden || this.modal.active || !typeBar)
|
|
17
|
+
return;
|
|
18
|
+
if (!typeBar.input.focused)
|
|
19
|
+
typeBar.input.focus();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
AppFocusManager
|
|
24
|
+
};
|