π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
β¨ feat(channel): open a link's side browser in the Channel portal (#22858)
Arvin Xu0b27300abcaa
diff --git a/src/features/Channels/AcceptancePanel.tsx b/src/features/Channels/PortalPanel.tsxsimilarity index 88%rename from src/features/Channels/AcceptancePanel.tsxrename to src/features/Channels/PortalPanel.tsxindex 7a370636e9d..e57c0bbb9dc 100644--- a/src/features/Channels/AcceptancePanel.tsx+++ b/src/features/Channels/PortalPanel.tsx@@ -9,22 +9,22 @@ import RightPanel from '@/features/RightPanel';import { styles } from './styles';import { THREAD_FLOAT_BREAKPOINT } from './ThreadPanel';-import { useAcceptancePanel } from './useAcceptancePanel';+import { usePortalPanel } from './usePortalPanel';/** Entity details a Channel can show beside its feed; anything else follows its own route. */export const CHANNEL_ENTITY_PORTAL_SCOPE = ['acceptance',] as const satisfies readonly InternalLinkReference['type'][];-/** The acceptance report behind a link in the feed, beside the Channel like a thread. */-export function AcceptancePanel({+/** A report or web page opened from a link in the feed, beside the Channel like a thread. */+export function PortalPanel({availableWidth = 1000,channelId,}: {availableWidth?: number;channelId: string;}): ReactNode {- const { close, open } = useAcceptancePanel(channelId);+ const { close, open } = usePortalPanel(channelId);const [preferredWidth, setPreferredWidth] = useState(720);const narrow = availableWidth < THREAD_FLOAT_BREAKPOINT;const maxWidth = narrow ? availableWidth : availableWidth - 360;diff --git a/src/features/Channels/index.tsx b/src/features/Channels/index.tsxindex 35c8c6790d7..3ca6dad5525 100644--- a/src/features/Channels/index.tsx+++ b/src/features/Channels/index.tsx@@ -14,19 +14,19 @@ import { channelActions, channelSelectors, useChannelStore } from '@/store/channimport { useChatStore } from '@/store/chat';import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';-import { AcceptancePanel, CHANNEL_ENTITY_PORTAL_SCOPE } from './AcceptancePanel';import { AgentProfilePanel } from './AgentProfilePanel';import { visibleChannelDetail } from './channelAccess';import { ChannelConversation } from './ChannelConversation';import { MEMBER_FLOAT_BREAKPOINT, MemberPanel } from './MemberPanel';import { MemberStatus } from './MemberStatus';import { openTopic } from './openTopic';+import { CHANNEL_ENTITY_PORTAL_SCOPE, PortalPanel } from './PortalPanel';import { DirectReplyStatus } from './ReplyActivity';import { type ReplyTopic, ReplyTopicPanel } from './ReplyTopicPanel';import { styles } from './styles';import { ThreadPageActions, ThreadPageTitle } from './ThreadPageTitle';import { THREAD_FLOAT_BREAKPOINT, ThreadPanel } from './ThreadPanel';-import { useAcceptancePanelOpen } from './useAcceptancePanel';+import { channelBrowserSessionId, usePortalPanelOpen } from './usePortalPanel';import { useThreadPanel } from './useThreadPanel';/** One Channel: the main conversation, with a thread beside it, or one thread as the page. */@@ -46,24 +46,21 @@ function EnabledChannelPage() {? detail.members.find((member) => member.agentId === detail.channel.agentId): undefined;const [topic, setTopic] = useState<(ReplyTopic & { channelId: string }) | null>(null);- const acceptanceOpen = useAcceptancePanelOpen();+ const portalOpen = usePortalPanelOpen();const clearPortalStack = useChatStore((s) => s.clearPortalStack);- // One side panel at a time. A report covers whatever was open and uncovers it when closed;- // explicitly opening another panel closes the report.- const threadId = acceptanceOpen ? null : panel.threadId;- const threadDraft = acceptanceOpen ? null : panel.draft;+ const openBrowser = useChatStore((s) => s.openBrowser);+ // One side panel at a time. A report or web page covers whatever was open and uncovers it+ // when closed; explicitly opening another panel closes it.+ const threadId = portalOpen ? null : panel.threadId;+ const threadDraft = portalOpen ? null : panel.draft;const pageThreadId = panel.pageThreadId;// A direct conversation's side panel is its Agent's profile; a workspace group's is the roster.const hasMemberPanel =!!directAgent || (!!detail?.channel.workspaceId && !detail.channel.agentId);const membersOpen =- hasMemberPanel &&- membersChannelId === channelId &&- !threadId &&- !threadDraft &&- !acceptanceOpen;+ hasMemberPanel && membersChannelId === channelId && !threadId && !threadDraft && !portalOpen;const visibleTopic = openTopic(topic, channelId, {- acceptance: acceptanceOpen,+ portal: portalOpen,members: membersOpen,thread: !!(threadId || threadDraft || pageThreadId),});@@ -117,7 +114,10 @@ function EnabledChannelPage() {)}/>- <EntityLinkHostProvider portal={CHANNEL_ENTITY_PORTAL_SCOPE}>+ <EntityLinkHostProvider+ portal={CHANNEL_ENTITY_PORTAL_SCOPE}+ onOpenSideBrowser={(url) => openBrowser(channelBrowserSessionId(channelId), url)}+ ><Flexbox horizontal ref={conversationRef} {...stylex.props(styles.conversations)}>{pageThreadId ? (<ChannelConversation@@ -126,7 +126,7 @@ function EnabledChannelPage() {threadId={pageThreadId}inert={(membersOpen && (conversationWidth ?? 1000) < MEMBER_FLOAT_BREAKPOINT) ||- (acceptanceOpen && (conversationWidth ?? 1000) < THREAD_FLOAT_BREAKPOINT)+ (portalOpen && (conversationWidth ?? 1000) < THREAD_FLOAT_BREAKPOINT)}/>) : (@@ -134,7 +134,7 @@ function EnabledChannelPage() {channelId={channelId}key={channelId}inert={- (!!(threadId || threadDraft || acceptanceOpen) &&+ (!!(threadId || threadDraft || portalOpen) &&(conversationWidth ?? 1000) < THREAD_FLOAT_BREAKPOINT) ||(membersOpen && (conversationWidth ?? 1000) < MEMBER_FLOAT_BREAKPOINT) ||(!!visibleTopic && (conversationWidth ?? 1000) < THREAD_FLOAT_BREAKPOINT)@@ -144,7 +144,7 @@ function EnabledChannelPage() {// A send that finishes behind an open report (toggle: false) must not close it.if (toggle !== false) clearPortalStack();// Under a report the thread only looks closed, so bring it back, don't toggle it off.- panel.openThread(nextThreadId, acceptanceOpen ? false : toggle);+ panel.openThread(nextThreadId, portalOpen ? false : toggle);}}onOpenTopic={(next) => {panel.close();@@ -195,7 +195,7 @@ function EnabledChannelPage() {onSendDraft={panel.send}/>)}- <AcceptancePanel availableWidth={conversationWidth} channelId={channelId} />+ <PortalPanel availableWidth={conversationWidth} channelId={channelId} /></Flexbox></EntityLinkHostProvider></Flexbox>diff --git a/src/features/Channels/openTopic.test.ts b/src/features/Channels/openTopic.test.tsindex d4a114faa04..1dc94880aae 100644--- a/src/features/Channels/openTopic.test.ts+++ b/src/features/Channels/openTopic.test.ts@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';import { openTopic } from './openTopic';const topic = { channelId: 'ch-1' } as Parameters<typeof openTopic>[0];-const none = { acceptance: false, members: false, thread: false };+const none = { members: false, portal: false, thread: false };describe('openTopic', () => {it('shows the topic of the current Channel when nothing covers it', () => {@@ -14,6 +14,6 @@ describe('openTopic', () => {it('hides the topic once a thread opens, including a thread opened as the page', () => {expect(openTopic(topic, 'ch-1', { ...none, thread: true })).toBeNull();expect(openTopic(topic, 'ch-1', { ...none, members: true })).toBeNull();- expect(openTopic(topic, 'ch-1', { ...none, acceptance: true })).toBeNull();+ expect(openTopic(topic, 'ch-1', { ...none, portal: true })).toBeNull();});});diff --git a/src/features/Channels/openTopic.ts b/src/features/Channels/openTopic.tsindex fd32c50869f..9617ff0d151 100644--- a/src/features/Channels/openTopic.ts+++ b/src/features/Channels/openTopic.ts@@ -2,13 +2,13 @@ import type { ReplyTopic } from './ReplyTopicPanel';/*** The reply topic shown beside the Channel. A thread, as the page or beside the Channel, the- * member list or a report replaces it; it belongs to the Channel it was opened from.+ * member list or a portal view (report, web page) replaces it; it belongs to the Channel it was opened from.*/export const openTopic = (topic: (ReplyTopic & { channelId: string }) | null,channelId: string | undefined,- covered: { acceptance: boolean; members: boolean; thread: boolean },+ covered: { members: boolean; portal: boolean; thread: boolean },) =>- topic?.channelId === channelId && !covered.thread && !covered.members && !covered.acceptance+ topic?.channelId === channelId && !covered.thread && !covered.members && !covered.portal? topic: null;diff --git a/src/features/Channels/useAcceptancePanel.ts b/src/features/Channels/useAcceptancePanel.tsdeleted file mode 100644index d321747931b..00000000000--- a/src/features/Channels/useAcceptancePanel.ts+++ /dev/null@@ -1,21 +0,0 @@-import { useLayoutEffect } from 'react';--import { isAcceptancePortalView } from '@/features/Home/acceptancePortalView';-import { useChatStore } from '@/store/chat';-import { chatPortalSelectors } from '@/store/chat/selectors';--export const useAcceptancePanelOpen = () =>- useChatStore((s) => isAcceptancePortalView(chatPortalSelectors.currentViewType(s)));--/** Whether a report is open beside this Channel, and how to close it. */-export const useAcceptancePanel = (channelId: string) => {- const open = useAcceptancePanelOpen();- const close = useChatStore((s) => s.clearPortalStack);- // The portal stack is global: a view left open on another page, or by the previous- // Channel, must not appear here.- useLayoutEffect(() => {- close();- return close;- }, [channelId, close]);- return { close, open };-};diff --git a/src/features/Channels/useAcceptancePanel.test.ts b/src/features/Channels/usePortalPanel.test.tssimilarity index 60%rename from src/features/Channels/useAcceptancePanel.test.tsrename to src/features/Channels/usePortalPanel.test.tsindex 4f82fd97c34..2b3d371d699 100644--- a/src/features/Channels/useAcceptancePanel.test.ts+++ b/src/features/Channels/usePortalPanel.test.ts@@ -7,17 +7,17 @@ import { beforeEach, describe, expect, it } from 'vitest';import { useChatStore } from '@/store/chat';import { PortalViewType } from '@/store/chat/slices/portal/initialState';-import { useAcceptancePanel } from './useAcceptancePanel';+import { channelBrowserSessionId, usePortalPanel } from './usePortalPanel';const acceptanceView = { acceptanceId: 'acc_1', type: PortalViewType.Acceptance } as const;-describe('useAcceptancePanel', () => {+describe('usePortalPanel', () => {beforeEach(() => {act(() => useChatStore.setState({ portalStack: [], showPortal: false }));});it('opens when a link pushes an acceptance onto the portal stack', () => {- const { result } = renderHook(() => useAcceptancePanel('chn_1'));+ const { result } = renderHook(() => usePortalPanel('chn_1'));expect(result.current.open).toBe(false);act(() => useChatStore.getState().openAcceptance('acc_1'));@@ -28,13 +28,13 @@ describe('useAcceptancePanel', () => {it('does not reopen a report left on the portal stack by another page', () => {act(() => useChatStore.setState({ portalStack: [acceptanceView], showPortal: true }));- const { result } = renderHook(() => useAcceptancePanel('chn_1'));+ const { result } = renderHook(() => usePortalPanel('chn_1'));expect(result.current.open).toBe(false);});it('closes the report when moving to another Channel', () => {- const { result, rerender } = renderHook(({ id }) => useAcceptancePanel(id), {+ const { result, rerender } = renderHook(({ id }) => usePortalPanel(id), {initialProps: { id: 'chn_1' },});act(() => useChatStore.getState().openAcceptance('acc_1'));@@ -45,11 +45,28 @@ describe('useAcceptancePanel', () => {});it('leaves no report behind after leaving the Channel page', () => {- const { unmount } = renderHook(() => useAcceptancePanel('chn_1'));+ const { unmount } = renderHook(() => usePortalPanel('chn_1'));act(() => useChatStore.getState().openAcceptance('acc_1'));unmount();expect(useChatStore.getState().portalStack).toEqual([]);});++ it('opens a link in the Channel side browser, apart from agent topics', () => {+ const { result } = renderHook(() => usePortalPanel('chn_1'));++ act(() =>+ useChatStore.getState().openBrowser(channelBrowserSessionId('chn_1'), 'https://example.com'),+ );++ expect(result.current.open).toBe(true);+ expect(useChatStore.getState().portalStack).toEqual([+ {+ request: { nonce: expect.any(Number), url: 'https://example.com' },+ sessionId: 'channel:chn_1',+ type: PortalViewType.Browser,+ },+ ]);+ });});diff --git a/src/features/Channels/usePortalPanel.ts b/src/features/Channels/usePortalPanel.tsnew file mode 100644index 00000000000..05a84bb0b8b--- /dev/null+++ b/src/features/Channels/usePortalPanel.ts@@ -0,0 +1,29 @@+import { useLayoutEffect } from 'react';++import { isAcceptancePortalView } from '@/features/Home/acceptancePortalView';+import { useChatStore } from '@/store/chat';+import { chatPortalSelectors } from '@/store/chat/selectors';+import { PortalViewType } from '@/store/chat/slices/portal/initialState';++/** Portal views a Channel shows beside its feed: a linked report, or a page in the side browser. */+export const isChannelPortalView = (viewType: PortalViewType | null) =>+ isAcceptancePortalView(viewType) || viewType === PortalViewType.Browser;++/** Each Channel browses in its own retained page, apart from every agent topic's. */+export const channelBrowserSessionId = (channelId: string) => `channel:${channelId}`;++export const usePortalPanelOpen = () =>+ useChatStore((s) => isChannelPortalView(chatPortalSelectors.currentViewType(s)));++/** Whether a portal view is open beside this Channel, and how to close it. */+export const usePortalPanel = (channelId: string) => {+ const open = usePortalPanelOpen();+ const close = useChatStore((s) => s.clearPortalStack);+ // The portal stack is global: a view left open on another page, or by the previous+ // Channel, must not appear here.+ useLayoutEffect(() => {+ close();+ return close;+ }, [channelId, close]);+ return { close, open };+};diff --git a/src/features/Conversation/WorkingSidebar/Browser/index.tsx b/src/features/Conversation/WorkingSidebar/Browser/index.tsxindex 092e95dd099..7ea6874f14d 100644--- a/src/features/Conversation/WorkingSidebar/Browser/index.tsx+++ b/src/features/Conversation/WorkingSidebar/Browser/index.tsx@@ -163,11 +163,23 @@ interface BrowserPaneProps {agentId?: string;composerTarget: ComposerTarget;onMetadataChange?: (metadata: { faviconUrl?: string; title: string; url: string }) => void;+ /**+ * A host that owns its own open requests (the Portal) passes them here and retires+ * them in `onRequestConsumed`. Without it the pane follows the working sidebar's+ * global request.+ */+ onRequestConsumed?: () => void;+ request?: BrowserOpenRequest | null;sessionId: string;}+export interface BrowserOpenRequest {+ nonce: number;+ url: string;+}+const BrowserPane = memo<BrowserPaneProps>((props) => {- const { agentId, composerTarget, onMetadataChange, sessionId } = props;+ const { agentId, composerTarget, onMetadataChange, onRequestConsumed, sessionId } = props;const { t } = useTranslation('chat');const state = useBrowserSidebarState(sessionId);const [address, setAddress] = useState('');@@ -179,8 +191,10 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {BROWSER_IMPORT_BANNER_DISMISSED_STORAGE_KEY,false,);- const browserRequest = useGlobalStore((s) => s.status.workingSidebarBrowserRequest);+ const globalRequest = useGlobalStore((s) => s.status.workingSidebarBrowserRequest);const clearBrowserTabRequest = useGlobalStore((s) => s.clearBrowserTabRequest);+ const ownsRequest = props.request !== undefined;+ const browserRequest = ownsRequest ? props.request : globalRequest;const consumedNonce = useRef<number>(undefined);const viewportRef = useRef<HTMLDivElement>(null);@@ -343,7 +357,8 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {if (!browserRequest || consumedNonce.current === browserRequest.nonce) return;consumedNonce.current = browserRequest.nonce;openUrl(browserRequest.url);- clearBrowserTabRequest();+ if (ownsRequest) onRequestConsumed?.();+ else clearBrowserTabRequest();// eslint-disable-next-line react-hooks/exhaustive-deps}, [browserRequest?.nonce]);diff --git a/src/features/EntityLink/Render/LinkChip.tsx b/src/features/EntityLink/Render/LinkChip.tsxindex 31704ea6f5e..4bdabd79740 100644--- a/src/features/EntityLink/Render/LinkChip.tsx+++ b/src/features/EntityLink/Render/LinkChip.tsx@@ -8,6 +8,8 @@ import { useTranslation } from 'react-i18next';import { useGlobalStore } from '@/store/global';+import { useEntityLinkSideBrowser } from '../host';+const styles = createStaticStyles(({ css, cssVar }) => ({chip: css`color: ${cssVar.colorLink};@@ -49,13 +51,14 @@ const isWebUrl = (href?: string) => !!href && /^https?:\/\//i.test(href);const LinkChip = memo<LinkChipProps>(({ href, icon, label }) => {const { t } = useTranslation('chat');const openInBrowserTab = useGlobalStore((s) => s.openInBrowserTab);+ const openInHostBrowser = useEntityLinkSideBrowser();const openInSideBrowser = useCallback((event: MouseEvent<HTMLElement>) => {event.preventDefault();- openInBrowserTab(href!);+ (openInHostBrowser ?? openInBrowserTab)(href!);},- [href, openInBrowserTab],+ [href, openInBrowserTab, openInHostBrowser],);const link = (diff --git a/src/features/EntityLink/Render/index.test.tsx b/src/features/EntityLink/Render/index.test.tsxindex 89942896f41..5ffc915c1de 100644--- a/src/features/EntityLink/Render/index.test.tsx+++ b/src/features/EntityLink/Render/index.test.tsx@@ -688,6 +688,36 @@ describe('Link Render β open an external link in the side browser', () => {);});+ it("opens the page in the host's side browser when the host has one", () => {+ mockConst.isDesktop = true;+ const openInHostBrowser = vi.fn();++ const { container } = render(+ <EntityLinkHostProvider portal={['acceptance']} onOpenSideBrowser={openInHostBrowser}>+ <Render+ id="msg-1"+ tagName="lobeLink"+ type="element"+ node={{+ properties: {+ linkDomain: 'localhost',+ linkHref: 'http://localhost:3022/observability/context',+ linkKind: 'generic',+ linkLabel: 'http://localhost:3022/observability/context',+ },+ }}+ >+ {null}+ </Render>+ </EntityLinkHostProvider>,+ );+ fireEvent.click(container.querySelector('[data-side-browser]')!);++ expect(openInHostBrowser).toHaveBeenCalledWith('http://localhost:3022/observability/context');+ // The working sidebar is not on this page; a request left for it would pop it open later.+ expect(mockOpenInBrowserTab).not.toHaveBeenCalled();+ });+it('keeps the action OUTSIDE the anchor, or the preload would swallow its click', () => {mockConst.isDesktop = true;diff --git a/src/features/EntityLink/host.tsx b/src/features/EntityLink/host.tsxindex a4a0a57fd73..58f707c3532 100644--- a/src/features/EntityLink/host.tsx+++ b/src/features/EntityLink/host.tsx@@ -29,14 +29,33 @@ const EntityLinkPortalContext = createContext<EntityLinkPortalScope>(true);*/const EntityLinkDismissContext = createContext<(() => void) | undefined>(undefined);+/**+ * Where a web link's "open in side browser" goes. Unset means the agent working+ * sidebar, which only the conversation mounts; a host with its own side browser+ * (a Channel's portal) routes the page there instead.+ */+const EntityLinkSideBrowserContext = createContext<((url: string) => void) | undefined>(undefined);+export const EntityLinkHostProvider: FC<- PropsWithChildren<{ onDismiss?: () => void; portal: EntityLinkPortalScope }>-> = ({ children, onDismiss, portal }) => (+ PropsWithChildren<{+ onDismiss?: () => void;+ onOpenSideBrowser?: (url: string) => void;+ portal: EntityLinkPortalScope;+ }>+> = ({ children, onDismiss, onOpenSideBrowser, portal }) => (<EntityLinkPortalContext value={portal}>- <EntityLinkDismissContext value={onDismiss}>{children}</EntityLinkDismissContext>+ <EntityLinkDismissContext value={onDismiss}>+ <EntityLinkSideBrowserContext value={onOpenSideBrowser}>+ {children}+ </EntityLinkSideBrowserContext>+ </EntityLinkDismissContext></EntityLinkPortalContext>);+/** The host's side browser opener, when it has one β see {@link EntityLinkHostProvider}. */+export const useEntityLinkSideBrowser = (): ((url: string) => void) | undefined =>+ use(EntityLinkSideBrowserContext);+/** The covering host's close callback, when it has one β see {@link EntityLinkHostProvider}. */export const useEntityLinkHostDismiss = (): (() => void) | undefined =>use(EntityLinkDismissContext);diff --git a/src/features/Portal/Browser/Body.tsx b/src/features/Portal/Browser/Body.tsxnew file mode 100644index 00000000000..57e99c978b1--- /dev/null+++ b/src/features/Portal/Browser/Body.tsx@@ -0,0 +1,38 @@+import { Flexbox } from '@lobehub/ui';+import { lazy, memo, Suspense } from 'react';++import type { ComposerTarget } from '@/features/Conversation/types/composerTarget';+import { useChatStore } from '@/store/chat';+import { chatPortalSelectors } from '@/store/chat/selectors';+import { PortalViewType } from '@/store/chat/slices/portal/initialState';++const BrowserPane = lazy(() => import('@/features/Conversation/WorkingSidebar/Browser'));++// The Portal sits beside a host's own composer, not inside a conversation, so the+// screenshot and element-pick actions have nowhere to send their result.+const NO_COMPOSER: ComposerTarget = { reason: 'no-composer', writable: false };++const Body = memo(() => {+ const view = useChatStore(chatPortalSelectors.browserPortal);+ const replacePortalView = useChatStore((s) => s.replacePortalView);++ if (!view) return null;++ return (+ <Flexbox flex={1} style={{ minHeight: 0 }}>+ <Suspense fallback={null}>+ <BrowserPane+ composerTarget={NO_COMPOSER}+ key={view.sessionId}+ request={view.request ?? null}+ sessionId={view.sessionId}+ onRequestConsumed={() =>+ replacePortalView({ sessionId: view.sessionId, type: PortalViewType.Browser })+ }+ />+ </Suspense>+ </Flexbox>+ );+});++export default Body;diff --git a/src/features/Portal/Browser/Title.tsx b/src/features/Portal/Browser/Title.tsxnew file mode 100644index 00000000000..c5618d5219e--- /dev/null+++ b/src/features/Portal/Browser/Title.tsx@@ -0,0 +1,21 @@+import { Text } from '@lobehub/ui';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useBrowserSidebarState } from '@/features/Conversation/WorkingSidebar/Browser/useBrowserSidebarState';+import { useChatStore } from '@/store/chat';+import { chatPortalSelectors } from '@/store/chat/selectors';++const Title = memo(() => {+ const { t } = useTranslation('chat');+ const sessionId = useChatStore((s) => chatPortalSelectors.browserPortal(s)?.sessionId);+ const { title } = useBrowserSidebarState(sessionId);++ return (+ <Text ellipsis={{ tooltipWhenOverflow: true }} style={{ minWidth: 0 }}>+ {title || t('workingPanel.browser.title')}+ </Text>+ );+});++export default Title;diff --git a/src/features/Portal/Browser/index.ts b/src/features/Portal/Browser/index.tsnew file mode 100644index 00000000000..df3f2c156c5--- /dev/null+++ b/src/features/Portal/Browser/index.ts@@ -0,0 +1,5 @@+import type { PortalImpl } from '../type';+import Body from './Body';+import Title from './Title';++export const Browser: PortalImpl = { Body, Title };diff --git a/src/features/Portal/router.tsx b/src/features/Portal/router.tsxindex da522ecdc59..08b12d647ce 100644--- a/src/features/Portal/router.tsx+++ b/src/features/Portal/router.tsx@@ -10,6 +10,7 @@ import { Acceptance } from './Acceptance';import { AcceptanceCheck } from './AcceptanceCheck';import { AgentDetail } from './AgentDetail';import { Artifacts } from './Artifacts';+import { Browser } from './Browser';import Header from './components/Header';import { PortalMoreMenuProvider } from './components/PortalMoreMenu/context';import { DashboardWidget } from './DashboardWidget';@@ -46,6 +47,7 @@ const VIEW_COMPONENTS: Record<PortalViewType, PortalImpl> = {Title: HomeTitle,},[PortalViewType.Artifact]: Artifacts,+ [PortalViewType.Browser]: Browser,[PortalViewType.DashboardWidget]: DashboardWidget,[PortalViewType.Document]: Document,[PortalViewType.Notebook]: Notebook,diff --git a/src/store/chat/slices/portal/action.ts b/src/store/chat/slices/portal/action.tsindex 8676a5838c0..4b25de29ad9 100644--- a/src/store/chat/slices/portal/action.ts+++ b/src/store/chat/slices/portal/action.ts@@ -686,6 +686,14 @@ export class ChatPortalActionImpl {this.#get().pushPortalView({ acceptanceId, type: PortalViewType.Acceptance });};+ openBrowser = (sessionId: string, url: string): void => {+ this.#get().pushPortalView({+ request: { nonce: Date.now(), url },+ sessionId,+ type: PortalViewType.Browser,+ });+ };+openAcceptanceCheck = (acceptanceId: string, checkId: string): void => {this.#get().pushPortalView({ acceptanceId, checkId, type: PortalViewType.AcceptanceCheck });};diff --git a/src/store/chat/slices/portal/initialState.ts b/src/store/chat/slices/portal/initialState.tsindex 8ffdd2bd1be..5950e751882 100644--- a/src/store/chat/slices/portal/initialState.ts+++ b/src/store/chat/slices/portal/initialState.ts@@ -14,6 +14,7 @@ export enum PortalViewType {AcceptanceCheck = 'acceptanceCheck',AgentDetail = 'agentDetail',Artifact = 'artifact',+ Browser = 'browser',DashboardWidget = 'dashboardWidget',Document = 'document',FilePreview = 'filePreview',@@ -107,6 +108,16 @@ export type PortalViewData =| { acceptanceId: string; checkId: string; type: PortalViewType.AcceptanceCheck }| { agentId: string; type: PortalViewType.AgentDetail }| { artifact: PortalArtifact; type: PortalViewType.Artifact }+ /**+ * The desktop side browser, for hosts without the working sidebar. `sessionId`+ * names the retained guest page; `request` navigates it once and is then dropped,+ * so returning to the view keeps wherever the user browsed to.+ */+ | {+ request?: { nonce: number; url: string };+ sessionId: string;+ type: PortalViewType.Browser;+ }| { runId?: string; type: PortalViewType.DashboardWidget; widgetId: string }| { agentDocumentId?: string; documentId: string; type: PortalViewType.Document }| { type: PortalViewType.Notebook }diff --git a/src/store/chat/slices/portal/selectors.ts b/src/store/chat/slices/portal/selectors.tsindex f93f657ded2..18e82781288 100644--- a/src/store/chat/slices/portal/selectors.ts+++ b/src/store/chat/slices/portal/selectors.ts@@ -316,6 +316,7 @@ const verifyReportRunId = (s: ChatStoreState) => getViewData(s, PortalViewType.Vconst acceptancePortalId = (s: ChatStoreState) =>getViewData(s, PortalViewType.Acceptance)?.acceptanceId;const acceptanceCheckPortal = (s: ChatStoreState) => getViewData(s, PortalViewType.AcceptanceCheck);+const browserPortal = (s: ChatStoreState) => getViewData(s, PortalViewType.Browser);const isPluginUIOpen = (id: string) => (s: ChatStoreState) =>toolMessageId(s) === id && showPortal(s);@@ -419,6 +420,9 @@ export const chatPortalSelectors = {// Acceptance dataacceptanceCheckPortal,acceptancePortalId,++ // Browser data+ browserPortal,};export * from './selectors/thread';