Skip to content

Commit afde575

Browse files
committed
cp dines
1 parent 0dc3485 commit afde575

2 files changed

Lines changed: 61 additions & 25 deletions

File tree

src/commands/blueprint/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const ListBlueprintsUI = ({
233233
createTextColumn(
234234
"name",
235235
"Name",
236-
(blueprint: BlueprintListItem) => blueprint.name || "(unnamed)",
236+
(blueprint: BlueprintListItem) => blueprint.name || "",
237237
{
238238
width: nameWidth,
239239
},

src/commands/snapshot/list.tsx

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ const ListSnapshotsUI = ({
4949
const [showPopup, setShowPopup] = React.useState(false);
5050
const [selectedOperation, setSelectedOperation] = React.useState(0);
5151
// eslint-disable-next-line @typescript-eslint/no-explicit-any
52-
const [selectedSnapshot, setSelectedSnapshot] = React.useState<any | null>(null);
53-
const [executingOperation, setExecutingOperation] = React.useState<string | null>(null);
54-
const [operationResult, setOperationResult] = React.useState<string | null>(null);
55-
const [operationError, setOperationError] = React.useState<Error | null>(null);
52+
const [selectedSnapshot, setSelectedSnapshot] = React.useState<any | null>(
53+
null,
54+
);
55+
const [executingOperation, setExecutingOperation] = React.useState<
56+
string | null
57+
>(null);
58+
const [operationResult, setOperationResult] = React.useState<string | null>(
59+
null,
60+
);
61+
const [operationError, setOperationError] = React.useState<Error | null>(
62+
null,
63+
);
5664
const [operationLoading, setOperationLoading] = React.useState(false);
5765

5866
// Calculate overhead for viewport height
@@ -154,16 +162,21 @@ const ListSnapshotsUI = ({
154162
// Build columns
155163
const columns = React.useMemo(
156164
() => [
157-
createTextColumn("id", "ID", (snapshot: SnapshotListItem) => snapshot.id, {
158-
width: idWidth,
159-
color: colors.idColor,
160-
dimColor: false,
161-
bold: false,
162-
}),
165+
createTextColumn(
166+
"id",
167+
"ID",
168+
(snapshot: SnapshotListItem) => snapshot.id,
169+
{
170+
width: idWidth + 1,
171+
color: colors.idColor,
172+
dimColor: false,
173+
bold: false,
174+
},
175+
),
163176
createTextColumn(
164177
"name",
165178
"Name",
166-
(snapshot: SnapshotListItem) => snapshot.name || "(unnamed)",
179+
(snapshot: SnapshotListItem) => snapshot.name || "",
167180
{
168181
width: nameWidth,
169182
},
@@ -279,10 +292,20 @@ const ListSnapshotsUI = ({
279292
setSelectedIndex(selectedIndex - 1);
280293
} else if (key.downArrow && selectedIndex < pageSnapshots - 1) {
281294
setSelectedIndex(selectedIndex + 1);
282-
} else if ((input === "n" || key.rightArrow) && !loading && !navigating && hasMore) {
295+
} else if (
296+
(input === "n" || key.rightArrow) &&
297+
!loading &&
298+
!navigating &&
299+
hasMore
300+
) {
283301
nextPage();
284302
setSelectedIndex(0);
285-
} else if ((input === "p" || key.leftArrow) && !loading && !navigating && hasPrev) {
303+
} else if (
304+
(input === "p" || key.leftArrow) &&
305+
!loading &&
306+
!navigating &&
307+
hasPrev
308+
) {
286309
prevPage();
287310
setSelectedIndex(0);
288311
} else if (input === "a" && selectedSnapshotItem) {
@@ -302,13 +325,17 @@ const ListSnapshotsUI = ({
302325
// Operation result display
303326
if (operationResult || operationError) {
304327
const operationLabel =
305-
operations.find((o) => o.key === executingOperation)?.label || "Operation";
328+
operations.find((o) => o.key === executingOperation)?.label ||
329+
"Operation";
306330
return (
307331
<>
308332
<Breadcrumb
309333
items={[
310334
{ label: "Snapshots" },
311-
{ label: selectedSnapshot?.name || selectedSnapshot?.id || "Snapshot" },
335+
{
336+
label:
337+
selectedSnapshot?.name || selectedSnapshot?.id || "Snapshot",
338+
},
312339
{ label: operationLabel, active: true },
313340
]}
314341
/>
@@ -329,7 +356,8 @@ const ListSnapshotsUI = ({
329356
// Operation loading state
330357
if (operationLoading && selectedSnapshot) {
331358
const operationLabel =
332-
operations.find((o) => o.key === executingOperation)?.label || "Operation";
359+
operations.find((o) => o.key === executingOperation)?.label ||
360+
"Operation";
333361
const messages: Record<string, string> = {
334362
delete: "Deleting snapshot...",
335363
};
@@ -357,7 +385,9 @@ const ListSnapshotsUI = ({
357385
<Breadcrumb
358386
items={[
359387
{ label: "Snapshots", active: !devboxId },
360-
...(devboxId ? [{ label: `Devbox: ${devboxId}`, active: true }] : []),
388+
...(devboxId
389+
? [{ label: `Devbox: ${devboxId}`, active: true }]
390+
: []),
361391
]}
362392
/>
363393
<SpinnerComponent message="Loading snapshots..." />
@@ -372,7 +402,9 @@ const ListSnapshotsUI = ({
372402
<Breadcrumb
373403
items={[
374404
{ label: "Snapshots", active: !devboxId },
375-
...(devboxId ? [{ label: `Devbox: ${devboxId}`, active: true }] : []),
405+
...(devboxId
406+
? [{ label: `Devbox: ${devboxId}`, active: true }]
407+
: []),
376408
]}
377409
/>
378410
<ErrorMessage message="Failed to list snapshots" error={error} />
@@ -387,7 +419,9 @@ const ListSnapshotsUI = ({
387419
<Breadcrumb
388420
items={[
389421
{ label: "Snapshots", active: !devboxId },
390-
...(devboxId ? [{ label: `Devbox: ${devboxId}`, active: true }] : []),
422+
...(devboxId
423+
? [{ label: `Devbox: ${devboxId}`, active: true }]
424+
: []),
391425
]}
392426
/>
393427
<Box>
@@ -509,21 +543,23 @@ export { ListSnapshotsUI };
509543
export async function listSnapshots(options: ListOptions) {
510544
try {
511545
const client = getClient();
512-
546+
513547
// Build query params
514548
const queryParams: Record<string, unknown> = {
515549
limit: DEFAULT_PAGE_SIZE,
516550
};
517551
if (options.devbox) {
518552
queryParams.devbox_id = options.devbox;
519553
}
520-
554+
521555
// Fetch snapshots
522-
const page = await client.devboxes.listDiskSnapshots(queryParams) as DiskSnapshotsCursorIDPage<{ id: string }>;
523-
556+
const page = (await client.devboxes.listDiskSnapshots(
557+
queryParams,
558+
)) as DiskSnapshotsCursorIDPage<{ id: string }>;
559+
524560
// Extract snapshots array
525561
const snapshots = page.snapshots || [];
526-
562+
527563
output(snapshots, { format: options.output, defaultFormat: "json" });
528564
} catch (error) {
529565
outputError("Failed to list snapshots", error);

0 commit comments

Comments
 (0)