Skip to content

Commit 91e52ca

Browse files
heavygeeHAPI
andcommitted
revert: remove SSE split-subscription changes that belong to PR tiann#694
The following files were accidentally included from work intended for a separate PR (session-list-status / SSE split subscriptions) due to that branch being submitted from main rather than its own worktree branch: - web/src/App.tsx (reverted to upstream/main) - web/src/hooks/useSSE.ts (reverted to upstream/main) - web/src/hooks/useSSE.test.ts (removed — added by other branch) - web/src/lib/appSseSubscriptions.ts (removed — added by other branch) - web/src/lib/appSseSubscriptions.test.ts (removed — added by other branch) - hub/src/sync/syncEngine.ts (reverted to upstream/main) Apologies for the noise. This PR (tiann#692) is scoped to the pluggable voice backend only. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
1 parent f9a9105 commit 91e52ca

6 files changed

Lines changed: 15 additions & 110 deletions

File tree

hub/src/sync/syncEngine.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ export class SyncEngine {
364364
): Promise<void> {
365365
await this.messageService.sendMessage(sessionId, payload)
366366
this.sessionCache.markMessageQueued(sessionId)
367-
this.sessionCache.recordSessionActivity(sessionId, Date.now())
368367
}
369368

370369
async cancelQueuedMessage(

web/src/App.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { useAppGoBack } from '@/hooks/useAppGoBack'
1919
import { useTranslation } from '@/lib/use-translation'
2020
import { VoiceProvider } from '@/lib/voice-context'
2121
import { requireHubUrlForLogin } from '@/lib/runtime-config'
22-
import { getAppGlobalSseSubscription, getAppSessionSseSubscription } from '@/lib/appSseSubscriptions'
2322
import { LoginPrompt } from '@/components/LoginPrompt'
2423
import { InstallPrompt } from '@/components/InstallPrompt'
2524
import { OfflineBanner } from '@/components/OfflineBanner'
@@ -296,44 +295,28 @@ function AppInner() {
296295
})
297296
}, [addToast, translateIncomingToast])
298297

299-
const globalEventSubscription = useMemo(() => getAppGlobalSseSubscription(), [])
300-
const sessionEventSubscription = useMemo(
301-
() => getAppSessionSseSubscription(selectedSessionId),
302-
[selectedSessionId]
303-
)
304-
const sseEnabled = Boolean(api && token)
298+
const eventSubscription = useMemo(() => {
299+
if (selectedSessionId) {
300+
return { sessionId: selectedSessionId }
301+
}
302+
return { all: true }
303+
}, [selectedSessionId])
305304

306-
const { subscriptionId: globalSubscriptionId } = useSSE({
307-
enabled: sseEnabled,
305+
const { subscriptionId } = useSSE({
306+
enabled: Boolean(api && token),
308307
token: token ?? '',
309308
baseUrl,
310-
subscription: globalEventSubscription,
311-
scope: 'global',
309+
subscription: eventSubscription,
312310
onConnect: handleSseConnect,
313311
onDisconnect: handleSseDisconnect,
314-
onEvent: () => {},
312+
onEvent: handleSseEvent,
315313
onToast: handleToast
316314
})
317315

318-
const { subscriptionId: sessionSubscriptionId } = useSSE({
319-
enabled: sseEnabled && Boolean(sessionEventSubscription),
320-
token: token ?? '',
321-
baseUrl,
322-
subscription: sessionEventSubscription ?? undefined,
323-
scope: 'full',
324-
onEvent: handleSseEvent
325-
})
326-
327-
useVisibilityReporter({
328-
api,
329-
subscriptionId: globalSubscriptionId,
330-
enabled: sseEnabled && !sessionEventSubscription
331-
})
332-
333316
useVisibilityReporter({
334317
api,
335-
subscriptionId: sessionSubscriptionId,
336-
enabled: sseEnabled && Boolean(sessionEventSubscription)
318+
subscriptionId,
319+
enabled: Boolean(api && token)
337320
})
338321

339322
// Loading auth source

web/src/hooks/useSSE.test.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

web/src/hooks/useSSE.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@ type SSESubscription = {
2121
machineId?: string
2222
}
2323

24-
export type SSEScope = 'global' | 'full'
25-
26-
const MESSAGE_STREAM_EVENT_TYPES = new Set<SyncEvent['type']>([
27-
'message-received',
28-
'messages-consumed',
29-
'message-cancelled'
30-
])
31-
32-
export function isGlobalScopedMessageStreamEvent(scope: SSEScope, eventType: SyncEvent['type']): boolean {
33-
return scope === 'global' && MESSAGE_STREAM_EVENT_TYPES.has(eventType)
34-
}
35-
3624
type VisibilityState = 'visible' | 'hidden'
3725

3826
type ToastEvent = Extract<SyncEvent, { type: 'toast' }>
@@ -117,7 +105,6 @@ export function useSSE(options: {
117105
token: string
118106
baseUrl: string
119107
subscription?: SSESubscription
120-
scope?: SSEScope
121108
onEvent: (event: SyncEvent) => void
122109
onConnect?: () => void
123110
onDisconnect?: (reason: string) => void
@@ -164,11 +151,10 @@ export function useSSE(options: {
164151
}, [options.onToast])
165152

166153
const subscription = options.subscription ?? {}
167-
const scope = options.scope ?? 'full'
168154

169155
const subscriptionKey = useMemo(() => {
170-
return `${scope}|${subscription.all ? '1' : '0'}|${subscription.sessionId ?? ''}|${subscription.machineId ?? ''}`
171-
}, [scope, subscription.all, subscription.sessionId, subscription.machineId])
156+
return `${subscription.all ? '1' : '0'}|${subscription.sessionId ?? ''}|${subscription.machineId ?? ''}`
157+
}, [subscription.all, subscription.sessionId, subscription.machineId])
172158

173159
useEffect(() => {
174160
if (!options.enabled) {
@@ -439,14 +425,6 @@ export function useSSE(options: {
439425
return
440426
}
441427

442-
if (scope === 'global' && MESSAGE_STREAM_EVENT_TYPES.has(event.type)) {
443-
if (event.type === 'message-received') {
444-
queueSessionListInvalidation()
445-
}
446-
onEventRef.current(event)
447-
return
448-
}
449-
450428
if (event.type === 'messages-consumed') {
451429
markMessagesConsumed(event.sessionId, event.localIds, event.invokedAt)
452430
}
@@ -597,7 +575,7 @@ export function useSSE(options: {
597575
}
598576
setSubscriptionId(null)
599577
}
600-
}, [options.baseUrl, options.enabled, options.scope, options.token, scope, subscriptionKey, queryClient, reconnectNonce])
578+
}, [options.baseUrl, options.enabled, options.token, subscriptionKey, queryClient, reconnectNonce])
601579

602580
return { subscriptionId }
603581
}

web/src/lib/appSseSubscriptions.test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

web/src/lib/appSseSubscriptions.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)