Refine script generation prompts for better timing and mouse movement#29
Merged
DeDuckProject merged 1 commit intomainfrom Mar 13, 2026
Merged
Conversation
- Replace blanket waitForTimeout(1500) rule with tiered timing: 300ms between routine actions, 800ms only after key visual moments (animations, state changes, panel openings). Eliminates stacked pauses. - Add mouse movement section: model should add a single intermediate waypoint before each target so the cursor doesn't teleport between interactions. Keeps it subtle — one waypoint, plausible coordinates. https://claude.ai/code/session_01WpqwtdViucvCCdgxj6RCGG
Owner
Author
|
/glimpse |
🧐 UI Demo PreviewChanges detected in: What changed: The demo script generator has been updated with improved timing and mouse movement instructions. Scripts now use shorter, more precise pauses and simulate natural cursor movement between interactions for more realistic recordings. 📱 Can't see the preview? Open it directly Demo script (auto-generated)import type { Page } from '@playwright/test';
export async function demo(page: Page): Promise<void> {
await page.goto('http://localhost:3000');
await page.waitForLoadState('networkidle');
await page.waitForTimeout(300);
// Look for a script generator form or input area
const diffInput = page.getByRole('textbox').first();
const hasDiffInput = await diffInput.isVisible().catch(() => false);
if (hasDiffInput) {
await page.mouse.move(400, 300);
await diffInput.click();
await page.waitForTimeout(300);
await diffInput.fill(`diff --git a/src/button.tsx b/src/button.tsx
- <button className="btn">Click me</button>
+ <button className="btn btn-primary">Click me</button>`);
await page.waitForTimeout(300);
}
// Look for a generate button
const generateBtn = page.getByRole('button', { name: /generate/i }).first();
const hasGenerateBtn = await generateBtn.isVisible().catch(() => false);
if (hasGenerateBtn) {
await page.mouse.move(500, 400);
await generateBtn.click();
await page.waitForTimeout(800);
}
// Look for output/result area showing the generated script
const outputArea = page.locator('pre, code, [data-testid*="output"], [data-testid*="result"], textarea').last();
const hasOutput = await outputArea.isVisible().catch(() => false);
if (hasOutput) {
await page.mouse.move(640, 360);
await outputArea.scrollIntoViewIfNeeded();
await page.waitForTimeout(300);
// Highlight the timing section in the output
await page.mouse.move(640, 400);
await page.waitForTimeout(300);
}
// Scroll through the page to show timing rules in the UI if displayed
await page.mouse.move(640, 360);
await page.evaluate(() => window.scrollTo({ top: 300, behavior: 'smooth' }));
await page.waitForTimeout(800);
await page.mouse.move(640, 500);
await page.evaluate(() => window.scrollTo({ top: 600, behavior: 'smooth' }));
await page.waitForTimeout(300);
// Look for any tabs or sections related to timing/mouse movement
const timingTab = page.getByRole('tab', { name: /timing/i }).first();
const hasTimingTab = await timingTab.isVisible().catch(() => false);
if (hasTimingTab) {
await page.mouse.move(400, 200);
await timingTab.click();
await page.waitForTimeout(800);
}
// Look for any settings or configuration panel
const settingsBtn = page.getByRole('button', { name: /settings|config|options/i }).first();
const hasSettings = await settingsBtn.isVisible().catch(() => false);
if (hasSettings) {
await page.mouse.move(900, 100);
await settingsBtn.click();
await page.waitForTimeout(800);
}
// Scroll back to top to show the full page state
await page.mouse.move(640, 200);
await page.evaluate(() => window.scrollTo({ top: 0, behavior: 'smooth' }));
await page.waitForTimeout(300);
}Generated by git-glimpse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Updated the script generation prompt instructions to provide more nuanced guidance on timing and mouse movement behavior, replacing a blanket pause recommendation with context-aware timing strategies.
Key Changes
page.mouse.move()with a single intermediate waypointImplementation Details
These changes improve the quality of generated scripts by:
https://claude.ai/code/session_01WpqwtdViucvCCdgxj6RCGG