Skip to content

Conversation

@seanmcguire12
Copy link
Member

why

what changed

test plan

@changeset-bot
Copy link

changeset-bot bot commented Oct 29, 2025

⚠️ No Changeset found

Latest commit: 530ae6d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Adds automatic cache refresh when self-heal updates action selectors during replay. When cached actions are replayed and the self-heal mechanism finds better selectors, the cache entry is now automatically updated with the healed selectors for future use.

Key Changes:

  • Added haveActionsChanged() method to detect differences between original and replayed actions
  • Added refreshCacheEntry() method to update cache with healed actions
  • Modified replayCachedActions() to check for changes after successful replay and refresh cache if needed
  • Added Action type import to support the new comparison logic

How it works:
After successfully replaying all cached actions, the code compares the original cached selectors with the potentially healed selectors returned from replay. If self-heal occurred and selectors changed, the cache is updated so future replays use the improved selectors rather than repeatedly triggering self-heal.

Confidence Score: 5/5

  • Safe to merge - clean implementation with proper error handling and logging
  • The implementation is well-structured with thorough action comparison logic, proper error handling in cache refresh, and clear logging. The changes are isolated to cache functionality and improve system resilience by learning from self-heal corrections.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/core/lib/v3/cache/ActCache.ts 5/5 Adds self-heal cache refresh: detects when replayed actions have changed selectors and updates cache entry

Sequence Diagram

sequenceDiagram
    participant Client
    participant ActCache
    participant ActHandler
    participant Storage
    
    Client->>ActCache: tryReplay(context, page, timeout)
    ActCache->>Storage: readJson(cacheKey)
    Storage-->>ActCache: entry with cached actions
    
    loop For each cached action
        ActCache->>ActHandler: actFromObserveResult(action, page, ...)
        alt Action succeeds
            ActHandler-->>ActCache: {success: true, actions: [updatedAction]}
        else Action fails & selfHeal enabled
            ActHandler->>ActHandler: capture new snapshot
            ActHandler->>ActHandler: run LLM inference for new selector
            ActHandler->>ActHandler: retry with healed selector
            ActHandler-->>ActCache: {success: true, actions: [actionWithNewSelector]}
        end
    end
    
    ActCache->>ActCache: haveActionsChanged(original, updated)
    alt Actions changed (e.g., selector healed)
        ActCache->>ActCache: refreshCacheEntry(context, updatedEntry)
        ActCache->>Storage: writeJson(cacheKey, updatedEntry)
        Storage-->>ActCache: success
        ActCache-->>Client: ActResult with updated actions
    else Actions unchanged
        ActCache-->>Client: ActResult with original actions
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@seanmcguire12 seanmcguire12 merged commit 62e1a7c into v3 Oct 29, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants