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:
Tommy D. Rossi
2026-02-26 13:33:42 +01:00
parent 5c58cac7da
commit de74b32c34
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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,