Skip to content

Commit 208110b

Browse files
ycjcl868ulivz
authored andcommitted
fix: replay ui bugs (#224)
1 parent 65dc34b commit 208110b

File tree

9 files changed

+70
-24
lines changed

9 files changed

+70
-24
lines changed

apps/agent-tars/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"build": "rimraf dist out && npm run typecheck && npm run build:reporter && electron-vite build && electron-forge make",
1919
"test": "vitest run",
2020
"publish:mac": "npm run build:reporter && electron-vite build && electron-forge publish --arch=universal --platform=darwin",
21+
"dev:reporter": "vite dev",
2122
"build:reporter": "vite build"
2223
},
2324
"peerDependencies": {

apps/agent-tars/src/main/ipcRoutes/action.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,20 @@ export const actionRoute = t.router({
140140
'utf-8',
141141
);
142142
const artifacts = await parseArtifacts(messages);
143-
const reportContent = reportHtmlTemplate.replace(
144-
' <!-- DATA -->',
145-
'<script>window.__OMEGA_REPORT_DATA__ = ' +
146-
JSON.stringify({
147-
messages,
148-
artifacts,
149-
}) +
150-
';</script>',
151-
);
143+
const reportContent = reportHtmlTemplate
144+
.replace(
145+
' <!-- DATA -->',
146+
'<script>window.__OMEGA_REPORT_DATA__ = ' +
147+
JSON.stringify({
148+
messages,
149+
artifacts,
150+
}) +
151+
';</script>',
152+
)
153+
.replace(
154+
/<title>.*?<\/title>/,
155+
`<title>${messages?.[0]?.content || 'Agent TARS'}</title>`,
156+
);
152157

153158
if (reportApiUrl) {
154159
const tempPath = path.join(

apps/agent-tars/src/renderer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8" />
5-
<title>Omega</title>
5+
<title>Agent TARS</title>
66
<meta
77
http-equiv="Content-Security-Policy"
88
content="default-src 'self' 'unsafe-inline' file: data: blob:; img-src 'self' file: data: blob:; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net/npm/ https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; font-src 'self' https://cdnjs.cloudflare.com https://fonts.googleapis.com; worker-src 'self' blob:; connect-src 'self' https://cdn.jsdelivr.net/npm/ blob:"

apps/agent-tars/src/renderer/src/agent/AgentFlow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class AgentFlow {
180180
]);
181181

182182
if (!this.abortController.signal.aborted) {
183-
this.eventManager.addEndEvent('> Omega Agent has finished.');
183+
this.eventManager.addEndEvent('> Agent TARS has finished.');
184184
}
185185
}
186186

apps/agent-tars/src/renderer/src/agent/mockEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ export const events = [
19511951
id: 'f65c6a4d-3bab-4246-a4b1-f45344133518',
19521952
type: 'end',
19531953
content: {
1954-
message: '> Omega Agent has finished.',
1954+
message: '> Agent TARS Agent has finished.',
19551955
},
19561956
timestamp: 1741906222166,
19571957
},

apps/agent-tars/src/renderer/src/components/ChatUI/MenuHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function MenuHeader() {
3636
<div className="w-9 h-9 rounded-xl bg-gradient-to-br from-primary/20 to-primary/5 flex items-center justify-center shadow-sm overflow-hidden">
3737
<motion.img
3838
src={Logo}
39-
alt="Omega Logo"
39+
alt="Agent TARS Logo"
4040
className="w-6 h-6 object-contain"
4141
whileHover={{ rotate: 10, scale: 1.1 }}
4242
transition={{ type: 'spring', stiffness: 300 }}
@@ -50,7 +50,7 @@ export function MenuHeader() {
5050
animate={{ opacity: 1 }}
5151
transition={{ delay: 0.2 }}
5252
>
53-
Omega
53+
Agent TARS
5454
</motion.span>
5555
</motion.div>
5656

apps/agent-tars/src/renderer/src/components/ChatUI/Replay.tsx

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ChatMessageUtil } from '@renderer/utils/ChatMessageUtils';
66
import { atom, useAtom } from 'jotai';
77
import { useState, useEffect, useRef } from 'react';
88
import { FiRotateCw, FiPause, FiPlay } from 'react-icons/fi';
9+
import { isReportHtmlMode } from '@renderer/constants';
910

1011
type ButtonState = 'replay' | 'pause' | 'continue';
1112

@@ -35,14 +36,19 @@ const BUTTON_CONFIGS: Record<ButtonState, ButtonConfig> = {
3536

3637
const replayAllMessages = atom<MessageItem[]>([]);
3738

39+
// wait 3s to replay
40+
const DEFAULT_COUNTDOWN = 3;
41+
3842
export function Replay() {
3943
const [allMessages, setAllMessages] = useAtom(replayAllMessages);
4044
const [, setEvents] = useAtom(eventsAtom);
4145
const [, setEventId] = useAtom(currentEventIdAtom);
4246
const { addMessage, updateMessage, setMessages, messageEndRef, messages } =
4347
useAppChat();
4448
const timerRef = useRef<NodeJS.Timeout>();
49+
const intervalRef = useRef<NodeJS.Timeout>();
4550
const [buttonState, setButtonState] = useState<ButtonState>('replay');
51+
const [countdown, setCountdown] = useState(DEFAULT_COUNTDOWN);
4652
const playbackRef = useRef<{
4753
currentIndex: number;
4854
eventIndex: number;
@@ -55,10 +61,37 @@ export function Replay() {
5561
}
5662
};
5763

64+
const clearCountDownInterval = () => {
65+
setCountdown(0);
66+
if (intervalRef.current) {
67+
clearInterval(intervalRef.current);
68+
intervalRef.current = undefined;
69+
}
70+
};
71+
5872
useEffect(() => {
59-
return () => clearPlayTimer();
73+
return () => {
74+
clearPlayTimer();
75+
clearCountDownInterval();
76+
};
6077
}, []);
6178

79+
useEffect(() => {
80+
if (isReportHtmlMode && allMessages.length) {
81+
intervalRef.current = setInterval(() => {
82+
setCountdown((prevCountdown) => {
83+
if (prevCountdown > 1) {
84+
return prevCountdown - 1;
85+
} else {
86+
clearCountDownInterval();
87+
handleTogglePlay();
88+
return 0;
89+
}
90+
});
91+
}, 1000);
92+
}
93+
}, [allMessages]);
94+
6295
useEffect(() => {
6396
if (allMessages.length === 0 && messages.length !== 0) {
6497
setAllMessages(messages);
@@ -131,6 +164,7 @@ export function Replay() {
131164
};
132165

133166
const handleTogglePlay = () => {
167+
clearCountDownInterval();
134168
switch (buttonState) {
135169
case 'replay':
136170
case 'continue':
@@ -146,15 +180,22 @@ export function Replay() {
146180
const currentConfig = BUTTON_CONFIGS[buttonState];
147181

148182
return (
149-
<button
150-
onClick={handleTogglePlay}
151-
className={`
183+
<div>
184+
<button
185+
onClick={handleTogglePlay}
186+
className={`
152187
flex items-center justify-center mx-auto mb-2 gap-2 px-4 py-2 text-sm font-medium rounded-lg ease-in-out
153188
${currentConfig.style}
154189
`}
155-
>
156-
{currentConfig.icon}
157-
<span>{currentConfig.label}</span>
158-
</button>
190+
>
191+
{currentConfig.icon}
192+
<span>{currentConfig.label}</span>
193+
</button>
194+
{isReportHtmlMode && countdown > 0 && (
195+
<p className="text-sm text-gray-500 dark:text-gray-400 text-center pb-2">
196+
start replay in <strong>{countdown}</strong> seconds
197+
</p>
198+
)}
199+
</div>
159200
);
160201
}

apps/agent-tars/src/renderer/src/components/LeftSidebar/TopBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function TopBar({
1919
}: TopBarProps) {
2020
return (
2121
<div className={`${styles.topbar} ${isCollapsed ? styles.collapsed : ''}`}>
22-
{!isCollapsed && <span className={styles.title}>Agent Tars</span>}
22+
{!isCollapsed && <span className={styles.title}>Agent TARS</span>}
2323
<div
2424
className={`${styles.controls} ${isCollapsed ? styles.controlsCollapsed : ''}`}
2525
>

apps/agent-tars/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import react from '@vitejs/plugin-react';
55
import { viteSingleFile } from 'vite-plugin-singlefile';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
8-
const workspaceDeps = ['@ui-tars/electron-ipc'];
98

109
export default defineConfig(
1110
(async () => {

0 commit comments

Comments
 (0)