diff --git a/desktop/src/app/navigation/useAppNavigation.ts b/desktop/src/app/navigation/useAppNavigation.ts index 4e5829e97b..b1659d9c49 100644 --- a/desktop/src/app/navigation/useAppNavigation.ts +++ b/desktop/src/app/navigation/useAppNavigation.ts @@ -50,6 +50,16 @@ export function useAppNavigation() { search: { ...next.search, ...companionCoordinates }, } : next; + + if ( + companionCoordinates && + (destination.to !== "/channels/$channelId" || + destination.params?.channelId !== + companionCoordinates.agentSessionChannel) + ) { + return false; + } + const nextLocation = router.buildLocation(destination as never); if (location.href === nextLocation.href && !behavior.force) { diff --git a/desktop/tests/e2e/agent-activity-window.spec.ts b/desktop/tests/e2e/agent-activity-window.spec.ts index 53a508b002..852d9ce60d 100644 --- a/desktop/tests/e2e/agent-activity-window.spec.ts +++ b/desktop/tests/e2e/agent-activity-window.spec.ts @@ -3,11 +3,12 @@ import { expect, test } from "@playwright/test"; import { installMockBridge, TEST_IDENTITIES } from "../helpers/bridge"; const AGENT_PUBKEY = TEST_IDENTITIES.tyler.pubkey; +const REPOSITORY_OWNER_PUBKEY = TEST_IDENTITIES.alice.pubkey; const AGENTS_CHANNEL_ID = "94a444a4-c0a3-5966-ab05-530c6ddc2301"; const GENERAL_CHANNEL_ID = "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50"; const COMMUNITY_ID = "e2e-default-community"; -test("keeps dedicated activity windows connected when opening a channel reference", async ({ +test("keeps dedicated activity windows pinned to their original channel", async ({ page, }) => { await installMockBridge(page, { @@ -31,7 +32,7 @@ test("keeps dedicated activity windows connected when opening a channel referenc () => typeof window.__BUZZ_E2E_SEED_OBSERVER_EVENTS__ === "function", ); await page.evaluate( - ({ agentPubkey, channelId, generalChannelId }) => { + ({ agentPubkey, channelId, generalChannelId, repositoryOwnerPubkey }) => { window.__BUZZ_E2E_SEED_OBSERVER_EVENTS__?.({ agentPubkey, events: [ @@ -48,7 +49,10 @@ test("keeps dedicated activity windows connected when opening a channel referenc params: { update: { sessionUpdate: "agent_message_chunk", - content: { type: "text", text: "Continue in #general" }, + content: { + type: "text", + text: `Continue in #general or open `, + }, }, }, }, @@ -91,6 +95,7 @@ test("keeps dedicated activity windows connected when opening a channel referenc agentPubkey: AGENT_PUBKEY, channelId: AGENTS_CHANNEL_ID, generalChannelId: GENERAL_CHANNEL_ID, + repositoryOwnerPubkey: REPOSITORY_OWNER_PUBKEY, }, ); @@ -103,19 +108,24 @@ test("keeps dedicated activity windows connected when opening a channel referenc name: "Open channel general", }); await expect(channelReference).toBeVisible(); + const activityWindowUrl = page.url(); await channelReference.click(); - await expect(page).toHaveURL( - new RegExp( - `#/channels/${GENERAL_CHANNEL_ID}\\?.*community=${COMMUNITY_ID}.*agentSessionChannel=${AGENTS_CHANNEL_ID}`, - ), - ); + await expect(page).toHaveURL(activityWindowUrl); await expect(panel).toBeVisible(); await expect(panel).toContainText("Activity ยท #agents"); await expect(panel).not.toContainText( "Other channel activity must stay hidden", ); + const repositoryChip = panel.getByRole("button", { + name: "Open repository relay-tools", + }); + await expect(repositoryChip).toBeVisible(); + await repositoryChip.click(); + await expect(page).toHaveURL(activityWindowUrl); + await expect(panel).toBeVisible(); + await page.getByTestId("agent-session-settings-menu-trigger").click(); const rawFeedToggle = page.getByTestId("agent-session-toggle-raw-feed"); await expect(rawFeedToggle).toHaveAttribute(