dsh-sessions-manager 3.4.0 → 3.4.2

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
@@ -464,7 +464,7 @@ function SessionPanel({ workspacesSvc }) {
464
464
  setBusy(null);
465
465
  const n = it.title || it.sessionId;
466
466
  showToast(action === "archive" ? `\u5DF2\u5F52\u6863\u300C${n}\u300D` : `\u5DF2\u6062\u590D\u300C${n}\u300D`);
467
- refresh();
467
+ setSessions((s) => s && s.map((x) => x.sessionId === it.sessionId ? { ...x, archived: action === "archive" } : x));
468
468
  }).catch((e) => {
469
469
  setBusy(null);
470
470
  setError(String(e && e.message || e));
@@ -477,8 +477,11 @@ function SessionPanel({ workspacesSvc }) {
477
477
  setBusy(null);
478
478
  const n = delTarget.title || delTarget.sessionId;
479
479
  showToast(`\u5DF2\u5220\u9664 ${n}\uFF08\u5DF2\u79FB\u5165\u56DE\u6536\u7AD9\uFF09`);
480
+ const sid = String(delTarget.sessionId);
480
481
  setDelTarget(null);
481
- refresh();
482
+ setSessions((s) => s && s.filter((x) => String(x.sessionId) !== sid));
483
+ loadTrash();
484
+ dsmLoadTrashIds();
482
485
  }).catch((e) => {
483
486
  setBusy(null);
484
487
  setDelTarget(null);
@@ -622,7 +625,7 @@ function SessionPanel({ workspacesSvc }) {
622
625
  setMoveMode("existing");
623
626
  setNewPath("");
624
627
  showToast(`\u5DF2\u628A\u300C${it.title || it.sessionId}\u300D\u79FB\u5230 ${r.workspaceTitle || targetPath}`);
625
- refresh();
628
+ setSessions((s) => s && s.map((x) => x.sessionId === it.sessionId ? { ...x, workspacePath: r.workspacePath || targetPath, workspaceTitle: r.workspaceTitle || targetPath } : x));
626
629
  }).catch((e) => {
627
630
  setBusy(null);
628
631
  setError(String(e && e.message || e));
@@ -1775,6 +1778,12 @@ function installSidebarWorkspaceDrag() {
1775
1778
  } catch (e) {
1776
1779
  }
1777
1780
  };
1781
+ document.addEventListener("pointerdown", (event) => {
1782
+ if (moving) return;
1783
+ const row = eventRow(event);
1784
+ if (!row || sessionForRow(row)) return;
1785
+ maybeRefresh();
1786
+ }, true);
1778
1787
  document.addEventListener("dragstart", (event) => {
1779
1788
  const row = eventRow(event);
1780
1789
  const item = row && sessionForRow(row);
@@ -1834,7 +1843,25 @@ function installSidebarWorkspaceDrag() {
1834
1843
  refresh();
1835
1844
  const observer = new MutationObserver(scheduleDecorate);
1836
1845
  observer.observe(document.body, { childList: true, subtree: true });
1837
- setInterval(refresh, 5e3);
1846
+ let lastRefreshAt = Date.now();
1847
+ const maybeRefresh = () => {
1848
+ if (typeof document !== "undefined" && document.hidden) return;
1849
+ lastRefreshAt = Date.now();
1850
+ return refresh();
1851
+ };
1852
+ const REFRESH_MS = 6e4;
1853
+ setInterval(() => {
1854
+ if (typeof document !== "undefined" && document.hidden) return;
1855
+ if (Date.now() - lastRefreshAt < REFRESH_MS) return;
1856
+ maybeRefresh();
1857
+ }, REFRESH_MS);
1858
+ if (typeof document !== "undefined" && document.addEventListener) {
1859
+ document.addEventListener("visibilitychange", () => {
1860
+ if (document.hidden) return;
1861
+ if (Date.now() - lastRefreshAt < 3e4) return;
1862
+ maybeRefresh();
1863
+ });
1864
+ }
1838
1865
  }
1839
1866
  function apply(ctx) {
1840
1867
  installSettingsNavIcons(ctx);