From 00e7da6669e75f510258b2b309c591085a9d1f08 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Thu, 25 Sep 2025 22:26:57 -0700 Subject: [PATCH] fix(node-help): refetch on locale or node change with last-write-wins guard - Watch both currentHelpNode and i18n.locale - Add requestId guard to ignore stale fetches - Keep UX responsive without debounce This eliminates the help locale race and updates content when switching language while help is open. --- src/stores/workspace/nodeHelpStore.ts | 43 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/stores/workspace/nodeHelpStore.ts b/src/stores/workspace/nodeHelpStore.ts index 003c8fa48..3d896891c 100644 --- a/src/stores/workspace/nodeHelpStore.ts +++ b/src/stores/workspace/nodeHelpStore.ts @@ -29,25 +29,32 @@ export const useNodeHelpStore = defineStore('nodeHelp', () => { return getNodeHelpBaseUrl(node) }) - // Watch for help node changes and fetch its docs markdown - watch( - () => currentHelpNode.value, - async (node) => { - helpContent.value = '' - errorMsg.value = null + let lastRequestId = 0 + async function refreshHelp(node: ComfyNodeDefImpl | null, locale: string) { + helpContent.value = '' + errorMsg.value = null - if (node) { - isLoading.value = true - try { - const locale = i18n.global.locale.value || 'en' - helpContent.value = await nodeHelpService.fetchNodeHelp(node, locale) - } catch (e: any) { - errorMsg.value = e.message - helpContent.value = node.description || '' - } finally { - isLoading.value = false - } - } + if (!node) return + + const requestId = ++lastRequestId + isLoading.value = true + try { + const text = await nodeHelpService.fetchNodeHelp(node, locale) + if (requestId !== lastRequestId) return + helpContent.value = text + } catch (e: any) { + if (requestId !== lastRequestId) return + errorMsg.value = e.message + helpContent.value = node.description || '' + } finally { + if (requestId === lastRequestId) isLoading.value = false + } + } + + watch( + () => [currentHelpNode.value, i18n.global.locale.value] as const, + async ([node, locale]) => { + await refreshHelp(node, locale || 'en') }, { immediate: true } )