clay-server 2.36.2-beta.6 → 2.36.2-beta.8

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.
@@ -733,6 +733,10 @@ export function processMessage(msg) {
733
733
  // applied at history_done time.
734
734
  store.set({ sessionIsProcessing: true });
735
735
  applyDeadSessionTodoCompaction();
736
+ // Server confirmed the turn started: pre-thinking dots have done
737
+ // their job, drop them so they aren't stranded if no further
738
+ // events make it through.
739
+ removeMatePreThinking();
736
740
  if (!(store.get('dmMode') && store.get('dmTargetUser') && store.get('dmTargetUser').isMate) && !store.get('matePreThinkingEl')) {
737
741
  setActivity("thinking");
738
742
  }
@@ -740,6 +744,10 @@ export function processMessage(msg) {
740
744
  break;
741
745
 
742
746
  case "compacting":
747
+ // Compacting means the SDK is mid-turn doing context compaction.
748
+ // Pre-thinking dots have served their purpose, clear them so the
749
+ // user sees the compaction indicator instead.
750
+ removeMatePreThinking();
743
751
  if (msg.active) {
744
752
  setActivity("compacting");
745
753
  } else if (!(store.get('dmMode') && store.get('dmTargetUser') && store.get('dmTargetUser').isMate)) {
@@ -934,6 +942,10 @@ export function processMessage(msg) {
934
942
  break;
935
943
 
936
944
  case "result":
945
+ // Result marks turn end. Drop pre-thinking even if no delta/tool
946
+ // event ever arrived (e.g. tool-only turn whose progress signals
947
+ // were missed by the client).
948
+ removeMatePreThinking();
937
949
  setActivity(null);
938
950
  stopThinking();
939
951
  markAllToolsDone();
@@ -623,6 +623,23 @@ function doShowMatePreThinking(mateName, mateAvatar) {
623
623
  }
624
624
  refreshIcons();
625
625
  scrollToBottom();
626
+ // Safety net: if no server event ever clears these dots (lost in transit,
627
+ // missed handler, etc.) the user sees them forever and assumes the
628
+ // session is hung. After 90s with zero progress, clear the indicator
629
+ // and log a system note so the user knows to retry.
630
+ if (matePreThinkingTimer) clearTimeout(matePreThinkingTimer);
631
+ matePreThinkingTimer = setTimeout(function () {
632
+ var stillThere = store.get('matePreThinkingEl');
633
+ if (!stillThere) return;
634
+ stillThere.remove();
635
+ store.set({ matePreThinkingEl: null });
636
+ matePreThinkingTimer = null;
637
+ var note = document.createElement("div");
638
+ note.className = "system-msg";
639
+ note.textContent = "No response received in 90s. The server may have stalled. Send another message to retry.";
640
+ addToMessages(note);
641
+ scrollToBottom();
642
+ }, 90000);
626
643
  }
627
644
 
628
645
  export function removeMatePreThinking() {
@@ -271,6 +271,9 @@ function handleMessage(msg) {
271
271
  case "stop_task":
272
272
  handleStopTask(msg);
273
273
  break;
274
+ case "rewind_files":
275
+ handleRewindFiles(msg);
276
+ break;
274
277
  case "permission_response":
275
278
  handlePermissionResponse(msg);
276
279
  break;
@@ -598,6 +601,22 @@ async function handleSetPermissionMode(msg) {
598
601
  }
599
602
  }
600
603
 
604
+ async function handleRewindFiles(msg) {
605
+ // Bridge the host's rewindFiles call to the in-process SDK query inside
606
+ // the worker. Both the dryRun preview and the actual restore go through
607
+ // here; the response carries the SDK's preview/result object back.
608
+ if (!queryInstance || typeof queryInstance.rewindFiles !== "function") {
609
+ sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, error: "rewindFiles not supported by active query" });
610
+ return;
611
+ }
612
+ try {
613
+ var result = await queryInstance.rewindFiles(msg.uuid, msg.opts || {});
614
+ sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, result: result });
615
+ } catch (e) {
616
+ sendToDaemon({ type: "rewind_files_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
617
+ }
618
+ }
619
+
601
620
  async function handleStopTask(msg) {
602
621
  if (!queryInstance) return;
603
622
  try {
@@ -688,6 +688,11 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
688
688
  var iterEnded = false;
689
689
  var iterError = null;
690
690
 
691
+ // Pending request/response correlation for handle methods that need a
692
+ // result from the worker (e.g. rewindFiles). Each entry is keyed by a
693
+ // requestId and holds { resolve, reject } of the in-flight Promise.
694
+ var pendingRewinds = {};
695
+
691
696
  function pushToIter(value) {
692
697
  if (iterEnded) return;
693
698
  if (iterWaiting) {
@@ -797,6 +802,16 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
797
802
  pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
798
803
  break;
799
804
 
805
+ case "rewind_files_response": {
806
+ var rp = pendingRewinds[msg.requestId];
807
+ if (rp) {
808
+ delete pendingRewinds[msg.requestId];
809
+ if (msg.error) rp.reject(new Error(msg.error));
810
+ else rp.resolve(msg.result);
811
+ }
812
+ break;
813
+ }
814
+
800
815
  case "query_done":
801
816
  console.log("[yoke/claude] IPC query_done received, pid=" + (worker.process ? worker.process.pid : "?"));
802
817
  worker._queryEnded = true;
@@ -934,6 +949,22 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
934
949
  endInput: function() {
935
950
  worker.send({ type: "end_messages" });
936
951
  },
952
+
953
+ // Claude SDK specific: rewind files to a previous state. The in-process
954
+ // handle calls rawQuery.rewindFiles directly; the worker variant has to
955
+ // hop through IPC and correlate the response by requestId.
956
+ rewindFiles: function(uuid, opts) {
957
+ var requestId = crypto.randomUUID();
958
+ return new Promise(function(resolve, reject) {
959
+ pendingRewinds[requestId] = { resolve: resolve, reject: reject };
960
+ try {
961
+ worker.send({ type: "rewind_files", requestId: requestId, uuid: uuid, opts: opts || {} });
962
+ } catch (e) {
963
+ delete pendingRewinds[requestId];
964
+ reject(e);
965
+ }
966
+ });
967
+ },
937
968
  };
938
969
 
939
970
  return handle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.36.2-beta.6",
3
+ "version": "2.36.2-beta.8",
4
4
  "description": "Self-hosted team workspace for Claude Code and Codex. Multi-user, browser-based, with persistent AI mates.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",