Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions apps/report/src/components/detail-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import type {
IExecutionDump,
} from '@midscene/core';
import { executionToMarkdown, getTaskSearchArea } from '@midscene/core';
import {
buildDeepAssertScreenshots,
isCurrentScreenshotFallback,
} from '@midscene/core/agent';
import {
Blackboard,
Player,
Expand Down Expand Up @@ -253,7 +257,13 @@ const DetailPanel = ({
activeTask.uiContext?.screenshot?.capturedAt,
);

contextLocatorView = activeTask.uiContext ? (
const evidenceScreenshots = buildDeepAssertScreenshots(activeTask);
const allowCurrentScreenshot =
evidenceScreenshots === undefined ||
isCurrentScreenshotFallback(activeTask);

contextLocatorView =
allowCurrentScreenshot && activeTask.uiContext ? (
<ScreenshotDisplay
title={`${isPageContextFrozen ? 'UI Context (Frozen)' : 'UI Context'} / ${contextScreenshotAt}`}
>
Expand All @@ -268,7 +278,16 @@ const DetailPanel = ({
</ScreenshotDisplay>
) : null;

if (activeTask.recorder?.length) {
if (evidenceScreenshots && evidenceScreenshots.length > 0) {
for (const [index, item] of evidenceScreenshots.entries()) {
screenshotItems.push({
timestamp: item.screenshotTimestamp ?? index,
screenshotTimestamp: item.screenshotTimestamp,
screenshot: item.screenshot,
timing: item.timing,
});
}
} else if (evidenceScreenshots === undefined && activeTask.recorder?.length) {
for (const item of activeTask.recorder) {
const screenshot = item.screenshot?.base64;
if (screenshot) {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export type AiActOptions = {
deepLocate?: boolean;
abortSignal?: AbortSignal;
context?: string;
AfterActPictures?: number;
Interval?: number;
};

type AiActInternalOptions = AiActOptions & {
Expand Down Expand Up @@ -400,6 +402,7 @@ export class Agent<InterfaceType extends AbstractInterface = AbstractInterface>
waitAfterAction: this.opts.waitAfterAction,
useDeviceTime: this.opts.useDeviceTime,
actionSpace: this.fullActionSpace,
getAssertionExecutions: () => this.dump.executions,
hooks: {
onSnapshotChange: async (runner) => {
const executionDump = runner.dump();
Expand Down Expand Up @@ -1234,6 +1237,10 @@ export class Agent<InterfaceType extends AbstractInterface = AbstractInterface>
deepLocate,
abortSignal,
internalReportDisplay,
{
AfterActPictures: opt?.AfterActPictures,
Interval: opt?.Interval,
},
);

// update cache
Expand Down Expand Up @@ -1399,7 +1406,7 @@ export class Agent<InterfaceType extends AbstractInterface = AbstractInterface>

async aiAssert(
assertion: TUserPrompt,
msg?: string,
msg?: string | AssertOptions,
opt?: AssertOptions,
): Promise<AgentAssertResult | undefined> {
return this.createInsight().aiAssert(assertion, msg, opt);
Expand Down
Loading