@emblemvault/hustle-react 1.4.0 → 1.4.1

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/index.js CHANGED
@@ -3969,6 +3969,7 @@ function HustleChat({
3969
3969
  const messagesEndRef = useRef(null);
3970
3970
  const fileInputRef = useRef(null);
3971
3971
  const messagesRef = useRef(messages);
3972
+ const pendingAutoContinueRef = useRef(false);
3972
3973
  useEffect(() => {
3973
3974
  if (initialSystemPrompt && !systemPrompt) {
3974
3975
  setSystemPrompt(initialSystemPrompt);
@@ -4075,22 +4076,27 @@ function HustleChat({
4075
4076
  useEffect(() => {
4076
4077
  if (!client) return;
4077
4078
  const unsubMaxTools = client.on("max_tools_reached", (event) => {
4078
- console.log(`[AUTO_CONTINUE] Max tools reached (${event.toolsExecuted}/${event.maxSteps}), auto-continuing...`);
4079
- setTimeout(() => {
4080
- sendContinue();
4081
- }, 100);
4079
+ console.log(`[AUTO_CONTINUE] Max tools reached (${event.toolsExecuted}/${event.maxSteps}), queuing auto-continue...`);
4080
+ pendingAutoContinueRef.current = true;
4082
4081
  });
4083
4082
  const unsubTimeout = client.on("timeout", (event) => {
4084
- console.log(`[AUTO_CONTINUE] Timeout: ${event.message}, auto-continuing...`);
4085
- setTimeout(() => {
4086
- sendContinue();
4087
- }, 100);
4083
+ console.log(`[AUTO_CONTINUE] Timeout: ${event.message}, queuing auto-continue...`);
4084
+ pendingAutoContinueRef.current = true;
4088
4085
  });
4089
4086
  return () => {
4090
4087
  unsubMaxTools();
4091
4088
  unsubTimeout();
4092
4089
  };
4093
- }, [client, sendContinue]);
4090
+ }, [client]);
4091
+ useEffect(() => {
4092
+ if (!isStreaming && pendingAutoContinueRef.current && isReady) {
4093
+ console.log("[AUTO_CONTINUE] Streaming ended, triggering continue...");
4094
+ pendingAutoContinueRef.current = false;
4095
+ setTimeout(() => {
4096
+ sendContinue();
4097
+ }, 50);
4098
+ }
4099
+ }, [isStreaming, isReady, sendContinue]);
4094
4100
  const sendMessage = useCallback(async () => {
4095
4101
  const content = inputValue.trim();
4096
4102
  if (!content || isStreaming || !isReady) return;