update prompt
This commit is contained in:
parent
14eed752dd
commit
ca78966624
|
|
@ -55,17 +55,31 @@ const PromptButton: React.FC<{
|
||||||
}> = ({ error, result }) => {
|
}> = ({ error, result }) => {
|
||||||
const gitCommitInfo = React.useContext(GitCommitInfoContext);
|
const gitCommitInfo = React.useContext(GitCommitInfoContext);
|
||||||
const prompt = React.useMemo(() => {
|
const prompt = React.useMemo(() => {
|
||||||
const diff = gitCommitInfo?.['pull.diff'] ?? gitCommitInfo?.['revision.diff'];
|
const promptParts = [
|
||||||
const pageSnapshot = result?.attachments.find(a => a.name === 'pageSnapshot')?.body;
|
'This test failed, suggest how to fix it. Please be correct, concise and keep Playwright best practices in mind.',
|
||||||
|
'Here is the error:',
|
||||||
return [
|
'\n',
|
||||||
'You are a helpful assistant. Help me understand the error cause. Here is the error:',
|
|
||||||
stripAnsiEscapes(error),
|
stripAnsiEscapes(error),
|
||||||
|
'\n',
|
||||||
|
];
|
||||||
|
|
||||||
|
const pageSnapshot = result?.attachments.find(a => a.name === 'pageSnapshot')?.body;
|
||||||
|
if (pageSnapshot)
|
||||||
|
promptParts.push(
|
||||||
|
'This is how the page looked at the end of the test:',
|
||||||
|
pageSnapshot,
|
||||||
|
'\n'
|
||||||
|
);
|
||||||
|
|
||||||
|
const diff = gitCommitInfo?.['pull.diff'] ?? gitCommitInfo?.['revision.diff'];
|
||||||
|
if (diff)
|
||||||
|
promptParts.push(
|
||||||
'And this is the code diff:',
|
'And this is the code diff:',
|
||||||
diff,
|
diff,
|
||||||
'And this is how the page looked:',
|
'\n'
|
||||||
pageSnapshot,
|
);
|
||||||
].join('\n\n');
|
|
||||||
|
return promptParts.join('\n');
|
||||||
}, [gitCommitInfo, result])
|
}, [gitCommitInfo, result])
|
||||||
|
|
||||||
return <CopyToClipboard value={prompt} icon={<icons.copilot />} title="Copy prompt to clipboard" />;
|
return <CopyToClipboard value={prompt} icon={<icons.copilot />} title="Copy prompt to clipboard" />;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue