@exagone313/dsh-podman 1.2.0 → 1.3.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 (98) 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 +6488 -3474
  61. package/dist/client/locales.d.ts +10 -1
  62. package/dist/client/locales.js +268 -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 +1 -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 +6 -4
  81. package/docs/architecture.zh.md +3 -1
  82. package/docs/configuration.md +28 -25
  83. package/docs/configuration.zh.md +15 -11
  84. package/docs/development-prompt.md +9 -7
  85. package/docs/development-prompt.zh.md +9 -7
  86. package/docs/development.md +25 -18
  87. package/docs/development.zh.md +22 -18
  88. package/docs/install-dsh-and-dsh-podman.md +15 -12
  89. package/docs/install-dsh-and-dsh-podman.zh.md +15 -9
  90. package/docs/uninstall.md +2 -0
  91. package/docs/uninstall.zh.md +2 -0
  92. package/docs/update.md +2 -0
  93. package/docs/update.zh.md +2 -0
  94. package/docs/usage.md +191 -39
  95. package/docs/usage.zh.md +150 -29
  96. package/package.json +8 -4
  97. package/dist/client/container-card-default-env.d.ts +0 -10
  98. package/dist/client/container-card-default-env.js +0 -69
@@ -1,4 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { COMPACT_DIALOG_CLASS } from "./container-card-dialog-styles.js";
2
3
  import { DIRECTORY_CLASS } from "./container-card-directory-styles.js";
3
4
  import { confineToRoot, crumbLabel, rootCrumbs } from "../project-path.js";
4
5
  import { Button, IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconFolderCloseRegular, IconFolderOpenRegular, Modal, } from "@deepseek-ai/dsh-client-ui-primitives";
@@ -6,12 +7,12 @@ import { useEffect, useRef, useState } from "react";
6
7
  // How long a listing may take before the browser admits it is still loading.
7
8
  const SLOW_SCAN_DELAY_MS = 300;
8
9
  // The directory browser a project mount path is chosen with. Its layout mirrors
9
- // dsh's own directory browser — a 680x500 dialog with two Miller columns,
10
- // chevron breadcrumbs and 28px folder rows — and it lists through the harness's
11
- // own host-side picker, never a container or the orchestrator. It is confined
12
- // to the projects root: the breadcrumb trail starts there, the browser never
13
- // navigates above it, and so it can only ever produce a path a project mount
14
- // accepts.
10
+ // dsh's own directory browser — two Miller columns, chevron breadcrumbs and 28px
11
+ // folder rows — under the small dialogs' shared compact cap, and it lists through
12
+ // the harness's own host-side picker, never a container or the orchestrator. It
13
+ // is confined to the projects root: the breadcrumb trail starts there, the
14
+ // browser never navigates above it, and so it can only ever produce a path a
15
+ // project mount accepts.
15
16
  export function DirectoryPickerModal(props) {
16
17
  const { t, open, root, start, picker, onSelect, onClose } = props;
17
18
  const [path, setPath] = useState(() => confineToRoot(root, start));
@@ -128,7 +129,7 @@ export function DirectoryPickerModal(props) {
128
129
  const crumbs = rootCrumbs(root, path);
129
130
  const visible = (entries) => entries.filter((entry) => showHidden || !entry.hidden);
130
131
  const truncated = level?.truncated === true || child?.truncated === true;
131
- return (_jsx(Modal, { open: open, onClose: onClose, title: t("browseTitle"), className: DIRECTORY_CLASS, headless: true, children: _jsxs("div", { className: "dsh-podman-directory-scope", children: [_jsxs("div", { className: "dsh-podman-directory-header", children: [_jsx("h2", { className: "dsh-podman-directory-title", children: t("browseTitle") }), _jsx("div", { className: "dsh-podman-directory-crumbbar", children: _jsxs("nav", { ref: trailRef, className: "dsh-podman-directory-crumbs", "aria-label": t("browseTitle"), children: [_jsx("span", { className: "dsh-podman-directory-crumbseat", children: _jsx("button", { type: "button", className: "dsh-podman-directory-crumb", disabled: busy, onClick: () => navigate(root), children: crumbLabel(root) }) }), crumbs.map((crumb) => (_jsxs("span", { className: "dsh-podman-directory-crumbseat", children: [_jsx(IconChevronRightOutlineRegular, { size: 12, className: "dsh-podman-directory-crumbchevron" }), _jsx("button", { type: "button", className: "dsh-podman-directory-crumb", disabled: busy, onClick: () => navigate(crumb), children: crumbLabel(crumb) })] }, crumb)))] }) })] }), _jsxs("div", { className: "dsh-podman-directory-content", children: [_jsxs("div", { className: "dsh-podman-directory-miller", children: [_jsx("ul", { className: "dsh-podman-directory-column", children: (level?.entries ?? []).length === 0 ? null : (visible(level?.entries ?? []).map((entry) => (_jsx(DirectoryRow, { entry: entry, selected: selected?.path === entry.path, busy: busy, onPick: select }, entry.path)))) }), selected === null ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "dsh-podman-directory-divider" }), _jsx("ul", { className: "dsh-podman-directory-column", children: visible(child?.entries ?? []).map((entry) => (_jsx(DirectoryRow, { entry: entry, selected: false, busy: busy, onPick: advance }, entry.path))) })] }))] }), error === ""
132
+ return (_jsx(Modal, { open: open, onClose: onClose, title: t("browseTitle"), className: `${DIRECTORY_CLASS} ${COMPACT_DIALOG_CLASS}`, headless: true, children: _jsxs("div", { className: "dsh-podman-directory-scope", children: [_jsxs("div", { className: "dsh-podman-directory-header", children: [_jsx("h2", { className: "dsh-podman-directory-title", children: t("browseTitle") }), _jsx("div", { className: "dsh-podman-directory-crumbbar", children: _jsxs("nav", { ref: trailRef, className: "dsh-podman-directory-crumbs", "aria-label": t("browseTitle"), children: [_jsx("span", { className: "dsh-podman-directory-crumbseat", children: _jsx("button", { type: "button", className: "dsh-podman-directory-crumb", disabled: busy, onClick: () => navigate(root), children: crumbLabel(root) }) }), crumbs.map((crumb) => (_jsxs("span", { className: "dsh-podman-directory-crumbseat", children: [_jsx(IconChevronRightOutlineRegular, { size: 12, className: "dsh-podman-directory-crumbchevron" }), _jsx("button", { type: "button", className: "dsh-podman-directory-crumb", disabled: busy, onClick: () => navigate(crumb), children: crumbLabel(crumb) })] }, crumb)))] }) })] }), _jsxs("div", { className: "dsh-podman-directory-content", children: [_jsxs("div", { className: "dsh-podman-directory-miller", children: [_jsx("ul", { className: "dsh-podman-directory-column", children: (level?.entries ?? []).length === 0 ? null : (visible(level?.entries ?? []).map((entry) => (_jsx(DirectoryRow, { entry: entry, selected: selected?.path === entry.path, busy: busy, onPick: select }, entry.path)))) }), selected === null ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "dsh-podman-directory-divider" }), _jsx("ul", { className: "dsh-podman-directory-column", children: visible(child?.entries ?? []).map((entry) => (_jsx(DirectoryRow, { entry: entry, selected: false, busy: busy, onPick: advance }, entry.path))) })] }))] }), error === ""
132
133
  ? null
133
134
  : (_jsx("p", { className: "dsh-podman-directory-error", role: "alert", children: error })), error === "" && truncated
134
135
  ? (_jsx("p", { className: "dsh-podman-directory-status", role: "status", children: t("browseTruncated") }))
@@ -0,0 +1,39 @@
1
+ import { type ContainerConfig } from "./container-card-config.js";
2
+ import { type ContainerView, type ImageView } from "./container-card-controller.js";
3
+ import { type DirectoryPickerFace } from "./directory-picker.js";
4
+ import { type Translate, type Translation } from "./locales.js";
5
+ import { type ReactNode } from "react";
6
+ export declare function ContainerEditModal(props: {
7
+ t: Translate;
8
+ open: boolean;
9
+ container: ContainerView;
10
+ images: readonly ImageView[];
11
+ volumes: readonly {
12
+ name: string;
13
+ }[];
14
+ secrets: readonly {
15
+ name: string;
16
+ }[];
17
+ busy: boolean;
18
+ enabled: boolean;
19
+ usable: boolean;
20
+ canPublish: boolean;
21
+ gatewayUnavailable: boolean;
22
+ projectName: string;
23
+ projectsRoot: string;
24
+ directoryPicker?: DirectoryPickerFace;
25
+ writable: boolean;
26
+ draft: ContainerConfig;
27
+ dirty: boolean;
28
+ pending: boolean;
29
+ marker?: string;
30
+ markerError?: boolean;
31
+ onBlockingError?: (error: Translation | undefined) => void;
32
+ rebuilds: boolean;
33
+ recreatePending: boolean;
34
+ onCreateSecret: (name: string, length?: number, charset?: string) => void;
35
+ onChange: (draft: ContainerConfig) => void;
36
+ onDiscard: () => void;
37
+ onApply: () => void;
38
+ onClose: () => void;
39
+ }): ReactNode;
@@ -0,0 +1,29 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ContainerDialog } from "./container-card-dialog.js";
3
+ import { ContainerForm } from "./container-card-form.js";
4
+ import { ConfirmButton } from "./container-card-shared.js";
5
+ import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
6
+ export function ContainerEditModal(props) {
7
+ const { t, open, container, images, volumes, secrets, busy, enabled, usable, canPublish, gatewayUnavailable, projectName, projectsRoot, directoryPicker, writable, draft, dirty, pending, marker, markerError, onBlockingError, rebuilds, recreatePending, onCreateSecret, onChange, onDiscard, onApply, onClose, } = props;
8
+ // The one primary action names what it does: a change that rebuilds the
9
+ // container reads as a destructive recreate, and one the running container
10
+ // takes on its own reads as an update.
11
+ const applyLabel = rebuilds ? t("recreateContainer") : t("updateContainer");
12
+ return (_jsx(ContainerDialog, { t: t, open: open, title: t("editContainerTitle"), onClose: onClose, marker: marker, markerError: markerError, actions: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: !enabled || (!dirty && !pending), onClick: onDiscard, children: t("discard") }), _jsx(ConfirmButton, { t: t, label: applyLabel, variant: rebuilds ? "outline" : "primary", destructive: rebuilds, title: rebuilds ? t("recreate") : t("updateContainer"), description: rebuilds
13
+ ? t("confirmRecreate", {
14
+ workspace: projectName,
15
+ container: container.containerName,
16
+ })
17
+ : t("confirmUpdate", {
18
+ workspace: projectName,
19
+ container: container.containerName,
20
+ }), confirmLabel: applyLabel, disabled: !usable || marker === undefined || markerError === true, pending: recreatePending || busy, onConfirm: onApply })] }), 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: enabled, canPublish: canPublish, gatewayUnavailable: gatewayUnavailable, writable: writable, projectsRoot: projectsRoot, directoryPicker: directoryPicker, mainProject: projectName, primaryProject: container.containerName === "default"
21
+ ? projectName
22
+ : "", confirmRemoveMount: true, onCreateSecret: onCreateSecret, onChangeImage: (image) => onChange({ ...draft, image }), onChangeEnv: (env) => onChange({ ...draft, env }), onChangeMounts: (mounts) => onChange({ ...draft, mounts }), onChangePaths: (paths) => onChange({ ...draft, paths }), onChangeSecretEnv: (secretEnv) => onChange({ ...draft, secretEnv }), onChangePorts: (ports) => onChange({ ...draft, ports }), onBlockingError: onBlockingError, name: {
23
+ /* A container's name is its identity, so the group states it. */
24
+ value: container.containerName,
25
+ error: "",
26
+ readOnly: true,
27
+ disabled: false,
28
+ } }) }));
29
+ }
@@ -1,12 +1,15 @@
1
1
  import { type MountInput } from "./container-card-controller.js";
2
2
  import { type DirectoryPickerFace } from "./directory-picker.js";
3
- import type { Translate } from "./locales.js";
3
+ import type { Translate, Translation } from "./locales.js";
4
4
  import { type ReactNode } from "react";
5
5
  export declare function EnvEditor(props: {
6
6
  t: Translate;
7
7
  env: Record<string, string>;
8
8
  busy: boolean;
9
9
  onChange: (env: Record<string, string>) => void;
10
+ onBlockingError?: (error: Translation | undefined) => void;
11
+ otherNames?: readonly string[];
12
+ onNames?: (names: readonly string[]) => void;
10
13
  }): ReactNode;
11
14
  export declare function MountsEditor(props: {
12
15
  t: Translate;
@@ -22,8 +25,8 @@ export declare function MountsEditor(props: {
22
25
  projectsRoot: string;
23
26
  directoryPicker?: DirectoryPickerFace;
24
27
  confirmRemove?: boolean;
25
- modeControl?: "remount" | "select";
26
28
  primaryProject?: string;
29
+ mainProject?: string;
27
30
  onAdd: (mount: MountInput) => void;
28
31
  onRemove: (mount: MountInput) => void;
29
32
  onUpdate?: (mount: MountInput, index: number) => void;
@@ -2,99 +2,111 @@ 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, emptyMount, Field, mountLabel, } from "./container-card-shared.js";
6
- import { greyId, imageSelect } from "./container-card-styles.js";
5
+ import { DiscardChangesModal, emptyMount, EnvRow, MountRow, orderedMounts, } from "./container-card-shared.js";
6
+ import { imageSelect } from "./container-card-styles.js";
7
+ import { ROW_LIST_CLASS } from "./container-card-table-styles.js";
8
+ import { mountInputsEqual, recordsEqual } from "./container-card-config.js";
7
9
  import { DirectoryPickerModal } from "./container-card-directory.js";
8
- import { forcedMountMode } from "../mount-enums.js";
9
- import { commitEnvDraft, emptyEnvDraft, envRows, removeEnvRow, renameEnvKey, setEnvValue, } from "../env-rows.js";
10
+ import { conflictingEnvNames, emptyEnvRow, envEditRows, envRecordFromRows, firstDuplicateEnvName, } from "../env-rows.js";
10
11
  import { hostPathForProjectName, projectNameFromHostPath, } from "../project-path.js";
11
- import { Button, Input, Modal } from "@deepseek-ai/dsh-client-ui-primitives";
12
- import { useId, useRef, useState } from "react";
13
- // One stable key per env row, so renaming a variable does not remount the row
14
- // and drop focus mid-keystroke. The parent keeps env as a record; rows are
15
- // positional, so the id list is aligned by index.
16
- let nextEnvId = 0;
12
+ import { Button, Modal } from "@deepseek-ai/dsh-client-ui-primitives";
13
+ import { useEffect, useMemo, useState } from "react";
17
14
  export function EnvEditor(props) {
18
- const { t, env, busy, onChange } = props;
19
- // The row being typed: it becomes a record entry only once its key is a real,
20
- // unused variable name, so an abandoned Add cannot apply a placeholder.
21
- const [draft, setDraft] = useState(undefined);
22
- const rows = envRows(env, draft);
23
- const idsRef = useRef([]);
24
- if (idsRef.current.length !== rows.length) {
25
- const ids = idsRef.current.slice(0, rows.length);
26
- while (ids.length < rows.length)
27
- ids.push(nextEnvId++);
28
- idsRef.current = ids;
15
+ const { t, env, busy, onChange, onBlockingError, otherNames, onNames } = props;
16
+ // The rows are the editor's own: a row keeps its place while its key is
17
+ // retyped, so clearing a key never drops the row — it stays, red, until its
18
+ // own Remove — and renaming one onto a name another row already holds keeps
19
+ // both rows. The parent's record is derived from the named rows alone, so an
20
+ // unnamed row is never applied.
21
+ const [rows, setRows] = useState(() => envEditRows(env));
22
+ // A parent record that no longer matches what these rows derive is an outside
23
+ // change — the snapshot resynced after an apply — so the rows are rebuilt
24
+ // from it instead of echoing the ones it replaced.
25
+ if (!recordsEqual(env, envRecordFromRows(rows))) {
26
+ setRows(envEditRows(env));
29
27
  }
30
- const commitDraft = () => {
31
- if (draft === undefined)
32
- return;
33
- if (draft.key === "") {
34
- // An untouched row is dropped rather than kept as an empty entry.
35
- setDraft(undefined);
36
- return;
37
- }
38
- const committed = commitEnvDraft(env, draft);
39
- // A duplicate key keeps the row open so the caller can fix it.
40
- if (committed === undefined)
41
- return;
42
- setDraft(undefined);
43
- onChange(committed);
28
+ // Every name this group holds — the rows as they are typed — then the other
29
+ // group's. A name that is empty or listed twice is a conflict, recomputed
30
+ // from the current rows on every change, so emptying a key or repeating one
31
+ // blocks the apply again immediately.
32
+ const names = useMemo(() => rows.map((row) => row.key), [rows]);
33
+ const conflicts = conflictingEnvNames([...names, ...(otherNames ?? [])]);
34
+ const duplicate = firstDuplicateEnvName([...names, ...(otherNames ?? [])]);
35
+ const keyMissing = names.includes("");
36
+ useEffect(() => {
37
+ onBlockingError?.(keyMissing
38
+ ? { key: "envNameRequired" }
39
+ : duplicate === undefined
40
+ ? undefined
41
+ : { key: "envNameDuplicate", params: { key: duplicate } });
42
+ }, [keyMissing, duplicate, onBlockingError]);
43
+ useEffect(() => {
44
+ onNames?.(names);
45
+ }, [names, onNames]);
46
+ // The row the user appended, which focuses itself as it opens.
47
+ const [focusId, setFocusId] = useState(undefined);
48
+ const update = (next) => {
49
+ setRows(next);
50
+ onChange(envRecordFromRows(next));
44
51
  };
45
- const updateKey = (index, key) => {
46
- const row = rows[index];
47
- if (row.pending) {
48
- setDraft({ key, value: row.value });
49
- return;
50
- }
51
- onChange(renameEnvKey(env, index, key));
52
+ const updateKey = (id, key) => {
53
+ update(rows.map((row) => (row.id === id ? { ...row, key } : row)));
52
54
  };
53
- const updateValue = (index, value) => {
54
- const row = rows[index];
55
- if (row.pending) {
56
- setDraft({ key: row.key, value });
57
- return;
58
- }
59
- onChange(setEnvValue(env, index, value));
55
+ const updateValue = (id, value) => {
56
+ update(rows.map((row) => (row.id === id ? { ...row, value } : row)));
60
57
  };
61
- const remove = (index) => {
62
- if (rows[index]?.pending === true) {
63
- setDraft(undefined);
64
- return;
65
- }
66
- onChange(removeEnvRow(env, index));
58
+ const remove = (id) => {
59
+ if (id === focusId)
60
+ setFocusId(undefined);
61
+ update(rows.filter((row) => row.id !== id));
67
62
  };
68
63
  const add = () => {
69
- setDraft((current) => current ?? emptyEnvDraft());
64
+ const row = emptyEnvRow();
65
+ setFocusId(row.id);
66
+ update([...rows, row]);
70
67
  };
71
- return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [rows.map((row, index) => (_jsxs("div", { style: {
72
- display: "flex",
73
- flexWrap: "wrap",
74
- alignItems: "center",
75
- gap: "8px",
76
- }, children: [_jsx(Input, { value: row.key, disabled: busy, placeholder: t("envKey"), "aria-label": t("envKey"), autoFocus: row.pending, onChange: (event) => updateKey(index, event.target.value), onBlur: row.pending ? commitDraft : undefined, onKeyDown: row.pending
77
- ? (event) => {
78
- if (event.key === "Enter")
79
- commitDraft();
80
- }
81
- : undefined, style: { width: "160px" } }), _jsx(Input, { value: row.value, disabled: busy, placeholder: t("envValue"), "aria-label": t("envValue"), onChange: (event) => updateValue(index, event.target.value), onBlur: row.pending ? commitDraft : undefined, style: { width: "200px" } }), _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => remove(index), children: t("removeEnv") })] }, idsRef.current[index]))), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: add, children: t("addEnv") }) })] }));
68
+ return (_jsxs("div", { className: ROW_LIST_CLASS, style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [rows.map((row) => {
69
+ // The row's Remove is named after the variable it removes, so a screen
70
+ // reader (and a row that has wrapped) never has to guess which row it
71
+ // belongs to; a still-unnamed row falls back to the plain wording.
72
+ const removeLabel = row.key === ""
73
+ ? t("removeEnv")
74
+ : t("removeVariable", { key: row.key });
75
+ return (_jsx(EnvRow, { t: t, mode: "edit", name: row.key, value: row.value, disabled: busy, autoFocus: row.id === focusId, keyInvalid: conflicts.has(row.key), onChangeName: (key) => updateKey(row.id, key), onChangeValue: (value) => updateValue(row.id, value), onRemove: () => remove(row.id), removeLabel: removeLabel }, row.id));
76
+ }), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: add, children: t("addEnv") }) })] }));
77
+ }
78
+ // The destination a mount row shows for a mount: a project mount's derived
79
+ // mirror under the projects root, or the destination the other kinds carry.
80
+ function mountDestination(mount, projectsRoot) {
81
+ if (mount.kind !== "project")
82
+ return mount.destination;
83
+ return mount.project.trim() === ""
84
+ ? ""
85
+ : hostPathForProjectName(projectsRoot, mount.project);
82
86
  }
83
87
  export function MountsEditor(props) {
84
- const { t, mounts, volumes, secrets, busy, enabled, projectsRoot, directoryPicker, confirmRemove, modeControl = "remount", primaryProject = "", onAdd, onRemove, onUpdate, } = props;
88
+ const { t, mounts, volumes, secrets, busy, enabled, projectsRoot, directoryPicker, confirmRemove, primaryProject = "", mainProject = "", onAdd, onRemove, onUpdate, } = props;
85
89
  const [adding, setAdding] = useState(false);
86
90
  const [browsing, setBrowsing] = useState(false);
87
91
  const [browseError, setBrowseError] = useState("");
92
+ const [confirmClose, setConfirmClose] = useState(false);
88
93
  const [draft, setDraft] = useState(emptyMount());
89
- const mountKindId = useId();
90
- const mountProjectId = useId();
91
- const mountDestinationId = useId();
92
- const mountModeId = useId();
93
- const mountVolumeId = useId();
94
- const mountSecretId = useId();
95
94
  const updateDraft = (patch) => {
96
95
  setDraft((prev) => ({ ...prev, ...patch }));
97
96
  };
97
+ // Picking a kind is not an edit; anything typed into the pristine kind's
98
+ // fields is, and closing then would lose it.
99
+ const dirty = !mountInputsEqual(draft, emptyMount(draft.kind));
100
+ const requestClose = () => {
101
+ if (dirty)
102
+ setConfirmClose(true);
103
+ else
104
+ setAdding(false);
105
+ };
106
+ const discardAndClose = () => {
107
+ setConfirmClose(false);
108
+ setAdding(false);
109
+ };
98
110
  const canAdd = draft.kind === "project"
99
111
  ? draft.project.trim() !== ""
100
112
  : draft.kind === "volume"
@@ -105,6 +117,7 @@ export function MountsEditor(props) {
105
117
  const openAdd = () => {
106
118
  setDraft(emptyMount());
107
119
  setBrowseError("");
120
+ setConfirmClose(false);
108
121
  setAdding(true);
109
122
  };
110
123
  const submit = () => {
@@ -113,69 +126,31 @@ export function MountsEditor(props) {
113
126
  onAdd(draft);
114
127
  setAdding(false);
115
128
  };
116
- const kindField = draft.kind === "tmpfs"
117
- ? (_jsx(Field, { label: t("mountDestination"), htmlFor: mountDestinationId, children: _jsx(Input, { id: mountDestinationId, value: draft.destination, disabled: busy, onChange: (event) => updateDraft({ destination: event.target.value }) }) }))
118
- : draft.kind === "volume"
119
- ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: t("mountVolume"), htmlFor: mountVolumeId, children: _jsxs("select", { id: mountVolumeId, style: imageSelect, value: draft.volume, disabled: busy, onChange: (event) => updateDraft({ volume: event.target.value }), children: [volumes.length === 0
120
- ? _jsx("option", { value: "", children: t("none") })
121
- : null, volumes.map((volume) => (_jsx("option", { value: volume.name, children: volume.name }, volume.name)))] }) }), _jsx(Field, { label: t("mountDestination"), htmlFor: mountDestinationId, children: _jsx(Input, { id: mountDestinationId, value: draft.destination, disabled: busy, onChange: (event) => updateDraft({ destination: event.target.value }) }) }), _jsx(Field, { label: t("mountMode"), htmlFor: mountModeId, children: _jsxs("select", { id: mountModeId, style: imageSelect, value: draft.mode, disabled: busy, onChange: (event) => updateDraft({ mode: event.target.value }), children: [_jsx("option", { value: "read_only", children: t("readOnly") }), _jsx("option", { value: "read_write", children: t("readWrite") })] }) })] }))
122
- : draft.kind === "secret"
123
- ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: t("mountSecret"), htmlFor: mountSecretId, children: _jsxs("select", { id: mountSecretId, style: imageSelect, value: draft.secret, disabled: busy, onChange: (event) => updateDraft({ secret: event.target.value }), children: [secrets.length === 0
124
- ? _jsx("option", { value: "", children: t("none") })
125
- : null, secrets.map((secret) => (_jsx("option", { value: secret.name, children: secret.name }, secret.name)))] }) }), _jsx(Field, { label: t("mountDestination"), htmlFor: mountDestinationId, children: _jsx(Input, { id: mountDestinationId, value: draft.destination, disabled: busy, onChange: (event) => updateDraft({ destination: event.target.value }) }) })] }))
126
- : (_jsxs(_Fragment, { children: [_jsx(Field, { label: t("mountProjectPath"), htmlFor: mountProjectId, children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [_jsx(Input, { id: mountProjectId, value: draft.project, disabled: busy, onChange: (event) => updateDraft({ project: event.target.value }) }), directoryPicker !== undefined
127
- ? (_jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => {
128
- setBrowseError("");
129
- setBrowsing(true);
130
- }, children: t("browse") }))
131
- : null] }) }), browseError === ""
132
- ? null
133
- : (_jsx("p", { style: { margin: 0, fontSize: "13px" }, role: "alert", children: browseError })), _jsx(Field, { label: t("mountMode"), htmlFor: mountModeId, children: _jsxs("select", { id: mountModeId, style: imageSelect, value: draft.mode, disabled: busy, onChange: (event) => updateDraft({ mode: event.target.value }), children: [_jsx("option", { value: "read_only", children: t("readOnly") }), _jsx("option", { value: "read_write", children: t("readWrite") })] }) })] }));
134
- return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [mounts.map((mount, index) => {
135
- const nextMode = mount.mode === "read_write"
136
- ? "read_only"
137
- : "read_write";
138
- const forced = forcedMountMode(mount.kind);
139
- const editable = mount.kind === "project" || mount.kind === "volume";
129
+ // The destination a project mount lands at: its project path mirrored under
130
+ // the projects root, which the host computes and the editor previews. The
131
+ // field stays read-only, since a project mount never takes a destination.
132
+ const projectDestination = draft.project.trim() === ""
133
+ ? ""
134
+ : hostPathForProjectName(projectsRoot, draft.project);
135
+ return (_jsxs("div", { className: ROW_LIST_CLASS, style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [orderedMounts(mounts, mainProject).map(({ mount, index }) => {
140
136
  const removable = mount.kind !== "project" ||
141
137
  primaryProject === "" ||
142
138
  mount.project !== primaryProject;
143
- return (_jsxs("div", { style: {
144
- display: "flex",
145
- flexWrap: "wrap",
146
- alignItems: "center",
147
- gap: "8px",
148
- }, children: [_jsx("code", { style: {
149
- ...greyId,
150
- flex: 1,
151
- fontSize: "13px",
152
- color: "var(--dsw-alias-label-primary)",
153
- }, children: mountLabel(t, mount, modeControl !== "select") }), modeControl === "select" && (editable || forced !== undefined)
154
- ? (_jsx("select", { style: imageSelect, value: forced ?? mount.mode, disabled: !enabled || forced !== undefined, "aria-label": t("mountMode"), onChange: (event) => onUpdate?.({ ...mount, mode: event.target.value }, index), children: forced !== undefined
155
- ? (_jsx("option", { value: forced, children: forced === "read_write"
156
- ? t("readWrite")
157
- : t("readOnly") }))
158
- : (_jsxs(_Fragment, { children: [_jsx("option", { value: "read_only", children: t("readOnly") }), _jsx("option", { value: "read_write", children: t("readWrite") })] })) }))
159
- : null, modeControl === "remount" && editable && onUpdate !== undefined &&
160
- (_jsx(ConfirmButton, { t: t, label: nextMode === "read_only"
161
- ? t("remountReadOnly")
162
- : t("remountReadWrite"), title: t("confirmTitle"), description: nextMode === "read_only"
163
- ? t("confirmRemountReadOnly", {
164
- mount: mountLabel(t, mount, false),
165
- })
166
- : t("confirmRemountReadWrite", {
167
- mount: mountLabel(t, mount, false),
168
- }), disabled: !enabled, onConfirm: () => onUpdate({ ...mount, mode: nextMode }, index) })), removable &&
169
- (confirmRemove
170
- ? (_jsx(ConfirmButton, { t: t, label: t("remove"), title: t("confirmTitle"), description: t("confirmRemoveMount", {
171
- mount: mountLabel(t, mount, false),
172
- }), disabled: !enabled, onConfirm: () => onRemove(mount) }))
173
- : (_jsx(Button, { variant: "outline", size: "sm", disabled: !enabled, onClick: () => onRemove(mount), children: t("remove") })))] }, index));
174
- }), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: !enabled, onClick: openAdd, children: t("addMount") }) }), _jsx(Modal, { open: adding, onClose: () => setAdding(false), title: t("addMount"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => setAdding(false), children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: busy || !canAdd, onClick: submit, children: t("addMount") })] }), children: _jsxs("div", { style: {
175
- display: "flex",
176
- flexDirection: "column",
177
- gap: "12px",
178
- }, children: [_jsx(Field, { label: t("mountKind"), htmlFor: mountKindId, children: _jsxs("select", { id: mountKindId, style: imageSelect, value: draft.kind, disabled: busy, onChange: (event) => setDraft(emptyMount(event.target.value)), children: [_jsx("option", { value: "project", children: t("mountProject") }), _jsx("option", { value: "tmpfs", children: t("mountTmpfs") }), _jsx("option", { value: "volume", children: t("mountVolume") }), _jsx("option", { value: "secret", children: t("mountSecret") })] }) }), kindField] }) }), directoryPicker === undefined ? null : (_jsx(DirectoryPickerModal, { t: t, open: browsing, root: projectsRoot, start: hostPathForProjectName(projectsRoot, draft.project), picker: directoryPicker, onSelect: (path) => {
139
+ const update = (patch) => {
140
+ onUpdate?.({ ...mount, ...patch }, index);
141
+ };
142
+ return (_jsx(MountRow
143
+ // A mount keeps the index it has in the draft as its key, so a
144
+ // category change reorders the list without remounting the row.
145
+ , { t: t, mode: "edit", mount: mount, destination: mountDestination(mount, projectsRoot), disabled: !enabled, volumes: volumes, secrets: secrets, onUpdate: update, onRemove: removable ? () => onRemove(mount) : undefined, confirmRemove: confirmRemove, removeDisabledReason: removable
146
+ ? undefined
147
+ : t("defaultMountNotRemovable") }, index));
148
+ }), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: !enabled, onClick: openAdd, children: t("addMount") }) }), _jsx(Modal, { open: adding, onClose: requestClose, title: t("addMount"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: requestClose, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: busy || !canAdd, onClick: submit, children: t("addMount") })] }), children: _jsx(MountRow, { t: t, mode: "edit", mount: draft, destination: draft.kind === "project"
149
+ ? projectDestination
150
+ : draft.destination, kindValue: _jsxs("select", { style: imageSelect, value: draft.kind, disabled: busy, "aria-label": t("mountKind"), onChange: (event) => setDraft(emptyMount(event.target.value)), children: [_jsx("option", { value: "project", children: t("mountProject") }), _jsx("option", { value: "tmpfs", children: t("mountTmpfs") }), _jsx("option", { value: "volume", children: t("mountVolume") }), _jsx("option", { value: "secret", children: t("mountSecret") })] }), disabled: busy, volumes: volumes, secrets: secrets, onUpdate: updateDraft, onBrowse: directoryPicker === undefined ? undefined : () => {
151
+ setBrowseError("");
152
+ setBrowsing(true);
153
+ }, browseError: browseError }) }), _jsx(DiscardChangesModal, { t: t, open: confirmClose, onCancel: () => setConfirmClose(false), onDiscard: discardAndClose }), directoryPicker === undefined ? null : (_jsx(DirectoryPickerModal, { t: t, open: browsing, root: projectsRoot, start: hostPathForProjectName(projectsRoot, draft.project), picker: directoryPicker, onSelect: (path) => {
179
154
  const project = projectNameFromHostPath(projectsRoot, path);
180
155
  if (project === undefined) {
181
156
  setBrowseError(t("browseOutsideRoot"));
@@ -0,0 +1,7 @@
1
+ import type { Context as ClientContext } from "@deepseek-ai/cordis";
2
+ export declare const SLOT_CLASS = "dsh-podman-slot-control";
3
+ export declare const FIELD_CLASS = "dsh-podman-readonly-field";
4
+ export declare const SLOT_INVALID_CLASS = "dsh-podman-slot-invalid";
5
+ export declare const FIELD_STYLES = "\n.dsh-podman-slot-control {\n flex: 1 1 0;\n width: 100%;\n min-width: 0;\n}\n.dsh-podman-slot-invalid,\n.dsh-podman-slot-invalid:focus-within {\n border-color: var(--dsw-alias-state-error-primary);\n}\n.dsh-podman-readonly-field {\n background: var(--dsw-alias-bg-module-platform);\n border-color: var(--dsw-alias-border-l3);\n}\n/* A fixed value takes no focus ring: nothing changes when it is focused, so its\n own lighter stroke stays put instead of the primitive's business-blue one. */\n.dsh-podman-readonly-field:focus-within {\n border-color: var(--dsw-alias-border-l3);\n}\n.dsh-podman-readonly-field input {\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n cursor: default;\n}\n";
6
+ /** Inject the value slot's stylesheet for the owning plugin lifetime. */
7
+ export declare function installFieldStyles(ctx: ClientContext): void;
@@ -0,0 +1,63 @@
1
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+ // The class on the wrapper of a shared row's value-slot text control: a
5
+ // read-only field's Input in the container block, or an editable field in an
6
+ // editor. The primitive's Input wrapper is an inline-flex box sized by its
7
+ // content, so this class lets the control claim the width of the slot it is
8
+ // given, with the field's own copy or remove control keeping the rest of the
9
+ // line. A select carries the same slot sizing through slotSelect
10
+ // (container-card-styles.ts).
11
+ export const SLOT_CLASS = "dsh-podman-slot-control";
12
+ // The extra class on a read-only field, which reads its value on the body scale
13
+ // instead of the control scale and sits on the module platform's own tint with
14
+ // a lighter stroke than an editable field. A lock drawn inline leads the value
15
+ // (container-card-shared.tsx), so the tint, the muted text and the glyph mark it
16
+ // as fixed before it is clicked, while an editable field keeps the card's plain
17
+ // surface and its business-blue focus ring.
18
+ export const FIELD_CLASS = "dsh-podman-readonly-field";
19
+ // The extra class on a value-slot control that holds a conflicting variable
20
+ // name — empty, or used twice: the wrapper's own stroke turns to the error state
21
+ // colour, so the row's key reads as the one to fix. It covers the focused state
22
+ // too, whose business stroke the primitive would otherwise give the wrapper.
23
+ export const SLOT_INVALID_CLASS = "dsh-podman-slot-invalid";
24
+ export const FIELD_STYLES = `
25
+ .dsh-podman-slot-control {
26
+ flex: 1 1 0;
27
+ width: 100%;
28
+ min-width: 0;
29
+ }
30
+ .dsh-podman-slot-invalid,
31
+ .dsh-podman-slot-invalid:focus-within {
32
+ border-color: var(--dsw-alias-state-error-primary);
33
+ }
34
+ .dsh-podman-readonly-field {
35
+ background: var(--dsw-alias-bg-module-platform);
36
+ border-color: var(--dsw-alias-border-l3);
37
+ }
38
+ /* A fixed value takes no focus ring: nothing changes when it is focused, so its
39
+ own lighter stroke stays put instead of the primitive's business-blue one. */
40
+ .dsh-podman-readonly-field:focus-within {
41
+ border-color: var(--dsw-alias-border-l3);
42
+ }
43
+ .dsh-podman-readonly-field input {
44
+ font-size: 13px;
45
+ line-height: 20px;
46
+ color: var(--dsw-alias-label-secondary);
47
+ cursor: default;
48
+ }
49
+ `;
50
+ /** Inject the value slot's stylesheet for the owning plugin lifetime. */
51
+ export function installFieldStyles(ctx) {
52
+ if (typeof document === "undefined")
53
+ return;
54
+ ctx.effect(() => {
55
+ const tag = document.createElement("style");
56
+ tag.dataset.plugin = "@exagone313/dsh-podman";
57
+ tag.textContent = FIELD_STYLES;
58
+ document.head.appendChild(tag);
59
+ return () => {
60
+ tag.remove();
61
+ };
62
+ }, "podman: field styles");
63
+ }
@@ -0,0 +1,47 @@
1
+ import { type PortConfig } from "./container-card-config.js";
2
+ import { type ImageView, type MountInput } from "./container-card-controller.js";
3
+ import { type DirectoryPickerFace } from "./directory-picker.js";
4
+ import { type Translate, type Translation } from "./locales.js";
5
+ import { type ReactNode } from "react";
6
+ export interface ContainerNameDraft {
7
+ value: string;
8
+ error: string;
9
+ readOnly: boolean;
10
+ disabled: boolean;
11
+ onChange?: (name: string) => void;
12
+ }
13
+ export declare function ContainerForm(props: {
14
+ t: Translate;
15
+ image: string;
16
+ env: Record<string, string>;
17
+ mounts: readonly MountInput[];
18
+ paths: readonly string[];
19
+ secretEnv: Record<string, string>;
20
+ ports: readonly PortConfig[];
21
+ images: readonly ImageView[];
22
+ volumes: readonly {
23
+ name: string;
24
+ }[];
25
+ secrets: readonly {
26
+ name: string;
27
+ }[];
28
+ busy: boolean;
29
+ enabled: boolean;
30
+ canPublish: boolean;
31
+ gatewayUnavailable: boolean;
32
+ writable: boolean;
33
+ projectsRoot: string;
34
+ directoryPicker?: DirectoryPickerFace;
35
+ mainProject: string;
36
+ primaryProject?: string;
37
+ confirmRemoveMount?: boolean;
38
+ onCreateSecret: (name: string, length?: number, charset?: string) => void;
39
+ onChangeImage: (image: string) => void;
40
+ onChangeEnv: (env: Record<string, string>) => void;
41
+ onChangeMounts: (mounts: MountInput[]) => void;
42
+ onChangePaths: (paths: string[]) => void;
43
+ onChangeSecretEnv: (secretEnv: Record<string, string>) => void;
44
+ onChangePorts: (ports: PortConfig[]) => void;
45
+ name: ContainerNameDraft;
46
+ onBlockingError?: (error: Translation | undefined) => void;
47
+ }): ReactNode;