Skip to content

Commit 11b11ed

Browse files
authored
fix(playground, report): fix ui bugs (#1259)
1 parent 42b6280 commit 11b11ed

File tree

8 files changed

+2927
-14
lines changed

8 files changed

+2927
-14
lines changed

apps/report/src/components/detail-side/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ const DetailSide = (): JSX.Element => {
212212
},
213213
]
214214
: []),
215+
...(task?.searchAreaUsage
216+
? [
217+
{
218+
key: 'searchAreaUsage',
219+
content: (
220+
<pre>{JSON.stringify(task.searchAreaUsage, undefined, 2)}</pre>
221+
),
222+
},
223+
]
224+
: []),
215225
...(task?.usage
216226
? [
217227
{

apps/report/src/components/sidebar/index.less

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
.task-meta-tokens {
7575
display: grid;
76-
grid-template-columns: 1fr auto 112px 26px;
76+
grid-template-columns: 1fr auto minmax(100px, 1fr) 55px 65px;
7777
gap: 8px;
7878
align-items: center;
7979
font-size: 12px;
@@ -91,11 +91,11 @@
9191
justify-content: center;
9292

9393
&:nth-child(2) {
94-
grid-column: 3;
94+
grid-column: 4;
9595
}
9696

9797
&:nth-child(3) {
98-
grid-column: 4;
98+
grid-column: 5;
9999
}
100100

101101
.token-value {
@@ -168,7 +168,7 @@
168168

169169

170170
&.pro-mode {
171-
grid-template-columns: 1fr auto 100px 55px 65px;
171+
grid-template-columns: 1fr auto minmax(100px, 1fr) 55px 65px;
172172
}
173173

174174
.status-icon {
@@ -230,7 +230,7 @@
230230
flex-shrink: 0;
231231

232232
&.pro-mode {
233-
grid-template-columns: 1fr auto 100px 55px 65px;
233+
grid-template-columns: 1fr auto minmax(100px, 1fr) 55px 65px;
234234
}
235235

236236
.header-name {

apps/report/src/components/sidebar/index.tsx

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import './index.less';
22
import { useAllCurrentTasks, useExecutionDump } from '@/components/store';
3-
import type { ExecutionTask, ExecutionTaskInsightLocate } from '@midscene/core';
3+
import type {
4+
AIUsageInfo,
5+
ExecutionTask,
6+
ExecutionTaskInsightLocate,
7+
} from '@midscene/core';
48
import { typeStr } from '@midscene/core/agent';
9+
10+
// Extended task type with searchAreaUsage
11+
type ExecutionTaskWithSearchAreaUsage = ExecutionTask & {
12+
searchAreaUsage?: AIUsageInfo;
13+
};
514
import {
615
type AnimationScript,
716
iconForStatus,
@@ -16,7 +25,7 @@ import type { PlaywrightTasks } from '../../types';
1625
import ReportOverview from '../report-overview';
1726

1827
const SideItem = (props: {
19-
task: ExecutionTask;
28+
task: ExecutionTaskWithSearchAreaUsage;
2029
selected?: boolean;
2130
onClick?: () => void;
2231
onItemHover?: (task: ExecutionTask | null, x?: number, y?: number) => any;
@@ -138,19 +147,31 @@ const SideItem = (props: {
138147
{/* Display usage info in table style if available and Pro mode is enabled */}
139148
{props.proModeEnabled && (
140149
<>
141-
<Tooltip title="The name of the model used this time">
150+
<Tooltip title={task.usage?.model_name || ''}>
142151
<div className="usage-column model-name">
143152
{task.usage?.model_name || '-'}
144153
</div>
145154
</Tooltip>
146155
<Tooltip title="Input tokens sent to the AI model">
147156
<div className="usage-column prompt-tokens">
148-
{task.usage?.prompt_tokens || '-'}
157+
{(() => {
158+
const mainUsage = task.usage?.prompt_tokens || 0;
159+
const searchAreaUsage =
160+
task.searchAreaUsage?.prompt_tokens || 0;
161+
const total = mainUsage + searchAreaUsage;
162+
return total > 0 ? total : '-';
163+
})()}
149164
</div>
150165
</Tooltip>
151166
<Tooltip title="Output tokens generated by the AI model">
152167
<div className="usage-column completion-tokens">
153-
{task.usage?.completion_tokens || '-'}
168+
{(() => {
169+
const mainUsage = task.usage?.completion_tokens || 0;
170+
const searchAreaUsage =
171+
task.searchAreaUsage?.completion_tokens || 0;
172+
const total = mainUsage + searchAreaUsage;
173+
return total > 0 ? total : '-';
174+
})()}
154175
</div>
155176
</Tooltip>
156177
</>
@@ -235,13 +256,24 @@ const Sidebar = (props: SidebarProps = {}): JSX.Element => {
235256
const totalPromptTokens =
236257
groupedDump?.executions
237258
.flatMap((e) => e.tasks)
238-
.reduce((acc, task) => acc + (task.usage?.prompt_tokens || 0), 0) || 0;
259+
.reduce((acc, task) => {
260+
const mainUsage = task.usage?.prompt_tokens || 0;
261+
const searchAreaUsage =
262+
(task as ExecutionTaskWithSearchAreaUsage).searchAreaUsage
263+
?.prompt_tokens || 0;
264+
return acc + mainUsage + searchAreaUsage;
265+
}, 0) || 0;
239266

240267
const totalCompletionTokens =
241268
groupedDump?.executions
242269
.flatMap((e) => e.tasks)
243-
.reduce((acc, task) => acc + (task.usage?.completion_tokens || 0), 0) ||
244-
0;
270+
.reduce((acc, task) => {
271+
const mainUsage = task.usage?.completion_tokens || 0;
272+
const searchAreaUsage =
273+
(task as ExecutionTaskWithSearchAreaUsage).searchAreaUsage
274+
?.completion_tokens || 0;
275+
return acc + mainUsage + searchAreaUsage;
276+
}, 0) || 0;
245277

246278
const executionContent = groupedDump ? (
247279
<div className="execution-info-section">

apps/report/test-data/ai-model.json

Lines changed: 2857 additions & 0 deletions
Large diffs are not rendered by default.

packages/core/src/agent/tasks.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ export class TaskExecutor {
251251
};
252252

253253
task.usage = usage;
254+
255+
// Store searchAreaUsage in task metadata
256+
if (dump?.taskInfo?.searchAreaUsage) {
257+
task.searchAreaUsage = dump.taskInfo.searchAreaUsage;
258+
}
254259
};
255260
this.insight.onceDumpUpdatedFn = dumpCollector;
256261
const shotTime = Date.now();

packages/core/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ export type ExecutionTask<
393393
cost?: number;
394394
};
395395
usage?: AIUsageInfo;
396+
searchAreaUsage?: AIUsageInfo;
396397
};
397398

398399
export interface ExecutionDump extends DumpMeta {

packages/visualizer/src/component/prompt-input/index.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
z-index: 10;
149149
justify-content: flex-end; /* Right align when only one button */
150150
gap: 8px; /* Add gap between buttons when there are multiple */
151+
pointer-events: none; /* Allow clicks to pass through the background */
152+
153+
/* Re-enable pointer events for child elements */
154+
> * {
155+
pointer-events: auto;
156+
}
151157
}
152158
}
153159

packages/web-integration/tests/ai/web/puppeteer/e2e.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ describe(
6666
'type "standard_user" in user name input, type "secret_sauce" in password',
6767
);
6868

69-
await agent.aiTap('Login');
69+
await agent.aiTap('Login', {
70+
deepThink: true,
71+
});
7072

7173
expect(beforeInvokeAction.mock.calls.length).toBeGreaterThan(1);
7274
expect(beforeInvokeAction.mock.calls.length).toEqual(

0 commit comments

Comments
 (0)