Skip to content

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

TypeScript

fix(desktop): protect deleted chats and opt-in journeys

Alfredo Lopezb1f72a768ccb
diff --git a/desktop-app/src/__tests__/chatStore.test.ts b/desktop-app/src/__tests__/chatStore.test.ts
index c861d6ae9..870ff8b14 100644
--- a/desktop-app/src/__tests__/chatStore.test.ts
+++ b/desktop-app/src/__tests__/chatStore.test.ts
@@ -1705,6 +1705,18 @@ describe('lastActiveChatId', () => {
const id = await store.getLastActiveChatId('agent-1')
expect(id).toBe('last-1')
})
+
+ it('does not reactivate a deleted chat when a late selection write arrives', async () => {
+ await store.createChat('agent-1', 'retained-1')
+ await store.setLastActiveChatId('agent-1', 'retained-1')
+ await store.createChat('agent-1', 'deleted-1')
+ await store.deleteChat('agent-1', 'deleted-1', TEAM_A_SCOPE)
+
+ await store.setLastActiveChatId('agent-1', 'deleted-1')
+
+ expect(await store.getLastActiveChatId('agent-1')).toBe('retained-1')
+ expect((await store.listChats('agent-1')).map(chat => chat.id)).toEqual(['retained-1'])
+ })
})
// ── onboarding ───────────────────────────────────────────────────────────────
diff --git a/desktop-app/src/chatStore.ts b/desktop-app/src/chatStore.ts
index e8b985e07..f7570a045 100644
--- a/desktop-app/src/chatStore.ts
+++ b/desktop-app/src/chatStore.ts
@@ -1565,6 +1565,7 @@ export class ChatStore {
async setLastActiveChatId(agentRef: string, chatId: string): Promise<void> {
return this.serializeIndex(agentRef, async () => {
const index = await this.getIndex(agentRef)
+ if (this.isDeletedInScope(index, chatId)) return
index.lastActiveChatId = chatId
await this.saveIndex(agentRef, index)
})
diff --git a/desktop-app/test/e2e-playwright/global-setup.ts b/desktop-app/test/e2e-playwright/global-setup.ts
index 95e3d1893..07479223a 100644
--- a/desktop-app/test/e2e-playwright/global-setup.ts
+++ b/desktop-app/test/e2e-playwright/global-setup.ts
@@ -142,7 +142,10 @@ export function validateBaseUrls({
}
}
-function kubectlCurrentContext(expectedContext: string): string {
+function readGlobalKubectlCurrentContext(expectedContext: string): string {
+ // Deliberately strict: `config current-context` reads the global kubeconfig
+ // context even when --context selects another context for object commands.
+ // E2E must refuse to start unless that global context already matches.
return execFileSync('kubectl', ['--context', expectedContext, 'config', 'current-context'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'],
@@ -185,7 +188,7 @@ async function globalSetup(): Promise<void> {
let current: string
try {
- current = kubectlCurrentContext(expected)
+ current = readGlobalKubectlCurrentContext(expected)
} catch (err) {
throw new Error(`[E2E-GUARD] Failed to read kubectl current-context: ${(err as Error).message}`)
}
diff --git a/desktop-app/test/e2e-playwright/human-stateless-continuity.spec.ts b/desktop-app/test/e2e-playwright/human-stateless-continuity.spec.ts
index a2dce3af8..f19d24b63 100644
--- a/desktop-app/test/e2e-playwright/human-stateless-continuity.spec.ts
+++ b/desktop-app/test/e2e-playwright/human-stateless-continuity.spec.ts
@@ -50,8 +50,6 @@ type JourneyMetrics = {
hcc_idle_floor_minutes: number
hcc_drain_grace_ms: number
hcc_heartbeat_poll_ms: number
- first_profile_path: string
- second_profile_path: string
stateful_pod_before: string[]
stateless_pod_before: string[]
stateless_initial_lifecycle_state: string
@@ -369,6 +367,11 @@ async function closeElectron(
return pid
}
+test.skip(
+ process.env.HUMAN_E2E_STATELESS_CONTINUITY !== '1',
+ 'Set HUMAN_E2E_STATELESS_CONTINUITY=1 for this recorded, cluster-mutating journey'
+)
+
test('human journey — two Hosts, restart, cache, and two verified stateless wake episodes', async ({}, testInfo) => {
test.setTimeout(1_800_000)
@@ -403,14 +406,13 @@ test('human journey — two Hosts, restart, cache, and two verified stateless wa
let app: ElectronApplication | undefined
let page: Page | undefined
+ let firstProfilePath = ''
const metrics: JourneyMetrics = {
hcc_idle_minutes: 0,
hcc_idle_floor_minutes: 0,
hcc_drain_grace_ms: 0,
hcc_heartbeat_poll_ms: 0,
- first_profile_path: '',
- second_profile_path: '',
stateful_pod_before: [],
stateless_pod_before: [],
stateless_initial_lifecycle_state: '',
@@ -497,7 +499,7 @@ test('human journey — two Hosts, restart, cache, and two verified stateless wa
const launched = await launchDesktopApp(testInfo)
app = launched.app
page = launched.page
- metrics.first_profile_path = await desktopProfilePath(app)
+ firstProfilePath = await desktopProfilePath(app)
await login(page, desktopCredentials())
await openAgentsPage(page)
await expect(
@@ -576,8 +578,7 @@ test('human journey — two Hosts, restart, cache, and two verified stateless wa
metrics.second_launch_to_window_ms = Date.now() - launchStarted
app = launched.app
page = launched.page
- metrics.second_profile_path = await desktopProfilePath(app)
- expect(metrics.second_profile_path).toBe(metrics.first_profile_path)
+ expect(await desktopProfilePath(app)).toBe(firstProfilePath)
await authenticatedWithoutRelogin(page)
metrics.second_launch_to_authenticated_ms = Date.now() - launchStarted