Skip to content

Conversation

@RianaAzad
Copy link
Contributor

No description provided.

@RianaAzad RianaAzad requested a review from FardinHash June 1, 2025 06:46
@RianaAzad RianaAzad self-assigned this Jun 1, 2025
@RianaAzad RianaAzad added bug Something isn't working enhancement New feature or request labels Jun 1, 2025
@RianaAzad RianaAzad requested review from Copilot and removed request for FardinHash June 1, 2025 06:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds timeouts and better error handling to messaging, enables auto-masking workflows with detailed debug logs, and bolsters fallback paths for settings retrieval.

  • Added a 10s timeout and branched error messages in ChromeAPI.sendMessage
  • Introduced testConnection and enhanced error-to-user messaging in useSettings
  • Embedded verbose console logging across content and background scripts for tracing

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/utils/chrome.js Added sendMessage timeout, refined error cases, logging, and a new testConnection method
src/hooks/useSettings.js Pre-flight connection check, mapped error messages to user-friendly prompts
src/content/content.js Inserted console logs during init, scanning, and masking steps
src/background/background.js Added debug logs in constructor, lifecycle events, message handling, and service worker code
Comments suppressed due to low confidence (4)

src/content/content.js:305

  • Avoid logging potentially sensitive content snippets to the console; this could expose user data. Remove or sanitize logged data.
console.log("Safe-Web Content Script: Found matches in text node:", matchDetails, "Text:", text.substring(0, 100));

src/content/content.js:316

  • This log outputs user-visible text, which may contain sensitive information. Consider removing or masking sensitive data before logging.
console.log("Safe-Web Content Script: Masking text node:", textNode.textContent.substring(0, 100));

src/content/content.js:6

  • Remove or guard debug console.log statements in production to reduce noise and potential performance impacts. Consider using a logging library with levels.
console.log("Safe-Web Content Script: Constructor called");

src/utils/utils.js:503

  • Prefer Array.isArray(obj) over instanceof Array for clearer intent and compatibility with cross-realm objects.
if (obj instanceof Array) return obj.map((item) => this.deepClone(item));

return;
}

const timeout = setTimeout(() => {
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Wrap timeout cleanup in a finally block so clearTimeout is guaranteed to run, even if an exception occurs before the sendMessage callback.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant