@runloop/rl-cli 0.0.1 → 0.0.2

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.
@@ -1,16 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Box, Text, useInput, useApp, useStdout } from 'ink';
4
- import TextInput from 'ink-text-input';
3
+ import { Box, Text, useInput, useStdout } from 'ink';
5
4
  import figures from 'figures';
6
- import { getClient } from '../utils/client.js';
7
5
  import { Header } from './Header.js';
8
- import { SpinnerComponent } from './Spinner.js';
9
- import { ErrorMessage } from './ErrorMessage.js';
10
- import { SuccessMessage } from './SuccessMessage.js';
11
6
  import { StatusBadge } from './StatusBadge.js';
12
7
  import { MetadataDisplay } from './MetadataDisplay.js';
13
8
  import { Breadcrumb } from './Breadcrumb.js';
9
+ import { DevboxActionsMenu } from './DevboxActionsMenu.js';
14
10
  // Format time ago in a succinct way
15
11
  const formatTimeAgo = (timestamp) => {
16
12
  const seconds = Math.floor((Date.now() - timestamp) / 1000);
@@ -32,33 +28,22 @@ const formatTimeAgo = (timestamp) => {
32
28
  return `${years}y ago`;
33
29
  };
34
30
  export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
35
- const { exit } = useApp();
36
31
  const { stdout } = useStdout();
37
- const [loading, setLoading] = React.useState(false);
38
- const [selectedOperation, setSelectedOperation] = React.useState(0);
39
- const [executingOperation, setExecutingOperation] = React.useState(null);
40
- const [operationInput, setOperationInput] = React.useState('');
41
- const [operationResult, setOperationResult] = React.useState(null);
42
- const [operationError, setOperationError] = React.useState(null);
43
32
  const [showDetailedInfo, setShowDetailedInfo] = React.useState(false);
44
33
  const [detailScroll, setDetailScroll] = React.useState(0);
45
- const [logsWrapMode, setLogsWrapMode] = React.useState(true);
46
- const [logsScroll, setLogsScroll] = React.useState(0);
47
- const [copyStatus, setCopyStatus] = React.useState(null);
34
+ const [showActions, setShowActions] = React.useState(false);
35
+ const [selectedOperation, setSelectedOperation] = React.useState(0);
48
36
  const selectedDevbox = initialDevbox;
49
- // Memoize time-based values to prevent re-rendering on every tick
50
- const formattedCreateTime = React.useMemo(() => selectedDevbox.create_time_ms ? new Date(selectedDevbox.create_time_ms).toLocaleString() : '', [selectedDevbox.create_time_ms]);
51
- const createTimeAgo = React.useMemo(() => selectedDevbox.create_time_ms ? formatTimeAgo(selectedDevbox.create_time_ms) : '', [selectedDevbox.create_time_ms]);
52
37
  const allOperations = [
53
- { key: 'logs', label: 'View Logs', color: 'blue', icon: figures.info },
54
- { key: 'exec', label: 'Execute Command', color: 'green', icon: figures.play },
55
- { key: 'upload', label: 'Upload File', color: 'green', icon: figures.arrowUp },
56
- { key: 'snapshot', label: 'Create Snapshot', color: 'yellow', icon: figures.circleFilled },
57
- { key: 'ssh', label: 'SSH onto the box', color: 'cyan', icon: figures.arrowRight },
58
- { key: 'tunnel', label: 'Open Tunnel', color: 'magenta', icon: figures.pointerSmall },
59
- { key: 'suspend', label: 'Suspend Devbox', color: 'yellow', icon: figures.squareSmallFilled },
60
- { key: 'resume', label: 'Resume Devbox', color: 'green', icon: figures.play },
61
- { key: 'delete', label: 'Shutdown Devbox', color: 'red', icon: figures.cross },
38
+ { key: 'logs', label: 'View Logs', color: 'blue', icon: figures.info, shortcut: 'l' },
39
+ { key: 'exec', label: 'Execute Command', color: 'green', icon: figures.play, shortcut: 'e' },
40
+ { key: 'upload', label: 'Upload File', color: 'green', icon: figures.arrowUp, shortcut: 'u' },
41
+ { key: 'snapshot', label: 'Create Snapshot', color: 'yellow', icon: figures.circleFilled, shortcut: 'n' },
42
+ { key: 'ssh', label: 'SSH onto the box', color: 'cyan', icon: figures.arrowRight, shortcut: 's' },
43
+ { key: 'tunnel', label: 'Open Tunnel', color: 'magenta', icon: figures.pointerSmall, shortcut: 't' },
44
+ { key: 'suspend', label: 'Suspend Devbox', color: 'yellow', icon: figures.squareSmallFilled, shortcut: 'p' },
45
+ { key: 'resume', label: 'Resume Devbox', color: 'green', icon: figures.play, shortcut: 'r' },
46
+ { key: 'delete', label: 'Shutdown Devbox', color: 'red', icon: figures.cross, shortcut: 'd' },
62
47
  ];
63
48
  // Filter operations based on devbox status
64
49
  const operations = selectedDevbox ? allOperations.filter(op => {
@@ -78,120 +63,12 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
78
63
  // Default for transitional states (provisioning, initializing)
79
64
  return op.key === 'logs' || op.key === 'delete';
80
65
  }) : allOperations;
81
- // Auto-execute operations that don't need input (delete, ssh, logs, suspend, resume)
82
- React.useEffect(() => {
83
- if ((executingOperation === 'delete' || executingOperation === 'ssh' || executingOperation === 'logs' || executingOperation === 'suspend' || executingOperation === 'resume') && !loading && selectedDevbox) {
84
- executeOperation();
85
- }
86
- }, [executingOperation]);
66
+ // Memoize time-based values to prevent re-rendering on every tick
67
+ const formattedCreateTime = React.useMemo(() => selectedDevbox.create_time_ms ? new Date(selectedDevbox.create_time_ms).toLocaleString() : '', [selectedDevbox.create_time_ms]);
68
+ const createTimeAgo = React.useMemo(() => selectedDevbox.create_time_ms ? formatTimeAgo(selectedDevbox.create_time_ms) : '', [selectedDevbox.create_time_ms]);
87
69
  useInput((input, key) => {
88
- // Handle operation input mode
89
- if (executingOperation && !operationResult && !operationError) {
90
- if (key.return && operationInput.trim()) {
91
- executeOperation();
92
- }
93
- else if (input === 'q' || key.escape) {
94
- console.clear();
95
- setExecutingOperation(null);
96
- setOperationInput('');
97
- }
98
- return;
99
- }
100
- // Handle operation result display
101
- if (operationResult || operationError) {
102
- if (input === 'q' || key.escape || key.return) {
103
- console.clear();
104
- setOperationResult(null);
105
- setOperationError(null);
106
- setExecutingOperation(null);
107
- setOperationInput('');
108
- setLogsWrapMode(true); // Reset wrap mode
109
- setLogsScroll(0); // Reset scroll
110
- setCopyStatus(null); // Reset copy status
111
- // Keep detail view open
112
- }
113
- else if ((key.upArrow || input === 'k') && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
114
- // Scroll up in logs
115
- setLogsScroll(Math.max(0, logsScroll - 1));
116
- }
117
- else if ((key.downArrow || input === 'j') && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
118
- // Scroll down in logs
119
- setLogsScroll(logsScroll + 1);
120
- }
121
- else if (key.pageUp && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
122
- // Page up
123
- setLogsScroll(Math.max(0, logsScroll - 10));
124
- }
125
- else if (key.pageDown && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
126
- // Page down
127
- setLogsScroll(logsScroll + 10);
128
- }
129
- else if (input === 'g' && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
130
- // Jump to top
131
- setLogsScroll(0);
132
- }
133
- else if (input === 'G' && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
134
- // Jump to bottom (last line)
135
- const logs = operationResult.__logs || [];
136
- const terminalHeight = stdout?.rows || 30;
137
- const viewportHeight = Math.max(10, terminalHeight - 10);
138
- const maxScroll = Math.max(0, logs.length - viewportHeight);
139
- setLogsScroll(maxScroll);
140
- }
141
- else if (input === 'w' && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
142
- // Toggle wrap mode for logs
143
- setLogsWrapMode(!logsWrapMode);
144
- }
145
- else if (input === 'c' && operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
146
- // Copy logs to clipboard
147
- const logs = operationResult.__logs || [];
148
- const logsText = logs.map((log) => {
149
- const time = new Date(log.timestamp_ms).toLocaleString();
150
- const level = log.level || 'INFO';
151
- const source = log.source || 'exec';
152
- const message = log.message || '';
153
- const cmd = log.cmd ? `[${log.cmd}] ` : '';
154
- const exitCode = log.exit_code !== null && log.exit_code !== undefined ? `(${log.exit_code}) ` : '';
155
- return `${time} ${level}/${source} ${exitCode}${cmd}${message}`;
156
- }).join('\n');
157
- // Copy to clipboard using pbcopy (macOS), xclip (Linux), or clip (Windows)
158
- const copyToClipboard = async (text) => {
159
- const { spawn } = await import('child_process');
160
- const platform = process.platform;
161
- let command;
162
- let args;
163
- if (platform === 'darwin') {
164
- command = 'pbcopy';
165
- args = [];
166
- }
167
- else if (platform === 'win32') {
168
- command = 'clip';
169
- args = [];
170
- }
171
- else {
172
- command = 'xclip';
173
- args = ['-selection', 'clipboard'];
174
- }
175
- const proc = spawn(command, args);
176
- proc.stdin.write(text);
177
- proc.stdin.end();
178
- proc.on('exit', (code) => {
179
- if (code === 0) {
180
- setCopyStatus('Copied to clipboard!');
181
- setTimeout(() => setCopyStatus(null), 2000);
182
- }
183
- else {
184
- setCopyStatus('Failed to copy');
185
- setTimeout(() => setCopyStatus(null), 2000);
186
- }
187
- });
188
- proc.on('error', () => {
189
- setCopyStatus('Copy not supported');
190
- setTimeout(() => setCopyStatus(null), 2000);
191
- });
192
- };
193
- copyToClipboard(logsText);
194
- }
70
+ // Skip input handling when in actions view
71
+ if (showActions) {
195
72
  return;
196
73
  }
197
74
  // Handle detailed info mode
@@ -218,17 +95,35 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
218
95
  }
219
96
  return;
220
97
  }
221
- // Operations selection mode
98
+ // Main view input handling
222
99
  if (input === 'q' || key.escape) {
223
100
  console.clear();
224
101
  onBack();
225
- setSelectedOperation(0);
226
102
  }
227
103
  else if (input === 'i') {
228
104
  setShowDetailedInfo(true);
229
105
  setDetailScroll(0);
230
106
  }
231
- else if (input === 'o') {
107
+ else if (key.upArrow && selectedOperation > 0) {
108
+ setSelectedOperation(selectedOperation - 1);
109
+ }
110
+ else if (key.downArrow && selectedOperation < operations.length - 1) {
111
+ setSelectedOperation(selectedOperation + 1);
112
+ }
113
+ else if (key.return || input === 'a') {
114
+ console.clear();
115
+ setShowActions(true);
116
+ }
117
+ else if (input) {
118
+ // Check if input matches any operation shortcut
119
+ const matchedOpIndex = operations.findIndex(op => op.shortcut === input);
120
+ if (matchedOpIndex !== -1) {
121
+ setSelectedOperation(matchedOpIndex);
122
+ console.clear();
123
+ setShowActions(true);
124
+ }
125
+ }
126
+ if (input === 'o') {
232
127
  // Open in browser
233
128
  const url = `https://platform.runloop.ai/devboxes/${selectedDevbox.id}`;
234
129
  const openBrowser = async () => {
@@ -248,118 +143,7 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
248
143
  };
249
144
  openBrowser();
250
145
  }
251
- else if (key.upArrow && selectedOperation > 0) {
252
- setSelectedOperation(selectedOperation - 1);
253
- }
254
- else if (key.downArrow && selectedOperation < operations.length - 1) {
255
- setSelectedOperation(selectedOperation + 1);
256
- }
257
- else if (key.return) {
258
- console.clear();
259
- const op = operations[selectedOperation].key;
260
- setExecutingOperation(op);
261
- }
262
146
  });
263
- const executeOperation = async () => {
264
- const client = getClient();
265
- const devbox = selectedDevbox;
266
- try {
267
- setLoading(true);
268
- switch (executingOperation) {
269
- case 'exec':
270
- const execResult = await client.devboxes.executeSync(devbox.id, {
271
- command: operationInput,
272
- });
273
- setOperationResult(execResult.stdout || execResult.stderr || 'Command executed');
274
- break;
275
- case 'upload':
276
- // For upload, operationInput should be file path
277
- const fs = await import('fs');
278
- const fileStream = fs.createReadStream(operationInput);
279
- const filename = operationInput.split('/').pop() || 'file';
280
- await client.devboxes.uploadFile(devbox.id, {
281
- path: filename,
282
- file: fileStream,
283
- });
284
- setOperationResult(`File ${filename} uploaded successfully`);
285
- break;
286
- case 'snapshot':
287
- const snapshot = await client.devboxes.snapshotDisk(devbox.id, {
288
- name: operationInput || `snapshot-${Date.now()}`,
289
- });
290
- setOperationResult(`Snapshot created: ${snapshot.id}`);
291
- break;
292
- case 'ssh':
293
- const sshKey = await client.devboxes.createSSHKey(devbox.id);
294
- // Save SSH key to persistent location
295
- const fsModule = await import('fs');
296
- const pathModule = await import('path');
297
- const osModule = await import('os');
298
- const sshDir = pathModule.join(osModule.homedir(), '.runloop', 'ssh_keys');
299
- fsModule.mkdirSync(sshDir, { recursive: true });
300
- const keyPath = pathModule.join(sshDir, `${devbox.id}.pem`);
301
- fsModule.writeFileSync(keyPath, sshKey.ssh_private_key, { mode: 0o600 });
302
- // Determine user from launch parameters
303
- const sshUser = devbox.launch_parameters?.user_parameters?.username || 'user';
304
- const proxyCommand = 'openssl s_client -quiet -verify_quiet -servername %h -connect ssh.runloop.ai:443 2>/dev/null';
305
- // Store SSH command details globally
306
- global.__sshCommand = {
307
- keyPath,
308
- proxyCommand,
309
- sshUser,
310
- url: sshKey.url,
311
- devboxName: devbox.name || devbox.id
312
- };
313
- // Exit Ink app to release terminal, SSH will be spawned after exit
314
- exit();
315
- break;
316
- case 'logs':
317
- const logsResult = await client.devboxes.logs.list(devbox.id);
318
- if (logsResult.logs.length === 0) {
319
- setOperationResult('No logs available for this devbox.');
320
- }
321
- else {
322
- // Store logs data for custom rendering - show all logs
323
- logsResult.__customRender = 'logs';
324
- logsResult.__logs = logsResult.logs; // Show all logs, not just last 50
325
- logsResult.__totalCount = logsResult.logs.length;
326
- setOperationResult(logsResult);
327
- }
328
- break;
329
- case 'tunnel':
330
- const port = parseInt(operationInput);
331
- if (isNaN(port) || port < 1 || port > 65535) {
332
- setOperationError(new Error('Invalid port number. Please enter a port between 1 and 65535.'));
333
- }
334
- else {
335
- const tunnel = await client.devboxes.createTunnel(devbox.id, { port });
336
- setOperationResult(`Tunnel created!\n\n` +
337
- `Local Port: ${port}\n` +
338
- `Public URL: ${tunnel.url}\n\n` +
339
- `You can now access port ${port} on the devbox via:\n${tunnel.url}`);
340
- }
341
- break;
342
- case 'suspend':
343
- await client.devboxes.suspend(devbox.id);
344
- setOperationResult(`Devbox ${devbox.id} suspended successfully`);
345
- break;
346
- case 'resume':
347
- await client.devboxes.resume(devbox.id);
348
- setOperationResult(`Devbox ${devbox.id} resumed successfully`);
349
- break;
350
- case 'delete':
351
- await client.devboxes.shutdown(devbox.id);
352
- setOperationResult(`Devbox ${devbox.id} shut down successfully`);
353
- break;
354
- }
355
- }
356
- catch (err) {
357
- setOperationError(err);
358
- }
359
- finally {
360
- setLoading(false);
361
- }
362
- };
363
147
  const uptime = selectedDevbox.create_time_ms
364
148
  ? Math.floor((Date.now() - selectedDevbox.create_time_ms) / 1000 / 60)
365
149
  : null;
@@ -489,108 +273,16 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
489
273
  });
490
274
  return lines;
491
275
  };
492
- // Operation result display
493
- if (operationResult || operationError) {
494
- const operationLabel = operations.find((o) => o.key === executingOperation)?.label || 'Operation';
495
- // Check for custom logs rendering
496
- if (operationResult && typeof operationResult === 'object' && operationResult.__customRender === 'logs') {
497
- const logs = operationResult.__logs || [];
498
- const totalCount = operationResult.__totalCount || 0;
499
- // Calculate viewport for scrolling
500
- const terminalHeight = stdout?.rows || 30;
501
- const terminalWidth = stdout?.columns || 120;
502
- const viewportHeight = Math.max(10, terminalHeight - 10); // Reserve space for header/footer
503
- const maxScroll = Math.max(0, logs.length - viewportHeight);
504
- const actualScroll = Math.min(logsScroll, maxScroll);
505
- const visibleLogs = logs.slice(actualScroll, actualScroll + viewportHeight);
506
- const hasMore = actualScroll + viewportHeight < logs.length;
507
- const hasLess = actualScroll > 0;
508
- return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
509
- { label: 'Devboxes' },
510
- { label: selectedDevbox?.name || selectedDevbox?.id || 'Devbox' },
511
- { label: 'Logs', active: true }
512
- ] }), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 1, children: [visibleLogs.map((log, index) => {
513
- const time = new Date(log.timestamp_ms).toLocaleTimeString();
514
- const level = log.level ? log.level[0].toUpperCase() : 'I';
515
- const source = log.source ? log.source.substring(0, 8) : 'exec';
516
- const fullMessage = log.message || '';
517
- const cmd = log.cmd ? `[${log.cmd.substring(0, 40)}${log.cmd.length > 40 ? '...' : ''}] ` : '';
518
- const exitCode = log.exit_code !== null && log.exit_code !== undefined ? `(${log.exit_code}) ` : '';
519
- let levelColor = 'gray';
520
- if (level === 'E')
521
- levelColor = 'red';
522
- else if (level === 'W')
523
- levelColor = 'yellow';
524
- else if (level === 'I')
525
- levelColor = 'cyan';
526
- if (logsWrapMode) {
527
- // Wrap mode: show full message on same line, let terminal handle wrapping
528
- return (_jsxs(Box, { children: [_jsx(Text, { color: "gray", dimColor: true, children: time }), _jsx(Text, { children: " " }), _jsx(Text, { color: levelColor, bold: true, children: level }), _jsxs(Text, { color: "gray", dimColor: true, children: ["/", source] }), _jsx(Text, { children: " " }), exitCode && _jsx(Text, { color: "yellow", children: exitCode }), cmd && _jsx(Text, { color: "blue", dimColor: true, children: cmd }), _jsx(Text, { children: fullMessage })] }, index));
529
- }
530
- else {
531
- // No-wrap mode: calculate actual metadata width and truncate accordingly
532
- // Time (11) + space (1) + Level (1) + /source (1+8) + space (1) + exitCode.length + cmd.length + border/padding (6)
533
- const metadataWidth = 11 + 1 + 1 + 1 + 8 + 1 + exitCode.length + cmd.length + 6;
534
- const availableMessageWidth = Math.max(20, terminalWidth - metadataWidth);
535
- const truncatedMessage = fullMessage.length > availableMessageWidth
536
- ? fullMessage.substring(0, availableMessageWidth - 3) + '...'
537
- : fullMessage;
538
- return (_jsxs(Box, { children: [_jsx(Text, { color: "gray", dimColor: true, children: time }), _jsx(Text, { children: " " }), _jsx(Text, { color: levelColor, bold: true, children: level }), _jsxs(Text, { color: "gray", dimColor: true, children: ["/", source] }), _jsx(Text, { children: " " }), exitCode && _jsx(Text, { color: "yellow", children: exitCode }), cmd && _jsx(Text, { color: "blue", dimColor: true, children: cmd }), _jsx(Text, { children: truncatedMessage })] }, index));
539
- }
540
- }), hasLess && (_jsx(Box, { children: _jsxs(Text, { color: "cyan", children: [figures.arrowUp, " More above"] }) })), hasMore && (_jsx(Box, { children: _jsxs(Text, { color: "cyan", children: [figures.arrowDown, " More below"] }) }))] }), _jsxs(Box, { marginTop: 1, paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: [figures.hamburger, " ", totalCount] }), _jsx(Text, { color: "gray", dimColor: true, children: " total logs" }), _jsx(Text, { color: "gray", dimColor: true, children: " \u2022 " }), _jsxs(Text, { color: "gray", dimColor: true, children: ["Viewing ", actualScroll + 1, "-", Math.min(actualScroll + viewportHeight, logs.length), " of ", logs.length] }), _jsx(Text, { color: "gray", dimColor: true, children: " \u2022 " }), _jsx(Text, { color: logsWrapMode ? 'green' : 'gray', bold: logsWrapMode, children: logsWrapMode ? 'Wrap: ON' : 'Wrap: OFF' }), copyStatus && (_jsxs(_Fragment, { children: [_jsx(Text, { color: "gray", dimColor: true, children: " \u2022 " }), _jsx(Text, { color: "green", bold: true, children: copyStatus })] }))] }), _jsx(Box, { marginTop: 1, paddingX: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Navigate \u2022 [g] Top \u2022 [G] Bottom \u2022 [w] Toggle Wrap \u2022 [c] Copy \u2022 [Enter], [q], or [esc] Back"] }) })] }));
541
- }
542
- return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
543
- { label: 'Devboxes' },
544
- { label: selectedDevbox?.name || selectedDevbox?.id || 'Devbox' },
545
- { label: operationLabel, active: true }
546
- ] }), _jsx(Header, { title: "Operation Result" }), operationResult && _jsx(SuccessMessage, { message: operationResult }), operationError && _jsx(ErrorMessage, { message: "Operation failed", error: operationError }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", dimColor: true, children: "Press [Enter], [q], or [esc] to continue" }) })] }));
547
- }
548
- // Operation input mode
549
- if (executingOperation && selectedDevbox) {
550
- const needsInput = executingOperation === 'exec' ||
551
- executingOperation === 'upload' ||
552
- executingOperation === 'snapshot' ||
553
- executingOperation === 'tunnel';
554
- const operationLabel = operations.find((o) => o.key === executingOperation)?.label || 'Operation';
555
- if (loading) {
556
- return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
557
- { label: 'Devboxes' },
558
- { label: selectedDevbox.name || selectedDevbox.id },
559
- { label: operationLabel, active: true }
560
- ] }), _jsx(Header, { title: "Executing Operation" }), _jsx(SpinnerComponent, { message: "Please wait..." })] }));
561
- }
562
- if (!needsInput) {
563
- // SSH, Logs, Suspend, Resume, and Delete operations are auto-executed via useEffect
564
- const messages = {
565
- ssh: 'Creating SSH key...',
566
- logs: 'Fetching logs...',
567
- suspend: 'Suspending devbox...',
568
- resume: 'Resuming devbox...',
569
- delete: 'Shutting down devbox...',
570
- };
571
- return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
572
- { label: 'Devboxes' },
573
- { label: selectedDevbox.name || selectedDevbox.id },
574
- { label: operationLabel, active: true }
575
- ] }), _jsx(Header, { title: "Executing Operation" }), _jsx(SpinnerComponent, { message: messages[executingOperation] || 'Please wait...' })] }));
576
- }
577
- const prompts = {
578
- exec: 'Command to execute:',
579
- upload: 'File path to upload:',
580
- snapshot: 'Snapshot name (optional):',
581
- tunnel: 'Port number to expose:',
582
- };
583
- return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
584
- { label: 'Devboxes' },
585
- { label: selectedDevbox.name || selectedDevbox.id },
586
- { label: operationLabel, active: true }
587
- ] }), _jsx(Header, { title: operationLabel }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "cyan", bold: true, children: selectedDevbox.name || selectedDevbox.id }) }), _jsx(Box, { children: _jsxs(Text, { color: "gray", children: [prompts[executingOperation], " "] }) }), _jsx(Box, { marginTop: 1, children: _jsx(TextInput, { value: operationInput, onChange: setOperationInput, placeholder: executingOperation === 'exec'
588
- ? 'ls -la'
589
- : executingOperation === 'upload'
590
- ? '/path/to/file'
591
- : executingOperation === 'tunnel'
592
- ? '8080'
593
- : 'my-snapshot' }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", dimColor: true, children: "Press [Enter] to execute \u2022 [q or esc] Cancel" }) })] })] }));
276
+ // Actions view - show the DevboxActionsMenu when an action is triggered
277
+ if (showActions) {
278
+ return (_jsx(DevboxActionsMenu, { devbox: selectedDevbox, onBack: () => {
279
+ setShowActions(false);
280
+ setSelectedOperation(0);
281
+ }, breadcrumbItems: [
282
+ { label: 'Devboxes' },
283
+ { label: selectedDevbox.name || selectedDevbox.id },
284
+ { label: 'Actions', active: true }
285
+ ] }));
594
286
  }
595
287
  // Detailed info mode - full screen
596
288
  if (showDetailedInfo) {
@@ -606,16 +298,16 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack }) => {
606
298
  { label: 'Devboxes' },
607
299
  { label: selectedDevbox.name || selectedDevbox.id },
608
300
  { label: 'Full Details', active: true }
609
- ] }), _jsx(Header, { title: `${selectedDevbox.name || selectedDevbox.id} - Complete Information` }), _jsx(Box, { flexDirection: "column", marginBottom: 1, children: _jsxs(Box, { marginBottom: 1, children: [_jsx(StatusBadge, { status: selectedDevbox.status }), _jsx(Text, { children: " " }), _jsx(Text, { color: "gray", dimColor: true, children: selectedDevbox.id })] }) }), _jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { flexDirection: "column", children: visibleLines }), hasLess && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "cyan", children: [figures.arrowUp, " More above"] }) })), hasMore && (_jsx(Box, { marginTop: hasLess ? 0 : 1, children: _jsxs(Text, { color: "cyan", children: [figures.arrowDown, " More below"] }) }))] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Scroll \u2022 [q or esc] Back to Operations \u2022 Line ", actualScroll + 1, "-", Math.min(actualScroll + viewportHeight, detailLines.length), " of ", detailLines.length] }) })] }));
301
+ ] }), _jsx(Header, { title: `${selectedDevbox.name || selectedDevbox.id} - Complete Information` }), _jsx(Box, { flexDirection: "column", marginBottom: 1, children: _jsxs(Box, { marginBottom: 1, children: [_jsx(StatusBadge, { status: selectedDevbox.status }), _jsx(Text, { children: " " }), _jsx(Text, { color: "gray", dimColor: true, children: selectedDevbox.id })] }) }), _jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { flexDirection: "column", children: visibleLines }), hasLess && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "cyan", children: [figures.arrowUp, " More above"] }) })), hasMore && (_jsx(Box, { marginTop: hasLess ? 0 : 1, children: _jsxs(Text, { color: "cyan", children: [figures.arrowDown, " More below"] }) }))] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Scroll \u2022 [q or esc] Back to Details \u2022 Line ", actualScroll + 1, "-", Math.min(actualScroll + viewportHeight, detailLines.length), " of ", detailLines.length] }) })] }));
610
302
  }
611
- // Operations selection mode (main detail view)
303
+ // Main detail view
612
304
  const lp = selectedDevbox.launch_parameters;
613
305
  const hasCapabilities = selectedDevbox.capabilities && selectedDevbox.capabilities.filter((c) => c !== 'unknown').length > 0;
614
306
  return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [
615
307
  { label: 'Devboxes' },
616
308
  { label: selectedDevbox.name || selectedDevbox.id, active: true }
617
- ] }), _jsx(Header, { title: "Devbox Details" }), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, paddingY: 0, children: [_jsxs(Box, { children: [_jsx(Text, { color: "cyan", bold: true, children: selectedDevbox.name || selectedDevbox.id }), _jsx(Text, { children: " " }), _jsx(StatusBadge, { status: selectedDevbox.status }), _jsxs(Text, { color: "gray", dimColor: true, children: [" \u2022 ", selectedDevbox.id] })] }), _jsxs(Box, { children: [_jsx(Text, { color: "gray", dimColor: true, children: formattedCreateTime }), _jsxs(Text, { color: "gray", dimColor: true, children: [" (", createTimeAgo, ")"] })] }), uptime !== null && selectedDevbox.status === 'running' && (_jsxs(Box, { children: [_jsxs(Text, { color: "green", dimColor: true, children: ["Uptime: ", uptime < 60 ? `${uptime}m` : `${Math.floor(uptime / 60)}h ${uptime % 60}m`] }), lp?.keep_alive_time_seconds && (_jsxs(Text, { color: "gray", dimColor: true, children: [" \u2022 Keep-alive: ", Math.floor(lp.keep_alive_time_seconds / 60), "m"] }))] }))] }), _jsxs(Box, { flexDirection: "row", gap: 1, children: [(lp?.resource_size_request || lp?.custom_cpu_cores || lp?.custom_gb_memory || lp?.custom_disk_size || lp?.architecture) && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: [figures.squareSmallFilled, " Resources"] }), _jsxs(Text, { dimColor: true, children: [lp?.resource_size_request && `${lp.resource_size_request}`, lp?.architecture && ` • ${lp.architecture}`, lp?.custom_cpu_cores && ` • ${lp.custom_cpu_cores}VCPU`, lp?.custom_gb_memory && ` • ${lp.custom_gb_memory}GB RAM`, lp?.custom_disk_size && ` • ${lp.custom_disk_size}GB DISC`] })] })), hasCapabilities && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "blue", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "blue", bold: true, children: [figures.tick, " Capabilities"] }), _jsx(Text, { dimColor: true, children: selectedDevbox.capabilities.filter((c) => c !== 'unknown').join(', ') })] })), (selectedDevbox.blueprint_id || selectedDevbox.snapshot_id) && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "magenta", bold: true, children: [figures.circleFilled, " Source"] }), _jsxs(Text, { dimColor: true, children: [selectedDevbox.blueprint_id && `BP: ${selectedDevbox.blueprint_id}`, selectedDevbox.snapshot_id && `Snap: ${selectedDevbox.snapshot_id}`] })] }))] }), selectedDevbox.metadata && Object.keys(selectedDevbox.metadata).length > 0 && (_jsx(Box, { borderStyle: "round", borderColor: "green", paddingX: 1, paddingY: 0, children: _jsx(MetadataDisplay, { metadata: selectedDevbox.metadata, showBorder: false }) })), selectedDevbox.failure_reason && (_jsxs(Box, { borderStyle: "round", borderColor: "red", paddingX: 1, paddingY: 0, children: [_jsxs(Text, { color: "red", bold: true, children: [figures.cross, " "] }), _jsx(Text, { color: "red", dimColor: true, children: selectedDevbox.failure_reason })] })), _jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "cyan", bold: true, children: [figures.play, " Operations"] }), _jsx(Box, { flexDirection: "column", children: operations.map((op, index) => {
309
+ ] }), _jsx(Header, { title: "Devbox Details" }), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, paddingY: 0, children: [_jsxs(Box, { children: [_jsx(Text, { color: "cyan", bold: true, children: selectedDevbox.name || selectedDevbox.id }), _jsx(Text, { children: " " }), _jsx(StatusBadge, { status: selectedDevbox.status }), _jsxs(Text, { color: "gray", dimColor: true, children: [" \u2022 ", selectedDevbox.id] })] }), _jsxs(Box, { children: [_jsx(Text, { color: "gray", dimColor: true, children: formattedCreateTime }), _jsxs(Text, { color: "gray", dimColor: true, children: [" (", createTimeAgo, ")"] })] }), uptime !== null && selectedDevbox.status === 'running' && (_jsxs(Box, { children: [_jsxs(Text, { color: "green", dimColor: true, children: ["Uptime: ", uptime < 60 ? `${uptime}m` : `${Math.floor(uptime / 60)}h ${uptime % 60}m`] }), lp?.keep_alive_time_seconds && (_jsxs(Text, { color: "gray", dimColor: true, children: [" \u2022 Keep-alive: ", Math.floor(lp.keep_alive_time_seconds / 60), "m"] }))] }))] }), _jsxs(Box, { flexDirection: "row", gap: 1, children: [(lp?.resource_size_request || lp?.custom_cpu_cores || lp?.custom_gb_memory || lp?.custom_disk_size || lp?.architecture) && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: [figures.squareSmallFilled, " Resources"] }), _jsxs(Text, { dimColor: true, children: [lp?.resource_size_request && `${lp.resource_size_request}`, lp?.architecture && ` • ${lp.architecture}`, lp?.custom_cpu_cores && ` • ${lp.custom_cpu_cores}VCPU`, lp?.custom_gb_memory && ` • ${lp.custom_gb_memory}GB RAM`, lp?.custom_disk_size && ` • ${lp.custom_disk_size}GB DISC`] })] })), hasCapabilities && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "blue", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "blue", bold: true, children: [figures.tick, " Capabilities"] }), _jsx(Text, { dimColor: true, children: selectedDevbox.capabilities.filter((c) => c !== 'unknown').join(', ') })] })), (selectedDevbox.blueprint_id || selectedDevbox.snapshot_id) && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 1, paddingY: 0, flexGrow: 1, children: [_jsxs(Text, { color: "magenta", bold: true, children: [figures.circleFilled, " Source"] }), _jsxs(Text, { dimColor: true, children: [selectedDevbox.blueprint_id && `BP: ${selectedDevbox.blueprint_id}`, selectedDevbox.snapshot_id && `Snap: ${selectedDevbox.snapshot_id}`] })] }))] }), selectedDevbox.metadata && Object.keys(selectedDevbox.metadata).length > 0 && (_jsx(Box, { borderStyle: "round", borderColor: "green", paddingX: 1, paddingY: 0, children: _jsx(MetadataDisplay, { metadata: selectedDevbox.metadata, showBorder: false }) })), selectedDevbox.failure_reason && (_jsxs(Box, { borderStyle: "round", borderColor: "red", paddingX: 1, paddingY: 0, children: [_jsxs(Text, { color: "red", bold: true, children: [figures.cross, " "] }), _jsx(Text, { color: "red", dimColor: true, children: selectedDevbox.failure_reason })] })), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: [figures.play, " Actions"] }), _jsx(Box, { flexDirection: "column", children: operations.map((op, index) => {
618
310
  const isSelected = index === selectedOperation;
619
- return (_jsxs(Box, { children: [_jsxs(Text, { color: isSelected ? 'cyan' : 'gray', children: [isSelected ? figures.pointer : ' ', " "] }), _jsxs(Text, { color: isSelected ? op.color : 'gray', bold: isSelected, children: [op.icon, " ", op.label] })] }, op.key));
620
- }) })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Navigate \u2022 [Enter] Select \u2022 [i] Full Details \u2022 [o] Browser \u2022 [q] Back"] }) })] }));
311
+ return (_jsxs(Box, { children: [_jsxs(Text, { color: isSelected ? 'cyan' : 'gray', children: [isSelected ? figures.pointer : ' ', " "] }), _jsxs(Text, { color: isSelected ? op.color : 'gray', bold: isSelected, children: [op.icon, " ", op.label] }), _jsxs(Text, { color: "gray", dimColor: true, children: [" [", op.shortcut, "]"] })] }, op.key));
312
+ }) })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "gray", dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Navigate \u2022 [Enter] Execute \u2022 [i] Full Details \u2022 [o] Browser \u2022 [q] Back"] }) })] }));
621
313
  };
@@ -7,32 +7,35 @@ export const getStatusDisplay = (status) => {
7
7
  }
8
8
  switch (status) {
9
9
  case 'running':
10
- return { icon: figures.circleFilled, color: 'green', text: 'RUNNING' };
10
+ return { icon: figures.circleFilled, color: 'green', text: 'RUNNING ' };
11
11
  case 'provisioning':
12
- return { icon: figures.hamburger, color: 'yellow', text: 'PROVISIONING' };
12
+ return { icon: figures.ellipsis, color: 'yellow', text: 'PROVISION ' };
13
13
  case 'initializing':
14
- return { icon: figures.ellipsis, color: 'cyan', text: 'INITIALIZING' };
14
+ return { icon: figures.ellipsis, color: 'cyan', text: 'INITIALIZE' };
15
15
  case 'suspended':
16
- return { icon: figures.circleDotted, color: 'yellow', text: 'SUSPENDED' };
16
+ return { icon: figures.circleDotted, color: 'yellow', text: 'SUSPENDED ' };
17
17
  case 'failure':
18
- return { icon: figures.cross, color: 'red', text: 'FAILED' };
18
+ return { icon: figures.cross, color: 'red', text: 'FAILED ' };
19
19
  case 'shutdown':
20
- return { icon: figures.circle, color: 'gray', text: 'SHUTDOWN' };
20
+ return { icon: figures.circle, color: 'gray', text: 'SHUTDOWN ' };
21
21
  case 'resuming':
22
- return { icon: figures.ellipsis, color: 'cyan', text: 'RESUMING' };
22
+ return { icon: figures.ellipsis, color: 'cyan', text: 'RESUMING ' };
23
23
  case 'suspending':
24
24
  return { icon: figures.ellipsis, color: 'yellow', text: 'SUSPENDING' };
25
25
  case 'ready':
26
- return { icon: figures.tick, color: 'green', text: 'READY' };
26
+ return { icon: figures.tick, color: 'green', text: 'READY ' };
27
27
  case 'build_complete':
28
28
  case 'building_complete':
29
- return { icon: figures.tick, color: 'green', text: 'COMPLETE' };
29
+ return { icon: figures.tick, color: 'green', text: 'COMPLETE ' };
30
30
  case 'building':
31
- return { icon: figures.ellipsis, color: 'yellow', text: 'BUILDING' };
31
+ return { icon: figures.ellipsis, color: 'yellow', text: 'BUILDING ' };
32
32
  case 'build_failed':
33
- return { icon: figures.cross, color: 'red', text: 'FAILED' };
33
+ return { icon: figures.cross, color: 'red', text: 'FAILED ' };
34
34
  default:
35
- return { icon: figures.questionMarkPrefix, color: 'gray', text: status.toUpperCase() };
35
+ // Truncate and pad any unknown status to 10 chars to match column width
36
+ const truncated = status.toUpperCase().slice(0, 10);
37
+ const padded = truncated.padEnd(10, ' ');
38
+ return { icon: figures.questionMarkPrefix, color: 'gray', text: padded };
36
39
  }
37
40
  };
38
41
  export const StatusBadge = ({ status, showText = true }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runloop/rl-cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Beautiful CLI for Runloop devbox management",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,6 +47,7 @@
47
47
  "dependencies": {
48
48
  "@inkjs/ui": "^2.0.0",
49
49
  "@runloop/api-client": "^0.55.0",
50
+ "@runloop/rl-cli": "^0.0.1",
50
51
  "chalk": "^5.3.0",
51
52
  "commander": "^12.1.0",
52
53
  "conf": "^13.0.1",