Skip to content

Conversation

@coleleavitt
Copy link

No description provided.

Comment on lines +29 to +68
spaRouteChangeCompleteSubscribe(
async (url) => {
const location = whereAmI(url);

// Only apply to home page, not spaces
if (location !== "home") return;

// Get current sources
const currentState = internalSearchStatesObserverStore.getState();
let currentSources = currentState.sources;

// If sources is empty (Perplexity hasn't initialized yet), use web as default
if (currentSources.length === 0) {
currentSources = ["web"];
}

// Add all configured connectors that aren't already present
const connectorsToAdd = connectorsToEnable.filter(
(connector) => !currentSources.includes(connector),
);

if (connectorsToAdd.length > 0) {
const updatedSources = [...currentSources, ...connectorsToAdd];
internalSearchStatesObserverStore.getState().setInternalSearchStates({
sources: updatedSources,
});
console.log(
"[Complexity] Added connectors to sources:",
connectorsToAdd,
"-> Result:",
updatedSources,
);
} else {
console.log("[Complexity] All configured connectors already enabled");
}
},
{
immediate: true,
},
);

Choose a reason for hiding this comment

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

🟡 MEDIUM - Async callback lacks error handling

Category: quality

Description:
The async callback passed to spaRouteChangeCompleteSubscribe has no try-catch wrapper, risking unhandled promise rejections if operations fail

Suggestion:
Wrap the async callback body in try-catch block to handle potential errors from store operations. Example: async (url) => { try { /* existing code */ } catch (err) { logger.error('[Complexity] Failed to update connectors', {err}); } }

Confidence: 65%
Rule: ts_handle_async_operations_with_proper_erro

Comment on lines +55 to +60
console.log(
"[Complexity] Added connectors to sources:",
connectorsToAdd,
"-> Result:",
updatedSources,
);

Choose a reason for hiding this comment

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

🟡 MEDIUM - console.log left in production code

Category: quality

Description:
Debug console.log statement should be removed or replaced with proper logger

Suggestion:
Use a proper logger (e.g., logger.info) or remove this debug statement

Confidence: 85%
Rule: general_console_log_committed

updatedSources,
);
} else {
console.log("[Complexity] All configured connectors already enabled");

Choose a reason for hiding this comment

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

🟡 MEDIUM - console.log left in production code

Category: quality

Description:
Debug console.log statement should be removed or replaced with proper logger

Suggestion:
Use a proper logger (e.g., logger.info) or remove this debug statement

Confidence: 85%
Rule: general_console_log_committed

@diffray-bot
Copy link

diffray diffray code review

Free public review - Want AI code reviews on your PRs? Check out diffray.ai

Summary

Validated 4 issues: 1 kept (async error handling), 1 filtered (incorrect subscription API assumption), 2 kept (console.log usage)

Issues Found: 3

See 3 individual line comment(s) for details.

Full issue list (click to expand)

🟡 MEDIUM - Async callback lacks error handling

File: perplexity/extension/src/plugins/connectors-always-on/index.loader.ts:29-68

Category: quality

Description: The async callback passed to spaRouteChangeCompleteSubscribe has no try-catch wrapper, risking unhandled promise rejections if operations fail

Suggestion: Wrap the async callback body in try-catch block to handle potential errors from store operations. Example: async (url) => { try { /* existing code */ } catch (err) { logger.error('[Complexity] Failed to update connectors', {err}); } }

Confidence: 65%

Rule: ts_handle_async_operations_with_proper_erro


🟡 MEDIUM - console.log left in production code

File: perplexity/extension/src/plugins/connectors-always-on/index.loader.ts:55-60

Category: quality

Description: Debug console.log statement should be removed or replaced with proper logger

Suggestion: Use a proper logger (e.g., logger.info) or remove this debug statement

Confidence: 85%

Rule: general_console_log_committed


🟡 MEDIUM - console.log left in production code

File: perplexity/extension/src/plugins/connectors-always-on/index.loader.ts:62

Category: quality

Description: Debug console.log statement should be removed or replaced with proper logger

Suggestion: Use a proper logger (e.g., logger.info) or remove this debug statement

Confidence: 85%

Rule: general_console_log_committed



Powered by diffray - AI Code Review

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.

3 participants