Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
fix: allow new Discord DMs to bind safely
Emre Sokullu7dc2826765ac
diff --git a/src/chrome/src/content/chat-observation.js b/src/chrome/src/content/chat-observation.jsindex 87568682a..523a242af 100644--- a/src/chrome/src/content/chat-observation.js+++ b/src/chrome/src/content/chat-observation.js@@ -180,7 +180,7 @@|| /^(.+) \(channel\)$/.exec(attribute(root, 'aria-label'))?.[1]|| (directMessageRoute ? `direct-message-${channelId}` : `channel-${channelId}`);return transcript && (directMessageRoute- ? !selectedDmRouteMismatch && transcriptMatchesDmRoute+ ? !selectedDmRouteMismatch && (channelLink || transcriptMatchesDmRoute): channelLink)? {root, transcript, name, channelId,diff --git a/src/firefox/src/content/chat-observation.js b/src/firefox/src/content/chat-observation.jsindex 87568682a..523a242af 100644--- a/src/firefox/src/content/chat-observation.js+++ b/src/firefox/src/content/chat-observation.js@@ -180,7 +180,7 @@|| /^(.+) \(channel\)$/.exec(attribute(root, 'aria-label'))?.[1]|| (directMessageRoute ? `direct-message-${channelId}` : `channel-${channelId}`);return transcript && (directMessageRoute- ? !selectedDmRouteMismatch && transcriptMatchesDmRoute+ ? !selectedDmRouteMismatch && (channelLink || transcriptMatchesDmRoute): channelLink)? {root, transcript, name, channelId,diff --git a/test/discord-guard.mjs b/test/discord-guard.mjsindex 689121dc9..5a1c693c5 100644--- a/test/discord-guard.mjs+++ b/test/discord-guard.mjs@@ -266,6 +266,25 @@ for (const [kind, engine, AgentClass, policy] of [assert.equal((await observe()).success,false,'a conflicting selected DM route fails closed');} finally {await page.close();}});+ await t.test('empty DMs bind only when the selected rail route confirms the pane',async()=>{+ const {page}=await setup();+ try {+ await page.locator('#channel').evaluate(el=>{+ el.setAttribute('href','/channels/@me/456');+ el.setAttribute('data-list-item-id','private-channels-uid_11___456');+ });+ await page.evaluate(()=>history.replaceState(null,'','/channels/@me/456'));+ await page.locator('[data-list-id=chat-messages]').evaluate(el=>el.replaceChildren());+ await page.locator('#composer').focus();+ const observe=()=>page.evaluate(()=>window.__wb_observe_chat_dom({}));+ assert.equal((await observe()).success,true,'an empty DM can bind from its matching selected rail link');+ await page.locator('#channel').evaluate(el=>el.removeAttribute('aria-current'));+ assert.equal((await observe()).success,false,'an empty DM without pane or rail route evidence fails closed');+ await page.locator('#channel').evaluate(el=>el.setAttribute('aria-current','page'));+ await page.evaluate(()=>history.replaceState(null,'','/channels/@me/789'));+ assert.equal((await observe()).success,false,'an empty DM cannot bind to a different selected route');+ } finally {await page.close();}+ });await t.test('channel observation recognizes the transcript, empty channels and stable server/channel identity',async()=>{const {page}=await setup();try {