Compare commits

..

1 Commits

Author SHA1 Message Date
CodeRabbit Fixer
2d84899656 fix: refactor(litegraph): localize hardcoded 'Value' prompt titles in NumberWidget.ts via vue-i18n (#9389)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 16:08:13 +01:00
4 changed files with 5 additions and 64 deletions

View File

@@ -121,68 +121,6 @@ describe('resolveSubgraphInputLink', () => {
expect(result).toBe('seed_input')
})
test('skips broken links where getLink returns undefined', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'valid_input', 'valid')
const broken = addLinkedInteriorInput(
subgraph,
'prompt',
'broken_input',
'broken'
)
const originalGetLink = subgraph.getLink.bind(subgraph)
vi.spyOn(subgraph, 'getLink').mockImplementation((linkId) => {
if (typeof linkId !== 'number') return originalGetLink(linkId)
if (linkId === broken.linkId) return undefined
return originalGetLink(linkId)
})
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => targetInput.name
)
expect(result).toBe('valid_input')
})
test('returns result from latest connection when multiple links resolve', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'older_input', 'older')
addLinkedInteriorInput(subgraph, 'prompt', 'newer_input', 'newer')
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => targetInput.name
)
expect(result).toBe('newer_input')
})
test('falls back to earlier link when latest resolve callback returns undefined', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('prompt')
addLinkedInteriorInput(subgraph, 'prompt', 'fallback_input', 'fallback')
const newer = addLinkedInteriorInput(
subgraph,
'prompt',
'skipped_input',
'skipped'
)
const result = resolveSubgraphInputLink(
subgraphNode,
'prompt',
({ targetInput }) => {
if (targetInput.link === newer.linkId) return undefined
return targetInput.name
}
)
expect(result).toBe('fallback_input')
})
test('caches getTargetWidget result within the same callback evaluation', () => {
const { subgraph, subgraphNode } = createSubgraphSetup('model')
const linked = addLinkedInteriorInput(

View File

@@ -1,3 +1,4 @@
import { t } from '@/i18n'
import type { INumericWidget } from '@/lib/litegraph/src/types/widgets'
import { evaluateInput, getWidgetStep } from '@/lib/litegraph/src/utils/widget'
@@ -65,7 +66,7 @@ export class NumberWidget
// Handle center click - show prompt
canvas.prompt(
'Value',
t('widgets.valuePromptTitle'),
this.value,
(v: string) => {
const parsed = evaluateInput(v)

View File

@@ -1,3 +1,4 @@
import { t } from '@/i18n'
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { IStringWidget } from '@/lib/litegraph/src/types/widgets'
@@ -40,7 +41,7 @@ export class TextWidget
override onClick({ e, node, canvas }: WidgetEventOptions) {
// Show prompt dialog for text input
canvas.prompt(
'Value',
t('widgets.valuePromptTitle'),
this.value,
(v: string) => {
if (v !== null) {

View File

@@ -2545,6 +2545,7 @@
},
"node2only": "Node 2.0 only",
"selectModel": "Select model",
"valuePromptTitle": "Value",
"uploadSelect": {
"placeholder": "Select...",
"placeholderImage": "Select image...",