@emblemvault/hustle-react 1.4.0 → 1.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.
@@ -3569,6 +3569,7 @@ function HustleChat({
3569
3569
  const messagesEndRef = react.useRef(null);
3570
3570
  const fileInputRef = react.useRef(null);
3571
3571
  const messagesRef = react.useRef(messages);
3572
+ const pendingAutoContinueRef = react.useRef(false);
3572
3573
  react.useEffect(() => {
3573
3574
  if (initialSystemPrompt && !systemPrompt) {
3574
3575
  setSystemPrompt(initialSystemPrompt);
@@ -3675,22 +3676,27 @@ function HustleChat({
3675
3676
  react.useEffect(() => {
3676
3677
  if (!client) return;
3677
3678
  const unsubMaxTools = client.on("max_tools_reached", (event) => {
3678
- console.log(`[AUTO_CONTINUE] Max tools reached (${event.toolsExecuted}/${event.maxSteps}), auto-continuing...`);
3679
- setTimeout(() => {
3680
- sendContinue();
3681
- }, 100);
3679
+ console.log(`[AUTO_CONTINUE] Max tools reached (${event.toolsExecuted}/${event.maxSteps}), queuing auto-continue...`);
3680
+ pendingAutoContinueRef.current = true;
3682
3681
  });
3683
3682
  const unsubTimeout = client.on("timeout", (event) => {
3684
- console.log(`[AUTO_CONTINUE] Timeout: ${event.message}, auto-continuing...`);
3685
- setTimeout(() => {
3686
- sendContinue();
3687
- }, 100);
3683
+ console.log(`[AUTO_CONTINUE] Timeout: ${event.message}, queuing auto-continue...`);
3684
+ pendingAutoContinueRef.current = true;
3688
3685
  });
3689
3686
  return () => {
3690
3687
  unsubMaxTools();
3691
3688
  unsubTimeout();
3692
3689
  };
3693
- }, [client, sendContinue]);
3690
+ }, [client]);
3691
+ react.useEffect(() => {
3692
+ if (!isStreaming && pendingAutoContinueRef.current && isReady) {
3693
+ console.log("[AUTO_CONTINUE] Streaming ended, triggering continue...");
3694
+ pendingAutoContinueRef.current = false;
3695
+ setTimeout(() => {
3696
+ sendContinue();
3697
+ }, 50);
3698
+ }
3699
+ }, [isStreaming, isReady, sendContinue]);
3694
3700
  const sendMessage = react.useCallback(async () => {
3695
3701
  const content = inputValue.trim();
3696
3702
  if (!content || isStreaming || !isReady) return;