mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 05:04:44 +00:00
Fix navigation tracking and ChatPanel window width initialization
Navigation tracking fixes: - Filter out chrome-extension:// URLs to avoid triggering on extension internal pages - Fixes "Could not establish connection" errors when sidepanel URL updates - Remove unused currentTabUrl/currentTabIndex tracking variables ChatPanel layout fixes: - Fix windowWidth initialization (was 0 due to too-early evaluation) - Set windowWidth in connectedCallback after DOM connection - Add requestAnimationFrame to ensure width is measured after layout - Add debug logging for troubleshooting layout issues - Now properly respects BREAKPOINT (800px) for mobile vs desktop layout
This commit is contained in:
parent
4f11cc15db
commit
7e79c05407
2 changed files with 20 additions and 14 deletions
|
|
@ -71,10 +71,6 @@ let agent: Agent;
|
|||
let chatPanel: ChatPanel;
|
||||
let agentUnsubscribe: (() => void) | undefined;
|
||||
|
||||
// Track current active tab for real-time navigation updates
|
||||
let currentTabUrl: string | undefined;
|
||||
let currentTabIndex: number | undefined;
|
||||
|
||||
// ============================================================================
|
||||
// HELPERS
|
||||
// ============================================================================
|
||||
|
|
@ -302,7 +298,8 @@ const renderApp = () => {
|
|||
// Listen for tab updates and insert navigation messages immediately
|
||||
chrome.tabs.onUpdated.addListener((_tabId, changeInfo, tab) => {
|
||||
// Only care about URL changes on the active tab
|
||||
if (changeInfo.url && tab.active && tab.url && agent) {
|
||||
// Ignore chrome-extension:// URLs (extension internal pages)
|
||||
if (changeInfo.url && tab.active && tab.url && agent && !tab.url.startsWith("chrome-extension://")) {
|
||||
const navMessage = createNavigationMessage(tab.url, tab.title || "Untitled", tab.favIconUrl, tab.index);
|
||||
agent.appendMessage(navMessage);
|
||||
}
|
||||
|
|
@ -311,7 +308,8 @@ chrome.tabs.onUpdated.addListener((_tabId, changeInfo, tab) => {
|
|||
// Listen for tab activation (user switches tabs)
|
||||
chrome.tabs.onActivated.addListener(async (activeInfo) => {
|
||||
const tab = await chrome.tabs.get(activeInfo.tabId);
|
||||
if (tab.url && agent) {
|
||||
// Ignore chrome-extension:// URLs (extension internal pages)
|
||||
if (tab.url && agent && !tab.url.startsWith("chrome-extension://")) {
|
||||
const navMessage = createNavigationMessage(tab.url, tab.title || "Untitled", tab.favIconUrl, tab.index);
|
||||
agent.appendMessage(navMessage);
|
||||
}
|
||||
|
|
@ -345,13 +343,6 @@ async function initApp() {
|
|||
};
|
||||
chatPanel.additionalTools = [browserJavaScriptTool];
|
||||
|
||||
// Initialize current tab state
|
||||
const [currentTab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||
if (currentTab?.url) {
|
||||
currentTabUrl = currentTab.url;
|
||||
currentTabIndex = currentTab.index;
|
||||
}
|
||||
|
||||
// Check for session in URL
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let sessionIdFromUrl = urlParams.get("session");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue