@co0ontty/wand 1.1.3 → 1.1.5

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/dist/server.js CHANGED
@@ -481,20 +481,28 @@ export async function startServer(config, configPath) {
481
481
  res.status(500).json({ error: getErrorMessage(error, "检查更新失败。") });
482
482
  }
483
483
  });
484
+ let updateInFlight = false;
484
485
  app.post("/api/update", async (_req, res) => {
486
+ if (updateInFlight) {
487
+ res.status(409).json({ error: "更新正在进行中,请稍候。" });
488
+ return;
489
+ }
490
+ updateInFlight = true;
485
491
  try {
486
- const { updateAvailable } = await checkNpmLatestVersion();
492
+ const { updateAvailable, latest } = await checkNpmLatestVersion(true);
487
493
  if (!updateAvailable) {
488
494
  res.json({ ok: true, message: "已经是最新版本。" });
489
495
  return;
490
496
  }
491
- res.json({ ok: true, message: "正在更新,请稍候..." });
492
- // Run update in background the server will restart
493
- execAsync(`npm install -g ${PKG_NAME}@latest`, { timeout: 120000 }).catch(() => { });
497
+ await execAsync(`npm install -g ${PKG_NAME}@latest`, { timeout: 120000 });
498
+ res.json({ ok: true, message: `已更新到 ${latest},请重启 wand 服务以生效。` });
494
499
  }
495
500
  catch (error) {
496
501
  res.status(500).json({ error: getErrorMessage(error, "更新失败。") });
497
502
  }
503
+ finally {
504
+ updateInFlight = false;
505
+ }
498
506
  });
499
507
  app.get("/api/sessions", (_req, res) => {
500
508
  res.json(processes.list());
@@ -3403,7 +3403,11 @@
3403
3403
  updateShellChrome();
3404
3404
 
3405
3405
  var selectedSession = state.sessions.find(function(s) { return s.id === id; });
3406
- state.currentMessages = [];
3406
+ if (data.messages && data.messages.length > 0) {
3407
+ state.currentMessages = data.messages;
3408
+ } else {
3409
+ state.currentMessages = [];
3410
+ }
3407
3411
 
3408
3412
  if (state.terminal) {
3409
3413
  syncTerminalBuffer(id, data.output || "", { mode: "replace" });
@@ -3849,7 +3853,8 @@
3849
3853
  function performUpdate() {
3850
3854
  var msgEl = document.getElementById("update-message");
3851
3855
  var updateBtn = document.getElementById("do-update-button");
3852
- if (updateBtn) updateBtn.disabled = true;
3856
+ if (!updateBtn) return;
3857
+ updateBtn.disabled = true;
3853
3858
  if (msgEl) {
3854
3859
  msgEl.textContent = "正在更新,请稍候...";
3855
3860
  msgEl.style.color = "var(--text-secondary)";
@@ -3864,11 +3869,15 @@
3864
3869
  .then(function(res) { return res.json(); })
3865
3870
  .then(function(data) {
3866
3871
  if (msgEl) {
3867
- msgEl.textContent = data.message || data.error || "更新请求已发送。";
3872
+ msgEl.textContent = data.message || data.error || "更新完成。";
3868
3873
  msgEl.style.color = data.error ? "var(--error)" : "var(--success)";
3869
3874
  msgEl.classList.remove("hidden");
3870
3875
  }
3871
- if (updateBtn) updateBtn.disabled = false;
3876
+ if (data.error) {
3877
+ updateBtn.disabled = false;
3878
+ } else {
3879
+ updateBtn.classList.add("hidden");
3880
+ }
3872
3881
  })
3873
3882
  .catch(function() {
3874
3883
  if (msgEl) {
@@ -3876,7 +3885,7 @@
3876
3885
  msgEl.style.color = "var(--error)";
3877
3886
  msgEl.classList.remove("hidden");
3878
3887
  }
3879
- if (updateBtn) updateBtn.disabled = false;
3888
+ updateBtn.disabled = false;
3880
3889
  });
3881
3890
  }
3882
3891
 
@@ -6579,7 +6588,11 @@
6579
6588
  }
6580
6589
  updateSessionSnapshot(snapshot);
6581
6590
  if (msg.sessionId === state.selectedId) {
6591
+ if (msg.data.messages && msg.data.messages.length > 0) {
6592
+ state.currentMessages = msg.data.messages;
6593
+ }
6582
6594
  updateTaskDisplay();
6595
+ scheduleChatRender();
6583
6596
  }
6584
6597
 
6585
6598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@co0ontty/wand",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "A web terminal for local CLI tools like Claude.",
5
5
  "type": "module",
6
6
  "bin": {