Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(desktop): remove back-to-conversation mechanism

Diego Zacariasb38b9d3c2004
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 0bda41b5f..93039a7ed 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -323,7 +323,7 @@ export function App() {
const [sandboxLocalSearchRequestId, setSandboxLocalSearchRequestId] = React.useState(0)
const [sandboxActionRequest, setSandboxActionRequest] = React.useState<{
id: number
- action: 'refresh' | 'back-to-apps' | 'back-to-conversation'
+ action: 'refresh' | 'back-to-apps'
} | null>(null)
const [commandPaletteOpen, setCommandPaletteOpen] = React.useState(false)
const [commandPaletteReturnToSandbox, setCommandPaletteReturnToSandbox] = React.useState(false)
@@ -811,47 +811,6 @@ export function App() {
setSidebarSettingsMenuOpen(false)
}, [])
- const handleSandboxUiBackToConversation = React.useCallback(async () => {
- if (!sandboxUiConversationOrigin) return
- const origin = sandboxUiConversationOrigin
- let refreshWarning: string | null = null
- try {
- if (origin.teamId && origin.teamId !== vm.getCurrentTeamId()) {
- await vm.handleEnsureTeamContext({ teamId: origin.teamId })
- }
- } catch (err) {
- const message = err instanceof Error ? err.message : String(err)
- if (!origin.teamId || vm.getCurrentTeamId() !== origin.teamId) {
- vm.pushToast(`Could not return to the conversation: ${message}`, 'error')
- throw err
- }
- // The authoritative switch completed but its follow-up refresh failed.
- // Keep the page aligned with the live team and surface the refresh problem.
- refreshWarning = message
- }
- setActiveSandboxUiApp(null)
- setSandboxUiConversationOrigin(null)
- setHeaderShellOverlayOpen(false)
- setSidebarSettingsMenuOpen(false)
- vm.handleSelectChatAgent(origin.agentName, {
- selectLatest: false,
- chatId: origin.chatId,
- title: origin.title,
- })
- if (refreshWarning) {
- vm.pushToast(
- `Returned to the conversation, but team data did not refresh: ${refreshWarning}`,
- 'warn'
- )
- }
- }, [
- sandboxUiConversationOrigin,
- vm.getCurrentTeamId,
- vm.handleEnsureTeamContext,
- vm.handleSelectChatAgent,
- vm.pushToast,
- ])
-
React.useEffect(() => {
setNotificationDrawerReady(false)
}, [activeSandboxUiApp?.appRef, headerNotificationTrayOpen])
@@ -1362,18 +1321,12 @@ export function App() {
vm.hostRuntimeStatus?.degraded?.reason !== 'llm_key_missing',
appMounted:
vm.navItem === DESKTOP_ROUTES.apps && Boolean(activeSandboxUiApp) && sandboxUiMounted,
- conversationOriginAvailable:
- vm.navItem === DESKTOP_ROUTES.apps &&
- Boolean(activeSandboxUiApp) &&
- sandboxUiMounted &&
- Boolean(sandboxUiConversationOrigin),
applicationBusy: vm.busy,
}),
[
activeSandboxUiApp,
chatDrawerVisible,
chatViewTabs,
- sandboxUiConversationOrigin,
sandboxUiMounted,
vm.activeChatId,
vm.busy,
@@ -1479,17 +1432,8 @@ export function App() {
setSidebarToggleRequestId(value => value + 1)
return
}
- if (
- commandId === 'app.refresh' ||
- commandId === 'app.backToApps' ||
- commandId === 'app.backToConversation'
- ) {
- const action =
- commandId === 'app.refresh'
- ? 'refresh'
- : commandId === 'app.backToApps'
- ? 'back-to-apps'
- : 'back-to-conversation'
+ if (commandId === 'app.refresh' || commandId === 'app.backToApps') {
+ const action = commandId === 'app.refresh' ? 'refresh' : 'back-to-apps'
setSandboxActionRequest(previous => ({ id: (previous?.id ?? 0) + 1, action }))
return
}
@@ -2154,7 +2098,6 @@ export function App() {
chatDrawerOpen={chatDrawerVisible}
titlebarLeadingContainer={titlebarLeadingRoot}
onToggleChatDrawer={toggleChatDrawer}
- onBackToConversation={handleSandboxUiBackToConversation}
onEmbeddedAppOpening={handleSandboxUiOpening}
onEmbeddedAppMounted={handleSandboxUiMounted}
onEmbeddedAppBack={handleSandboxUiClosed}
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 1b4013c6a..53ccf47a5 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -57,7 +57,7 @@ const sandboxUiPageHarness = vi.hoisted(() => ({
localSearchRequestId?: number
actionRequest?: {
id: number
- action: 'refresh' | 'back-to-apps' | 'back-to-conversation'
+ action: 'refresh' | 'back-to-apps'
} | null
onEmbeddedAppOpening?: (app: {
appRef: string
@@ -599,7 +599,6 @@ describe('App deep-link orchestration', () => {
expect(sandboxUiPageHarness.props?.actionRequest).toEqual({ id: 1, action: 'refresh' })
act(() => commandPaletteHarness.props?.onExecute('app.backToApps'))
expect(sandboxUiPageHarness.props?.actionRequest).toEqual({ id: 2, action: 'back-to-apps' })
- expect(commandPaletteHarness.props?.isEligible('app.backToConversation')).toBe(false)
})
it('resets controlled command requests with the authenticated shell lifetime', async () => {
@@ -1024,6 +1023,38 @@ describe('App deep-link orchestration', () => {
)
})
+ // Guard for conversationOrigin use (3): retiring back-to-conversation must not
+ // touch the deep-link team restore, which re-selects the originating chat after
+ // rolling a failed cross-team link back to the original team. Passes before and
+ // after the retirement.
+ it('re-selects the originating chat when a failed cross-team link rolls the team back', async () => {
+ currentController = makeController({
+ initialExperienceLoading: false,
+ navItem: DESKTOP_ROUTES.chat,
+ selectedAgent: 'alpha',
+ activeChatId: 'chat-1',
+ } as Partial<AppController>)
+ render(<App />)
+ await waitFor(() => expect(emitDeepLink).not.toBeNull())
+
+ act(() => {
+ emitDeepLink?.({ id: 1, appRef: 'ns/missing', teamId: 'team-b' })
+ })
+ await confirmPendingAppLink()
+
+ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))
+ // Team rolled back to the original, then the origin chat re-selected.
+ expect(currentController.handleEnsureTeamContext).toHaveBeenNthCalledWith(2, {
+ teamId: 'team-a',
+ announce: true,
+ })
+ expect(currentController.handleSelectChatAgent).toHaveBeenCalledWith('alpha', {
+ selectLatest: false,
+ chatId: 'chat-1',
+ title: 'Conversation',
+ })
+ })
+
it('closes the active embed before switching teams for a failed cross-team handoff', async () => {
const ensureTeamContext = vi.fn(async (): Promise<boolean> => true)
currentController = makeController({
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/chatSelectionAcrossRouteChange.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/chatSelectionAcrossRouteChange.test.tsx
index 470ba685a..e8933e49e 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/chatSelectionAcrossRouteChange.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/chatSelectionAcrossRouteChange.test.tsx
@@ -14,9 +14,9 @@
* `switchToChat` fast path while already on the chat route; from any other route
* it must go through the pending-selection path, which survives the re-run. The
* two affected entry points are the sidebar session list
- * (`SidebarNav` -> `onSelectChatAgent`) and "back to conversation"
- * (`App.handleSandboxUiBackToConversation`); both funnel through the same
- * selector, so these tests pin the mechanism both rely on.
+ * (`SidebarNav` -> `onSelectChatAgent`) and the deep-link team restore that
+ * re-selects the originating chat (`App.restoreSandboxUiDeepLinkTeam`); both
+ * funnel through the same selector, so these tests pin the mechanism both rely on.
*/
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { act, waitFor } from '@testing-library/react'
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsx
index 6e73ea498..330850e4a 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx
+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx
@@ -4,13 +4,7 @@ import { IconButton, StatusBanner } from '@components/Common'
import { joinClasses } from '@lib/classNames'
import SandboxCurrentContentSearch from '../components/SandboxCurrentContentSearch'
import type { AppFindState } from '../components/SandboxCurrentContentSearch/types'
-import {
- IconChat,
- IconChevronLeft,
- IconCopy,
- IconRefresh,
- IconSandboxUi,
-} from '../components/SidebarNav/icons'
+import { IconChat, IconCopy, IconRefresh, IconSandboxUi } from '../components/SidebarNav/icons'
import { clickableRowProps } from '../lib/clickableRowProps'
import type { SandboxUiAppListing } from '../lib/sandboxUiAppSelection.types'
import type {
@@ -222,7 +216,6 @@ export function SandboxUiPage({
chatDrawerOpen = false,
titlebarLeadingContainer = null,
onToggleChatDrawer,
- onBackToConversation,
onEmbeddedAppOpening,
onEmbeddedAppMounted,
onEmbeddedAppBack,
@@ -496,17 +489,6 @@ export function SandboxUiPage({
onEmbeddedAppBack?.()
}, [closeEmbed, onEmbeddedAppBack])
- const handleBackToConversation = useCallback(async () => {
- if (!conversationOrigin || !onBackToConversation) return
- try {
- await onBackToConversation()
- await closeEmbed()
- } catch {
- // The owner keeps the embedded app open and reports the failed team or
- // conversation transition without leaving the two views inconsistent.
- }
- }, [closeEmbed, conversationOrigin, onBackToConversation])
-
// In-place hard-reload of the embedded app — fetches freshly-arrived
// server data (e.g. new inbox items) without tearing the view down, so the
// user no longer has to navigate away and back to see updates.
@@ -522,10 +504,8 @@ export function SandboxUiPage({
onRefresh()
} else if (actionRequest.action === 'back-to-apps') {
void onBackToApps()
- } else {
- void handleBackToConversation()
}
- }, [actionRequest, handleBackToConversation, launch.kind, onBackToApps, onRefresh])
+ }, [actionRequest, launch.kind, onBackToApps, onRefresh])
const onCopyDeepLink = useCallback(async () => {
try {
@@ -624,8 +604,7 @@ export function SandboxUiPage({
// the wrapper unconditionally would inject an empty <div> into the shared
// title bar. Only portal when at least one control will render.
const hasLeadingActions =
- launch.kind === 'mounted' ||
- Boolean(conversationOrigin && (onToggleChatDrawer || onBackToConversation))
+ launch.kind === 'mounted' || Boolean(conversationOrigin && onToggleChatDrawer)
return (
<section className="page" data-testid="sandbox-ui-mounted">
{/* App actions live in the native title bar's leading slot (icon-only,
@@ -637,28 +616,18 @@ export function SandboxUiPage({
hasLeadingActions &&
createPortal(
<div className="window-titlebar__leading-actions">
- {conversationOrigin && (onToggleChatDrawer || onBackToConversation) ? (
+ {conversationOrigin && onToggleChatDrawer ? (
// The originating conversation lives in the drawer beside the
- // live embed now, so when a drawer toggle is wired this control
- // opens/closes that drawer (chat icon, open/close label). When
- // no toggle is wired it falls back to the destroy-and-reconstitute
- // "back to conversation" path (chevron, "Back to {title}"; also
- // reachable via the app.backToConversation command).
+ // live embed, so this control opens/closes that drawer (chat
+ // icon, open/close label). The conversation-origin variant keeps
+ // its own class so the toggle can later move to the app header.
<TitlebarLeadingAction
className="sandbox-ui-conversation-btn"
- label={
- onToggleChatDrawer
- ? chatDrawerOpen
- ? 'Close chat drawer'
- : 'Open chat drawer'
- : `Back to ${conversationOrigin.title}`
- }
- pressed={onToggleChatDrawer ? chatDrawerOpen : undefined}
- onClick={
- onToggleChatDrawer ? onToggleChatDrawer : () => void handleBackToConversation()
- }
+ label={chatDrawerOpen ? 'Close chat drawer' : 'Open chat drawer'}
+ pressed={chatDrawerOpen}
+ onClick={onToggleChatDrawer}
>
- {onToggleChatDrawer ? <IconChat /> : <IconChevronLeft />}
+ <IconChat />
</TitlebarLeadingAction>
) : null}
{launch.kind === 'mounted' && onToggleChatDrawer && !conversationOrigin && (
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.types.ts b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
index d535b29b5..406ffc91f 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.types.ts
+++ b/desktop-app/ui/src/pages/SandboxUiPage.types.ts
@@ -18,7 +18,7 @@ export type SandboxUiShortcutOpenResult =
export type SandboxUiPageProps = {
actionRequest?: {
id: number
- action: 'refresh' | 'back-to-apps' | 'back-to-conversation'
+ action: 'refresh' | 'back-to-apps'
} | null
boundsRefreshKey?: string | number
conversationOrigin?: SandboxUiConversationOrigin | null
@@ -33,7 +33,6 @@ export type SandboxUiPageProps = {
chatDrawerOpen?: boolean
titlebarLeadingContainer?: HTMLElement | null
onToggleChatDrawer?: () => void
- onBackToConversation?: () => void | Promise<void>
onEmbeddedAppOpening?: (app: ActiveSandboxUiApp) => void
onEmbeddedAppMounted?: () => void
onEmbeddedAppBack?: () => void
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index ba301b9e1..2febce067 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -373,38 +373,6 @@ describe('SandboxUiPage', () => {
expect(sandboxUi.reload).not.toHaveBeenCalled()
})
- it('routes controlled conversation return through the existing transition owner', async () => {
- sandboxUi.listApps.mockResolvedValue({
- apps: [
- {
- appRef: 'sandbox-recipes/sales-crm',
- title: 'Sales CRM',
- defaultPath: '/',
- ready: true,
- phase: 'active',
- updatedAt: null,
- },
- ],
- })
- sandboxUi.open.mockResolvedValue(undefined)
- sandboxUi.close.mockResolvedValue(undefined)
- const onBackToConversation = vi.fn().mockResolvedValue(undefined)
- const props = {
- conversationOrigin: { agentName: 'agent', chatId: 'chat', title: 'Conversation' },
- onBackToConversation,
- }
- const { rerender } = render(<SandboxUiPage {...props} actionRequest={null} />)
- fireEvent.click(await screen.findByRole('button', { name: 'Open Sales CRM' }))
- await screen.findByRole('button', { name: 'Refresh app content' })
-
- rerender(<SandboxUiPage {...props} actionRequest={{ id: 1, action: 'back-to-conversation' }} />)
-
- await waitFor(() => {
- expect(onBackToConversation).toHaveBeenCalledOnce()
- expect(sandboxUi.close).toHaveBeenCalledOnce()
- })
- })
-
it('runs contextual find only against the mounted active WebContents contract', async () => {
sandboxUi.listApps.mockResolvedValueOnce({
apps: [
@@ -624,81 +592,7 @@ describe('SandboxUiPage', () => {
})
})
- it('returns to the originating conversation from an app', async () => {
- sandboxUi.listApps.mockResolvedValueOnce({
- apps: [
- {
- appRef: 'sandbox-recipes/sales-crm',
- title: "Andy's Sales CRM",
- defaultPath: '/',
- ready: true,
- phase: 'active',
- updatedAt: null,
- },
- ],
- })
- sandboxUi.open.mockResolvedValueOnce(undefined)
- sandboxUi.close.mockResolvedValueOnce(undefined)
- const onBackToConversation = vi.fn()
-
- render(
- <SandboxUiPage
- conversationOrigin={{
- agentName: 'sales-agent',
- chatId: 'chat-123',
- title: 'Quarterly planning',
- }}
- onBackToConversation={onBackToConversation}
- />
- )
-
- fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- fireEvent.click(await screen.findByRole('button', { name: 'Back to Quarterly planning' }))
-
- await waitFor(() => {
- expect(sandboxUi.close).toHaveBeenCalledTimes(1)
- expect(onBackToConversation).toHaveBeenCalledTimes(1)
- })
- })
-
- it('keeps a long conversation return label available to assistive technology and the native title tooltip', async () => {
- const title =
- 'A deliberately long conversation title that must remain available to assistive technology'
- sandboxUi.listApps.mockResolvedValueOnce({
- apps: [
- {
- appRef: 'sandbox-recipes/sales-crm',
- title: "Andy's Sales CRM",
- defaultPath: '/',
- ready: true,
- phase: 'active',
- updatedAt: null,
- },
- ],
- })
- sandboxUi.open.mockResolvedValueOnce(undefined)
-
- render(
- <SandboxUiPage
- conversationOrigin={{ agentName: 'sales-agent', chatId: 'chat-123', title }}
- onBackToConversation={vi.fn()}
- />
- )
-
- fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- // Icon-only control with no drawer toggle wired: it falls back to the
- // back-to-conversation path (chevron icon, "Back to {title}" label). The full
- // label is both the accessible name and the native `title` — the native title
- // is the only tooltip that can render over the native app WebContentsView,
- // which always paints above the renderer DOM. There is no DOM flyout.
- const button = await screen.findByRole('button', { name: `Back to ${title}` })
-
- expect(button.getAttribute('title')).toBe(`Back to ${title}`)
- expect(button.closest('.titlebar-leading-action')?.querySelector('[role="tooltip"]')).toBeNull()
- expect(button.querySelector('svg path')?.getAttribute('d')).toBe('m15 18-6-6 6-6')
- })
-
- it('shows a chat-drawer toggle (not a back button) when a conversation origin has a drawer toggle wired', async () => {
+ it('shows a chat-drawer toggle when a conversation origin has a drawer toggle wired', async () => {
sandboxUi.listApps.mockResolvedValueOnce({
apps: [
{
@@ -713,7 +607,6 @@ describe('SandboxUiPage', () => {
})
sandboxUi.open.mockResolvedValueOnce(undefined)
const onToggleChatDrawer = vi.fn()
- const onBackToConversation = vi.fn()
render(
<SandboxUiPage
@@ -724,16 +617,14 @@ describe('SandboxUiPage', () => {
}}
chatDrawerOpen={false}
onToggleChatDrawer={onToggleChatDrawer}
- onBackToConversation={onBackToConversation}
/>
)
fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- // With a drawer toggle wired the originating conversation lives in the drawer,
- // so this control opens/closes the drawer — it must NOT be labeled "Back to
- // {title}" (the bug) nor fall back to destroying the embed. Chat icon, native
- // title = the open/close label, and it drives the toggle only.
+ // With a conversation origin the leading control opens/closes the chat drawer
+ // where that conversation lives. Chat icon, native title = the open/close
+ // label, and it drives the toggle only — never a destroy-and-reconstitute.
const toggle = await screen.findByRole('button', { name: 'Open chat drawer' })
expect(screen.queryByRole('button', { name: 'Back to Quarterly planning' })).toBeNull()
expect(toggle.getAttribute('title')).toBe('Open chat drawer')
@@ -744,47 +635,9 @@ describe('SandboxUiPage', () => {
fireEvent.click(toggle)
expect(onToggleChatDrawer).toHaveBeenCalledTimes(1)
- expect(onBackToConversation).not.toHaveBeenCalled()
expect(sandboxUi.close).not.toHaveBeenCalled()
})
- it('keeps the app mounted when returning to the conversation fails', async () => {
- sandboxUi.listApps.mockResolvedValueOnce({
- apps: [
- {
- appRef: 'sandbox-recipes/sales-crm',
- title: "Andy's Sales CRM",
- defaultPath: '/',
- ready: true,
- phase: 'active',
- updatedAt: null,
- },
- ],
- })
- sandboxUi.open.mockResolvedValueOnce(undefined)
- const onBackToConversation = vi.fn().mockRejectedValue(new Error('team switch failed'))
-
- render(
- <SandboxUiPage
- conversationOrigin={{
- agentName: 'sales-agent',
- chatId: 'chat-123',
- title: 'Quarterly planning',
- teamId: 'team-b',
- }}
- onBackToConversation={onBackToConversation}
- />
- )
-
- fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
- fireEvent.click(await screen.findByRole('button', { name: 'Back to Quarterly planning' }))
-
- await waitFor(() => expect(onBackToConversation).toHaveBeenCalledOnce())
- expect(sandboxUi.close).not.toHaveBeenCalled()
- // Still mounted (not returned to the picker) — the embed chrome is present.
- expect(screen.getByTestId('sandbox-ui-mounted')).toBeTruthy()
- })
-
it('keeps the conversation origin during Strict Mode effect replay', async () => {
sandboxUi.listApps.mockResolvedValue({
apps: [
@@ -799,7 +652,7 @@ describe('SandboxUiPage', () => {
],
})
sandboxUi.open.mockResolvedValueOnce(undefined)
- const onBackToConversation = vi.fn()
+ const onToggleChatDrawer = vi.fn()
const onEmbeddedAppBack = vi.fn()
render(
@@ -810,7 +663,7 @@ describe('SandboxUiPage', () => {
chatId: 'chat-123',
title: 'Plan the launch',
}}
- onBackToConversation={onBackToConversation}
+ onToggleChatDrawer={onToggleChatDrawer}
onEmbeddedAppBack={onEmbeddedAppBack}
/>
</React.StrictMode>
@@ -818,7 +671,9 @@ describe('SandboxUiPage', () => {
fireEvent.click(await screen.findByRole('button', { name: 'Open Agentic Task Board' }))
- expect(await screen.findByRole('button', { name: 'Back to Plan the launch' })).toBeTruthy()
+ // The conversation-origin leading control survives the double-invoke without
+ // tearing the embed down.
+ expect(await screen.findByRole('button', { name: 'Open chat drawer' })).toBeTruthy()
expect(onEmbeddedAppBack).not.toHaveBeenCalled()
})