Skip to content

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

TypeScript

fix(desktop): r1-m1 preserve manual team changes during retries

Josuéaa2de789ec87
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.json
index 217be56ab..ade10e944 100644
--- a/desktop-app/package-lock.json
+++ b/desktop-app/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "evenfire",
- "version": "0.1.333",
+ "version": "0.1.334",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "evenfire",
- "version": "0.1.333",
+ "version": "0.1.334",
"license": "MPL-2.0",
"dependencies": {
"@clerum/desktop-app-links": "file:../packages/desktop-app-links",
diff --git a/desktop-app/package.json b/desktop-app/package.json
index bc9ba85c2..700328947 100644
--- a/desktop-app/package.json
+++ b/desktop-app/package.json
@@ -1,7 +1,7 @@
{
"name": "evenfire",
"productName": "Evenfire",
- "version": "0.1.333",
+ "version": "0.1.334",
"private": true,
"license": "MPL-2.0",
"description": "Evenfire desktop client for secure agent and workflow access",
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index c5c9916c2..6d73f5a03 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -80,6 +80,9 @@ const TRANSIENT_TEAM_CONTEXT_ERROR_CODES = new Set([
'UND_ERR_SOCKET',
])
+const SANDBOX_UI_DEEP_LINK_MANUAL_TEAM_CHANGE_MESSAGE =
+ 'App link paused because you switched teams. Retry to open it from the current team, or dismiss it.'
+
function errorMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error || 'Unknown error')
}
@@ -595,9 +598,30 @@ export function App() {
let switchedTeam = Boolean(
restoreTeamId && pending.link.teamId && restoreTeamId !== pending.link.teamId
)
+ const currentTeamId = vm.getCurrentTeamId()
try {
if (processingGeneration !== sandboxUiDeepLinkGenerationRef.current) return
- if (pending.link.teamId && pending.link.teamId !== vm.getCurrentTeamId()) {
+ if (
+ restoreTeamId &&
+ pending.retryCount &&
+ pending.link.teamId &&
+ currentTeamId !== pending.link.teamId
+ ) {
+ sandboxUiDeepLinkRestoreTeamByIdRef.current.delete(pending.link.id)
+ clearSandboxUiDeepLinkProcessing(pending.link.id)
+ const next = failPendingSandboxUiDeepLink(
+ pendingSandboxUiDeepLinksRef.current,
+ pending.link.id,
+ SANDBOX_UI_DEEP_LINK_MANUAL_TEAM_CHANGE_MESSAGE
+ )
+ setPendingSandboxUiDeepLinkState(next)
+ vm.pushToast(
+ `Could not open app link: ${SANDBOX_UI_DEEP_LINK_MANUAL_TEAM_CHANGE_MESSAGE}`,
+ 'error'
+ )
+ return
+ }
+ if (pending.link.teamId && pending.link.teamId !== currentTeamId) {
await closeActiveSandboxUiEmbedForHandoff()
try {
const didSwitchTeam = await vm.handleEnsureTeamContext({
@@ -712,6 +736,7 @@ export function App() {
activeSandboxUiApp,
bootSplashLoading,
closeActiveSandboxUiEmbedForHandoff,
+ clearSandboxUiDeepLinkProcessing,
deferSandboxUiDeepLink,
launchSandboxUiApp,
pendingSandboxUiDeepLinks,
@@ -723,6 +748,7 @@ export function App() {
vm.handleEnsureTeamContext,
vm.isAuthenticated,
vm.pushToast,
+ setPendingSandboxUiDeepLinkState,
])
React.useEffect(() => {
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 27bd886df..3fdd6da14 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -712,6 +712,80 @@ describe('App deep-link orchestration', () => {
expect(ensureTeamContext).toHaveBeenCalledTimes(1)
})
+ it('does not override a manual team switch while a cross-team app link is retrying', async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true })
+ let liveTeamId = 'team-a'
+ const ensureTeamContext = vi.fn(async ({ teamId }: { teamId?: string }) => {
+ if (!teamId || teamId === liveTeamId) return false
+ liveTeamId = teamId
+ return true
+ })
+ currentController = makeController({
+ initialExperienceLoading: false,
+ handleEnsureTeamContext: ensureTeamContext,
+ getCurrentTeamId: () => liveTeamId,
+ })
+ listApps.mockResolvedValue({
+ apps: [
+ {
+ appRef: 'ns/app',
+ title: 'Linked App',
+ defaultPath: '/',
+ ready: false,
+ phase: 'deploying',
+ },
+ ],
+ })
+ render(<App />)
+ await waitFor(() => expect(emitDeepLink).not.toBeNull())
+
+ act(() => {
+ emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })
+ })
+ await confirmPendingAppLink()
+
+ await waitFor(() => {
+ expect(currentController.pushToast).toHaveBeenCalledWith(
+ 'Linked App is still starting up. This link will retry shortly.',
+ 'info'
+ )
+ })
+ expect(liveTeamId).toBe('team-b')
+ expect(ensureTeamContext).toHaveBeenCalledTimes(1)
+
+ liveTeamId = 'team-c'
+ await act(async () => {
+ vi.advanceTimersByTime(1_000)
+ await Promise.resolve()
+ })
+
+ await waitFor(() => expect(currentController.pushToast).toHaveBeenCalledTimes(2))
+ const retryNoise = currentController.pushToast.mock.calls.filter(
+ ([message, tone]) =>
+ message === 'Linked App is still starting up. This link will retry shortly.' &&
+ tone === 'info'
+ )
+ expect(retryNoise).toHaveLength(1)
+ expect(currentController.pushToast).toHaveBeenCalledWith(
+ expect.stringContaining('you switched teams'),
+ 'error'
+ )
+ expect(confirmDialogHarness.props?.title).toBe('App link could not be opened')
+ expect(liveTeamId).toBe('team-c')
+ expect(ensureTeamContext).toHaveBeenCalledTimes(1)
+ expect(currentController.handleNavSelect).not.toHaveBeenCalledWith(DESKTOP_ROUTES.apps)
+ expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeUndefined()
+ expect(acknowledgeDeepLink).not.toHaveBeenCalled()
+
+ await act(async () => {
+ vi.advanceTimersByTime(60_000)
+ await Promise.resolve()
+ })
+ expect(liveTeamId).toBe('team-c')
+ expect(ensureTeamContext).toHaveBeenCalledTimes(1)
+ expect(acknowledgeDeepLink).not.toHaveBeenCalled()
+ })
+
it('retries a transient team-context failure and opens without duplicate mounts', async () => {
vi.useFakeTimers({ shouldAdvanceTime: true })
let liveTeamId = 'team-a'