Skip to content

feat: demo chat#34

Open
Mahesh1303 wants to merge 1 commit intodevfrom
feat/browserExtension-demo
Open

feat: demo chat#34
Mahesh1303 wants to merge 1 commit intodevfrom
feat/browserExtension-demo

Conversation

@Mahesh1303
Copy link
Contributor

No description provided.

@Mahesh1303 Mahesh1303 requested a review from Copilot September 21, 2025 20:09
Copy link
Contributor

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 implements a demo chat feature for the browser extension, adding file upload capabilities, screenshot analysis, and interactive text highlighting functionality to enhance the user experience with mock AI responses.

Key changes include:

  • Added file upload functionality with demo AI analysis responses
  • Enhanced chat interface with screenshot capabilities and random text highlighting
  • Updated UI styling for improved dark theme consistency and better user experience

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
browser-extension/vite.config.ts Fixed TypeScript compatibility by adding type assertion for crx plugin
browser-extension/src/sidepanel/index.html Added viewport meta tag and page title for better mobile support
browser-extension/src/sidepanel/index.css Complete redesign with modern dark theme and improved layout styles
browser-extension/src/sidepanel/App.tsx Added file upload handler and demo response generation for chat functionality
browser-extension/src/sidepanel/App.css Updated styles for file upload button and cleaned up duplicate CSS rules
browser-extension/src/service_worker.ts Added chat request handling, screenshot capture, and text highlighting features
browser-extension/src/content/views/App.tsx Enhanced floating button with better styling and accessibility
browser-extension/src/content/views/App.css Comprehensive styling improvements for the floating toggle button
browser-extension/src/content/test.js Added test script for verifying content script injection
browser-extension/src/content/main.tsx Improved content script initialization with better error handling
browser-extension/src/content.ts Added message handling for token saving from web app
browser-extension/package.json Updated @crxjs/vite-plugin to newer version
browser-extension/manifest.config.ts Added content script entries for test and token handling
apps/web/src/app/token/page.tsx Created token generation page for extension authentication

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +67 to 87
} else if (message.action === "chatResponse" && message.payload) {
setMessages((prevMessages) => {
const filteredMessages = prevMessages.filter(
(msg) => msg.type !== "loading"
);
return [
...filteredMessages,
{ type: "llm", text: message.payload.text },
];
});
} else if (message.action === "screenshotResponse" && message.payload) {
setMessages((prevMessages) => {
const filteredMessages = prevMessages.filter(
(msg) => msg.type !== "loading"
);
return [
...filteredMessages,
{ type: "llm", text: message.payload.text },
];
});
}
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

These three message handling blocks contain identical logic for filtering loading messages and adding LLM responses. Consider extracting this into a helper function to reduce code duplication.

Copilot uses AI. Check for mistakes.
Comment on lines +163 to +164
const { tabId } = await chrome.tabs.query({ active: true, currentWindow: true }).then(tabs => ({ tabId: tabs[0]?.id }));

Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

This line unnecessarily destructures and reconstructs the tabId. It should be simplified to const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true }); const tabId = activeTab?.id; for better readability.

Suggested change
const { tabId } = await chrome.tabs.query({ active: true, currentWindow: true }).then(tabs => ({ tabId: tabs[0]?.id }));
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true });
const tabId = activeTab?.id;

Copilot uses AI. Check for mistakes.
Comment on lines +194 to +196
let node;
while (node = walker.nextNode()) {
textNodes.push(node as Text);
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

Assignment inside the while condition can be confusing and may trigger linting warnings. Consider using a more explicit loop structure: let node = walker.nextNode(); while (node) { textNodes.push(node as Text); node = walker.nextNode(); }

Suggested change
let node;
while (node = walker.nextNode()) {
textNodes.push(node as Text);
let node = walker.nextNode();
while (node) {
textNodes.push(node as Text);
node = walker.nextNode();

Copilot uses AI. Check for mistakes.
Comment on lines +9 to 11
const isRestrictedDomain = ['extension://', 'chrome://', 'moz-extension://'].some(protocol =>
window.location.href.startsWith(protocol)
);
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

The protocol check could be more robust by using window.location.protocol instead of checking the full href. This would be more precise: ['extension:', 'chrome:', 'moz-extension:'].includes(window.location.protocol)

Suggested change
const isRestrictedDomain = ['extension://', 'chrome://', 'moz-extension://'].some(protocol =>
window.location.href.startsWith(protocol)
);
const isRestrictedDomain = ['extension:', 'chrome:', 'moz-extension:'].includes(window.location.protocol);

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant