@exagone313/dsh-podman 1.7.0 → 1.8.1

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.
Files changed (117) hide show
  1. package/cordis.patch.yml +3 -1
  2. package/dist/approval-reasons.d.ts +37 -0
  3. package/dist/approval-reasons.js +128 -0
  4. package/dist/approval-template-summary.d.ts +8 -0
  5. package/dist/approval-template-summary.js +163 -0
  6. package/dist/approval.d.ts +8 -4
  7. package/dist/approval.js +104 -10
  8. package/dist/client/ContainerCard.js +8 -2
  9. package/dist/client/container-card-controller.d.ts +13 -5
  10. package/dist/client/container-card-controller.js +60 -24
  11. package/dist/client/container-card-create-config.d.ts +23 -0
  12. package/dist/client/container-card-create-config.js +48 -0
  13. package/dist/client/container-card-create-modal.d.ts +9 -1
  14. package/dist/client/container-card-create-modal.js +37 -41
  15. package/dist/client/container-card-create-volume.d.ts +10 -0
  16. package/dist/client/container-card-create-volume.js +34 -0
  17. package/dist/client/container-card-dialog-styles.d.ts +4 -2
  18. package/dist/client/container-card-dialog-styles.js +47 -4
  19. package/dist/client/container-card-edit-modal.d.ts +5 -1
  20. package/dist/client/container-card-edit-modal.js +55 -19
  21. package/dist/client/container-card-editors.d.ts +9 -0
  22. package/dist/client/container-card-editors.js +300 -43
  23. package/dist/client/container-card-form.d.ts +2 -1
  24. package/dist/client/container-card-form.js +26 -8
  25. package/dist/client/container-card-images.js +9 -31
  26. package/dist/client/container-card-mount-actions.d.ts +12 -0
  27. package/dist/client/container-card-mount-actions.js +35 -0
  28. package/dist/client/container-card-mount-sources.d.ts +34 -0
  29. package/dist/client/container-card-mount-sources.js +180 -0
  30. package/dist/client/container-card-names.d.ts +2 -0
  31. package/dist/client/container-card-names.js +12 -0
  32. package/dist/client/container-card-row.d.ts +16 -1
  33. package/dist/client/container-card-row.js +69 -25
  34. package/dist/client/container-card-secrets.d.ts +2 -0
  35. package/dist/client/container-card-secrets.js +60 -17
  36. package/dist/client/container-card-shared.d.ts +17 -9
  37. package/dist/client/container-card-shared.js +122 -93
  38. package/dist/client/container-card-styles.d.ts +6 -0
  39. package/dist/client/container-card-styles.js +22 -0
  40. package/dist/client/container-card-table-styles.d.ts +2 -1
  41. package/dist/client/container-card-table-styles.js +14 -0
  42. package/dist/client/container-card-templates.d.ts +81 -0
  43. package/dist/client/container-card-templates.js +1004 -0
  44. package/dist/client/container-card-toast.js +1 -1
  45. package/dist/client/container-card-volumes.js +6 -20
  46. package/dist/client/container-card-workspace.d.ts +10 -2
  47. package/dist/client/container-card-workspace.js +98 -5
  48. package/dist/client/container-template-ui.d.ts +163 -0
  49. package/dist/client/container-template-ui.js +579 -0
  50. package/dist/client/download.d.ts +1 -0
  51. package/dist/client/download.js +23 -0
  52. package/dist/client/image-facts.d.ts +18 -0
  53. package/dist/client/image-facts.js +44 -0
  54. package/dist/client/index.js +13478 -3438
  55. package/dist/client/locales.d.ts +1 -1
  56. package/dist/client/locales.js +120 -0
  57. package/dist/client/podman-containers.js +47 -18
  58. package/dist/client/podman-terminal-guide.js +4 -2
  59. package/dist/client/podman-terminal.js +4 -2
  60. package/dist/client/template-client.d.ts +9 -0
  61. package/dist/client/template-client.js +52 -0
  62. package/dist/client/template-protocol.d.ts +60 -0
  63. package/dist/client/template-protocol.js +4 -0
  64. package/dist/client/terminal-errors.d.ts +11 -0
  65. package/dist/client/terminal-errors.js +26 -0
  66. package/dist/client/terminal-protocol.d.ts +5 -0
  67. package/dist/client/terminal-protocol.js +5 -0
  68. package/dist/client/terminal-styles.d.ts +2 -1
  69. package/dist/client/terminal-styles.js +9 -1
  70. package/dist/client/terminal-transport.d.ts +17 -2
  71. package/dist/client/terminal-transport.js +31 -8
  72. package/dist/client/tool-presentations.d.ts +32 -0
  73. package/dist/client/tool-presentations.js +33 -0
  74. package/dist/client/tool-views.js +17 -7
  75. package/dist/client/workspace-target.d.ts +54 -0
  76. package/dist/client/workspace-target.js +86 -0
  77. package/dist/container-template.d.ts +153 -0
  78. package/dist/container-template.js +1058 -0
  79. package/dist/generated/version.d.ts +2 -2
  80. package/dist/generated/version.js +2 -2
  81. package/dist/grpc/proto/dshguest/v1/guest.proto +11 -0
  82. package/dist/guest-rpc.d.ts +1 -0
  83. package/dist/guest-rpc.js +12 -0
  84. package/dist/index.js +7 -1
  85. package/dist/mount-enums.d.ts +2 -0
  86. package/dist/mount-enums.js +17 -0
  87. package/dist/mount-order.d.ts +14 -0
  88. package/dist/mount-order.js +49 -0
  89. package/dist/project-path.d.ts +14 -0
  90. package/dist/project-path.js +25 -0
  91. package/dist/template-apply.d.ts +21 -0
  92. package/dist/template-apply.js +102 -0
  93. package/dist/template-files.d.ts +23 -0
  94. package/dist/template-files.js +186 -0
  95. package/dist/template-image.d.ts +22 -0
  96. package/dist/template-image.js +80 -0
  97. package/dist/template-route.d.ts +9 -0
  98. package/dist/template-route.js +278 -0
  99. package/dist/terminal-route.js +49 -7
  100. package/dist/tool-defs.js +27 -1
  101. package/dist/tool-handlers.js +69 -1
  102. package/dist/tool-params.d.ts +38 -0
  103. package/dist/tool-params.js +30 -0
  104. package/docs/README.md +4 -3
  105. package/docs/architecture.md +42 -12
  106. package/docs/architecture.zh.md +22 -8
  107. package/docs/configuration.md +19 -20
  108. package/docs/configuration.zh.md +3 -4
  109. package/docs/development-prompt.md +49 -45
  110. package/docs/development-prompt.zh.md +47 -43
  111. package/docs/development.md +46 -28
  112. package/docs/development.zh.md +60 -46
  113. package/docs/uninstall.md +3 -3
  114. package/docs/uninstall.zh.md +2 -2
  115. package/docs/usage.md +155 -23
  116. package/docs/usage.zh.md +104 -14
  117. package/package.json +6 -5
@@ -2,6 +2,8 @@ import { type SnapshotStore } from "@deepseek-ai/dsh-client-store";
2
2
  import type { ConfigForm, ConfigFormSnapshot } from "@deepseek-ai/dsh-client-ui-settings/client";
3
3
  import { type CacheView, type ContainerView, type ImageView, type MountInput, type PtcView, type PublishedPortView, type SecretView, type VolumeView, type WorkspaceView } from "./card-protocol.js";
4
4
  import { type CardClient } from "./card-client.js";
5
+ import { type TemplateClient } from "./template-client.js";
6
+ import type { TemplateApplyRequest, TemplateApplyView, TemplateBuildRequest, TemplateBuildView, TemplateEntryView, TemplateInspectionView, TemplateInspectRequest, TemplatePublishRequest, TemplatePublishView } from "./template-protocol.js";
5
7
  import { type ContainerConfig, type PortConfig } from "./container-card-config.js";
6
8
  import { type DirectoryPickerFace } from "./directory-picker.js";
7
9
  export declare const CONTAINER_NS = "podman";
@@ -29,7 +31,7 @@ export interface ContainerCreateConfig {
29
31
  export type { CacheView, ContainerConfig, ContainerView, ImageView, MountInput, PublishedPortView, SecretView, VolumeView, WorkspaceView, };
30
32
  export interface CardToast {
31
33
  seq: number;
32
- kind: "ok" | "error";
34
+ kind: "ok" | "warn" | "error";
33
35
  text: string;
34
36
  }
35
37
  export interface CardState {
@@ -87,7 +89,7 @@ export interface ContainerCardFace {
87
89
  setContainerPaths: (workspace: string, container: string, paths: readonly string[]) => void;
88
90
  publishContainerPort: (workspace: string, container: string, port: number, suggestedHostPort?: number) => void;
89
91
  unpublishContainerPort: (workspace: string, container: string, port: number, protocol: string) => void;
90
- createVolume: (name: string) => void;
92
+ createVolume: (name: string) => Promise<boolean>;
91
93
  removeVolume: (name: string) => void;
92
94
  removeImage: (imageId: string) => void;
93
95
  rebuildImage: (imageId: string) => void;
@@ -96,17 +98,23 @@ export interface ContainerCardFace {
96
98
  rebuildBaseImage: (name: string) => void;
97
99
  pullBaseImage: (name: string) => void;
98
100
  setDefaultImage: (name: string) => void;
99
- createSecret: (name: string, length?: number, charset?: string) => void;
101
+ createSecret: (name: string, length?: number, charset?: string) => Promise<boolean>;
100
102
  removeSecret: (name: string) => void;
101
103
  setSecret: (name: string, value: string) => void;
102
104
  addContainerSecret: (workspace: string, container: string, envVar: string, secret: string) => void;
103
105
  removeContainerSecret: (workspace: string, container: string, envVar: string) => void;
104
106
  saveContainerEnv: (env: Record<string, string>) => void;
105
107
  applyDefaultEnv: (workspace: string) => void;
106
- applyContainerConfig: (workspace: string, container: string, base: ContainerConfig, next: ContainerConfig) => void;
108
+ applyContainerConfig: (workspace: string, container: string, base: ContainerConfig, next: ContainerConfig) => Promise<boolean>;
109
+ listTemplates: (workspace: string) => Promise<TemplateEntryView[]>;
110
+ inspectTemplate: (request: TemplateInspectRequest) => Promise<TemplateInspectionView>;
111
+ buildTemplate: (request: TemplateBuildRequest) => Promise<TemplateBuildView>;
112
+ applyTemplate: (request: TemplateApplyRequest) => Promise<TemplateApplyView>;
113
+ publishTemplate: (request: TemplatePublishRequest) => Promise<TemplatePublishView>;
107
114
  }
108
115
  export declare class ContainerCardController {
109
116
  private readonly scope;
117
+ private readonly templateClient;
110
118
  private readonly store;
111
119
  private readonly drafts;
112
120
  private readonly client;
@@ -123,7 +131,7 @@ export declare class ContainerCardController {
123
131
  private directoryPicker;
124
132
  private locale;
125
133
  private noticeIsError;
126
- constructor(scope: ConfigForm<ContainerSettings>, client?: CardClient);
134
+ constructor(scope: ConfigForm<ContainerSettings>, client?: CardClient, templateClient?: TemplateClient);
127
135
  private draft;
128
136
  private project;
129
137
  private publish;
@@ -4,6 +4,7 @@
4
4
  import { createSnapshotStore, } from "@deepseek-ai/dsh-client-store";
5
5
  import { absentPtcView, bareActionKey, containerActionKey, scopedActionKey, } from "./card-protocol.js";
6
6
  import { createCardClient } from "./card-client.js";
7
+ import { createTemplateClient, } from "./template-client.js";
7
8
  import { configNeedsRecreate, envDiff, mountDiff, pathsEqual, portDiff, } from "./container-card-config.js";
8
9
  import { versionState as pluginVersionState } from "../version-compat.js";
9
10
  export const CONTAINER_NS = "podman";
@@ -79,6 +80,7 @@ function commandKey(request) {
79
80
  // and no document round-trip is involved.
80
81
  export class ContainerCardController {
81
82
  scope;
83
+ templateClient;
82
84
  store;
83
85
  drafts = new Map();
84
86
  client;
@@ -107,8 +109,9 @@ export class ContainerCardController {
107
109
  // Whether the notice currently published reports a failure rather than a
108
110
  // result, so the card can announce it as an alert.
109
111
  noticeIsError = false;
110
- constructor(scope, client = createCardClient()) {
112
+ constructor(scope, client = createCardClient(), templateClient = createTemplateClient()) {
111
113
  this.scope = scope;
114
+ this.templateClient = templateClient;
112
115
  this.client = client;
113
116
  this.store = createSnapshotStore(this.project());
114
117
  scope.subscribe(() => {
@@ -352,26 +355,32 @@ export class ContainerCardController {
352
355
  // takes effect. Each dispatch reports its own failure and never rejects, so
353
356
  // one refused change does not strand the rest; the recreate runs last, only
354
357
  // when the image or the environment changed, since those are the two fields
355
- // it carries.
358
+ // it carries. Resolves whether every dispatched change was accepted, which is
359
+ // what a template-sourced replace waits for before publishing its ports.
356
360
  async applyConfig(workspace, container, base, next) {
361
+ let applied = true;
362
+ const run = async (request) => {
363
+ if (!(await request))
364
+ applied = false;
365
+ };
357
366
  const mounts = mountDiff(base.mounts, next.mounts);
358
367
  for (const mount of mounts.removed) {
359
- await this.request("container_mount_remove", workspace, "", {
368
+ await run(this.request("container_mount_remove", workspace, "", {
360
369
  container,
361
370
  mount,
362
- });
371
+ }));
363
372
  }
364
373
  for (const mount of mounts.updated) {
365
- await this.request("container_mount_update", workspace, "", {
374
+ await run(this.request("container_mount_update", workspace, "", {
366
375
  container,
367
376
  mount,
368
- });
377
+ }));
369
378
  }
370
379
  for (const mount of mounts.added) {
371
- await this.request("container_mount_add", workspace, "", {
380
+ await run(this.request("container_mount_add", workspace, "", {
372
381
  container,
373
382
  mount,
374
- });
383
+ }));
375
384
  }
376
385
  // A secret env var has no in-place update: a changed value is detached and
377
386
  // reattached, so the variable never keeps a stale secret name.
@@ -381,52 +390,53 @@ export class ContainerCardController {
381
390
  ...secrets.changed.map(([envVar]) => envVar),
382
391
  ];
383
392
  for (const secretEnvName of detach) {
384
- await this.request("container_secret_remove", workspace, "", {
393
+ await run(this.request("container_secret_remove", workspace, "", {
385
394
  container,
386
395
  secretEnvName,
387
- });
396
+ }));
388
397
  }
389
398
  for (const [secretEnvName, secret] of [...secrets.added, ...secrets.changed]) {
390
- await this.request("container_secret_add", workspace, "", {
399
+ await run(this.request("container_secret_add", workspace, "", {
391
400
  container,
392
401
  secretEnvName,
393
402
  secret,
394
- });
403
+ }));
395
404
  }
396
405
  if (!pathsEqual(base.paths, next.paths)) {
397
- await this.request("container_path_set", workspace, "", {
406
+ await run(this.request("container_path_set", workspace, "", {
398
407
  container,
399
408
  paths: [...next.paths],
400
- });
409
+ }));
401
410
  }
402
411
  const ports = portDiff(base.ports, next.ports);
403
412
  for (const published of ports.removed) {
404
- await this.request("container_unpublish_port", workspace, "", {
413
+ await run(this.request("container_unpublish_port", workspace, "", {
405
414
  container,
406
415
  port: published.port,
407
416
  protocol: published.protocol,
408
- });
417
+ }));
409
418
  }
410
419
  for (const published of ports.added) {
411
- await this.request("container_publish_port", workspace, "", {
420
+ await run(this.request("container_publish_port", workspace, "", {
412
421
  container,
413
422
  port: published.port,
414
423
  protocol: published.protocol,
415
424
  ...(published.suggestedHostPort > 0
416
425
  ? { suggestedHostPort: published.suggestedHostPort }
417
426
  : {}),
418
- });
427
+ }));
419
428
  }
420
429
  // The recreate command is what carries a new image or environment. Every
421
430
  // other group is applied by the commands above, and a mount or a secret
422
431
  // environment variable recreates the container on its own, so the recreate
423
432
  // only runs when one of the two fields it applies changed.
424
433
  if (configNeedsRecreate(base, next)) {
425
- await this.request("recreate", workspace, next.image, {
434
+ await run(this.request("recreate", workspace, next.image, {
426
435
  container,
427
436
  env: next.env,
428
- });
437
+ }));
429
438
  }
439
+ return applied;
430
440
  }
431
441
  inject() {
432
442
  return {
@@ -473,7 +483,7 @@ export class ContainerCardController {
473
483
  port,
474
484
  protocol,
475
485
  }),
476
- createVolume: (name) => this.command("volume_create", name, ""),
486
+ createVolume: (name) => this.request("volume_create", name, ""),
477
487
  removeVolume: (name) => this.command("volume_remove", name, ""),
478
488
  removeImage: (imageId) => this.command("image_remove", imageId, ""),
479
489
  rebuildImage: (imageId) => this.command("image_rebuild", imageId, ""),
@@ -485,7 +495,7 @@ export class ContainerCardController {
485
495
  this.edit("defaultImage", name);
486
496
  this.save("defaultImage");
487
497
  },
488
- createSecret: (name, length, charset) => this.command("secret_create", name, "", {
498
+ createSecret: (name, length, charset) => this.request("secret_create", name, "", {
489
499
  ...(length ? { length } : {}),
490
500
  ...(charset ? { charset } : {}),
491
501
  }),
@@ -504,8 +514,34 @@ export class ContainerCardController {
504
514
  void this.scope.set("containerEnv", env);
505
515
  },
506
516
  applyDefaultEnv: (workspace) => this.command("default_env_sync", workspace, ""),
507
- applyContainerConfig: (workspace, container, base, next) => {
508
- void this.applyConfig(workspace, container, base, next);
517
+ applyContainerConfig: (workspace, container, base, next) => this.applyConfig(workspace, container, base, next),
518
+ listTemplates: (workspace) => this.templateClient.list(workspace),
519
+ inspectTemplate: (request) => this.templateClient.inspect(request),
520
+ buildTemplate: async (request) => {
521
+ const result = await this.templateClient.build(request);
522
+ void this.reload();
523
+ return result;
524
+ },
525
+ applyTemplate: async (request) => {
526
+ const result = await this.templateClient.apply(request);
527
+ void this.reload();
528
+ return result;
529
+ },
530
+ publishTemplate: async (request) => {
531
+ try {
532
+ const result = await this.templateClient.publish(request);
533
+ if (result.warnings.length > 0) {
534
+ this.showToast("warn", result.warnings.join("\n"));
535
+ }
536
+ return result;
537
+ }
538
+ catch (error) {
539
+ this.showToast("error", error instanceof Error ? error.message : String(error));
540
+ return { warnings: [] };
541
+ }
542
+ finally {
543
+ void this.reload();
544
+ }
509
545
  },
510
546
  };
511
547
  }
@@ -0,0 +1,23 @@
1
+ import type { MountInput } from "./card-protocol.js";
2
+ export interface CreateDraftPort {
3
+ port: number;
4
+ protocol: string;
5
+ endpoint: string;
6
+ suggestedHostPort: number;
7
+ hostPort: number;
8
+ }
9
+ export interface CreateWorkspace {
10
+ projectName: string;
11
+ imageId: string;
12
+ }
13
+ export interface CreateDraft {
14
+ image: string;
15
+ env: Record<string, string>;
16
+ mounts: readonly MountInput[];
17
+ paths: readonly string[];
18
+ secretEnv: Record<string, string>;
19
+ ports: readonly CreateDraftPort[];
20
+ }
21
+ export declare function initialMounts(workspace: CreateWorkspace): MountInput[];
22
+ export declare function initialConfig(workspace: CreateWorkspace, defaultImage: string, defaultEnv: Record<string, string>): CreateDraft;
23
+ export declare function createDialogConfig(base: CreateDraft, named: boolean, workspaceProject: string): CreateDraft;
@@ -0,0 +1,48 @@
1
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+ // The draft a Create/Add dialog opens on, kept out of the React component so the
5
+ // named/default distinction can be tested. Only the workspace's default
6
+ // container forces the workspace's own project mount: that mount is what every
7
+ // tool operates on. A named draft opens with exactly the mounts it was given —
8
+ // a template's own, or the plain Add default — all of them removable.
9
+ import { withForcedProjectMount } from "../container-template.js";
10
+ import { mergeDefaultEnv } from "../container-env.js";
11
+ import { orderedEnvRecord } from "../env-rows.js";
12
+ // The project mount every new container starts with; it is the pristine mount
13
+ // the draft is compared against for its dirty state.
14
+ export function initialMounts(workspace) {
15
+ return [{
16
+ kind: "project",
17
+ project: workspace.projectName,
18
+ destination: "",
19
+ mode: "read_write",
20
+ volume: "",
21
+ secret: "",
22
+ }];
23
+ }
24
+ // The workspace's image (or the configured default), its own project mount, and
25
+ // the workspace's default environment. The defaults are seeded so the values a
26
+ // new container inherits are visible: a value left alone keeps the default, and
27
+ // an edited one is sent as that container's own.
28
+ export function initialConfig(workspace, defaultImage, defaultEnv) {
29
+ return {
30
+ image: workspace.imageId || defaultImage,
31
+ env: orderedEnvRecord(mergeDefaultEnv(defaultEnv, undefined)),
32
+ mounts: initialMounts(workspace),
33
+ paths: [],
34
+ secretEnv: {},
35
+ ports: [],
36
+ };
37
+ }
38
+ // createDialogConfig is the draft the dialog actually opens on. The default
39
+ // container forces the workspace's own project mount first, keeping the mode a
40
+ // template declared for it and adding it read-write only when the template
41
+ // omitted it. A named container keeps exactly the mounts it was given, so a
42
+ // template that omits the workspace project mount opens without it.
43
+ export function createDialogConfig(base, named, workspaceProject) {
44
+ return named ? base : {
45
+ ...base,
46
+ mounts: withForcedProjectMount(base.mounts, workspaceProject),
47
+ };
48
+ }
@@ -1,9 +1,15 @@
1
1
  import { type ContainerCreateConfig, type ImageView, type WorkspaceView } from "./container-card-controller.js";
2
+ import { type ContainerConfig } from "./container-card-config.js";
2
3
  import { type DirectoryPickerFace } from "./directory-picker.js";
3
4
  import { type Translate } from "./locales.js";
4
5
  import { type ReactNode } from "react";
5
6
  export declare function CreateContainerModal(props: {
6
7
  t: Translate;
8
+ initial?: {
9
+ name?: string;
10
+ config: ContainerConfig;
11
+ };
12
+ forcedProject?: string;
7
13
  workspace: WorkspaceView;
8
14
  images: readonly ImageView[];
9
15
  volumes: readonly {
@@ -23,6 +29,8 @@ export declare function CreateContainerModal(props: {
23
29
  gatewayUnavailable: boolean;
24
30
  open: boolean;
25
31
  onClose: () => void;
26
- onCreateSecret: (name: string, length?: number, charset?: string) => void;
32
+ onBack?: () => void;
33
+ createVolume: (name: string) => Promise<boolean>;
34
+ onCreateSecret: (name: string, length?: number, charset?: string) => Promise<boolean>;
27
35
  onCreate: (container: string, config: ContainerCreateConfig) => void;
28
36
  }): ReactNode;
@@ -1,48 +1,29 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { configsEqual } from "./container-card-config.js";
3
+ import { createDialogConfig, initialConfig, } from "./container-card-create-config.js";
3
4
  import { ContainerDialog } from "./container-card-dialog.js";
4
5
  import { ContainerForm } from "./container-card-form.js";
5
6
  import { DiscardChangesModal, namePattern } from "./container-card-shared.js";
6
7
  import { DEFAULT_CONTAINER_NAME, PTC_CONTAINER_NAME, reservedContainerName, } from "./container-card-ptc.js";
7
- import { mergeDefaultEnv } from "../container-env.js";
8
- import { orderedEnvRecord } from "../env-rows.js";
9
8
  import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
10
9
  import { useEffect, useRef, useState } from "react";
11
- // The project mount every new container starts with; it is the pristine mount
12
- // the draft is compared against for its dirty state.
13
- function initialMounts(workspace) {
14
- return [
15
- {
16
- kind: "project",
17
- project: workspace.projectName,
18
- destination: "",
19
- mode: "read_write",
20
- volume: "",
21
- secret: "",
22
- },
23
- ];
24
- }
25
- // The draft an Add/Create dialog opens on: the workspace's image (or the
26
- // configured default), its own project mount, and the workspace's default
27
- // environment. The defaults are seeded so the values a new container inherits
28
- // are visible: a value left alone keeps the default, and an edited one is sent
29
- // as that container's own.
30
- function initialConfig(workspace, defaultImage, defaultEnv) {
31
- return {
32
- image: workspace.imageId || defaultImage,
33
- env: orderedEnvRecord(mergeDefaultEnv(defaultEnv, undefined)),
34
- mounts: initialMounts(workspace),
35
- paths: [],
36
- secretEnv: {},
37
- ports: [],
38
- };
39
- }
40
10
  export function CreateContainerModal(props) {
41
- const { t, workspace, images, volumes, secrets, busy, writable, defaultImage, defaultEnv, projectsRoot, directoryPicker, named, existing, gatewayUnavailable, open, onClose, onCreateSecret, onCreate, } = props;
42
- const [draft, setDraft] = useState(() => initialConfig(workspace, defaultImage, defaultEnv));
43
- const [name, setName] = useState("");
11
+ const { t, workspace, initial, forcedProject, images, volumes, secrets, busy, writable, defaultImage, defaultEnv, projectsRoot, directoryPicker, named, existing, gatewayUnavailable, open, onClose, onBack, createVolume, onCreateSecret, onCreate, } = props;
12
+ // The draft the dialog opens on: a named draft keeps exactly the mounts it
13
+ // was given; the default container forces the workspace's own project mount
14
+ // first and keeps the mode a template declared for it.
15
+ const pristineConfig = () => {
16
+ const base = initial?.config ??
17
+ initialConfig(workspace, defaultImage, defaultEnv);
18
+ return createDialogConfig(base, named, workspace.projectName);
19
+ };
20
+ const [draft, setDraft] = useState(pristineConfig);
21
+ const [name, setName] = useState(initial?.name ?? "");
44
22
  const [submitting, setSubmitting] = useState(false);
45
23
  const [confirmClose, setConfirmClose] = useState(false);
24
+ // Back leaves for the Load template popup the draft was handed from; a draft
25
+ // the user has edited is confirmed before that draft is dropped.
26
+ const [confirmBack, setConfirmBack] = useState(false);
46
27
  // A row the editors flagged as conflicting — unnamed or named twice — refuses
47
28
  // the create; the footer says why until it is fixed or removed.
48
29
  const [blockingError, setBlockingError] = useState(undefined);
@@ -60,12 +41,15 @@ export function CreateContainerModal(props) {
60
41
  if (initialized.current)
61
42
  return;
62
43
  initialized.current = true;
63
- setDraft(initialConfig(workspace, defaultImage, defaultEnv));
64
- setName("");
44
+ const base = initial?.config ??
45
+ initialConfig(workspace, defaultImage, defaultEnv);
46
+ setDraft(createDialogConfig(base, named, workspace.projectName));
47
+ setName(initial?.name ?? "");
65
48
  setSubmitting(false);
66
49
  setConfirmClose(false);
67
- }, [open, workspace, defaultImage, defaultEnv]);
68
- const pristine = initialConfig(workspace, defaultImage, defaultEnv);
50
+ setConfirmBack(false);
51
+ }, [open, workspace, defaultImage, defaultEnv, initial, named]);
52
+ const pristine = pristineConfig();
69
53
  const reservedName = reservedContainerName(name);
70
54
  const nameTaken = existing.includes(name);
71
55
  const namePatternOk = namePattern.test(name);
@@ -94,10 +78,22 @@ export function CreateContainerModal(props) {
94
78
  else
95
79
  onClose();
96
80
  };
81
+ // Back returns to the template popup with the draft it handed on; an edited
82
+ // draft is confirmed first, so the editor is never left open by a back.
83
+ const requestBack = () => {
84
+ if (dirty)
85
+ setConfirmBack(true);
86
+ else
87
+ onBack?.();
88
+ };
97
89
  const discardAndClose = () => {
98
90
  setConfirmClose(false);
99
91
  onClose();
100
92
  };
93
+ const discardAndBack = () => {
94
+ setConfirmBack(false);
95
+ onBack?.();
96
+ };
101
97
  const submit = () => {
102
98
  if (!canCreate || submitting)
103
99
  return;
@@ -113,11 +109,11 @@ export function CreateContainerModal(props) {
113
109
  };
114
110
  return (_jsxs(_Fragment, { children: [_jsx(ContainerDialog, { t: t, open: open, title: named ? t("addContainer") : t("createContainer"), onClose: requestClose, marker: blockingError === undefined
115
111
  ? undefined
116
- : t(blockingError.key, blockingError.params), markerError: blockingError !== undefined, actions: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: requestClose, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: !canCreate || submitting || blockingError !== undefined, onClick: submit, children: named ? t("addContainer") : t("createContainer") })] }), children: _jsx(ContainerForm, { t: t, image: draft.image, env: draft.env, mounts: draft.mounts, paths: draft.paths, secretEnv: draft.secretEnv, ports: draft.ports, images: images, volumes: volumes, secrets: secrets, busy: busy, enabled: !busy, canPublish: !busy && !gatewayUnavailable, gatewayUnavailable: gatewayUnavailable, writable: writable, projectsRoot: projectsRoot, directoryPicker: directoryPicker, mainProject: workspace.projectName,
112
+ : t(blockingError.key, blockingError.params), markerError: blockingError !== undefined, actions: _jsxs(_Fragment, { children: [onBack === undefined ? null : (_jsx(Button, { variant: "outline", size: "sm", onClick: requestBack, children: t("templateBack") })), _jsx(Button, { variant: "outline", size: "sm", onClick: requestClose, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: !canCreate || submitting || blockingError !== undefined, onClick: submit, children: named ? t("addContainer") : t("createContainer") })] }), children: _jsx(ContainerForm, { t: t, image: draft.image, env: draft.env, mounts: draft.mounts, paths: draft.paths, secretEnv: draft.secretEnv, ports: draft.ports, images: images, volumes: volumes, secrets: secrets, busy: busy, enabled: !busy, canPublish: !busy && !gatewayUnavailable, gatewayUnavailable: gatewayUnavailable, writable: writable, projectsRoot: projectsRoot, directoryPicker: directoryPicker, mainProject: workspace.projectName,
117
113
  // The workspace's default container always keeps its main project
118
114
  // mount, so Create greys out its Remove; a named container (Add) keeps
119
115
  // the mounts it was given, the seeded project one included.
120
- primaryProject: named ? "" : workspace.projectName, onCreateSecret: onCreateSecret, onChangeImage: (image) => setDraft({ ...draft, image }), onChangeEnv: (env) => setDraft({ ...draft, env }), onChangeMounts: (mounts) => setDraft({ ...draft, mounts }), onChangePaths: (paths) => setDraft({ ...draft, paths }), onChangeSecretEnv: (secretEnv) => setDraft({ ...draft, secretEnv }), onChangePorts: (ports) => setDraft({ ...draft, ports }), onBlockingError: setBlockingError, name: named
116
+ primaryProject: named ? (forcedProject ?? "") : workspace.projectName, onCreateVolume: createVolume, onCreateSecret: onCreateSecret, onChangeImage: (image) => setDraft({ ...draft, image }), onChangeEnv: (env) => setDraft({ ...draft, env }), onChangeMounts: (mounts) => setDraft({ ...draft, mounts }), onChangePaths: (paths) => setDraft({ ...draft, paths }), onChangeSecretEnv: (secretEnv) => setDraft({ ...draft, secretEnv }), onChangePorts: (ports) => setDraft({ ...draft, ports }), onBlockingError: setBlockingError, name: named
121
117
  ? {
122
118
  value: name,
123
119
  error: nameError,
@@ -132,5 +128,5 @@ export function CreateContainerModal(props) {
132
128
  error: "",
133
129
  readOnly: true,
134
130
  disabled: false,
135
- } }) }), _jsx(DiscardChangesModal, { t: t, open: confirmClose, onCancel: () => setConfirmClose(false), onDiscard: discardAndClose })] }));
131
+ } }) }), _jsx(DiscardChangesModal, { t: t, open: confirmClose, onCancel: () => setConfirmClose(false), onDiscard: discardAndClose }), _jsx(DiscardChangesModal, { t: t, open: confirmBack, onCancel: () => setConfirmBack(false), onDiscard: discardAndBack })] }));
136
132
  }
@@ -0,0 +1,10 @@
1
+ import type { Translate } from "./locales.js";
2
+ import { type ReactNode } from "react";
3
+ export declare function CreateVolumeModal(props: {
4
+ t: Translate;
5
+ open: boolean;
6
+ busy: boolean;
7
+ writable: boolean;
8
+ onCreate: (name: string) => void;
9
+ onClose: () => void;
10
+ }): ReactNode;
@@ -0,0 +1,34 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
+ //
4
+ // SPDX-License-Identifier: MIT
5
+ // The one create-volume form. The settings Storage tab and a volume mount row in
6
+ // the container editor both open it, so a volume is named and validated once, in
7
+ // the same surface, wherever it is created from. It owns its draft and clears it
8
+ // on a successful create; the caller learns the created name and lists it, or
9
+ // selects it in its own picker, once the host answers.
10
+ import { Field } from "./container-card-shared.js";
11
+ import { hint } from "./container-card-styles.js";
12
+ import { createdName } from "./container-card-names.js";
13
+ import { Button, Input, Modal } from "@deepseek-ai/dsh-client-ui-primitives";
14
+ import { useId, useState } from "react";
15
+ export function CreateVolumeModal(props) {
16
+ const { t, open, busy, writable, onCreate, onClose } = props;
17
+ const [name, setName] = useState("");
18
+ const volumeId = useId();
19
+ const canCreate = createdName(name) !== undefined;
20
+ const submit = () => {
21
+ const volume = createdName(name);
22
+ if (volume === undefined)
23
+ return;
24
+ onCreate(volume);
25
+ setName("");
26
+ onClose();
27
+ };
28
+ return (_jsx(Modal, { open: open, onClose: onClose, title: t("volumesTitle"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: onClose, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: !canCreate, onClick: submit, children: t("createVolume") })] }), children: _jsxs(Field, { label: t("volumeName"), htmlFor: volumeId, children: [_jsx(Input, { id: volumeId, value: name, disabled: !writable || busy, autoFocus: true, onChange: (event) => setName(event.target.value), onKeyDown: (event) => {
29
+ if (event.key === "Enter")
30
+ submit();
31
+ } }), name !== "" && !canCreate
32
+ ? (_jsx("p", { style: { ...hint, margin: 0 }, role: "alert", children: t("invalidName") }))
33
+ : null] }) }));
34
+ }
@@ -2,6 +2,8 @@ import type { Context as ClientContext } from "@deepseek-ai/cordis";
2
2
  export declare const CONTAINER_DIALOG_CLASS = "dsh-podman-container-dialog";
3
3
  export declare const CONTAINER_DIALOG_CONTENT_CLASS = "dsh-podman-container-dialog-content";
4
4
  export declare const COMPACT_DIALOG_CLASS = "dsh-podman-compact-dialog";
5
- export declare const CONTAINER_DIALOG_STYLES = "\n.dsh-podman-container-dialog.dsh-podman-container-dialog {\n width: min(1100px, 92vw);\n max-height: min(85vh, 100%);\n gap: 0;\n padding: 0;\n}\n.dsh-podman-container-dialog-content.dsh-podman-container-dialog-content {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-height: 0;\n}\n/* The header, the body and the footer share one 24px inset. The header and the\n footer stay pinned, and the body is the one region allowed to scroll: it is\n the content region's last element (the description, when a caller gives one,\n is a paragraph before it). */\n.dsh-podman-container-dialog-content > div:first-child {\n flex: none;\n padding: 24px 24px 12px;\n}\n.dsh-podman-container-dialog-content > div:last-child {\n min-height: 0;\n overflow-y: auto;\n padding: 0 24px;\n}\n.dsh-podman-container-dialog > div:last-child {\n flex: none;\n padding: 24px;\n}\n.dsh-podman-compact-dialog.dsh-podman-compact-dialog {\n width: min(480px, 92vw);\n}\n";
6
- /** Inject the container dialogs' stylesheet for the owning plugin lifetime. */
5
+ export declare const TEMPLATE_DIALOG_CLASS = "dsh-podman-template-dialog";
6
+ export declare const TEMPLATE_DIALOG_CONTENT_CLASS = "dsh-podman-template-dialog-content";
7
+ export declare const CONTAINER_DIALOG_STYLES = "\n.dsh-podman-container-dialog.dsh-podman-container-dialog {\n width: min(1100px, 92vw);\n max-height: min(85vh, 100%);\n gap: 0;\n padding: 0;\n}\n.dsh-podman-container-dialog-content.dsh-podman-container-dialog-content {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-height: 0;\n}\n/* The header, the body and the footer share one 24px inset. The header and the\n footer stay pinned, and the body is the one region allowed to scroll: it is\n the content region's last element (the description, when a caller gives one,\n is a paragraph before it). */\n.dsh-podman-container-dialog-content > div:first-child {\n flex: none;\n padding: 24px 24px 12px;\n}\n.dsh-podman-container-dialog-content > div:last-child {\n min-height: 0;\n overflow-y: auto;\n padding: 0 24px;\n}\n.dsh-podman-container-dialog > div:last-child {\n flex: none;\n padding: 24px;\n}\n.dsh-podman-compact-dialog.dsh-podman-compact-dialog {\n width: min(480px, 92vw);\n}\n.dsh-podman-template-dialog.dsh-podman-template-dialog {\n width: min(900px, 92vw);\n max-height: min(85vh, 100%);\n gap: 0;\n padding: 0;\n}\n.dsh-podman-template-dialog-content.dsh-podman-template-dialog-content {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-height: 0;\n}\n/* The header and the footer stay pinned and the body is the one region allowed\n to scroll. The picker's description is a paragraph between the header and the\n body, so div:first-child is still the header and div:last-child is still the\n body (the footer is the dialog's own last child, outside the content). */\n.dsh-podman-template-dialog-content > div:first-child {\n flex: none;\n padding: 24px 24px 12px;\n}\n.dsh-podman-template-dialog-content > div:last-child {\n min-height: 0;\n overflow-y: auto;\n padding: 0 24px;\n}\n.dsh-podman-template-dialog > div:last-child {\n flex: none;\n padding: 24px;\n}\n";
8
+ /** Inject the dialogs' stylesheet for the owning plugin lifetime. */
7
9
  export declare function installDialogStyles(ctx: ClientContext): void;
@@ -16,10 +16,24 @@ export const CONTAINER_DIALOG_CLASS = "dsh-podman-container-dialog";
16
16
  // the flex column that may shrink is what pins the header while the body below
17
17
  // takes the remaining height.
18
18
  export const CONTAINER_DIALOG_CONTENT_CLASS = "dsh-podman-container-dialog-content";
19
- // The class the small dialogs carry (the Publish port dialog, the Create secret
20
- // dialog and the project-directory picker): they keep an explicit compact cap
21
- // instead of the container dialogs' desktop width.
19
+ // The class the compact dialogs carry (the Publish port dialog, the Create
20
+ // secret dialog and the project-directory picker): they keep an explicit
21
+ // compact cap instead of the container dialogs' desktop width.
22
22
  export const COMPACT_DIALOG_CLASS = "dsh-podman-compact-dialog";
23
+ // The class passed to Modal for the two template popups (the template picker and
24
+ // the template details popup). They follow the container dialogs' contract — an
25
+ // explicit height cap, a pinned header and footer, and one scrolling body — but
26
+ // keep their own pair of classes: the template dialogs render lists and preview
27
+ // sections, never the container form, so they must not inherit a rule the
28
+ // container dialogs add for that form. The width is wider than the compact cap
29
+ // and a little narrower than the editor's 1100px, which suits the picker's rows
30
+ // and the details popup's stacked sections while staying a comfortable measure.
31
+ export const TEMPLATE_DIALOG_CLASS = "dsh-podman-template-dialog";
32
+ // The class passed as the template dialogs' contentClassName: the primitive
33
+ // wraps the header, the optional description and the body in this region, so
34
+ // making it the flex column that may shrink is what pins the header while the
35
+ // body below takes the remaining height.
36
+ export const TEMPLATE_DIALOG_CONTENT_CLASS = "dsh-podman-template-dialog-content";
23
37
  export const CONTAINER_DIALOG_STYLES = `
24
38
  .dsh-podman-container-dialog.dsh-podman-container-dialog {
25
39
  width: min(1100px, 92vw);
@@ -53,8 +67,37 @@ export const CONTAINER_DIALOG_STYLES = `
53
67
  .dsh-podman-compact-dialog.dsh-podman-compact-dialog {
54
68
  width: min(480px, 92vw);
55
69
  }
70
+ .dsh-podman-template-dialog.dsh-podman-template-dialog {
71
+ width: min(900px, 92vw);
72
+ max-height: min(85vh, 100%);
73
+ gap: 0;
74
+ padding: 0;
75
+ }
76
+ .dsh-podman-template-dialog-content.dsh-podman-template-dialog-content {
77
+ display: flex;
78
+ flex-direction: column;
79
+ flex: 1 1 auto;
80
+ min-height: 0;
81
+ }
82
+ /* The header and the footer stay pinned and the body is the one region allowed
83
+ to scroll. The picker's description is a paragraph between the header and the
84
+ body, so div:first-child is still the header and div:last-child is still the
85
+ body (the footer is the dialog's own last child, outside the content). */
86
+ .dsh-podman-template-dialog-content > div:first-child {
87
+ flex: none;
88
+ padding: 24px 24px 12px;
89
+ }
90
+ .dsh-podman-template-dialog-content > div:last-child {
91
+ min-height: 0;
92
+ overflow-y: auto;
93
+ padding: 0 24px;
94
+ }
95
+ .dsh-podman-template-dialog > div:last-child {
96
+ flex: none;
97
+ padding: 24px;
98
+ }
56
99
  `;
57
- /** Inject the container dialogs' stylesheet for the owning plugin lifetime. */
100
+ /** Inject the dialogs' stylesheet for the owning plugin lifetime. */
58
101
  export function installDialogStyles(ctx) {
59
102
  if (typeof document === "undefined")
60
103
  return;
@@ -22,6 +22,7 @@ export declare function ContainerEditModal(props: {
22
22
  projectName: string;
23
23
  projectsRoot: string;
24
24
  directoryPicker?: DirectoryPickerFace;
25
+ forcedProject?: string;
25
26
  writable: boolean;
26
27
  draft: ContainerConfig;
27
28
  dirty: boolean;
@@ -31,9 +32,12 @@ export declare function ContainerEditModal(props: {
31
32
  onBlockingError?: (error: Translation | undefined) => void;
32
33
  rebuilds: boolean;
33
34
  recreatePending: boolean;
34
- onCreateSecret: (name: string, length?: number, charset?: string) => void;
35
+ createVolume: (name: string) => Promise<boolean>;
36
+ onCreateSecret: (name: string, length?: number, charset?: string) => Promise<boolean>;
35
37
  onChange: (draft: ContainerConfig) => void;
36
38
  onDiscard: () => void;
37
39
  onApply: () => void;
38
40
  onClose: () => void;
41
+ onBack?: () => void;
42
+ backBaseline?: ContainerConfig;
39
43
  }): ReactNode;