Skip to content

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

TypeScript

fix(desktop): make two renderer paths checkable without changing what they do

Alfredo Lopeze02f0c2ef839
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 0df02e5cc..85f9f33e3 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -1420,16 +1420,23 @@ export function App() {
if (!currentIdentity) return
let stalePending: PendingSandboxUiDeepLink | null = null
const now = Date.now()
- const pending = pendingSandboxUiDeepLinksRef.current.find(item => {
+ // Written as a loop rather than `.find()` because TypeScript's control-flow
+ // analysis does not track assignments made inside a callback: `stalePending`
+ // would narrow to `never` at the read below. The scan keeps `find`'s exact
+ // semantics — it stops at the first eligible entry, so only stale entries
+ // ahead of that entry are captured.
+ let pending: PendingSandboxUiDeepLink | undefined
+ for (const item of pendingSandboxUiDeepLinksRef.current) {
if (isPendingSandboxUiDeepLinkStale(item, currentIdentity)) {
stalePending = item
- return false
+ continue
}
- if (isPendingSandboxUiDeepLinkAwaitingConfirmation(item, currentIdentity)) return false
- if (item.failedMessage) return false
- if (item.nextRetryAt && item.nextRetryAt > now) return false
- return true
- })
+ if (isPendingSandboxUiDeepLinkAwaitingConfirmation(item, currentIdentity)) continue
+ if (item.failedMessage) continue
+ if (item.nextRetryAt && item.nextRetryAt > now) continue
+ pending = item
+ break
+ }
if (stalePending) {
void acknowledgeSandboxUiDeepLink(stalePending.link.id)
return
diff --git a/desktop-app/ui/src/lib/chatMessageSemantics.ts b/desktop-app/ui/src/lib/chatMessageSemantics.ts
index 637ba32c0..53149df6a 100644
--- a/desktop-app/ui/src/lib/chatMessageSemantics.ts
+++ b/desktop-app/ui/src/lib/chatMessageSemantics.ts
@@ -196,7 +196,8 @@ export function findChatSemanticMatches(
if (index < 0) break
const start = folded.starts[index]!
const end = folded.ends[index + needle.length - 1]!
- while (flowFragments[fragmentCursor]?.end <= start) fragmentCursor += 1
+ while (fragmentCursor < flowFragments.length && flowFragments[fragmentCursor]!.end <= start)
+ fragmentCursor += 1
const ranges: Array<{ fragmentId: string; start: number; end: number }> = []
for (
let fragmentIndex = fragmentCursor;