codeant-ai-for-open-source[bot] commented on code in PR #43784:
URL: https://github.com/apache/superset/pull/43784#discussion_r3910782024


##########
superset/utils/screenshot_utils.py:
##########
@@ -818,15 +894,87 @@ def _raise_if_budget_exhausted() -> None:
                 if report_execution_context or task_budget is not None
                 else None
             )
-            tile_screenshot = page.screenshot(
-                type="png",
-                clip=clip,
-                **(
-                    {"timeout": capture_timeout * 1000}
-                    if capture_timeout is not None
-                    else {}
-                ),
-            )
+            tile_screenshot: bytes | None = None
+            for capture_attempt in range(1, 
TILED_SCREENSHOT_MAX_CAPTURE_ATTEMPTS + 1):
+                capture_started_at = time.monotonic()
+                try:
+                    candidate = page.screenshot(
+                        type="png",
+                        clip=clip,
+                        **(
+                            {"timeout": capture_timeout * 1000}
+                            if capture_timeout is not None
+                            else {}
+                        ),
+                    )
+                except PlaywrightTimeout:
+                    capture_elapsed = time.monotonic() - capture_started_at
+                    logger.warning(
+                        "report_capture_tile_timeout tile=%s/%s attempt=%s/%s "
+                        "capture_elapsed_seconds=%.2f%s",
+                        i + 1,
+                        num_tiles,
+                        capture_attempt,
+                        TILED_SCREENSHOT_MAX_CAPTURE_ATTEMPTS,
+                        capture_elapsed,
+                        context_suffix,
+                    )
+                    if capture_attempt == 
TILED_SCREENSHOT_MAX_CAPTURE_ATTEMPTS:
+                        raise
+                else:
+                    capture_elapsed = time.monotonic() - capture_started_at
+                    is_uniform, dominant_ratio = 
is_screenshot_nearly_uniform(candidate)
+                    is_blank = is_uniform and visible_chart_holders > 0
+                    logger.debug(

Review Comment:
   **Suggestion:** `visible_chart_holders > 0` rejects uniform tiles even when 
visible holders are valid terminal error or empty states permitted by 
readiness. [incorrect condition logic]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=dcde50c8ac544ee3b390d67b526e3b6a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=dcde50c8ac544ee3b390d67b526e3b6a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/screenshot_utils.py
   **Line:** 927:928
   **Comment:**
        *Incorrect Condition Logic: `visible_chart_holders > 0` rejects uniform 
tiles even when visible holders are valid terminal error or empty states 
permitted by readiness.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43784&comment_hash=a7cbb2cb4de68d001513b32cd3b604ced3a664af9a89bb02a73515d4af9811ec&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43784&comment_hash=a7cbb2cb4de68d001513b32cd3b604ced3a664af9a89bb02a73515d4af9811ec&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/utils/screenshot_utils.py:
##########
@@ -818,15 +894,87 @@ def _raise_if_budget_exhausted() -> None:
                 if report_execution_context or task_budget is not None
                 else None
             )
-            tile_screenshot = page.screenshot(
-                type="png",
-                clip=clip,
-                **(
-                    {"timeout": capture_timeout * 1000}
-                    if capture_timeout is not None
-                    else {}
-                ),
-            )
+            tile_screenshot: bytes | None = None
+            for capture_attempt in range(1, 
TILED_SCREENSHOT_MAX_CAPTURE_ATTEMPTS + 1):
+                capture_started_at = time.monotonic()
+                try:
+                    candidate = page.screenshot(
+                        type="png",
+                        clip=clip,
+                        **(
+                            {"timeout": capture_timeout * 1000}
+                            if capture_timeout is not None
+                            else {}
+                        ),
+                    )

Review Comment:
   **Suggestion:** `capture_timeout` is calculated once before the retry loop, 
so three attempts can each consume the same remaining deadline and run past the 
report execution limit. [logic error]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0cc83e6d65624ce2b733347da5c7f6cb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0cc83e6d65624ce2b733347da5c7f6cb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/screenshot_utils.py
   **Line:** 898:909
   **Comment:**
        *Logic Error: `capture_timeout` is calculated once before the retry 
loop, so three attempts can each consume the same remaining deadline and run 
past the report execution limit.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43784&comment_hash=fc7a37e2ac9ad09336b98f868314161d23edd5ed8aef69367fdae83f7634bcce&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43784&comment_hash=fc7a37e2ac9ad09336b98f868314161d23edd5ed8aef69367fdae83f7634bcce&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to