Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r1-l6 confirm authenticated incoming app links
Josué28426f3b085e
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex 519a17a91..27bd886df 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -214,6 +214,14 @@ describe('App deep-link orchestration', () => {})}+ async function confirmPendingAppLink(): Promise<void> {+ await waitFor(() => expect(confirmDialogHarness.props?.title).toBe('Open app link?'))+ await act(async () => {+ confirmDialogHarness.props?.onConfirm()+ await Promise.resolve()+ })+ }+it('keeps logged-out app links pending until the user confirms after login', async () => {currentController = makeController({initialExperienceLoading: false,@@ -256,6 +264,86 @@ describe('App deep-link orchestration', () => {await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))})+ it('requires confirmation before navigating an authenticated app link', async () => {+ currentController = makeController({ initialExperienceLoading: false })+ listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'ns/app',+ title: 'Linked App',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ },+ ],+ })+ render(<App />)+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app' })+ })++ await waitFor(() => expect(confirmDialogHarness.props?.title).toBe('Open app link?'))+ expect(currentController.handleNavSelect).not.toHaveBeenCalledWith(DESKTOP_ROUTES.apps)+ expect(acknowledgeDeepLink).not.toHaveBeenCalled()++ await confirmPendingAppLink()+ await reportShortcutOpenResult()++ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))+ expect(currentController.handleNavSelect).toHaveBeenCalledWith(DESKTOP_ROUTES.apps)+ })++ it('acknowledges an authenticated app link when confirmation is cancelled', async () => {+ currentController = makeController({ initialExperienceLoading: false })+ render(<App />)+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app' })+ })++ await waitFor(() => expect(confirmDialogHarness.props?.title).toBe('Open app link?'))+ await act(async () => {+ confirmDialogHarness.props?.onCancel()+ await Promise.resolve()+ })++ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))+ expect(currentController.handleNavSelect).not.toHaveBeenCalledWith(DESKTOP_ROUTES.apps)+ expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeUndefined()+ })++ it('does not duplicate an authenticated confirmation for the same link id', async () => {+ currentController = makeController({ initialExperienceLoading: false })+ listApps.mockResolvedValue({+ apps: [+ {+ appRef: 'ns/app',+ title: 'Linked App',+ defaultPath: '/',+ ready: true,+ phase: 'active',+ },+ ],+ })+ render(<App />)+ await waitFor(() => expect(emitDeepLink).not.toBeNull())++ act(() => {+ emitDeepLink?.({ id: 1, appRef: 'ns/app' })+ emitDeepLink?.({ id: 1, appRef: 'ns/app' })+ })++ await confirmPendingAppLink()+ await reportShortcutOpenResult()++ await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))+ expect(acknowledgeDeepLink).toHaveBeenCalledTimes(1)+ expect(currentController.handleNavSelect).toHaveBeenCalledTimes(1)+ })+it('purges user A links synchronously before user B can process them', async () => {const { rerender } = render(<App />)await waitFor(() => expect(emitDeepLink).not.toBeNull())@@ -329,6 +417,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/missing', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))expect(currentController.handleEnsureTeamContext).toHaveBeenNthCalledWith(1, {@@ -367,6 +456,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/missing', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))expect(closeSandboxUi).toHaveBeenCalledOnce()@@ -399,6 +489,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})+ await confirmPendingAppLink()await reportShortcutOpenResult()await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))@@ -437,6 +528,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/missing', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => expect(ensureTeamContext).toHaveBeenCalledTimes(1))liveTeamId = 'team-c'await act(async () => {@@ -471,6 +563,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app' })})+ await confirmPendingAppLink()await reportShortcutOpenResult()await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))@@ -500,6 +593,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app' })})+ await confirmPendingAppLink()await waitFor(() => {expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeGreaterThan(0)@@ -532,6 +626,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app' })})+ await confirmPendingAppLink()await waitFor(() => {expect(currentController.pushToast).toHaveBeenCalledWith(@@ -582,6 +677,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => {expect(currentController.pushToast).toHaveBeenCalledWith(@@ -650,6 +746,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => {expect(currentController.pushToast).toHaveBeenCalledWith(@@ -686,6 +783,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => expect(ensureTeamContext).toHaveBeenCalledTimes(1))await waitFor(() => {@@ -724,6 +822,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app', teamId: 'team-b' })})+ await confirmPendingAppLink()await waitFor(() => expect(acknowledgeDeepLink).toHaveBeenCalledWith(1))expect(ensureTeamContext).toHaveBeenCalledTimes(1)@@ -756,6 +855,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 1, appRef: 'ns/app' })})+ await confirmPendingAppLink()await reportShortcutOpenResult({ status: 'failed', message: 'native mount failed' })expect(acknowledgeDeepLink).not.toHaveBeenCalledWith(1)@@ -763,6 +863,7 @@ describe('App deep-link orchestration', () => {act(() => {emitDeepLink?.({ id: 2, appRef: 'ns/next' })})+ await confirmPendingAppLink()await waitFor(() => {expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeGreaterThan(1)})diff --git a/desktop-app/ui/src/lib/__tests__/sandboxUiDeepLinkState.test.ts b/desktop-app/ui/src/lib/__tests__/sandboxUiDeepLinkState.test.tsindex 54f98fafc..2a12c9736 100644--- a/desktop-app/ui/src/lib/__tests__/sandboxUiDeepLinkState.test.ts+++ b/desktop-app/ui/src/lib/__tests__/sandboxUiDeepLinkState.test.ts@@ -219,6 +219,18 @@ describe('pending sandbox UI deep-link state', () => {expect(isPendingSandboxUiDeepLinkStale(confirmed[0]!, 'user-b')).toBe(true)})+ it('requires confirmation for links received by the authenticated identity', () => {+ const pending = enqueuePendingSandboxUiDeepLink([], { id: 1, appRef: 'ns/app' }, null, 'user-a')++ expect(isPendingSandboxUiDeepLinkAwaitingConfirmation(pending[0]!, 'user-a')).toBe(true)+ expect(isPendingSandboxUiDeepLinkStale(pending[0]!, 'user-a')).toBe(false)++ const confirmed = confirmPendingSandboxUiDeepLink(pending, 1, 'user-a')++ expect(isPendingSandboxUiDeepLinkAwaitingConfirmation(confirmed[0]!, 'user-a')).toBe(false)+ expect(isPendingSandboxUiDeepLinkStale(confirmed[0]!, 'user-b')).toBe(true)+ })+it('treats authenticated queued links as stale after an identity change', () => {const pending = enqueuePendingSandboxUiDeepLink([], { id: 1, appRef: 'ns/app' }, null, 'user-a')diff --git a/desktop-app/ui/src/lib/sandboxUiDeepLinkState.ts b/desktop-app/ui/src/lib/sandboxUiDeepLinkState.tsindex 510f99627..983373fad 100644--- a/desktop-app/ui/src/lib/sandboxUiDeepLinkState.ts+++ b/desktop-app/ui/src/lib/sandboxUiDeepLinkState.ts@@ -42,7 +42,7 @@ export function isPendingSandboxUiDeepLinkAwaitingConfirmation(currentIdentity: string | null): boolean {if (!currentIdentity) return false- return pending.receivedIdentity === null && pending.confirmedIdentity !== currentIdentity+ return pending.confirmedIdentity !== currentIdentity}export function isPendingSandboxUiDeepLinkStale(