dsh-mcviseron-plugin 0.6.4 → 0.6.6

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
@@ -32,6 +32,20 @@ __export(index_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(index_exports);
34
34
 
35
+ // src/api.ts
36
+ var MCVISERON_API = {
37
+ describe: "/api/dsh-mcviseron/settings/describe",
38
+ mutate: "/api/dsh-mcviseron/settings/mutate"
39
+ };
40
+ var SESSION_END_API = {
41
+ state: "/api/dsh-mcviseron/session-end/state",
42
+ set: "/api/dsh-mcviseron/session-end/set",
43
+ global: "/api/dsh-mcviseron/session-end/global"
44
+ };
45
+ var AUTH_COOKIE_API = {
46
+ prune: "/api/dsh-mcviseron/auth-cookies/prune"
47
+ };
48
+
35
49
  // src/client/AppearanceScheduleRow.tsx
36
50
  var import_react = require("react");
37
51
 
@@ -456,16 +470,158 @@ function FallbackRestartRow({ t }) {
456
470
 
457
471
  // src/client/SessionEndControl.tsx
458
472
  var import_react4 = require("react");
473
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
459
474
 
460
- // src/api.ts
461
- var MCVISERON_API = {
462
- describe: "/api/dsh-mcviseron/settings/describe",
463
- mutate: "/api/dsh-mcviseron/settings/mutate"
464
- };
465
- var SESSION_END_API = {
466
- state: "/api/dsh-mcviseron/session-end/state",
467
- set: "/api/dsh-mcviseron/session-end/set"
468
- };
475
+ // src/client/SessionEndGlobalNotice.ts
476
+ var HOST_ID = "mcviseron-session-end-global";
477
+ var FALLBACK_TOP = 56;
478
+ var MIN_TOP = 120;
479
+ function globalNoticeText(action) {
480
+ const name = action.label.trim() !== "" ? action.label : "\u4F1A\u8BDD \u2026" + action.sessionId.slice(-6);
481
+ const mode = action.mode === "restart" ? "\u81EA\u52A8\u91CD\u542F" : action.mode === "close" ? "\u81EA\u52A8\u5173\u95ED DSH" : "\u5173\u95ED\u7535\u8111";
482
+ return "\u300C" + name + "\u300D\u5DF2\u542F\u7528 AI \u4F1A\u8BDD" + mode;
483
+ }
484
+ function globalNoticeKey(action) {
485
+ return action.sessionId + ":" + action.mode + ":" + String(action.armedAt);
486
+ }
487
+ function navigationBottom() {
488
+ for (const selector of ["header", '[role="banner"]']) {
489
+ const element = document.querySelector(selector);
490
+ if (element === null) continue;
491
+ const rect = element.getBoundingClientRect();
492
+ if (rect.height > 0 && rect.top <= 8) return Math.round(rect.bottom);
493
+ }
494
+ return FALLBACK_TOP;
495
+ }
496
+ function placeBelowNavigation(host) {
497
+ const measured = navigationBottom();
498
+ const nav = measured > 0 && measured < 240 ? measured : 56;
499
+ host.style.top = String(Math.max(nav + 48, MIN_TOP)) + "px";
500
+ }
501
+ function ensureHost() {
502
+ if (typeof document === "undefined") return void 0;
503
+ const existing = document.getElementById(HOST_ID);
504
+ if (existing !== null) return existing;
505
+ const host = document.createElement("div");
506
+ host.id = HOST_ID;
507
+ host.setAttribute("role", "status");
508
+ host.setAttribute("aria-live", "polite");
509
+ host.style.cssText = [
510
+ "position:fixed",
511
+ "top:56px",
512
+ "right:12px",
513
+ "z-index:10000",
514
+ "display:flex",
515
+ "flex-direction:column",
516
+ "gap:8px",
517
+ "max-width:min(380px,calc(100vw - 24px))",
518
+ "pointer-events:none"
519
+ ].join(";");
520
+ placeBelowNavigation(host);
521
+ document.body.appendChild(host);
522
+ return host;
523
+ }
524
+ function card(action, dismiss) {
525
+ const element = document.createElement("div");
526
+ element.style.cssText = [
527
+ "pointer-events:auto",
528
+ "display:flex",
529
+ "align-items:flex-start",
530
+ "gap:9px",
531
+ "padding:10px 11px",
532
+ "border-radius:12px",
533
+ "border:1px solid var(--dsw-alias-state-warn-primary, rgba(227,179,65,.65))",
534
+ "background:var(--dsw-alias-bg-layer-2, #1f2023)",
535
+ "color:var(--dsw-alias-label-primary, #f2f3f5)",
536
+ "box-shadow:var(--dsw-elevation-prominent, 0 8px 28px rgba(0,0,0,.35))",
537
+ "font-size:12px",
538
+ "line-height:1.45"
539
+ ].join(";");
540
+ const dot = document.createElement("span");
541
+ dot.setAttribute("aria-hidden", "true");
542
+ dot.style.cssText = "flex:none;width:8px;height:8px;margin-top:4px;border-radius:50%;background:var(--dsw-alias-state-warn-primary,#e3b341)";
543
+ const body = document.createElement("div");
544
+ body.style.cssText = "flex:1;min-width:0";
545
+ const title = document.createElement("div");
546
+ title.textContent = globalNoticeText(action);
547
+ title.style.cssText = "font-weight:600";
548
+ const hint = document.createElement("div");
549
+ hint.textContent = action.waiting ? "\u6B63\u5728\u7B49\u5F85\u4EFB\u52A1\u7ED3\u675F" + (action.runningAgents + action.runningJobs > 0 ? " \xB7 " + String(action.runningAgents) + " \u4E2A\u4F1A\u8BDD / " + String(action.runningJobs) + " \u4E2A\u4EFB\u52A1" : "") : "\u672C\u8F6E\u6700\u7EC8\u56DE\u590D\u540E\u6267\u884C";
550
+ hint.style.cssText = "margin-top:2px;color:var(--dsw-alias-label-secondary,#a8adb7);font-size:11px";
551
+ body.append(title, hint);
552
+ const close = document.createElement("button");
553
+ close.type = "button";
554
+ close.setAttribute("aria-label", "\u5173\u95ED\u63D0\u793A");
555
+ close.textContent = "\xD7";
556
+ close.style.cssText = [
557
+ "flex:none",
558
+ "border:0",
559
+ "background:transparent",
560
+ "color:var(--dsw-alias-label-tertiary,#8b919c)",
561
+ "cursor:pointer",
562
+ "font-size:16px",
563
+ "line-height:1",
564
+ "padding:0 2px"
565
+ ].join(";");
566
+ close.addEventListener("click", dismiss);
567
+ element.append(dot, body, close);
568
+ return element;
569
+ }
570
+ function startSessionEndGlobalNotice() {
571
+ if (typeof document === "undefined" || typeof fetch !== "function") return () => {
572
+ };
573
+ let stopped = false;
574
+ let timer;
575
+ const dismissed = /* @__PURE__ */ new Set();
576
+ const clear = () => {
577
+ document.getElementById(HOST_ID)?.remove();
578
+ };
579
+ const render = (actions) => {
580
+ const active = new Set(actions.map(globalNoticeKey));
581
+ for (const key of dismissed) if (!active.has(key)) dismissed.delete(key);
582
+ const visible = actions.filter((action) => !dismissed.has(globalNoticeKey(action)));
583
+ if (visible.length === 0) {
584
+ clear();
585
+ return;
586
+ }
587
+ const host = ensureHost();
588
+ if (host === void 0) return;
589
+ placeBelowNavigation(host);
590
+ host.replaceChildren(...visible.map((action) => card(action, () => {
591
+ dismissed.add(globalNoticeKey(action));
592
+ render(actions);
593
+ })));
594
+ };
595
+ const poll = async () => {
596
+ try {
597
+ const response = await fetch(SESSION_END_API.global, {
598
+ method: "POST",
599
+ credentials: "same-origin",
600
+ cache: "no-store"
601
+ });
602
+ if (stopped) return;
603
+ const body = await response.json();
604
+ if (stopped || body.ok !== true || !Array.isArray(body.actions)) return;
605
+ render(body.actions.filter((action) => action.requestedBy === "ai"));
606
+ } catch {
607
+ }
608
+ };
609
+ const onResize = () => {
610
+ const host = document.getElementById(HOST_ID);
611
+ if (host !== null) placeBelowNavigation(host);
612
+ };
613
+ window.addEventListener("resize", onResize);
614
+ void poll();
615
+ timer = setInterval(() => {
616
+ void poll();
617
+ }, 2e3);
618
+ return () => {
619
+ stopped = true;
620
+ if (timer !== void 0) clearInterval(timer);
621
+ window.removeEventListener("resize", onResize);
622
+ clear();
623
+ };
624
+ }
469
625
 
470
626
  // src/client/SessionEndControl.tsx
471
627
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -478,13 +634,21 @@ var INITIAL = {
478
634
  runningJobs: 0,
479
635
  available: { restart: true, close: true, shutdown: true }
480
636
  };
637
+ var TRIGGER_CSS = [
638
+ ".mcviseron-session-end-trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}",
639
+ ".mcviseron-session-end-trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline:none}",
640
+ ".mcviseron-session-end-trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}",
641
+ ".mcviseron-session-end-trigger svg{width:14px;height:14px}",
642
+ ".mcviseron-session-end-chevron{display:inline-flex;transition:transform .12s;color:var(--dsw-alias-label-caption)}",
643
+ ".mcviseron-session-end-chevron.open{transform:rotate(180deg)}"
644
+ ].join("\n");
481
645
  var labelStyle = {
482
646
  display: "inline-flex",
483
647
  alignItems: "center",
484
- gap: 6,
485
- padding: "0 6px",
648
+ gap: 4,
649
+ padding: "0 4px",
486
650
  height: 28,
487
- borderRadius: 8,
651
+ borderRadius: "var(--dsw-radius-sm)",
488
652
  fontSize: 12,
489
653
  lineHeight: 1.3,
490
654
  color: "var(--dsw-alias-label-secondary)",
@@ -493,47 +657,20 @@ var labelStyle = {
493
657
  var triggerStyle = {
494
658
  display: "inline-flex",
495
659
  alignItems: "center",
496
- justifyContent: "space-between",
497
- gap: 6,
660
+ gap: 4,
498
661
  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,
662
+ minWidth: 0,
663
+ maxWidth: 220,
664
+ padding: "0 4px 0 8px",
665
+ border: "none",
666
+ borderRadius: "var(--dsw-radius-sm)",
530
667
  background: "transparent",
531
- color: "var(--dsw-alias-label-primary)",
668
+ color: "var(--dsw-alias-label-secondary)",
669
+ cursor: "pointer",
670
+ outline: "none",
532
671
  fontSize: 13,
533
- lineHeight: "20px",
534
- padding: "7px 10px",
535
- textAlign: "left",
536
- cursor: "pointer"
672
+ fontWeight: 500,
673
+ lineHeight: "20px"
537
674
  };
538
675
  var noticeStyle = {
539
676
  display: "inline-flex",
@@ -555,15 +692,18 @@ var shutdownNoticeStyle = {
555
692
  background: "var(--dsw-alias-state-error-tertiary)",
556
693
  color: "var(--dsw-alias-state-error-primary)"
557
694
  };
695
+ function triggerIcon(mode) {
696
+ if (mode === "restart") return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconRefreshOutlineRegular, {});
697
+ if (mode === "close") return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconCloseCircleFillRegular, {});
698
+ if (mode === "shutdown") return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconStopFillRegular, {});
699
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconClockOutlineRegular, {});
700
+ }
558
701
  function SessionEndControl(props) {
559
702
  const { t } = props;
560
703
  const sessionId = props.sessionId;
561
704
  const [state, setState] = (0, import_react4.useState)(INITIAL);
562
705
  const [busy, setBusy] = (0, import_react4.useState)(false);
563
706
  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
707
  (0, import_react4.useEffect)(() => {
568
708
  if (sessionId === void 0 || sessionId === "") {
569
709
  setState(INITIAL);
@@ -579,11 +719,7 @@ function SessionEndControl(props) {
579
719
  });
580
720
  const body = await response.json();
581
721
  if (cancelled || body.ok !== true) return;
582
- setState((prev) => ({
583
- ...prev,
584
- ...body,
585
- available: body.available ?? prev.available
586
- }));
722
+ setState((prev) => ({ ...prev, ...body, available: body.available ?? prev.available }));
587
723
  } catch {
588
724
  }
589
725
  };
@@ -596,46 +732,8 @@ function SessionEndControl(props) {
596
732
  clearInterval(timer);
597
733
  };
598
734
  }, [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]);
735
+ (0, import_react4.useEffect)(() => startSessionEndGlobalNotice(), []);
623
736
  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
737
  const change = (mode) => {
640
738
  setOpen(false);
641
739
  if (mode === "shutdown" && typeof window !== "undefined" && typeof window.confirm === "function") {
@@ -654,11 +752,7 @@ function SessionEndControl(props) {
654
752
  body: JSON.stringify({ sessionId, mode })
655
753
  }).then(async (response) => await response.json()).then((body) => {
656
754
  if (body.ok === true) {
657
- setState((prev) => ({
658
- ...prev,
659
- ...body,
660
- available: body.available ?? prev.available
661
- }));
755
+ setState((prev) => ({ ...prev, ...body, available: body.available ?? prev.available }));
662
756
  }
663
757
  }).catch(() => {
664
758
  }).finally(() => {
@@ -669,7 +763,60 @@ function SessionEndControl(props) {
669
763
  const aiRequested = state.mode !== "off" && state.requestedBy === "ai";
670
764
  const shutdown = state.mode === "shutdown";
671
765
  const notice = shutdown ? t("sessionEnd.userShutdown") : aiRequested ? state.mode === "close" ? t("sessionEnd.aiClose") : state.waiting ? t("sessionEnd.aiWaiting") : t("sessionEnd.aiRestart") : "";
766
+ const items = [
767
+ { id: "off", label: t("sessionEnd.off"), icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconClockOutlineRegular, {}) },
768
+ {
769
+ id: "restart",
770
+ label: t("sessionEnd.restart"),
771
+ icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconRefreshOutlineRegular, {}),
772
+ disabled: !state.available.restart
773
+ },
774
+ {
775
+ id: "close",
776
+ label: t("sessionEnd.close"),
777
+ icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconCloseCircleFillRegular, {}),
778
+ disabled: !state.available.close
779
+ },
780
+ {
781
+ id: "shutdown",
782
+ label: t("sessionEnd.shutdown"),
783
+ icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconStopFillRegular, {}),
784
+ disabled: !state.available.shutdown,
785
+ danger: true
786
+ }
787
+ ];
788
+ const anchor = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
789
+ "button",
790
+ {
791
+ type: "button",
792
+ className: "mcviseron-session-end-trigger",
793
+ "aria-label": t("sessionEnd.label"),
794
+ "aria-haspopup": "menu",
795
+ "aria-expanded": open,
796
+ title: t("sessionEnd.hint"),
797
+ style: triggerStyle,
798
+ disabled: busy,
799
+ onClick: () => {
800
+ setOpen((value) => !value);
801
+ },
802
+ children: [
803
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { display: "inline-flex", flex: "none" }, children: triggerIcon(state.mode) }),
804
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: t(
805
+ state.mode === "off" ? "sessionEnd.off" : state.mode === "restart" ? "sessionEnd.restart" : state.mode === "close" ? "sessionEnd.close" : "sessionEnd.shutdown"
806
+ ) }),
807
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
808
+ "span",
809
+ {
810
+ className: open ? "mcviseron-session-end-chevron open" : "mcviseron-session-end-chevron",
811
+ "aria-hidden": true,
812
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.IconChevronDownOutlineRegular, {})
813
+ }
814
+ )
815
+ ]
816
+ }
817
+ );
672
818
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
819
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: TRIGGER_CSS }),
673
820
  notice !== "" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
674
821
  "span",
675
822
  {
@@ -678,75 +825,24 @@ function SessionEndControl(props) {
678
825
  children: notice
679
826
  }
680
827
  ),
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
828
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: labelStyle, title: t("sessionEnd.hint"), children: [
688
829
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("sessionEnd.label") }),
689
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
690
- "button",
830
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
831
+ import_dsh_client_ui_primitives2.Menu,
691
832
  {
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)"
833
+ open,
834
+ anchor,
835
+ items,
836
+ selectedId: state.mode,
837
+ onSelect: (id) => {
838
+ change(id);
702
839
  },
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
- ))
840
+ onClose: () => {
841
+ setOpen(false);
842
+ },
843
+ align: "end",
844
+ side: "top",
845
+ portal: true
750
846
  }
751
847
  )
752
848
  ] })
@@ -836,7 +932,7 @@ async function writePluginConfig(path, value) {
836
932
  }
837
933
 
838
934
  // src/client/ConfigForm.tsx
839
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
935
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
840
936
  var import_jsx_runtime5 = require("react/jsx-runtime");
841
937
  function readPath(config, path) {
842
938
  let current = config;
@@ -957,7 +1053,7 @@ function renderControl(field, value, disabled, commit, t) {
957
1053
  switch (field.kind) {
958
1054
  case "switch":
959
1055
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
960
- import_dsh_client_ui_primitives2.Switch,
1056
+ import_dsh_client_ui_primitives3.Switch,
961
1057
  {
962
1058
  checked: value === true,
963
1059
  label: t(field.label),
@@ -1059,6 +1155,9 @@ function ConfigForm({ t, title, description, fields }) {
1059
1155
  ] });
1060
1156
  }
1061
1157
  var AUTO_REVIEW_FIELDS = [
1158
+ { path: ["autoReviewFix", "reviewContextGuard"], label: "form.autoReview.reviewGuard", hint: "form.autoReview.reviewGuardHint", kind: "switch" },
1159
+ { path: ["autoReviewFix", "reviewMaxHistoryChars"], label: "form.autoReview.reviewMaxHistory", hint: "form.autoReview.reviewMaxHistoryHint", kind: "number", min: 2e4, max: 6e5 },
1160
+ { path: ["autoReviewFix", "reviewKeepRecentEntries"], label: "form.autoReview.reviewKeepRecent", kind: "number", min: 4, max: 64 },
1062
1161
  { path: ["autoReviewFix", "translateApprovalReason"], label: "form.autoReview.translate", hint: "form.autoReview.translateHint", kind: "switch" },
1063
1162
  { path: ["autoReviewFix", "keepPresetGuard"], label: "form.autoReview.keepPreset", hint: "form.autoReview.keepPresetHint", kind: "switch" },
1064
1163
  { path: ["autoReviewFix", "translateTimeoutMs"], label: "form.autoReview.timeout", kind: "number", min: 500, max: 6e4 },
@@ -1222,6 +1321,10 @@ function SettingsSection({ t }) {
1222
1321
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.restart") }),
1223
1322
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.restartHint") })
1224
1323
  ] }),
1324
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1325
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.authCookie") }),
1326
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.authCookieHint") })
1327
+ ] }),
1225
1328
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1226
1329
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.sessionEnd") }),
1227
1330
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.sessionEndHint") })
@@ -1379,7 +1482,7 @@ var zh = {
1379
1482
  "restart.confirm": "\u786E\u5B9A\u8981\u91CD\u542F DeepSeek Harness \u5417\uFF1F\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD\u3002",
1380
1483
  "sessionEnd.label": "\u4F1A\u8BDD\u540E\u91CD\u542F",
1381
1484
  "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",
1485
+ "sessionEnd.off": "\u4E0D\u505A\u64CD\u4F5C",
1383
1486
  "sessionEnd.restart": "\u91CD\u542F DSH",
1384
1487
  "sessionEnd.close": "\u5173\u95ED DSH",
1385
1488
  "sessionEnd.shutdown": "\u5173\u95ED\u7535\u8111",
@@ -1426,6 +1529,11 @@ var zh = {
1426
1529
  "form.failed": "\u4FDD\u5B58\u5931\u8D25",
1427
1530
  "form.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6\u8BBE\u7F6E\uFF1A\u8BF7\u786E\u8BA4 profile \u4E2D\u7684\u63D2\u4EF6\u6761\u76EE id \u4E3A mcviseron",
1428
1531
  "form.autoSave": "\u4FEE\u6539\u540E\u81EA\u52A8\u4FDD\u5B58",
1532
+ "form.autoReview.reviewGuard": "\u88C1\u526A Auto review \u4E0A\u4E0B\u6587",
1533
+ "form.autoReview.reviewGuardHint": "\u53EA\u538B\u7F29 reviewer \u7684\u5386\u53F2\uFF1B\u5F53\u524D\u52A8\u4F5C\u3001\u5DE5\u7A0B\u7EA6\u675F\u548C\u4EBA\u7C7B\u6307\u4EE4\u4FDD\u7559\uFF0C\u907F\u514D\u957F\u4F1A\u8BDD\u628A\u5BA1\u67E5\u6A21\u578B\u6491\u7206",
1534
+ "form.autoReview.reviewMaxHistory": "\u5BA1\u67E5\u5386\u53F2\u4E0A\u9650\uFF08\u5B57\u7B26\uFF09",
1535
+ "form.autoReview.reviewMaxHistoryHint": "\u9ED8\u8BA4 120000\uFF1B\u8D85\u51FA\u540E\u65E7\u5DE5\u5177\u8C03\u7528\u4F1A\u6298\u53E0\u6210\u6458\u8981",
1536
+ "form.autoReview.reviewKeepRecent": "\u4FDD\u7559\u6700\u8FD1\u5386\u53F2\u6761\u6570",
1429
1537
  "form.autoReview.translate": "\u7FFB\u8BD1\u5BA1\u6279\u7406\u7531",
1430
1538
  "form.autoReview.translateHint": "\u82F1\u6587\u5BA1\u67E5\u7406\u7531\u4F1A\u9644\u4E0A\u4E2D\u6587\u7FFB\u8BD1\uFF0C\u5E76\u5199\u5165\u5BA1\u6279\u4E8B\u4EF6\uFF1B\u8F6C\u624B\u52A8\u540E\u88AB\u62D2\u65F6\uFF0C\u81EA\u52A8\u5BA1\u67E5\u7406\u7531\u4F1A\u4F5C\u4E3A notice \u4EA4\u56DE AI",
1431
1539
  "form.autoReview.keepPreset": "\u9000\u51FA\u65F6\u4FDD\u6301\u6743\u9650\u9884\u8BBE",
@@ -1461,6 +1569,8 @@ var zh = {
1461
1569
  "page.tab.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1462
1570
  "page.sessionEnd.title": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1463
1571
  "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",
1572
+ "page.components.authCookie": "\u8BA4\u8BC1 cookie \u6E05\u7406",
1573
+ "page.components.authCookieHint": "\u81EA\u52A8\u8FD0\u884C\uFF0C\u65E0\u8BBE\u7F6E",
1464
1574
  "page.components.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1465
1575
  "page.components.sessionEndHint": "\u8F93\u5165\u6846\u5DE6\u4FA7\u7684\u300C\u4F1A\u8BDD\u540E\u91CD\u542F\u300D\u4E0B\u62C9",
1466
1576
  "form.sessionEnd.enabled": "\u542F\u7528\u4F1A\u8BDD\u540E\u52A8\u4F5C",
@@ -1500,7 +1610,7 @@ var en = {
1500
1610
  "restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
1501
1611
  "sessionEnd.label": "Restart after session",
1502
1612
  "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",
1613
+ "sessionEnd.off": "No action",
1504
1614
  "sessionEnd.restart": "Restart DSH",
1505
1615
  "sessionEnd.close": "Close DSH",
1506
1616
  "sessionEnd.shutdown": "Shut down PC",
@@ -1547,6 +1657,11 @@ var en = {
1547
1657
  "form.failed": "Save failed",
1548
1658
  "form.unavailable": "Cannot read the plugin settings: check that the profile entry id is mcviseron",
1549
1659
  "form.autoSave": "Changes save automatically",
1660
+ "form.autoReview.reviewGuard": "Trim the Auto-review context",
1661
+ "form.autoReview.reviewGuardHint": "Compacts only the reviewer history; the pending action, project constraints and human instructions stay",
1662
+ "form.autoReview.reviewMaxHistory": "Reviewer history limit (chars)",
1663
+ "form.autoReview.reviewMaxHistoryHint": "Defaults to 120000; older tool calls collapse into a summary",
1664
+ "form.autoReview.reviewKeepRecent": "Recent entries to keep",
1550
1665
  "form.autoReview.translate": "Translate the approval reason",
1551
1666
  "form.autoReview.translateHint": "Appends a Chinese translation to the reviewer note and writes it into the approval event; a manual rejection returns the auto-review reason to the AI",
1552
1667
  "form.autoReview.keepPreset": "Keep the permission preset on shutdown",
@@ -1582,6 +1697,8 @@ var en = {
1582
1697
  "page.tab.sessionEnd": "After-session action",
1583
1698
  "page.sessionEnd.title": "After-session action",
1584
1699
  "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.",
1700
+ "page.components.authCookie": "Auth-cookie cleanup",
1701
+ "page.components.authCookieHint": "Runs automatically; no settings",
1585
1702
  "page.components.sessionEnd": "After-session action",
1586
1703
  "page.components.sessionEndHint": "The \u201CRestart after session\u201D dropdown left of the composer",
1587
1704
  "form.sessionEnd.enabled": "Enable after-session actions",
@@ -1597,6 +1714,7 @@ var en = {
1597
1714
 
1598
1715
  // src/client/index.ts
1599
1716
  var NS = "mcviseron";
1717
+ var authCookiePruneStarted = false;
1600
1718
  var inject = ["slots", "locale"];
1601
1719
  function registerSafely(ctx, name, options, component, onRegistered, onFailed) {
1602
1720
  const slots = ctx.slots;
@@ -1619,6 +1737,18 @@ function registerSafely(ctx, name, options, component, onRegistered, onFailed) {
1619
1737
  }
1620
1738
  }
1621
1739
  function apply(ctx) {
1740
+ if (!authCookiePruneStarted) {
1741
+ authCookiePruneStarted = true;
1742
+ try {
1743
+ void fetch(AUTH_COOKIE_API.prune, {
1744
+ method: "POST",
1745
+ credentials: "same-origin",
1746
+ cache: "no-store"
1747
+ }).catch(() => {
1748
+ });
1749
+ } catch {
1750
+ }
1751
+ }
1622
1752
  try {
1623
1753
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "mcviseron: dictionaries");
1624
1754
  } catch (error) {