From f3d1031f0fcee94345bb59552a995dc27458cfe2 Mon Sep 17 00:00:00 2001 From: ycjcl868 Date: Wed, 19 Mar 2025 15:29:07 +0800 Subject: [PATCH 1/4] fix: ui bugfix --- apps/agent-tars/package.json | 1 + apps/agent-tars/src/renderer/index.html | 2 +- .../renderer/src/components/ChatUI/Replay.tsx | 46 +++++++++++++++---- apps/agent-tars/vite.config.ts | 1 - 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/apps/agent-tars/package.json b/apps/agent-tars/package.json index c0c7f5f1a..6d22e3c55 100644 --- a/apps/agent-tars/package.json +++ b/apps/agent-tars/package.json @@ -18,6 +18,7 @@ "build": "rimraf dist out && npm run typecheck && npm run build:reporter && electron-vite build && electron-forge make", "test": "vitest run", "publish:mac": "npm run build:reporter && electron-vite build && electron-forge publish --arch=universal --platform=darwin", + "dev:reporter": "vite dev", "build:reporter": "vite build" }, "peerDependencies": { diff --git a/apps/agent-tars/src/renderer/index.html b/apps/agent-tars/src/renderer/index.html index 0c32fc61e..1585b0887 100644 --- a/apps/agent-tars/src/renderer/index.html +++ b/apps/agent-tars/src/renderer/index.html @@ -2,7 +2,7 @@ - Omega + Agent TARS = { const replayAllMessages = atom([]); +// wait 3s to replay +const DEFAULT_COUNTDOWN = 3; + export function Replay() { const [allMessages, setAllMessages] = useAtom(replayAllMessages); const [, setEvents] = useAtom(eventsAtom); @@ -43,6 +47,7 @@ export function Replay() { useAppChat(); const timerRef = useRef(); const [buttonState, setButtonState] = useState('replay'); + const [countdown, setCountdown] = useState(DEFAULT_COUNTDOWN); const playbackRef = useRef<{ currentIndex: number; eventIndex: number; @@ -56,7 +61,25 @@ export function Replay() { }; useEffect(() => { - return () => clearPlayTimer(); + let countDownInterval: NodeJS.Timeout; + if (isReportHtmlMode) { + countDownInterval = setInterval(() => { + setCountdown((prevCountdown) => { + if (prevCountdown > 1) { + return prevCountdown - 1; + } else { + clearInterval(countDownInterval); + startPlayback(); + return 0; + } + }); + }, 1000); + } + + return () => { + clearPlayTimer(); + countDownInterval && clearInterval(countDownInterval); + }; }, []); useEffect(() => { @@ -146,15 +169,22 @@ export function Replay() { const currentConfig = BUTTON_CONFIGS[buttonState]; return ( - + > + {currentConfig.icon} + {currentConfig.label} + + {isReportHtmlMode && countdown > 0 && ( +

+ start replay in {countdown} seconds +

+ )} + ); } diff --git a/apps/agent-tars/vite.config.ts b/apps/agent-tars/vite.config.ts index 3a9c44771..4bf7548b1 100644 --- a/apps/agent-tars/vite.config.ts +++ b/apps/agent-tars/vite.config.ts @@ -5,7 +5,6 @@ import react from '@vitejs/plugin-react'; import { viteSingleFile } from 'vite-plugin-singlefile'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const workspaceDeps = ['@ui-tars/electron-ipc']; export default defineConfig( (async () => { From baced47ab6e0aba3179d9b97d58d9dae1e662f91 Mon Sep 17 00:00:00 2001 From: ycjcl868 Date: Wed, 19 Mar 2025 16:32:17 +0800 Subject: [PATCH 2/4] fix: replay auto replay --- .../agent-tars/src/renderer/src/agent/AgentFlow.ts | 2 +- .../src/renderer/src/agent/mockEvents.ts | 2 +- .../renderer/src/components/ChatUI/MenuHeader.tsx | 4 ++-- .../src/renderer/src/components/ChatUI/Replay.tsx | 14 +++++++++----- .../renderer/src/components/LeftSidebar/TopBar.tsx | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/agent-tars/src/renderer/src/agent/AgentFlow.ts b/apps/agent-tars/src/renderer/src/agent/AgentFlow.ts index 276e3e1f6..2ab5df01e 100644 --- a/apps/agent-tars/src/renderer/src/agent/AgentFlow.ts +++ b/apps/agent-tars/src/renderer/src/agent/AgentFlow.ts @@ -180,7 +180,7 @@ export class AgentFlow { ]); if (!this.abortController.signal.aborted) { - this.eventManager.addEndEvent('> Omega Agent has finished.'); + this.eventManager.addEndEvent('> Agent TARS has finished.'); } } diff --git a/apps/agent-tars/src/renderer/src/agent/mockEvents.ts b/apps/agent-tars/src/renderer/src/agent/mockEvents.ts index 874c7a1ae..227f1395d 100644 --- a/apps/agent-tars/src/renderer/src/agent/mockEvents.ts +++ b/apps/agent-tars/src/renderer/src/agent/mockEvents.ts @@ -1951,7 +1951,7 @@ export const events = [ id: 'f65c6a4d-3bab-4246-a4b1-f45344133518', type: 'end', content: { - message: '> Omega Agent has finished.', + message: '> Agent TARS Agent has finished.', }, timestamp: 1741906222166, }, diff --git a/apps/agent-tars/src/renderer/src/components/ChatUI/MenuHeader.tsx b/apps/agent-tars/src/renderer/src/components/ChatUI/MenuHeader.tsx index 6e29c16cd..5a5f829a7 100644 --- a/apps/agent-tars/src/renderer/src/components/ChatUI/MenuHeader.tsx +++ b/apps/agent-tars/src/renderer/src/components/ChatUI/MenuHeader.tsx @@ -36,7 +36,7 @@ export function MenuHeader() {
- Omega + Agent TARS diff --git a/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx b/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx index 8df058cc8..8ab4d6d02 100644 --- a/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx +++ b/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx @@ -60,27 +60,31 @@ export function Replay() { } }; + useEffect(() => { + return () => { + clearPlayTimer(); + }; + }, []); + useEffect(() => { let countDownInterval: NodeJS.Timeout; - if (isReportHtmlMode) { + if (isReportHtmlMode && allMessages.length) { countDownInterval = setInterval(() => { setCountdown((prevCountdown) => { if (prevCountdown > 1) { return prevCountdown - 1; } else { clearInterval(countDownInterval); - startPlayback(); + handleTogglePlay(); return 0; } }); }, 1000); } - return () => { - clearPlayTimer(); countDownInterval && clearInterval(countDownInterval); }; - }, []); + }, [allMessages]); useEffect(() => { if (allMessages.length === 0 && messages.length !== 0) { diff --git a/apps/agent-tars/src/renderer/src/components/LeftSidebar/TopBar.tsx b/apps/agent-tars/src/renderer/src/components/LeftSidebar/TopBar.tsx index 73605aad4..8145c740e 100644 --- a/apps/agent-tars/src/renderer/src/components/LeftSidebar/TopBar.tsx +++ b/apps/agent-tars/src/renderer/src/components/LeftSidebar/TopBar.tsx @@ -19,7 +19,7 @@ export function TopBar({ }: TopBarProps) { return (
- {!isCollapsed && Agent Tars} + {!isCollapsed && Agent TARS}
From 9722306a655dac17e8c78da501c04491b05beda7 Mon Sep 17 00:00:00 2001 From: ycjcl868 Date: Wed, 19 Mar 2025 16:11:50 +0800 Subject: [PATCH 3/4] fix: count down --- .../renderer/src/components/ChatUI/Replay.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx b/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx index 8ab4d6d02..5bf5585ff 100644 --- a/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx +++ b/apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx @@ -46,6 +46,7 @@ export function Replay() { const { addMessage, updateMessage, setMessages, messageEndRef, messages } = useAppChat(); const timerRef = useRef(); + const intervalRef = useRef(); const [buttonState, setButtonState] = useState('replay'); const [countdown, setCountdown] = useState(DEFAULT_COUNTDOWN); const playbackRef = useRef<{ @@ -60,30 +61,35 @@ export function Replay() { } }; + const clearCountDownInterval = () => { + setCountdown(0); + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = undefined; + } + }; + useEffect(() => { return () => { clearPlayTimer(); + clearCountDownInterval(); }; }, []); useEffect(() => { - let countDownInterval: NodeJS.Timeout; if (isReportHtmlMode && allMessages.length) { - countDownInterval = setInterval(() => { + intervalRef.current = setInterval(() => { setCountdown((prevCountdown) => { if (prevCountdown > 1) { return prevCountdown - 1; } else { - clearInterval(countDownInterval); + clearCountDownInterval(); handleTogglePlay(); return 0; } }); }, 1000); } - return () => { - countDownInterval && clearInterval(countDownInterval); - }; }, [allMessages]); useEffect(() => { @@ -158,6 +164,7 @@ export function Replay() { }; const handleTogglePlay = () => { + clearCountDownInterval(); switch (buttonState) { case 'replay': case 'continue': From a8b7560113ff58ff8e8d171da543fdb1d7015137 Mon Sep 17 00:00:00 2001 From: ycjcl868 Date: Wed, 19 Mar 2025 16:32:37 +0800 Subject: [PATCH 4/4] fix: reporter with title --- apps/agent-tars/src/main/ipcRoutes/action.ts | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/agent-tars/src/main/ipcRoutes/action.ts b/apps/agent-tars/src/main/ipcRoutes/action.ts index 256d4c7cc..0724973b6 100644 --- a/apps/agent-tars/src/main/ipcRoutes/action.ts +++ b/apps/agent-tars/src/main/ipcRoutes/action.ts @@ -140,15 +140,20 @@ export const actionRoute = t.router({ 'utf-8', ); const artifacts = await parseArtifacts(messages); - const reportContent = reportHtmlTemplate.replace( - ' ', - '', - ); + const reportContent = reportHtmlTemplate + .replace( + ' ', + '', + ) + .replace( + /.*?<\/title>/, + `<title>${messages?.[0]?.content || 'Agent TARS'}`, + ); if (reportApiUrl) { const tempPath = path.join(