dsh-mcviseron-plugin 0.6.2 → 0.6.3

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.
package/lib/client.js CHANGED
@@ -454,10 +454,7 @@ function FallbackRestartRow({ t }) {
454
454
  ] });
455
455
  }
456
456
 
457
- // src/client/SettingsSection.tsx
458
- var import_react5 = require("react");
459
-
460
- // src/client/ConfigForm.tsx
457
+ // src/client/SessionEndControl.tsx
461
458
  var import_react4 = require("react");
462
459
 
463
460
  // src/api.ts
@@ -465,6 +462,302 @@ var MCVISERON_API = {
465
462
  describe: "/api/dsh-mcviseron/settings/describe",
466
463
  mutate: "/api/dsh-mcviseron/settings/mutate"
467
464
  };
465
+ var SESSION_END_API = {
466
+ state: "/api/dsh-mcviseron/session-end/state",
467
+ set: "/api/dsh-mcviseron/session-end/set"
468
+ };
469
+
470
+ // src/client/SessionEndControl.tsx
471
+ var import_jsx_runtime4 = require("react/jsx-runtime");
472
+ var INITIAL = {
473
+ enabled: true,
474
+ mode: "off",
475
+ requestedBy: "none",
476
+ waiting: false,
477
+ runningAgents: 0,
478
+ runningJobs: 0,
479
+ available: { restart: true, close: true, shutdown: true }
480
+ };
481
+ var labelStyle = {
482
+ display: "inline-flex",
483
+ alignItems: "center",
484
+ gap: 6,
485
+ padding: "0 6px",
486
+ height: 28,
487
+ borderRadius: 8,
488
+ fontSize: 12,
489
+ lineHeight: 1.3,
490
+ color: "var(--dsw-alias-label-secondary)",
491
+ whiteSpace: "nowrap"
492
+ };
493
+ var triggerStyle = {
494
+ display: "inline-flex",
495
+ alignItems: "center",
496
+ justifyContent: "space-between",
497
+ gap: 6,
498
+ height: 28,
499
+ minWidth: 92,
500
+ maxWidth: 150,
501
+ borderRadius: 10,
502
+ border: "1px solid var(--dsw-alias-border-l3)",
503
+ background: "var(--dsw-alias-bg-layer-2)",
504
+ color: "var(--dsw-alias-label-primary)",
505
+ fontSize: 12,
506
+ lineHeight: 1.3,
507
+ padding: "0 8px",
508
+ cursor: "pointer"
509
+ };
510
+ var menuStyle = {
511
+ position: "fixed",
512
+ zIndex: 1e4,
513
+ padding: 6,
514
+ display: "flex",
515
+ flexDirection: "column",
516
+ gap: 2,
517
+ borderRadius: 14,
518
+ border: "1px solid var(--dsw-alias-border-l3)",
519
+ background: "var(--dsw-alias-bg-layer-2)",
520
+ boxShadow: "0 18px 44px rgba(0, 0, 0, 0.32)"
521
+ };
522
+ var menuOptionStyle = {
523
+ display: "flex",
524
+ alignItems: "center",
525
+ justifyContent: "space-between",
526
+ gap: 10,
527
+ width: "100%",
528
+ border: 0,
529
+ borderRadius: 10,
530
+ background: "transparent",
531
+ color: "var(--dsw-alias-label-primary)",
532
+ fontSize: 13,
533
+ lineHeight: "20px",
534
+ padding: "7px 10px",
535
+ textAlign: "left",
536
+ cursor: "pointer"
537
+ };
538
+ var noticeStyle = {
539
+ display: "inline-flex",
540
+ alignItems: "center",
541
+ gap: 4,
542
+ padding: "3px 8px",
543
+ borderRadius: 999,
544
+ border: "1px solid var(--dsw-alias-state-warn-primary)",
545
+ background: "var(--dsw-alias-state-warn-tertiary)",
546
+ color: "var(--dsw-alias-state-warn-primary)",
547
+ fontSize: 12,
548
+ fontWeight: 700,
549
+ lineHeight: "18px",
550
+ whiteSpace: "nowrap"
551
+ };
552
+ var shutdownNoticeStyle = {
553
+ ...noticeStyle,
554
+ borderColor: "var(--dsw-alias-state-error-primary)",
555
+ background: "var(--dsw-alias-state-error-tertiary)",
556
+ color: "var(--dsw-alias-state-error-primary)"
557
+ };
558
+ function SessionEndControl(props) {
559
+ const { t } = props;
560
+ const sessionId = props.sessionId;
561
+ const [state, setState] = (0, import_react4.useState)(INITIAL);
562
+ const [busy, setBusy] = (0, import_react4.useState)(false);
563
+ const [open, setOpen] = (0, import_react4.useState)(false);
564
+ const [menu, setMenu] = (0, import_react4.useState)({ left: 0, bottom: 0, minWidth: 0 });
565
+ const triggerRef = (0, import_react4.useRef)(null);
566
+ const menuRef = (0, import_react4.useRef)(null);
567
+ (0, import_react4.useEffect)(() => {
568
+ if (sessionId === void 0 || sessionId === "") {
569
+ setState(INITIAL);
570
+ return;
571
+ }
572
+ let cancelled = false;
573
+ const load = async () => {
574
+ try {
575
+ const response = await fetch(SESSION_END_API.state, {
576
+ method: "POST",
577
+ headers: { "content-type": "application/json" },
578
+ body: JSON.stringify({ sessionId })
579
+ });
580
+ const body = await response.json();
581
+ if (cancelled || body.ok !== true) return;
582
+ setState((prev) => ({
583
+ ...prev,
584
+ ...body,
585
+ available: body.available ?? prev.available
586
+ }));
587
+ } catch {
588
+ }
589
+ };
590
+ void load();
591
+ const timer = setInterval(() => {
592
+ void load();
593
+ }, 1500);
594
+ return () => {
595
+ cancelled = true;
596
+ clearInterval(timer);
597
+ };
598
+ }, [sessionId]);
599
+ (0, import_react4.useEffect)(() => {
600
+ if (!open) return;
601
+ const close = () => {
602
+ setOpen(false);
603
+ };
604
+ const onPointer = (event) => {
605
+ const target = event.target;
606
+ if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;
607
+ setOpen(false);
608
+ };
609
+ const onKey = (event) => {
610
+ if (event.key === "Escape") setOpen(false);
611
+ };
612
+ document.addEventListener("mousedown", onPointer);
613
+ document.addEventListener("keydown", onKey);
614
+ window.addEventListener("resize", close);
615
+ window.addEventListener("scroll", close, true);
616
+ return () => {
617
+ document.removeEventListener("mousedown", onPointer);
618
+ document.removeEventListener("keydown", onKey);
619
+ window.removeEventListener("resize", close);
620
+ window.removeEventListener("scroll", close, true);
621
+ };
622
+ }, [open]);
623
+ if (sessionId === void 0 || sessionId === "") return null;
624
+ const toggleMenu = () => {
625
+ if (open) {
626
+ setOpen(false);
627
+ return;
628
+ }
629
+ const rect = triggerRef.current?.getBoundingClientRect();
630
+ if (rect === void 0) return;
631
+ const minWidth = Math.max(rect.width, 176);
632
+ const left = Math.min(
633
+ Math.max(8, rect.left),
634
+ Math.max(8, window.innerWidth - minWidth - 8)
635
+ );
636
+ setMenu({ left, bottom: window.innerHeight - rect.top + 6, minWidth });
637
+ setOpen(true);
638
+ };
639
+ const change = (mode) => {
640
+ setOpen(false);
641
+ if (mode === "shutdown" && typeof window !== "undefined" && typeof window.confirm === "function") {
642
+ if (!window.confirm(t("sessionEnd.shutdownConfirm"))) return;
643
+ }
644
+ setBusy(true);
645
+ setState((prev) => ({
646
+ ...prev,
647
+ mode,
648
+ requestedBy: mode === "off" ? "none" : "user",
649
+ waiting: false
650
+ }));
651
+ void fetch(SESSION_END_API.set, {
652
+ method: "POST",
653
+ headers: { "content-type": "application/json" },
654
+ body: JSON.stringify({ sessionId, mode })
655
+ }).then(async (response) => await response.json()).then((body) => {
656
+ if (body.ok === true) {
657
+ setState((prev) => ({
658
+ ...prev,
659
+ ...body,
660
+ available: body.available ?? prev.available
661
+ }));
662
+ }
663
+ }).catch(() => {
664
+ }).finally(() => {
665
+ setBusy(false);
666
+ });
667
+ };
668
+ if (state.enabled === false) return null;
669
+ const aiRequested = state.mode !== "off" && state.requestedBy === "ai";
670
+ const shutdown = state.mode === "shutdown";
671
+ const notice = shutdown ? t("sessionEnd.userShutdown") : aiRequested ? state.mode === "close" ? t("sessionEnd.aiClose") : state.waiting ? t("sessionEnd.aiWaiting") : t("sessionEnd.aiRestart") : "";
672
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
673
+ notice !== "" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
674
+ "span",
675
+ {
676
+ style: shutdown ? shutdownNoticeStyle : noticeStyle,
677
+ title: state.waiting ? t("sessionEnd.aiWaiting") : notice,
678
+ children: notice
679
+ }
680
+ ),
681
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
682
+ .mcviseron-session-end-trigger { transition: background 120ms ease, border-color 120ms ease; }
683
+ .mcviseron-session-end-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-3)); }
684
+ .mcviseron-session-end-option { transition: background 120ms ease; }
685
+ .mcviseron-session-end-option:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-3)); }
686
+ ` }),
687
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: labelStyle, title: t("sessionEnd.hint"), children: [
688
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("sessionEnd.label") }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
690
+ "button",
691
+ {
692
+ ref: triggerRef,
693
+ type: "button",
694
+ className: "mcviseron-session-end-trigger",
695
+ "aria-label": t("sessionEnd.label"),
696
+ "aria-haspopup": "listbox",
697
+ "aria-expanded": open,
698
+ title: t("sessionEnd.hint"),
699
+ style: {
700
+ ...triggerStyle,
701
+ borderColor: aiRequested ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-border-l3)"
702
+ },
703
+ disabled: busy,
704
+ onClick: toggleMenu,
705
+ children: [
706
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t(
707
+ state.mode === "off" ? "sessionEnd.off" : state.mode === "restart" ? "sessionEnd.restart" : state.mode === "close" ? "sessionEnd.close" : "sessionEnd.shutdown"
708
+ ) }),
709
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": true, style: { fontSize: 10, opacity: 0.75 }, children: open ? "\u25B4" : "\u25BE" })
710
+ ]
711
+ }
712
+ ),
713
+ open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
714
+ "div",
715
+ {
716
+ ref: menuRef,
717
+ role: "listbox",
718
+ "aria-label": t("sessionEnd.label"),
719
+ style: { ...menuStyle, left: menu.left, bottom: menu.bottom, minWidth: menu.minWidth },
720
+ children: [
721
+ ["off", "sessionEnd.off", false],
722
+ ["restart", "sessionEnd.restart", !state.available.restart],
723
+ ["close", "sessionEnd.close", !state.available.close],
724
+ ["shutdown", "sessionEnd.shutdown", !state.available.shutdown]
725
+ ].map(([value, label, disabled]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
726
+ "button",
727
+ {
728
+ type: "button",
729
+ role: "option",
730
+ "aria-selected": state.mode === value,
731
+ disabled,
732
+ className: "mcviseron-session-end-option",
733
+ style: {
734
+ ...menuOptionStyle,
735
+ color: state.mode === value ? "var(--dsw-alias-brand-primary)" : menuOptionStyle.color,
736
+ fontWeight: state.mode === value ? 600 : 400,
737
+ opacity: disabled ? 0.45 : 1,
738
+ cursor: disabled ? "default" : "pointer"
739
+ },
740
+ onClick: () => {
741
+ if (!disabled) change(value);
742
+ },
743
+ children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t(label) }),
745
+ state.mode === value ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": true, children: "\u2713" }) : null
746
+ ]
747
+ },
748
+ value
749
+ ))
750
+ }
751
+ )
752
+ ] })
753
+ ] });
754
+ }
755
+
756
+ // src/client/SettingsSection.tsx
757
+ var import_react6 = require("react");
758
+
759
+ // src/client/ConfigForm.tsx
760
+ var import_react5 = require("react");
468
761
 
469
762
  // src/namespace.ts
470
763
  var MCVISERON_SETTINGS_NAMESPACE = "mcviseron";
@@ -544,7 +837,7 @@ async function writePluginConfig(path, value) {
544
837
 
545
838
  // src/client/ConfigForm.tsx
546
839
  var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
547
- var import_jsx_runtime4 = require("react/jsx-runtime");
840
+ var import_jsx_runtime5 = require("react/jsx-runtime");
548
841
  function readPath(config, path) {
549
842
  let current = config;
550
843
  for (const key of path) {
@@ -554,8 +847,8 @@ function readPath(config, path) {
554
847
  return current;
555
848
  }
556
849
  function NumberControl({ value, min, max, disabled, onCommit }) {
557
- const [draft, setDraft] = (0, import_react4.useState)(value === void 0 ? "" : String(value));
558
- (0, import_react4.useEffect)(() => {
850
+ const [draft, setDraft] = (0, import_react5.useState)(value === void 0 ? "" : String(value));
851
+ (0, import_react5.useEffect)(() => {
559
852
  setDraft(value === void 0 ? "" : String(value));
560
853
  }, [value]);
561
854
  const commit = () => {
@@ -568,7 +861,7 @@ function NumberControl({ value, min, max, disabled, onCommit }) {
568
861
  }
569
862
  if (parsed !== value) onCommit(parsed);
570
863
  };
571
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
864
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
572
865
  "input",
573
866
  {
574
867
  type: "number",
@@ -588,11 +881,11 @@ function NumberControl({ value, min, max, disabled, onCommit }) {
588
881
  );
589
882
  }
590
883
  function TextControl({ value, disabled, onCommit }) {
591
- const [draft, setDraft] = (0, import_react4.useState)(value);
592
- (0, import_react4.useEffect)(() => {
884
+ const [draft, setDraft] = (0, import_react5.useState)(value);
885
+ (0, import_react5.useEffect)(() => {
593
886
  setDraft(value);
594
887
  }, [value]);
595
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
888
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
596
889
  "input",
597
890
  {
598
891
  type: "text",
@@ -611,17 +904,38 @@ function TextControl({ value, disabled, onCommit }) {
611
904
  }
612
905
  );
613
906
  }
907
+ function TextareaControl({ value, disabled, onCommit }) {
908
+ const [draft, setDraft] = (0, import_react5.useState)(value);
909
+ (0, import_react5.useEffect)(() => {
910
+ setDraft(value);
911
+ }, [value]);
912
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
913
+ "textarea",
914
+ {
915
+ value: draft,
916
+ disabled,
917
+ rows: 4,
918
+ onChange: (event) => {
919
+ setDraft(event.target.value);
920
+ },
921
+ onBlur: () => {
922
+ if (draft !== value) onCommit(draft);
923
+ },
924
+ style: { ...pageStyles.formControl, minHeight: 88, resize: "vertical" }
925
+ }
926
+ );
927
+ }
614
928
  function ListControl({ value, disabled, onCommit }) {
615
929
  const joined = value.join(", ");
616
- const [draft, setDraft] = (0, import_react4.useState)(joined);
617
- (0, import_react4.useEffect)(() => {
930
+ const [draft, setDraft] = (0, import_react5.useState)(joined);
931
+ (0, import_react5.useEffect)(() => {
618
932
  setDraft(value.join(", "));
619
933
  }, [value]);
620
934
  const commit = () => {
621
935
  const next = draft.split(",").map((item) => item.trim()).filter((item) => item !== "");
622
936
  if (next.join("\0") !== value.join("\0")) onCommit(next);
623
937
  };
624
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
938
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
625
939
  "input",
626
940
  {
627
941
  type: "text",
@@ -642,7 +956,7 @@ function ListControl({ value, disabled, onCommit }) {
642
956
  function renderControl(field, value, disabled, commit, t) {
643
957
  switch (field.kind) {
644
958
  case "switch":
645
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
959
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
646
960
  import_dsh_client_ui_primitives2.Switch,
647
961
  {
648
962
  checked: value === true,
@@ -654,7 +968,7 @@ function renderControl(field, value, disabled, commit, t) {
654
968
  }
655
969
  );
656
970
  case "number":
657
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
971
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
658
972
  NumberControl,
659
973
  {
660
974
  value: typeof value === "number" ? value : void 0,
@@ -665,9 +979,11 @@ function renderControl(field, value, disabled, commit, t) {
665
979
  }
666
980
  );
667
981
  case "text":
668
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TextControl, { value: typeof value === "string" ? value : "", disabled, onCommit: commit });
982
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TextControl, { value: typeof value === "string" ? value : "", disabled, onCommit: commit });
983
+ case "textarea":
984
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TextareaControl, { value: typeof value === "string" ? value : "", disabled, onCommit: commit });
669
985
  case "list":
670
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
986
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
671
987
  ListControl,
672
988
  {
673
989
  value: Array.isArray(value) ? value.filter((item) => typeof item === "string") : [],
@@ -678,7 +994,7 @@ function renderControl(field, value, disabled, commit, t) {
678
994
  }
679
995
  );
680
996
  case "select":
681
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
997
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
682
998
  "select",
683
999
  {
684
1000
  value: typeof value === "string" ? value : "",
@@ -687,16 +1003,16 @@ function renderControl(field, value, disabled, commit, t) {
687
1003
  commit(event.target.value);
688
1004
  },
689
1005
  style: pageStyles.formControl,
690
- children: (field.options ?? []).map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: option.value, children: t(option.label) }, option.value))
1006
+ children: (field.options ?? []).map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: option.value, children: t(option.label) }, option.value))
691
1007
  }
692
1008
  );
693
1009
  }
694
1010
  }
695
1011
  function ConfigForm({ t, title, description, fields }) {
696
- const [config, setConfig] = (0, import_react4.useState)({});
697
- const [status, setStatus] = (0, import_react4.useState)("loading");
698
- const [message, setMessage] = (0, import_react4.useState)("");
699
- (0, import_react4.useEffect)(() => {
1012
+ const [config, setConfig] = (0, import_react5.useState)({});
1013
+ const [status, setStatus] = (0, import_react5.useState)("loading");
1014
+ const [message, setMessage] = (0, import_react5.useState)("");
1015
+ (0, import_react5.useEffect)(() => {
700
1016
  let cancelled = false;
701
1017
  void (async () => {
702
1018
  const view = await readPluginConfig();
@@ -726,20 +1042,20 @@ function ConfigForm({ t, title, description, fields }) {
726
1042
  };
727
1043
  const disabled = status === "loading" || status === "saving" || status === "unavailable";
728
1044
  const statusText = status === "loading" ? t("form.loading") : status === "saving" ? t("form.saving") : status === "saved" ? t("form.saved") : status === "failed" ? t("form.failed") + (message === "" ? "" : " (" + message + ")") : status === "unavailable" ? t("form.unavailable") : t("form.autoSave");
729
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: pageStyles.card, children: [
730
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.cardTitle, children: t(title) }),
731
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.cardBody, children: t(description) }),
732
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.form, children: fields.map((field) => {
1045
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.card, children: [
1046
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardTitle, children: t(title) }),
1047
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardBody, children: t(description) }),
1048
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.form, children: fields.map((field) => {
733
1049
  const value = readPath(config, field.path);
734
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: pageStyles.formRow, children: [
735
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formLabel, children: t(field.label) }),
736
- field.hint === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formHint, children: t(field.hint) }),
1050
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.formRow, children: [
1051
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.formLabel, children: t(field.label) }),
1052
+ field.hint === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.formHint, children: t(field.hint) }),
737
1053
  renderControl(field, value, disabled, (next) => {
738
1054
  void save(field.path, next);
739
1055
  }, t)
740
1056
  ] }, field.path.join("."));
741
1057
  }) }),
742
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formStatus, children: statusText })
1058
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.formStatus, children: statusText })
743
1059
  ] });
744
1060
  }
745
1061
  var AUTO_REVIEW_FIELDS = [
@@ -782,16 +1098,23 @@ var TASK_GUARD_FIELDS = [
782
1098
  { path: ["taskGuard", "include"], label: "form.taskGuard.include", hint: "form.taskGuard.listHint", kind: "list" },
783
1099
  { path: ["taskGuard", "exclude"], label: "form.taskGuard.exclude", hint: "form.taskGuard.listHint", kind: "list" }
784
1100
  ];
1101
+ var SESSION_END_FIELDS = [
1102
+ { path: ["sessionEnd", "enabled"], label: "form.sessionEnd.enabled", hint: "form.sessionEnd.enabledHint", kind: "switch" },
1103
+ { path: ["sessionEnd", "graceMs"], label: "form.sessionEnd.grace", hint: "form.sessionEnd.graceHint", kind: "number", min: 0, max: 15e3 },
1104
+ { path: ["sessionEnd", "notifyEmailOnAi"], label: "form.sessionEnd.notifyEmail", hint: "form.sessionEnd.notifyEmailHint", kind: "switch" },
1105
+ { path: ["sessionEnd", "emailSubject"], label: "form.sessionEnd.emailSubject", kind: "text" },
1106
+ { path: ["sessionEnd", "emailBody"], label: "form.sessionEnd.emailBody", hint: "form.sessionEnd.emailBodyHint", kind: "textarea" }
1107
+ ];
785
1108
 
786
1109
  // src/client/SettingsSection.tsx
787
- var import_jsx_runtime5 = require("react/jsx-runtime");
1110
+ var import_jsx_runtime6 = require("react/jsx-runtime");
788
1111
  function SettingsSection({ t }) {
789
- const [tab, setTab] = (0, import_react5.useState)("restart");
790
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.page, children: [
791
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { style: pageStyles.heading, children: t("page.title") }),
792
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: pageStyles.lede, children: t("page.description") }),
793
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.tabs, role: "tablist", children: [
794
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1112
+ const [tab, setTab] = (0, import_react6.useState)("restart");
1113
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.page, children: [
1114
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { style: pageStyles.heading, children: t("page.title") }),
1115
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { style: pageStyles.lede, children: t("page.description") }),
1116
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.tabs, role: "tablist", children: [
1117
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
795
1118
  "button",
796
1119
  {
797
1120
  type: "button",
@@ -804,7 +1127,7 @@ function SettingsSection({ t }) {
804
1127
  children: t("page.tab.restart")
805
1128
  }
806
1129
  ),
807
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1130
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
808
1131
  "button",
809
1132
  {
810
1133
  type: "button",
@@ -817,7 +1140,7 @@ function SettingsSection({ t }) {
817
1140
  children: t("page.tab.autoReview")
818
1141
  }
819
1142
  ),
820
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1143
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
821
1144
  "button",
822
1145
  {
823
1146
  type: "button",
@@ -830,7 +1153,20 @@ function SettingsSection({ t }) {
830
1153
  children: t("page.tab.taskGuard")
831
1154
  }
832
1155
  ),
833
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1156
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1157
+ "button",
1158
+ {
1159
+ type: "button",
1160
+ role: "tab",
1161
+ "aria-selected": tab === "sessionEnd",
1162
+ onClick: () => {
1163
+ setTab("sessionEnd");
1164
+ },
1165
+ style: tab === "sessionEnd" ? { ...pageStyles.tab, ...pageStyles.tabActive } : pageStyles.tab,
1166
+ children: t("page.tab.sessionEnd")
1167
+ }
1168
+ ),
1169
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
834
1170
  "button",
835
1171
  {
836
1172
  type: "button",
@@ -844,7 +1180,7 @@ function SettingsSection({ t }) {
844
1180
  }
845
1181
  )
846
1182
  ] }),
847
- tab === "restart" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RestartCard, { t }) : tab === "autoReview" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1183
+ tab === "restart" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RestartCard, { t }) : tab === "autoReview" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
848
1184
  ConfigForm,
849
1185
  {
850
1186
  t,
@@ -852,7 +1188,7 @@ function SettingsSection({ t }) {
852
1188
  description: "page.autoReview.description",
853
1189
  fields: AUTO_REVIEW_FIELDS
854
1190
  }
855
- ) : tab === "taskGuard" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1191
+ ) : tab === "taskGuard" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
856
1192
  ConfigForm,
857
1193
  {
858
1194
  t,
@@ -860,25 +1196,37 @@ function SettingsSection({ t }) {
860
1196
  description: "page.taskGuard.description",
861
1197
  fields: TASK_GUARD_FIELDS
862
1198
  }
863
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.card, children: [
864
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardTitle, children: t("page.components.title") }),
865
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
866
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.appearance") }),
867
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.appearanceHint") })
1199
+ ) : tab === "sessionEnd" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1200
+ ConfigForm,
1201
+ {
1202
+ t,
1203
+ title: "page.sessionEnd.title",
1204
+ description: "page.sessionEnd.description",
1205
+ fields: SESSION_END_FIELDS
1206
+ }
1207
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.card, children: [
1208
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: pageStyles.cardTitle, children: t("page.components.title") }),
1209
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1210
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.appearance") }),
1211
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.appearanceHint") })
1212
+ ] }),
1213
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1214
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.autoReviewFix") }),
1215
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.autoReviewFixHint") })
868
1216
  ] }),
869
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
870
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.autoReviewFix") }),
871
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.autoReviewFixHint") })
1217
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1218
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.taskGuard") }),
1219
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.taskGuardHint") })
872
1220
  ] }),
873
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
874
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.taskGuard") }),
875
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.taskGuardHint") })
1221
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1222
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.restart") }),
1223
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.restartHint") })
876
1224
  ] }),
877
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
878
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.restart") }),
879
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.restartHint") })
1225
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1226
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.sessionEnd") }),
1227
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.sessionEndHint") })
880
1228
  ] }),
881
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardStatus, children: t("page.components.note") })
1229
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: pageStyles.cardStatus, children: t("page.components.note") })
882
1230
  ] })
883
1231
  ] });
884
1232
  }
@@ -1029,6 +1377,18 @@ var zh = {
1029
1377
  "restart.restarting": "\u6B63\u5728\u91CD\u542F\u2026\u7A97\u53E3\u4F1A\u77ED\u6682\u5173\u95ED",
1030
1378
  "restart.failed": "\u91CD\u542F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
1031
1379
  "restart.confirm": "\u786E\u5B9A\u8981\u91CD\u542F DeepSeek Harness \u5417\uFF1F\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD\u3002",
1380
+ "sessionEnd.label": "\u4F1A\u8BDD\u540E\u91CD\u542F",
1381
+ "sessionEnd.hint": "\u672C\u8F6E\u6700\u7EC8\u56DE\u590D\u5B8C\u6574\u663E\u793A\u540E\u6267\u884C\uFF1BAI \u9700\u8981\u91CD\u542F\u63D2\u4EF6\u65F6\u53EF\u81EA\u52A8\u8BBE\u7F6E\u3002",
1382
+ "sessionEnd.off": "\u5173\u95ED",
1383
+ "sessionEnd.restart": "\u91CD\u542F DSH",
1384
+ "sessionEnd.close": "\u5173\u95ED DSH",
1385
+ "sessionEnd.shutdown": "\u5173\u95ED\u7535\u8111",
1386
+ "sessionEnd.aiRestart": "AI \u5DF2\u8BF7\u6C42\uFF1A\u672C\u8F6E\u7ED3\u675F\u540E\u91CD\u542F DSH",
1387
+ "sessionEnd.aiClose": "AI \u5DF2\u8BF7\u6C42\uFF1A\u672C\u8F6E\u7ED3\u675F\u540E\u5173\u95ED DSH",
1388
+ "sessionEnd.aiWaiting": "AI \u5DF2\u8BF7\u6C42\u91CD\u542F\uFF1B\u7B49\u5F85\u5176\u5B83\u4EFB\u52A1\u7ED3\u675F",
1389
+ "sessionEnd.userShutdown": "\u672C\u8F6E\u7ED3\u675F\u540E\u5C06\u5173\u95ED\u7535\u8111",
1390
+ "sessionEnd.shutdownConfirm": "\u786E\u5B9A\u8981\u5728\u672C\u8F6E\u7ED3\u675F\u540E\u5173\u95ED\u7535\u8111\u5417\uFF1F",
1391
+ "sessionEnd.failed": "\u8BBE\u7F6E\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
1032
1392
  "page.title": "MCviseron \u63D2\u4EF6",
1033
1393
  "page.description": "\u603B\u63D2\u4EF6\u7684\u7EC4\u4EF6\u8BBE\u7F6E\u3002\u5916\u89C2\u8BBE\u7F6E\u4ECD\u5728\u300C\u901A\u7528 \u2192 \u5916\u89C2\u300D\u4E2D\u3002",
1034
1394
  "page.tab.restart": "\u91CD\u542F",
@@ -1097,7 +1457,21 @@ var zh = {
1097
1457
  "form.taskGuard.todoTimeout": "todo \u7FFB\u8BD1\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
1098
1458
  "form.taskGuard.include": "\u53EA\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
1099
1459
  "form.taskGuard.exclude": "\u4E0D\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
1100
- "form.taskGuard.listHint": "\u9017\u53F7\u5206\u9694\uFF0C\u652F\u6301 *\uFF1B\u7559\u7A7A\u8868\u793A\u5168\u90E8"
1460
+ "form.taskGuard.listHint": "\u9017\u53F7\u5206\u9694\uFF0C\u652F\u6301 *\uFF1B\u7559\u7A7A\u8868\u793A\u5168\u90E8",
1461
+ "page.tab.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1462
+ "page.sessionEnd.title": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1463
+ "page.sessionEnd.description": "\u672C\u8F6E\u6700\u7EC8\u56DE\u590D\u5B8C\u6574\u663E\u793A\u540E\u6267\u884C\u4E00\u6B21\u52A8\u4F5C\uFF1B\u91CD\u542F\u4F1A\u7B49\u5F85\u6240\u6709\u4F1A\u8BDD\u4E0E\u540E\u53F0\u4EFB\u52A1\u7ED3\u675F\uFF0C\u8BBE\u7F6E\u9875\u7684\u91CD\u542F\u4E0D\u53D7\u6B64\u7EA6\u675F\u3002",
1464
+ "page.components.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1465
+ "page.components.sessionEndHint": "\u8F93\u5165\u6846\u5DE6\u4FA7\u7684\u300C\u4F1A\u8BDD\u540E\u91CD\u542F\u300D\u4E0B\u62C9",
1466
+ "form.sessionEnd.enabled": "\u542F\u7528\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1467
+ "form.sessionEnd.enabledHint": "\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u663E\u793A\u300C\u4F1A\u8BDD\u540E\u91CD\u542F\u300D\u4E0B\u62C9\uFF0C\u5E76\u5141\u8BB8 AI \u8BBE\u7F6E",
1468
+ "form.sessionEnd.grace": "\u6700\u7EC8\u56DE\u590D\u663E\u793A\u7B49\u5F85\uFF08\u6BEB\u79D2\uFF09",
1469
+ "form.sessionEnd.graceHint": "turn/end \u540E\u518D\u7B49\u5F85\u8FD9\u6BB5\u65F6\u95F4\uFF0C\u907F\u514D\u6587\u5B57\u8FD8\u5728\u6E32\u67D3\u5C31\u91CD\u542F",
1470
+ "form.sessionEnd.notifyEmail": "AI \u5F00\u542F\u65F6\u53D1\u9001\u90AE\u4EF6\u63D0\u9192",
1471
+ "form.sessionEnd.notifyEmailHint": "\u9700\u8981\u5DF2\u5B89\u88C5\u5E76\u914D\u7F6E\u53EF\u53D1\u9001\u7684 dsh-email-notify\uFF1B\u590D\u7528\u5176 SMTP \u914D\u7F6E\uFF0C\u4E0D\u4FEE\u6539\u90AE\u4EF6\u63D2\u4EF6",
1472
+ "form.sessionEnd.emailSubject": "\u90AE\u4EF6\u4E3B\u9898\u6A21\u677F",
1473
+ "form.sessionEnd.emailBody": "\u90AE\u4EF6\u6B63\u6587\u6A21\u677F",
1474
+ "form.sessionEnd.emailBodyHint": "\u53EF\u7528 {{actionText}} / {{sessionName}} / {{sessionId}} / {{time}} / {{reason}}"
1101
1475
  };
1102
1476
  var en = {
1103
1477
  "row.title": "Switch light/dark by time",
@@ -1124,6 +1498,18 @@ var en = {
1124
1498
  "restart.restarting": "Restarting\u2026 the window will close briefly",
1125
1499
  "restart.failed": "Restart failed \u2014 try again",
1126
1500
  "restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
1501
+ "sessionEnd.label": "Restart after session",
1502
+ "sessionEnd.hint": "Runs after the final reply is fully displayed; the AI can arm it when a plugin change needs a restart.",
1503
+ "sessionEnd.off": "Off",
1504
+ "sessionEnd.restart": "Restart DSH",
1505
+ "sessionEnd.close": "Close DSH",
1506
+ "sessionEnd.shutdown": "Shut down PC",
1507
+ "sessionEnd.aiRestart": "AI requested: restart DSH after this turn",
1508
+ "sessionEnd.aiClose": "AI requested: close DSH after this turn",
1509
+ "sessionEnd.aiWaiting": "AI requested restart; waiting for other tasks",
1510
+ "sessionEnd.userShutdown": "The computer will shut down after this turn",
1511
+ "sessionEnd.shutdownConfirm": "Shut down the computer after this turn?",
1512
+ "sessionEnd.failed": "Could not update the session-end action",
1127
1513
  "page.title": "MCviseron plugin",
1128
1514
  "page.description": "Settings for the master plugin components. Appearance still lives under General \u2192 Appearance.",
1129
1515
  "page.tab.restart": "Restart",
@@ -1192,7 +1578,21 @@ var en = {
1192
1578
  "form.taskGuard.todoTimeout": "Todo translation timeout (ms)",
1193
1579
  "form.taskGuard.include": "Count only these tools",
1194
1580
  "form.taskGuard.exclude": "Exclude these tools",
1195
- "form.taskGuard.listHint": "Comma-separated, * supported; empty means all"
1581
+ "form.taskGuard.listHint": "Comma-separated, * supported; empty means all",
1582
+ "page.tab.sessionEnd": "After-session action",
1583
+ "page.sessionEnd.title": "After-session action",
1584
+ "page.sessionEnd.description": "One action after the final reply is fully displayed. A restart waits for every running conversation and background job; the Settings restart button is not delayed.",
1585
+ "page.components.sessionEnd": "After-session action",
1586
+ "page.components.sessionEndHint": "The \u201CRestart after session\u201D dropdown left of the composer",
1587
+ "form.sessionEnd.enabled": "Enable after-session actions",
1588
+ "form.sessionEnd.enabledHint": "Show the \u201CRestart after session\u201D dropdown in the composer and let the AI arm it",
1589
+ "form.sessionEnd.grace": "Final-reply render grace (ms)",
1590
+ "form.sessionEnd.graceHint": "Wait after turn/end so the final text is fully rendered before acting",
1591
+ "form.sessionEnd.notifyEmail": "Email me when the AI arms it",
1592
+ "form.sessionEnd.notifyEmailHint": "Requires an installed, sendable dsh-email-notify; reuses its SMTP settings without modifying it",
1593
+ "form.sessionEnd.emailSubject": "Email subject template",
1594
+ "form.sessionEnd.emailBody": "Email body template",
1595
+ "form.sessionEnd.emailBodyHint": "Placeholders: {{actionText}} / {{sessionName}} / {{sessionId}} / {{time}} / {{reason}}"
1196
1596
  };
1197
1597
 
1198
1598
  // src/client/index.ts
@@ -1249,6 +1649,11 @@ function apply(ctx) {
1249
1649
  order: 13,
1250
1650
  locale: NS
1251
1651
  }, FallbackRestartRow);
1652
+ registerSafely(ctx, "conversation.input.left", {
1653
+ id: "mcviseron-session-end",
1654
+ order: 20,
1655
+ locale: NS
1656
+ }, SessionEndControl);
1252
1657
  registerSafely(ctx, "settings.section", {
1253
1658
  id: "mcviseron",
1254
1659
  order: 115,