dshmarket 1.21.0 → 1.21.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/client/client.js CHANGED
@@ -4704,6 +4704,13 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
4704
4704
  setUpdatingName(name);
4705
4705
  updateIdleStrikes.current = 0;
4706
4706
  sessionStorage.setItem("dshm-updating", JSON.stringify({ name }));
4707
+ const updateRecordId = nextRecordId();
4708
+ setRecords((list) => enqueue(list, {
4709
+ id: updateRecordId,
4710
+ kind: "update",
4711
+ name,
4712
+ state: "running"
4713
+ }));
4707
4714
  return fetch("/dsh-market/update", {
4708
4715
  method: "POST",
4709
4716
  headers: { "content-type": "application/json" },
@@ -4718,11 +4725,13 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
4718
4725
  sessionStorage.removeItem("dshm-updating");
4719
4726
  setUpdatingName(null);
4720
4727
  if (body.cancelled === true) {
4728
+ setRecords((list) => drop(list, updateRecordId));
4721
4729
  refreshInstalled();
4722
4730
  if (body.partial === true) setInstallError(t("partialNote"));
4723
4731
  return;
4724
4732
  }
4725
4733
  if (status === 200 && body.ok) {
4734
+ setRecords((list) => patch(list, updateRecordId, { state: "done" }));
4726
4735
  setUpdatedNames((names) => names.concat(name));
4727
4736
  if (body.activation && typeof body.activation === "object") setActivations((prev) => ({
4728
4737
  ...prev,
@@ -4734,9 +4743,17 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
4734
4743
  if (status === 409) {
4735
4744
  if (body.agentsBusy === true) {
4736
4745
  const running = Array.isArray(body.runningAgents) && body.runningAgents.length > 0 ? ` (${body.runningAgents.join(", ")})` : "";
4746
+ setRecords((list) => patch(list, updateRecordId, {
4747
+ state: "failed",
4748
+ reason: t("agentBusyUpdate") + running
4749
+ }));
4737
4750
  setInstallError(t("agentBusyUpdate") + running);
4738
4751
  return;
4739
4752
  }
4753
+ setRecords((list) => patch(list, updateRecordId, {
4754
+ state: "failed",
4755
+ reason: t("busyWait")
4756
+ }));
4740
4757
  setInstallError(t("busyWait"));
4741
4758
  return;
4742
4759
  }
@@ -4747,6 +4764,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
4747
4764
  });
4748
4765
  const text = (v) => typeof v === "string" ? v : v && typeof v.text === "string" ? v.text : v == null ? "" : JSON.stringify(v);
4749
4766
  const detail = text(body.error) || humanOutput([text(body.stderr), text(body.stdout)].filter(Boolean).join("\n")) || "exit " + body.exitCode;
4767
+ setRecords((list) => patch(list, updateRecordId, {
4768
+ state: "failed",
4769
+ reason: detail.trim().slice(-600)
4770
+ }));
4750
4771
  setInstallError(t("updateFail") + ": " + name + " — " + detail.trim().slice(-600));
4751
4772
  }
4752
4773
  }).catch(() => {});