mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 17:00:59 +00:00
Only insert navigation messages on user message submit, not during idle browsing
- Remove automatic navigation message insertion from tab change listeners - Tab listeners now only track current tab state (currentTabUrl, currentTabIndex) - Navigation messages are only inserted via onBeforeSend callback when user submits - Prevents spam of navigation messages when user is just browsing without interacting with agent
This commit is contained in:
parent
c66695f062
commit
4a2ef56954
1 changed files with 5 additions and 18 deletions
|
|
@ -298,11 +298,12 @@ const renderApp = () => {
|
|||
// TAB NAVIGATION TRACKING
|
||||
// ============================================================================
|
||||
|
||||
// Listen for tab updates to insert navigation messages in real-time
|
||||
// Listen for tab updates to track current tab state (don't insert messages yet)
|
||||
chrome.tabs.onUpdated.addListener((_tabId, changeInfo, tab) => {
|
||||
// Only care about URL changes on the active tab
|
||||
if (changeInfo.url && tab.active && tab.url) {
|
||||
handleTabNavigation(tab.url, tab.title || "Untitled", tab.favIconUrl, tab.index);
|
||||
currentTabUrl = tab.url;
|
||||
currentTabIndex = tab.index;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -310,25 +311,11 @@ chrome.tabs.onUpdated.addListener((_tabId, changeInfo, tab) => {
|
|||
chrome.tabs.onActivated.addListener(async (activeInfo) => {
|
||||
const tab = await chrome.tabs.get(activeInfo.tabId);
|
||||
if (tab.url) {
|
||||
handleTabNavigation(tab.url, tab.title || "Untitled", tab.favIconUrl, tab.index);
|
||||
currentTabUrl = tab.url;
|
||||
currentTabIndex = tab.index;
|
||||
}
|
||||
});
|
||||
|
||||
function handleTabNavigation(url: string, title: string, favicon?: string, tabIndex?: number) {
|
||||
// Update current tab tracking
|
||||
const urlChanged = currentTabUrl !== url;
|
||||
const tabChanged = currentTabIndex !== tabIndex;
|
||||
|
||||
currentTabUrl = url;
|
||||
currentTabIndex = tabIndex;
|
||||
|
||||
// Only insert navigation message if something changed and we have an agent
|
||||
if ((urlChanged || tabChanged) && agent) {
|
||||
const navMessage = createNavigationMessage(url, title, favicon, tabIndex);
|
||||
agent.appendMessage(navMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// INIT
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue