Skip to content

100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.

Fix three frontend bugs: children counter, cross-video seek race, poll leak

thejesh23779e6f032873
diff --git a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_travel_planner_agent_team/client/app/plan/page.tsx b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_travel_planner_agent_team/client/app/plan/page.tsx
index 6030b329..af2322c1 100644
--- a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_travel_planner_agent_team/client/app/plan/page.tsx
+++ b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_travel_planner_agent_team/client/app/plan/page.tsx
@@ -958,7 +958,7 @@ export default function Plan() {
<NumberInput
value={field.value}
onChange={field.onChange}
- min={1}
+ min={0}
/>
</FormControl>
<FormMessage />
diff --git a/advanced_ai_agents/multi_agent_apps/ai_negotiation_battle_simulator/frontend/src/app/page.tsx b/advanced_ai_agents/multi_agent_apps/ai_negotiation_battle_simulator/frontend/src/app/page.tsx
index b8a5b651..73abf3ac 100644
--- a/advanced_ai_agents/multi_agent_apps/ai_negotiation_battle_simulator/frontend/src/app/page.tsx
+++ b/advanced_ai_agents/multi_agent_apps/ai_negotiation_battle_simulator/frontend/src/app/page.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useState, useEffect } from "react";
+import { useState, useEffect, useRef } from "react";
import { useCoAgent, useCopilotAction } from "@copilotkit/react-core";
import { motion, AnimatePresence } from "framer-motion";
import {
@@ -362,10 +362,19 @@ export default function NegotiationBattle() {
}
};
+ const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
+
+ // Stop polling on unmount so we don't fetch/setState on an unmounted component
+ // or keep polling forever when a run never reaches deal/no_deal.
+ useEffect(() => () => {
+ if (pollRef.current) clearInterval(pollRef.current);
+ }, []);
+
const runNegotiation = async () => {
// This will be handled by the agent automatically
// Just need to poll for state updates
- const pollInterval = setInterval(async () => {
+ if (pollRef.current) clearInterval(pollRef.current);
+ pollRef.current = setInterval(async () => {
try {
const stateRes = await fetch('http://localhost:8000/get_negotiation_state');
const stateData = await stateRes.json();
@@ -385,7 +394,7 @@ export default function NegotiationBattle() {
});
if (stateData.status === "deal" || stateData.status === "no_deal") {
- clearInterval(pollInterval);
+ if (pollRef.current) clearInterval(pollRef.current);
}
} catch (error) {
console.error('Error polling state:', error);
diff --git a/advanced_llm_apps/multimodal_video_moment_finder/frontend/app/page.tsx b/advanced_llm_apps/multimodal_video_moment_finder/frontend/app/page.tsx
index edc7e96d..10874473 100644
--- a/advanced_llm_apps/multimodal_video_moment_finder/frontend/app/page.tsx
+++ b/advanced_llm_apps/multimodal_video_moment_finder/frontend/app/page.tsx
@@ -160,13 +160,21 @@ export default function Home() {
const jumpToMoment = (moment: Moment) => {
setVideoTimestamp(moment.timestamp);
+ const switchingVideo = moment.video_id !== selectedVideo;
setSelectedVideo(moment.video_id);
- setTimeout(() => {
+ const seek = () => {
if (videoRef.current) {
videoRef.current.currentTime = moment.timestamp;
videoRef.current.play();
}
- }, 100);
+ };
+ if (switchingVideo && videoRef.current) {
+ // The <video src> changes on the re-render triggered above; a fixed 100ms
+ // timeout races that reload, so seek only once the new file has loaded.
+ videoRef.current.addEventListener("loadeddata", seek, { once: true });
+ } else {
+ setTimeout(seek, 100);
+ }
};
// Drag and drop