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.
This commit is contained in:
Benjamin Lu
2025-09-25 22:26:57 -07:00
parent 3ee0d394ca
commit 00e7da6669

View File

@@ -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 }
)