fix: skip diff mode when search string is provided in snapshot/markdown/html
When both showDiffSinceLastCall and search were set, the diff block returned early and the search filter was silently ignored. Now all three functions (snapshot, getPageMarkdown, getCleanHTML) skip diffing when a search string is present, ensuring the agent always gets filtered results.
This commit is contained in:
@@ -76,8 +76,8 @@ export async function getCleanHTML(options: GetCleanHTMLOptions): Promise<string
|
||||
const previousSnapshot = pageSnapshots.get(snapshotKey)
|
||||
pageSnapshots.set(snapshotKey, htmlStr)
|
||||
|
||||
// Return diff if we have a previous snapshot and diff mode is enabled
|
||||
if (showDiffSinceLastCall && previousSnapshot) {
|
||||
// Never diff when agent is searching — search should always filter the full content
|
||||
if (showDiffSinceLastCall && previousSnapshot && !search) {
|
||||
const diffResult = createSmartDiff({
|
||||
oldContent: previousSnapshot,
|
||||
newContent: htmlStr,
|
||||
|
||||
@@ -772,8 +772,8 @@ export class PlaywrightExecutor {
|
||||
this.lastSnapshots.set(resolvedPage, snapshotStr)
|
||||
}
|
||||
|
||||
// Return diff if we have a previous snapshot and diff mode is enabled
|
||||
if (showDiffSinceLastCall && previousSnapshot && shouldCacheSnapshot) {
|
||||
// Never diff when agent is searching — search should always filter the full snapshot
|
||||
if (showDiffSinceLastCall && previousSnapshot && shouldCacheSnapshot && !search) {
|
||||
const diffResult = createSmartDiff({
|
||||
oldContent: previousSnapshot,
|
||||
newContent: snapshotStr,
|
||||
|
||||
@@ -172,8 +172,8 @@ export async function getPageMarkdown(options: GetPageMarkdownOptions): Promise<
|
||||
const previousSnapshot = lastMarkdownSnapshots.get(page)
|
||||
lastMarkdownSnapshots.set(page, markdown)
|
||||
|
||||
// Return diff if we have a previous snapshot and diff mode is enabled
|
||||
if (showDiffSinceLastCall && previousSnapshot) {
|
||||
// Never diff when agent is searching — search should always filter the full content
|
||||
if (showDiffSinceLastCall && previousSnapshot && !search) {
|
||||
const diffResult = createSmartDiff({
|
||||
oldContent: previousSnapshot,
|
||||
newContent: markdown,
|
||||
|
||||
Reference in New Issue
Block a user