Merge pull request #2256 from bashrusakh/fix/issue-2244-todo-event-resilience

fix(sync): route directory-less todo updates
This commit is contained in:
Serhii Dziupin
2026-08-06 18:09:24 +03:00
committed by GitHub
4 changed files with 101 additions and 7 deletions
+15 -3
View File
@@ -697,7 +697,7 @@ const dispatchVSCodeRuntimeNotificationEvent = (directory: string, payload: Even
}))
}
const createEventRoutingIndex = (): EventRoutingIndex => ({
export const createEventRoutingIndex = (): EventRoutingIndex => ({
sessionDirectoryById: new Map(),
messageSessionById: new Map(),
sessionMessageIdsById: new Map(),
@@ -997,8 +997,12 @@ const childStoreHasMessagePartState = (
return Object.prototype.hasOwnProperty.call(getDirectoryEventState(store, batch).part, messageID)
}
const getActiveDirectoryFallback = (childStores: ChildStoreManager): string | null => {
const getActiveDirectoryFallback = (
childStores: ChildStoreManager,
sessionID?: string | null,
): string | null => {
if (!_activeDirectory || !_activeSession) return null
if (sessionID && sessionID !== _activeSession) return null
return childStores.getChild(_activeDirectory) ? _activeDirectory : null
}
@@ -1029,6 +1033,14 @@ const resolveDirectoryFromRoutingIndex = (
if (found) {
return found
}
// The global stream does not always include a directory. During a session
// transition, its routing index can lag the active session briefly; route
// a session-addressed event only when that session is the one being viewed.
const activeDirectory = getActiveDirectoryFallback(childStores, sessionID)
if (activeDirectory) {
return activeDirectory
}
}
const messageID = getMessageIdFromPayload(payload)
@@ -1384,7 +1396,7 @@ async function resyncDirectoryAfterReconnect(
ingestDirectoryStateIntoRoutingIndex(routingIndex, directory, store.getState())
}
function handleEvent(
export function handleEvent(
rawDirectory: string,
payload: Event,
childStores: ChildStoreManager,