Skip to content

Commit

Permalink
Include mouse data when analyzing execution data
Browse files Browse the repository at this point in the history
  • Loading branch information
bhackett1024 committed Jan 23, 2025
1 parent 7d02bb5 commit 45c7365
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/components/chat/Chat.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { getSimulationRecording, getSimulationEnhancedPrompt } from '~/lib/repla
import { getIFrameSimulationData, type SimulationData } from '~/lib/replay/Recording';
import { getCurrentIFrame } from '../workbench/Preview';
import { getCurrentMouseData } from '../workbench/PointSelector';
import { assert } from '~/lib/replay/ReplayProtocolClient';
import { anthropicNumFreeUsesCookieName, anthropicApiKeyCookieName, MaxFreeUses } from '~/utils/freeUses';
import type { FileMap } from '~/lib/stores/files';
import { shouldIncludeFile } from '~/utils/fileUtils';
Expand Down Expand Up @@ -284,7 +283,8 @@ export const ChatImpl = memo(
const getEnhancedPrompt = async (recordingId: string, repositoryContents: string) => {
let enhancedPrompt, message;
try {
enhancedPrompt = await getSimulationEnhancedPrompt(recordingId, repositoryContents);
const mouseData = getCurrentMouseData();
enhancedPrompt = await getSimulationEnhancedPrompt(recordingId, repositoryContents, mouseData);
message = `Explanation of the bug:\n\n${enhancedPrompt}`;
} catch (e) {
console.error("Error enhancing prompt", e);
Expand Down
10 changes: 7 additions & 3 deletions app/lib/replay/SimulationPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ async function enhancePromptFromFailureData(
return prompt;
}

export async function getSimulationEnhancedPrompt(recordingId: string, repositoryContents: string): Promise<string> {
export async function getSimulationEnhancedPrompt(
recordingId: string,
repositoryContents: string,
mouseData: MouseData | undefined
): Promise<string> {
const client = new ProtocolClient();
await client.initialize();
try {
Expand All @@ -241,10 +245,10 @@ export async function getSimulationEnhancedPrompt(recordingId: string, repositor
method: "Session.experimentalCommand",
params: {
name: "analyzeExecutionPoint",
params: {},
params: { mouseData },
},
sessionId,
}) as { rval: ExecutionDataAnalysisResult };;
}) as { rval: ExecutionDataAnalysisResult };

const { points, failureData } = rval;
assert(failureData, "No failure data");
Expand Down

0 comments on commit 45c7365

Please sign in to comment.