@exagone313/dsh-podman 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/card-route.d.ts +8 -0
  2. package/dist/card-route.js +19 -8
  3. package/dist/client/ContainerCard.js +147 -110
  4. package/dist/client/card-protocol.d.ts +4 -0
  5. package/dist/client/card-protocol.js +34 -0
  6. package/dist/client/container-card-caches.d.ts +1 -1
  7. package/dist/client/container-card-caches.js +19 -17
  8. package/dist/client/container-card-config.d.ts +47 -0
  9. package/dist/client/container-card-config.js +160 -0
  10. package/dist/client/container-card-controller.d.ts +35 -3
  11. package/dist/client/container-card-controller.js +263 -41
  12. package/dist/client/container-card-create-modal.d.ts +5 -1
  13. package/dist/client/container-card-create-modal.js +111 -94
  14. package/dist/client/container-card-defaults.d.ts +16 -0
  15. package/dist/client/container-card-defaults.js +147 -0
  16. package/dist/client/container-card-dialog-styles.d.ts +7 -0
  17. package/dist/client/container-card-dialog-styles.js +70 -0
  18. package/dist/client/container-card-dialog.d.ts +12 -0
  19. package/dist/client/container-card-dialog.js +47 -0
  20. package/dist/client/container-card-directory-styles.d.ts +1 -1
  21. package/dist/client/container-card-directory-styles.js +5 -5
  22. package/dist/client/container-card-directory.js +8 -7
  23. package/dist/client/container-card-edit-modal.d.ts +39 -0
  24. package/dist/client/container-card-edit-modal.js +29 -0
  25. package/dist/client/container-card-editors.d.ts +5 -2
  26. package/dist/client/container-card-editors.js +109 -134
  27. package/dist/client/container-card-field-styles.d.ts +7 -0
  28. package/dist/client/container-card-field-styles.js +63 -0
  29. package/dist/client/container-card-form.d.ts +47 -0
  30. package/dist/client/container-card-form.js +61 -0
  31. package/dist/client/container-card-group.d.ts +9 -0
  32. package/dist/client/container-card-group.js +22 -0
  33. package/dist/client/container-card-images.d.ts +6 -2
  34. package/dist/client/container-card-images.js +63 -23
  35. package/dist/client/container-card-paths.js +43 -52
  36. package/dist/client/container-card-ports.d.ts +3 -4
  37. package/dist/client/container-card-ports.js +74 -38
  38. package/dist/client/container-card-resources.d.ts +38 -0
  39. package/dist/client/container-card-resources.js +73 -0
  40. package/dist/client/container-card-row.d.ts +11 -19
  41. package/dist/client/container-card-row.js +122 -122
  42. package/dist/client/container-card-secrets.d.ts +31 -3
  43. package/dist/client/container-card-secrets.js +174 -56
  44. package/dist/client/container-card-shared.d.ts +173 -6
  45. package/dist/client/container-card-shared.js +616 -57
  46. package/dist/client/container-card-status.d.ts +18 -0
  47. package/dist/client/container-card-status.js +166 -0
  48. package/dist/client/container-card-styles.d.ts +49 -7
  49. package/dist/client/container-card-styles.js +396 -40
  50. package/dist/client/container-card-table-styles.d.ts +15 -0
  51. package/dist/client/container-card-table-styles.js +237 -0
  52. package/dist/client/container-card-tabs-styles.d.ts +5 -0
  53. package/dist/client/container-card-tabs-styles.js +46 -0
  54. package/dist/client/container-card-toast.d.ts +5 -0
  55. package/dist/client/container-card-toast.js +10 -0
  56. package/dist/client/container-card-volumes.d.ts +1 -0
  57. package/dist/client/container-card-volumes.js +14 -19
  58. package/dist/client/container-card-workspace.d.ts +8 -12
  59. package/dist/client/container-card-workspace.js +76 -14
  60. package/dist/client/index.js +6491 -3474
  61. package/dist/client/locales.d.ts +10 -1
  62. package/dist/client/locales.js +270 -114
  63. package/dist/client/relative-time.d.ts +10 -0
  64. package/dist/client/relative-time.js +74 -0
  65. package/dist/client/slot-contract.d.ts +8 -0
  66. package/dist/client/tool-views.js +2 -1
  67. package/dist/container-env.js +1 -1
  68. package/dist/env-rows.d.ts +9 -11
  69. package/dist/env-rows.js +72 -40
  70. package/dist/generated/version.d.ts +2 -2
  71. package/dist/generated/version.js +2 -2
  72. package/dist/guest-terminal.js +1 -1
  73. package/dist/mount-enums.d.ts +11 -0
  74. package/dist/mount-enums.js +60 -0
  75. package/dist/subprocess.js +1 -1
  76. package/dist/terminal-sessions.js +2 -2
  77. package/dist/terminal-shells.js +1 -1
  78. package/dist/tool-handlers.js +1 -1
  79. package/dist/workspace-binding.js +2 -2
  80. package/docs/architecture.md +4 -4
  81. package/docs/architecture.zh.md +1 -1
  82. package/docs/configuration.md +26 -25
  83. package/docs/configuration.zh.md +13 -11
  84. package/docs/development-prompt.md +7 -7
  85. package/docs/development-prompt.zh.md +7 -7
  86. package/docs/development.md +20 -16
  87. package/docs/development.zh.md +17 -16
  88. package/docs/install-dsh-and-dsh-podman.md +13 -12
  89. package/docs/install-dsh-and-dsh-podman.zh.md +13 -9
  90. package/docs/usage.md +189 -39
  91. package/docs/usage.zh.md +148 -29
  92. package/package.json +35 -31
  93. package/dist/client/container-card-default-env.d.ts +0 -10
  94. package/dist/client/container-card-default-env.js +0 -69
@@ -1,6 +1,14 @@
1
1
  import { type CardSnapshot } from "./client/card-protocol.js";
2
2
  import { type ReasonLocale } from "./approval-reasons.js";
3
3
  import { type WorkspaceResolver } from "./workspace-binding.js";
4
+ export declare function containerMountView(mount: any, projectsRoot: string): {
5
+ projectName: string;
6
+ destination: string;
7
+ kind: string;
8
+ mode: string;
9
+ volume: string;
10
+ secret: string;
11
+ };
4
12
  /** Build the live snapshot the card renders. */
5
13
  export declare function cardSnapshot(resolver: WorkspaceResolver, workspaceRegistry: any, harnessVersion?: string): Promise<CardSnapshot>;
6
14
  /**
@@ -9,8 +9,8 @@ import { CARD_PATH, } from "./client/card-protocol.js";
9
9
  import { renderCacheCleanNotice, renderDefaultEnvSyncNotice, renderPublishNotice, resolveReasonLocale, } from "./approval-reasons.js";
10
10
  import { mergeDefaultEnv, missingDefaultEnv } from "./container-env.js";
11
11
  import { portProtocolFromProto, portProtocolToProto } from "./publish-port.js";
12
- import { defaultMountMode, mountKindToProto, mountModeToProto, } from "./mount-enums.js";
13
- import { mountInputToProto, validateMountInput } from "./mount-input.js";
12
+ import { defaultMountMode, mountKindToProto, mountModeToProto, normalizeMountKind, normalizeMountMode, } from "./mount-enums.js";
13
+ import { mountInputToProto, projectMountMirror, validateMountInput, } from "./mount-input.js";
14
14
  import { unaryGuest } from "./guest-rpc.js";
15
15
  import { workspaceSlug } from "./workspace-binding.js";
16
16
  import { GIT_COMMIT, VERSION } from "./generated/version.js";
@@ -75,12 +75,23 @@ function cacheCleanModeToProto(mode) {
75
75
  // containerMountView and imageView rebuild the snapshot's nested objects from
76
76
  // an explicit allow-list, so a field added to the proto later cannot reach the
77
77
  // browser just because it exists on the wire (see AGENTS.md "Security").
78
- function containerMountView(mount) {
78
+ //
79
+ // The mount kind and mode are normalised here, at the host boundary, so every
80
+ // snapshot carries the card's own short spelling no matter which enum spelling
81
+ // the decode produced. A project mount's destination is implicit on the wire:
82
+ // it is always the project path mirrored under the projects root, so the view
83
+ // computes it rather than showing an empty field.
84
+ export function containerMountView(mount, projectsRoot) {
85
+ const projectName = stringField(mount?.projectName);
86
+ const kind = normalizeMountKind(mount?.kind);
87
+ const destination = stringField(mount?.destination);
79
88
  return {
80
- projectName: stringField(mount?.projectName),
81
- destination: stringField(mount?.destination),
82
- kind: stringField(mount?.kind),
83
- mode: stringField(mount?.mode),
89
+ projectName,
90
+ destination: destination === "" && kind === "project" && projectName !== ""
91
+ ? projectMountMirror(projectsRoot, projectName)
92
+ : destination,
93
+ kind,
94
+ mode: normalizeMountMode(mount?.mode),
84
95
  volume: stringField(mount?.volume),
85
96
  secret: stringField(mount?.secret),
86
97
  };
@@ -239,7 +250,7 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
239
250
  imageId: container.imageId ?? "",
240
251
  status: container.status ?? "",
241
252
  createdAt: container.createdAt ?? "",
242
- mounts: (container.mounts ?? []).map(containerMountView),
253
+ mounts: (container.mounts ?? []).map((mount) => containerMountView(mount, resolver.getConfig().projectsRoot)),
243
254
  paths: container.paths ?? [],
244
255
  env: container.env ?? {},
245
256
  secretEnv: container.secretEnv ?? {},
@@ -1,56 +1,48 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
3
  //
4
4
  // SPDX-License-Identifier: MIT
5
- import { BaseImageRow, ImageBuildModal, ImageItem, } from "./container-card-images.js";
6
- import { CachesSection } from "./container-card-caches.js";
7
- import { DefaultEnvironmentSection } from "./container-card-default-env.js";
8
- import { SecretsSection } from "./container-card-secrets.js";
9
- import { ConfirmButton } from "./container-card-shared.js";
10
- import { banner, footerRow, hint, imageSelect, sectionTitle, } from "./container-card-styles.js";
11
- import { VolumesSection } from "./container-card-volumes.js";
5
+ import { DefaultsSection } from "./container-card-defaults.js";
6
+ import { StatusSection } from "./container-card-status.js";
7
+ import { ImagesSection, StorageSection } from "./container-card-resources.js";
12
8
  import { WorkspaceSection } from "./container-card-workspace.js";
13
- import { Button, Modal, writeClipboard, } from "@deepseek-ai/dsh-client-ui-primitives";
14
- import { useEffect, useRef, useState } from "react";
15
- // The labels of the version lines, emphasised against their values.
16
- const versionLabel = { fontWeight: 600 };
9
+ import { countLabel, StatusChip, } from "./container-card-shared.js";
10
+ import { TABS_CLASS } from "./container-card-tabs-styles.js";
11
+ import { actionRow, banner, hint, pageColumn, statusStrip, tabPanel, } from "./container-card-styles.js";
12
+ import { Button, SegmentedTabs } from "@deepseek-ai/dsh-client-ui-primitives";
13
+ import { useEffect, useId, useState } from "react";
14
+ // The moment a workspace's newest container was created: the workspaces are
15
+ // ordered by it, most recent first. A timestamp the browser cannot read counts
16
+ // as no moment at all, so a broken row never claims the top of the list.
17
+ function newestContainerAt(containers) {
18
+ return containers.reduce((newest, container) => {
19
+ const at = Date.parse(container.createdAt);
20
+ return Number.isNaN(at) ? newest : Math.max(newest, at);
21
+ }, Number.NEGATIVE_INFINITY);
22
+ }
23
+ // A chip's tone and wording for a version divergence: the status table's own
24
+ // warn/error tones, with the divergence named in the chip's words too, so a
25
+ // green "ready" is the only reading that means ready and matching.
26
+ function versionChip(t, base, state) {
27
+ if (state === "major-mismatch") {
28
+ return {
29
+ tone: "error",
30
+ label: `${base.label} · ${t("versionIncompatible")}`,
31
+ };
32
+ }
33
+ if (state === "minor-mismatch") {
34
+ return {
35
+ tone: "warn",
36
+ label: `${base.label} · ${t("versionCompatibleDifferent")}`,
37
+ };
38
+ }
39
+ return base;
40
+ }
17
41
  export function ContainerCard(props) {
18
42
  const { t } = props;
19
43
  const state = props.useContainerCard((snapshot) => snapshot);
20
- const [buildOpen, setBuildOpen] = useState(false);
21
- const [imageId, setImageId] = useState("");
22
- const [parent, setParent] = useState("");
23
- const [packages, setPackages] = useState([]);
24
- const [defaultOpen, setDefaultOpen] = useState(false);
25
- const [defaultImage, setDefaultImage] = useState(state.defaultImage);
26
- const [copyState, setCopyState] = useState("idle");
27
- const copyResetTimer = useRef();
28
- // Copies the version lines as displayed, so a user can paste them into a bug
29
- // report without transcribing anything.
30
- const copyVersions = async () => {
31
- const lines = [
32
- `${t("dsh")} ${state.dshVersion || t("versionUnknown")}`,
33
- `${t("cardTitle")} ${state.version}${state.commit ? ` · ${state.commit}` : ""}`,
34
- `${t("orchestrator")} ${state.orchestratorVersion || t("versionUnknown")}${state.orchestratorCommit ? ` · ${state.orchestratorCommit}` : ""}`,
35
- `${t("gateway")} ${state.gatewayState === "running"
36
- ? `${state.gatewayVersion}${state.gatewayCommit ? ` · ${state.gatewayCommit}` : ""}`
37
- : state.gatewayState === "incompatible"
38
- ? t("gatewayIncompatible")
39
- : t("gatewayNotRunning")}`,
40
- ];
41
- setCopyState((await writeClipboard(lines.join("\n"))) ? "copied" : "failed");
42
- if (copyResetTimer.current !== undefined) {
43
- clearTimeout(copyResetTimer.current);
44
- }
45
- copyResetTimer.current = setTimeout(() => setCopyState("idle"), 1500);
46
- };
47
- // The reset timer is cancelled on unmount, so it cannot fire against an
48
- // unmounted component.
49
- useEffect(() => () => {
50
- if (copyResetTimer.current !== undefined) {
51
- clearTimeout(copyResetTimer.current);
52
- }
53
- }, []);
44
+ const [tab, setTab] = useState("workspaces");
45
+ const tabsId = useId();
54
46
  // The Plugins page renders a one-liner in its list and this component again
55
47
  // as the entry's page, so the orchestrator snapshot is only fetched for the
56
48
  // page. Re-reading on every page view keeps a workspace created since the
@@ -61,73 +53,118 @@ export function ContainerCard(props) {
61
53
  props.reload();
62
54
  }, [props.view]);
63
55
  // The list shows only the one-liner; the page heading already carries the
64
- // plugin's title and description.
65
- if (props.view === "summary")
66
- return t("cardDescription");
67
- const baseImages = state.images.filter((image) => image.isBase);
68
- const customImages = state.images.filter((image) => !image.isBase);
69
- const defaultCandidates = [
70
- ...baseImages.map((image) => image.imageId),
71
- ...customImages.map((image) => image.imageId),
72
- ];
56
+ // plugin's title and description. The one-liner reports what the snapshot
57
+ // actually holds, and whether the orchestrator answered it.
58
+ if (props.view === "summary") {
59
+ if (state.loadState === "loading")
60
+ return t("loading");
61
+ if (!state.available)
62
+ return t("unavailable");
63
+ return [
64
+ countLabel(t, state.workspaces.length, "countWorkspaceOne", "countWorkspaceMany"),
65
+ countLabel(t, state.containers.length, "countContainerOne", "countContainerMany"),
66
+ t(state.orchestratorReady
67
+ ? "orchestratorReady"
68
+ : "orchestratorUnavailable"),
69
+ ].join(" · ");
70
+ }
71
+ if (state.loadState === "loading") {
72
+ return (_jsx("div", { style: { padding: "8px 0", fontSize: "13px", opacity: 0.8 }, role: "status", children: _jsx("p", { style: { margin: 0 }, children: t("loading") }) }));
73
+ }
73
74
  if (!state.available) {
74
- return (_jsxs("div", { style: { padding: "8px 0", fontSize: "13px", opacity: 0.8 }, children: [_jsx("p", { style: { margin: 0 }, children: t("unavailable") }), state.notice === ""
75
- ? null
76
- : (_jsxs("p", { style: { margin: "4px 0 0" }, role: "status", children: [t("notice"), ": ", state.notice] })), _jsx("div", { style: { marginTop: "8px" }, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
75
+ return (_jsxs("div", { style: { padding: "8px 0", fontSize: "13px", opacity: 0.8 }, children: [_jsx("p", { style: { margin: 0 }, role: "alert", children: t("unavailable") }), state.notice === "" ? null : (_jsxs("p", { style: { margin: "4px 0 0" }, role: state.noticeIsError ? "alert" : "status", children: [t("notice"), ": ", state.notice] })), _jsx("div", { style: { marginTop: "8px" }, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
77
76
  }
78
- return (_jsxs("div", { children: [state.notice === "" ? null : (_jsxs("div", { style: banner, role: "status", children: [t("notice"), ": ", state.notice] })), state.versionState === "ok" ? null : (_jsx("div", { style: state.versionState === "major-mismatch"
79
- ? { ...banner, borderColor: "var(--dsw-alias-state-error-primary)" }
80
- : banner, role: state.versionState === "major-mismatch" ? "alert" : "status", children: t(state.versionState === "major-mismatch"
81
- ? "versionMismatchMajor"
82
- : "versionMismatchMinor") })), _jsx("div", { style: sectionTitle, children: t("workspacesTitle") }), state.workspaces.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (state.workspaces.map((workspace) => (_jsx(WorkspaceSection, { t: t, workspace: workspace, containers: state.containers.filter((container) => container.workspaceSlug === workspace.workspaceSlug), images: state.images, volumes: state.volumes, secrets: state.secrets, busy: state.busy, defaultImage: state.defaultImage, projectsRoot: state.projectsRoot, directoryPicker: state.directoryPicker, onRemove: props.remove, onRemoveWorkspace: props.removeWorkspace, onRecreate: props.recreate, onCreate: props.createContainer, onStartContainer: props.startContainer, onAddContainerMount: props.addContainerMount, onRemoveContainerMount: props.removeContainerMount, onUpdateContainerMount: props.updateContainerMount, onSetContainerPaths: props.setContainerPaths, onAddContainerSecret: props.addContainerSecret, onRemoveContainerSecret: props.removeContainerSecret, onPublishContainerPort: props.publishContainerPort, onUnpublishContainerPort: props.unpublishContainerPort, gatewayUnavailable: state.gatewayState === "absent" ||
83
- state.gatewayState === "incompatible", onSyncDefaults: props.syncDefaultEnv, defaultEnvCount: Object.keys(state.containerEnv).length }, workspace.workspaceSlug)))), _jsxs("div", { style: {
84
- display: "flex",
85
- flexWrap: "wrap",
86
- alignItems: "center",
87
- gap: "8px",
88
- }, children: [_jsx("div", { style: { ...sectionTitle, flex: 1 }, children: t("imagesTitle") }), _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: () => {
89
- setDefaultImage(state.defaultImage);
90
- setDefaultOpen(true);
91
- }, children: t("setDefaultImage") }), _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: () => {
92
- setImageId("");
93
- setParent(baseImages[0]?.imageId ?? customImages[0]?.imageId ?? "");
94
- setPackages([]);
95
- setBuildOpen(true);
96
- }, children: t("buildImage") }), _jsx(ConfirmButton, { t: t, label: t("rebuildAllImages"), title: t("confirmTitle"), description: t("confirmRebuildAllImages"), disabled: state.busy, onConfirm: props.rebuildAllImages })] }), _jsx("div", { style: sectionTitle, children: t("baseImagesTitle") }), baseImages.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (baseImages.map((image) => (_jsx(BaseImageRow, { t: t, image: image, busy: state.busy, defaultImage: state.defaultImage, onRebuild: props.rebuildBaseImage, onPull: props.pullBaseImage, onSetDefault: props.setDefaultImage }, image.imageId)))), _jsx("div", { style: sectionTitle, children: t("customImagesTitle") }), customImages.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (customImages.map((image) => (_jsx(ImageItem, { t: t, image: image, busy: state.busy, defaultImage: state.defaultImage, onRemove: props.removeImage, onRebuild: props.rebuildImage, onSetDefault: props.setDefaultImage }, image.imageId)))), _jsx(ImageBuildModal, { t: t, images: state.images, open: buildOpen, imageId: imageId, parent: parent, packages: packages, onImageId: setImageId, onParent: setParent, onPackages: setPackages, onClose: () => setBuildOpen(false), onBuild: () => {
97
- props.buildImage(imageId.trim(), parent.trim(), packages);
98
- setImageId("");
99
- setParent("");
100
- setPackages([]);
101
- setBuildOpen(false);
102
- } }), _jsxs(Modal, { open: defaultOpen, onClose: () => setDefaultOpen(false), title: t("setDefaultImageTitle"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => setDefaultOpen(false), children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: defaultImage === "", onClick: () => {
103
- props.setDefaultImage(defaultImage);
104
- setDefaultOpen(false);
105
- }, children: t("setDefaultImage") })] }), children: [_jsxs("select", { style: imageSelect, value: defaultImage, onChange: (event) => setDefaultImage(event.target.value), children: [defaultCandidates.length === 0
106
- ? _jsx("option", { value: "", children: t("none") })
107
- : null, defaultCandidates.map((name) => (_jsx("option", { value: name, children: name }, name)))] }), _jsx("p", { style: hint, children: t("defaultImageHint") })] }), _jsx(CachesSection, { t: t, caches: state.caches, busy: state.busy, onClean: props.cleanCaches }), _jsx(VolumesSection, { t: t, volumes: state.volumes, busy: state.busy, writable: state.writable, onCreate: props.createVolume, onRemove: props.removeVolume }), _jsx(SecretsSection, { t: t, secrets: state.secrets, busy: state.busy, writable: state.writable, onCreate: props.createSecret, onRemove: props.removeSecret, onSet: props.setSecret }), _jsx(DefaultEnvironmentSection, { t: t, env: state.containerEnv, busy: state.busy, writable: state.writable, onSave: props.saveContainerEnv, onSync: props.syncDefaultEnv }), _jsxs("div", { style: {
77
+ const tabId = (value) => `${tabsId}-tab-${value}`;
78
+ const panelId = (value) => `${tabsId}-panel-${value}`;
79
+ // Both daemons read as ready or not ready. The orchestrator stays unknown
80
+ // only until its first snapshot settles; the gateway keeps the snapshot's own
81
+ // unknown when the orchestrator cannot report it at all, because "unknown" is
82
+ // then the fact rather than a state this card can resolve. A daemon that runs
83
+ // with a diverging version carries that divergence in the chip's own tone and
84
+ // words, so its version is never colour alone.
85
+ const orchestratorChip = state.orchestratorKnown
86
+ ? state.orchestratorReady
87
+ ? versionChip(t, { tone: "ok", label: t("orchestratorReady") }, state.versionState)
88
+ : { tone: "error", label: t("orchestratorNotReady") }
89
+ : { tone: "muted", label: t("orchestratorUnknown") };
90
+ const gatewayChip = state.gatewayState === "running"
91
+ ? versionChip(t, { tone: "ok", label: t("gatewayReady") }, state.gatewayVersionState)
92
+ : state.gatewayState === "absent"
93
+ ? { tone: "warn", label: t("gatewayNotReady") }
94
+ : state.gatewayState === "incompatible"
95
+ ? { tone: "error", label: t("gatewayNotReady") }
96
+ : { tone: "muted", label: t("gatewayUnknown") };
97
+ const noWorkspace = state.workspaces.length === 0;
98
+ // Every known workspace is listed, including the ones without a container:
99
+ // the workspaces whose newest container was created most recently come first,
100
+ // the empty ones sort last (where they also read muted), and each workspace
101
+ // lists its default container first, since that is the one its own mount and
102
+ // create actions target.
103
+ const workspaceRows = state.workspaces
104
+ .map((workspace) => ({
105
+ workspace,
106
+ containers: state.containers
107
+ .filter((container) => container.workspaceSlug === workspace.workspaceSlug)
108
+ .sort((left, right) => Number(right.containerName === "default") -
109
+ Number(left.containerName === "default")),
110
+ }))
111
+ .sort((left, right) => {
112
+ const leftEmpty = left.containers.length === 0;
113
+ const rightEmpty = right.containers.length === 0;
114
+ // An empty workspace is always last, whatever the other holds.
115
+ if (leftEmpty || rightEmpty) {
116
+ return Number(leftEmpty) - Number(rightEmpty);
117
+ }
118
+ return newestContainerAt(right.containers) -
119
+ newestContainerAt(left.containers);
120
+ });
121
+ // The strip counts what it names: the workspaces that actually hold a
122
+ // container (an empty workspace is listed, but it has nothing to count), and
123
+ // the running containers alone.
124
+ const containerWorkspaces = workspaceRows.filter(({ containers }) => containers.length > 0).length;
125
+ const runningContainers = state.containers.filter((container) => container.status === "running").length;
126
+ return (_jsxs("div", { style: pageColumn, children: [state.notice === ""
127
+ ? null
128
+ : (_jsxs("div", { style: banner, role: state.noticeIsError ? "alert" : "status", children: [t("notice"), ": ", state.notice] })), state.versionState === "ok" ? null : (_jsxs("div", { style: {
129
+ ...banner,
108
130
  display: "flex",
109
- flexWrap: "wrap",
110
131
  alignItems: "center",
111
132
  gap: "8px",
112
- }, children: [_jsx("div", { style: { ...sectionTitle, flex: 1 }, children: t("versionsTitle") }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => void copyVersions(), children: copyState === "copied"
113
- ? t("copied")
114
- : copyState === "failed"
115
- ? t("copyFailed")
116
- : t("copyVersions") })] }), _jsxs("div", { style: {
117
- ...hint,
118
- display: "flex",
119
- flexDirection: "column",
120
- gap: "2px",
121
- margin: 0,
122
- }, children: [_jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("dsh") }), state.dshVersion
123
- ? (` ${state.dshVersion}`)
124
- : (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: { color: "var(--dsw-alias-state-error-primary)" }, children: t("versionUnknown") })] }))] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("cardTitle") }), state.version ? ` ${state.version}` : "", state.commit ? ` · ${state.commit}` : ""] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("orchestrator") }), state.orchestratorVersion
125
- ? (` ${state.orchestratorVersion}`)
126
- : (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: { color: "var(--dsw-alias-state-error-primary)" }, children: t("versionUnknown") })] })), state.orchestratorCommit ? ` · ${state.orchestratorCommit}` : ""] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("gateway") }), state.gatewayState === "running"
127
- ? ` ${state.gatewayVersion}${state.gatewayCommit ? ` · ${state.gatewayCommit}` : ""}`
128
- : (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: state.gatewayState === "incompatible"
129
- ? { color: "var(--dsw-alias-state-error-primary)" }
130
- : undefined, children: state.gatewayState === "incompatible"
131
- ? t("gatewayIncompatible")
132
- : t("gatewayNotRunning") })] }))] })] }), _jsx("div", { style: footerRow, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
133
+ }, role: state.versionState === "major-mismatch" ? "alert" : "status", children: [_jsx(StatusChip, { tone: state.versionState === "major-mismatch" ? "error" : "warn", label: t(state.versionState === "major-mismatch"
134
+ ? "versionIncompatible"
135
+ : "versionCompatibleDifferent") }), _jsx("span", { children: t(state.versionState === "major-mismatch"
136
+ ? "versionMismatchMajor"
137
+ : "versionMismatchMinor") })] })), _jsxs("div", { style: statusStrip, role: "group", "aria-label": t("statusOverview"), children: [_jsx(StatusChip, { tone: "muted", label: countLabel(t, containerWorkspaces, "countWorkspaceOne", "countWorkspaceMany") }), _jsx(StatusChip, { tone: "muted", label: countLabel(t, runningContainers, "countRunningContainerOne", "countRunningContainerMany") }), _jsx(StatusChip, { tone: orchestratorChip.tone, label: orchestratorChip.label }), _jsx(StatusChip, { tone: gatewayChip.tone, label: gatewayChip.label })] }), _jsx(SegmentedTabs, { label: t("settingsTabs"), className: TABS_CLASS, value: tab, onChange: setTab, items: [
138
+ {
139
+ value: "workspaces",
140
+ label: t("tabWorkspaces"),
141
+ id: tabId("workspaces"),
142
+ panelId: panelId("workspaces"),
143
+ },
144
+ {
145
+ value: "images",
146
+ label: t("tabImages"),
147
+ id: tabId("images"),
148
+ panelId: panelId("images"),
149
+ },
150
+ {
151
+ value: "storage",
152
+ label: t("tabStorage"),
153
+ id: tabId("storage"),
154
+ panelId: panelId("storage"),
155
+ },
156
+ {
157
+ value: "defaults",
158
+ label: t("tabDefaults"),
159
+ id: tabId("defaults"),
160
+ panelId: panelId("defaults"),
161
+ },
162
+ {
163
+ value: "status",
164
+ label: t("tabStatus"),
165
+ id: tabId("status"),
166
+ panelId: panelId("status"),
167
+ },
168
+ ] }), _jsx("div", { id: panelId("workspaces"), role: "tabpanel", "aria-labelledby": tabId("workspaces"), hidden: tab !== "workspaces", style: tab === "workspaces" ? tabPanel : undefined, children: noWorkspace ? _jsx("p", { style: hint, children: t("noWorkspaces") }) : (workspaceRows.map(({ workspace, containers }) => (_jsx(WorkspaceSection, { t: t, workspace: workspace, containers: containers, images: state.images, volumes: state.volumes, secrets: state.secrets, busy: state.busy, writable: state.writable, locale: state.locale, pendingActions: state.pendingActions, defaultImage: state.defaultImage, defaultEnv: state.containerEnv, projectsRoot: state.projectsRoot, directoryPicker: state.directoryPicker, onRemove: props.remove, onRecreate: props.recreate, onRemoveWorkspace: props.removeWorkspace, onCreate: props.createContainer, onCreateSecret: props.createSecret, onStartContainer: props.startContainer, onApplyContainerConfig: props.applyContainerConfig, gatewayUnavailable: state.gatewayState === "absent" ||
169
+ state.gatewayState === "incompatible" }, workspace.workspaceSlug)))) }), _jsx("div", { id: panelId("images"), role: "tabpanel", "aria-labelledby": tabId("images"), hidden: tab !== "images", style: tab === "images" ? tabPanel : undefined, children: _jsx(ImagesSection, { t: t, images: state.images, busy: state.busy, pendingActions: state.pendingActions, defaultImage: state.defaultImage, locale: state.locale, onBuildImage: props.buildImage, onRebuildAllImages: props.rebuildAllImages, onRebuildBaseImage: props.rebuildBaseImage, onPullBaseImage: props.pullBaseImage, onRemoveImage: props.removeImage, onRebuildImage: props.rebuildImage, onSetDefaultImage: props.setDefaultImage }) }), _jsx("div", { id: panelId("storage"), role: "tabpanel", "aria-labelledby": tabId("storage"), hidden: tab !== "storage", style: tab === "storage" ? tabPanel : undefined, children: _jsx(StorageSection, { t: t, volumes: state.volumes, secrets: state.secrets, caches: state.caches, busy: state.busy, writable: state.writable, pendingActions: state.pendingActions, onCleanCaches: props.cleanCaches, onCreateVolume: props.createVolume, onRemoveVolume: props.removeVolume, onCreateSecret: props.createSecret, onRemoveSecret: props.removeSecret, onSetSecret: props.setSecret }) }), _jsx("div", { id: panelId("defaults"), role: "tabpanel", "aria-labelledby": tabId("defaults"), hidden: tab !== "defaults", style: tab === "defaults" ? tabPanel : undefined, children: _jsx(DefaultsSection, { t: t, images: state.images, defaultImage: state.defaultImage, env: state.containerEnv, workspaces: state.workspaces, containers: state.containers, busy: state.busy, writable: state.writable, onSetDefaultImage: props.setDefaultImage, onSaveEnv: props.saveContainerEnv, onApplyDefaultEnv: props.applyDefaultEnv }) }), _jsx("div", { id: panelId("status"), role: "tabpanel", "aria-labelledby": tabId("status"), hidden: tab !== "status", style: tab === "status" ? tabPanel : undefined, children: _jsx(StatusSection, { t: t, dshVersion: state.dshVersion, version: state.version, commit: state.commit, versionState: state.versionState, orchestratorVersion: state.orchestratorVersion, orchestratorCommit: state.orchestratorCommit, orchestratorReady: state.orchestratorReady, orchestratorKnown: state.orchestratorKnown, gatewayState: state.gatewayState, gatewayVersion: state.gatewayVersion, gatewayCommit: state.gatewayCommit, gatewayVersionState: state.gatewayVersionState }) }), _jsx("div", { style: actionRow, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
133
170
  }
@@ -8,6 +8,10 @@ export interface MountInput {
8
8
  secret: string;
9
9
  }
10
10
  export type CommandOp = "remove" | "workspace_remove" | "recreate" | "create" | "volume_create" | "volume_remove" | "image_remove" | "secret_create" | "secret_remove" | "secret_set" | "image_rebuild" | "image_rebuild_all" | "image_build" | "image_base_rebuild" | "image_base_pull" | "container_secret_add" | "container_secret_remove" | "container_mount_add" | "container_mount_remove" | "container_mount_update" | "container_publish_port" | "container_unpublish_port" | "container_path_set" | "default_env_sync" | "cache_clean";
11
+ export declare function containerActionKey(op: CommandOp, workspace: string, container: string): string;
12
+ export declare function scopedActionKey(op: CommandOp, scope: string): string;
13
+ export declare function bareActionKey(op: CommandOp): string;
14
+ export declare function containerActionPending(pendingActions: readonly string[], workspace: string, container: string): boolean;
11
15
  export interface CommandRequest {
12
16
  op: CommandOp;
13
17
  workspace: string;
@@ -8,3 +8,37 @@
8
8
  // registers and matches the whole pathname (a path outside `/api/` is refused
9
9
  // at registration).
10
10
  export const CARD_PATH = "/api/podman/card";
11
+ // The stable identity of one in-flight command: its operation plus the
12
+ // identifiers it acts on, e.g. "remove:team:default" or "volume_create:data".
13
+ // The controller keys its in-flight set with these builders and every control
14
+ // looks its own command up in CardState.pendingActions, so both halves must
15
+ // derive the key the same way. Identifiers never contain ":" (container and
16
+ // volume names, workspace slugs, cache modes), while an image id may, which is
17
+ // why keys are only ever compared whole.
18
+ export function containerActionKey(op, workspace, container) {
19
+ return `${op}:${workspace}:${container}`;
20
+ }
21
+ export function scopedActionKey(op, scope) {
22
+ return `${op}:${scope}`;
23
+ }
24
+ export function bareActionKey(op) {
25
+ return op;
26
+ }
27
+ // The operations keyed by containerActionKey(op, workspace, container), so a
28
+ // container row can tell whether any command on its own container is in flight.
29
+ const CONTAINER_OPS = [
30
+ "remove",
31
+ "recreate",
32
+ "create",
33
+ "container_mount_add",
34
+ "container_mount_remove",
35
+ "container_mount_update",
36
+ "container_path_set",
37
+ "container_secret_add",
38
+ "container_secret_remove",
39
+ "container_publish_port",
40
+ "container_unpublish_port",
41
+ ];
42
+ export function containerActionPending(pendingActions, workspace, container) {
43
+ return CONTAINER_OPS.some((op) => pendingActions.includes(containerActionKey(op, workspace, container)));
44
+ }
@@ -5,6 +5,6 @@ import { type ReactNode } from "react";
5
5
  export declare function CachesSection(props: {
6
6
  t: TranslateNS<typeof NS>;
7
7
  caches: readonly CacheView[];
8
- busy: boolean;
8
+ pendingActions: readonly string[];
9
9
  onClean: (mode: string) => void;
10
10
  }): ReactNode;
@@ -2,8 +2,10 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
3
  //
4
4
  // SPDX-License-Identifier: MIT
5
- import { ConfirmButton } from "./container-card-shared.js";
6
- import { hint, sectionTitle, wsBody } from "./container-card-styles.js";
5
+ import { ConfirmButton, countLabel } from "./container-card-shared.js";
6
+ import { CardGroup } from "./container-card-group.js";
7
+ import { scopedActionKey } from "./card-protocol.js";
8
+ import { cardList, cardRow, containerNameHeading, hint, rowDivider, rowMain, rowMeta, } from "./container-card-styles.js";
7
9
  // Format a byte count with binary units, e.g. "1.2 GiB".
8
10
  function formatBytes(bytes) {
9
11
  if (!Number.isFinite(bytes) || bytes <= 0)
@@ -17,20 +19,20 @@ function formatBytes(bytes) {
17
19
  }
18
20
  return `${unit === 0 ? String(value) : value.toFixed(1)} ${units[unit]}`;
19
21
  }
20
- // The package-manager build caches: their current size and the two cleanup
21
- // actions. The caches are re-downloadable, so neither action is destructive.
22
+ // The package-manager build caches: one row per manager with its current size,
23
+ // and the two cleanup actions on the card's title row. Keeping the latest
24
+ // versions only prunes older files, so it reads as the warn-tinted, cautious
25
+ // action it is; removing every cached package stays error-coloured, because it
26
+ // is a full clear.
22
27
  export function CachesSection(props) {
23
- const { t, caches, busy, onClean } = props;
24
- const disabled = busy || caches.length === 0;
25
- return (_jsxs(_Fragment, { children: [_jsx("div", { style: sectionTitle, children: t("cachesTitle") }), _jsxs("div", { style: wsBody, children: [caches.length === 0
26
- ? _jsx("p", { style: { ...hint, margin: 0 }, children: t("noCaches") })
27
- : (caches.map((cache) => (_jsxs("div", { style: {
28
- display: "flex",
29
- flexWrap: "wrap",
30
- alignItems: "center",
31
- gap: "8px",
32
- }, children: [_jsx("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: cache.manager }), _jsx("span", { style: hint, children: t("cacheUsage", {
33
- size: formatBytes(cache.bytes),
34
- n: cache.files,
35
- }) })] }, cache.manager)))), _jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [_jsx(ConfirmButton, { t: t, label: t("cacheKeepLatest"), title: t("confirmTitle"), description: t("confirmCacheKeepLatest"), disabled: disabled, onConfirm: () => onClean("keep-latest") }), _jsx(ConfirmButton, { t: t, label: t("cacheRemoveAll"), title: t("confirmTitle"), description: t("confirmCacheRemoveAll"), disabled: disabled, onConfirm: () => onClean("all") })] })] })] }));
28
+ const { t, caches, pendingActions, onClean } = props;
29
+ const disabled = caches.length === 0;
30
+ return (_jsx(CardGroup, { title: t("cachesTitle"), summary: countLabel(t, caches.length, "countCacheOne", "countCacheMany"), hasContent: caches.length > 0, action: _jsxs(_Fragment, { children: [_jsx(ConfirmButton, { t: t, emphasis: "warn", label: t("cacheKeepLatest"), title: t("cacheKeepLatest"), description: t("confirmCacheKeepLatest"), confirmLabel: t("cacheKeepLatest"), disabled: disabled, pending: pendingActions.includes(scopedActionKey("cache_clean", "keep-latest")), onConfirm: () => onClean("keep-latest") }), _jsx(ConfirmButton, { t: t, destructive: true, label: t("cacheRemoveAll"), title: t("cacheRemoveAll"), description: t("confirmCacheRemoveAll"), confirmLabel: t("cacheRemoveAll"), disabled: disabled, pending: pendingActions.includes(scopedActionKey("cache_clean", "all")), onConfirm: () => onClean("all") })] }), children: caches.length === 0
31
+ ? _jsx("p", { style: { ...hint, margin: 0 }, children: t("noCaches") })
32
+ : (_jsx("div", { style: cardList, children: caches.map((cache, index) => (_jsx("div", { style: index === caches.length - 1
33
+ ? cardRow
34
+ : { ...cardRow, ...rowDivider }, children: _jsxs("div", { style: rowMain, children: [_jsx("span", { style: containerNameHeading, children: cache.manager }), _jsx("span", { style: rowMeta, children: t("cacheUsage", {
35
+ size: formatBytes(cache.bytes),
36
+ n: cache.files,
37
+ }) })] }) }, cache.manager))) })) }));
36
38
  }
@@ -0,0 +1,47 @@
1
+ import type { ContainerView, MountInput } from "./card-protocol.js";
2
+ import type { ContainerPluginKey } from "./locales.js";
3
+ export interface PortConfig {
4
+ port: number;
5
+ protocol: string;
6
+ endpoint: string;
7
+ suggestedHostPort: number;
8
+ hostPort: number;
9
+ }
10
+ export interface ContainerConfig {
11
+ image: string;
12
+ env: Record<string, string>;
13
+ mounts: readonly MountInput[];
14
+ paths: readonly string[];
15
+ secretEnv: Record<string, string>;
16
+ ports: readonly PortConfig[];
17
+ }
18
+ export declare function containerConfigFrom(container: ContainerView): ContainerConfig;
19
+ export declare function recordsEqual(a: Record<string, string>, b: Record<string, string>): boolean;
20
+ export declare function mountKey(mount: MountInput): string;
21
+ export declare function mountInputsEqual(a: MountInput, b: MountInput): boolean;
22
+ export declare function mountsEqual(a: readonly MountInput[], b: readonly MountInput[]): boolean;
23
+ export declare function pathsEqual(a: readonly string[], b: readonly string[]): boolean;
24
+ export declare function portsEqual(a: readonly PortConfig[], b: readonly PortConfig[]): boolean;
25
+ export declare function configsEqual(a: ContainerConfig, b: ContainerConfig): boolean;
26
+ export type ConfigGroupId = "image" | "env" | "mounts" | "paths" | "secretEnv" | "ports";
27
+ export declare const configGroupLabels: Record<ConfigGroupId, ContainerPluginKey>;
28
+ export declare function configChangedKeys(base: ContainerConfig, next: ContainerConfig): ConfigGroupId[];
29
+ export declare function configRebuildsContainer(base: ContainerConfig, next: ContainerConfig): boolean;
30
+ export declare function configNeedsRecreate(base: ContainerConfig, next: ContainerConfig): boolean;
31
+ export interface MountDiff {
32
+ added: MountInput[];
33
+ removed: MountInput[];
34
+ updated: MountInput[];
35
+ }
36
+ export declare function mountDiff(base: readonly MountInput[], next: readonly MountInput[]): MountDiff;
37
+ export interface EnvDiff {
38
+ added: [string, string][];
39
+ removed: string[];
40
+ changed: [string, string][];
41
+ }
42
+ export declare function envDiff(base: Record<string, string>, next: Record<string, string>): EnvDiff;
43
+ export interface PortDiff {
44
+ added: PortConfig[];
45
+ removed: PortConfig[];
46
+ }
47
+ export declare function portDiff(base: readonly PortConfig[], next: readonly PortConfig[]): PortDiff;