diff --git a/src/renderer/src/components/tasks/OutputFieldsDisplay.test.tsx b/src/renderer/src/components/tasks/OutputFieldsDisplay.test.tsx index a4410ac..e658f1b 100644 --- a/src/renderer/src/components/tasks/OutputFieldsDisplay.test.tsx +++ b/src/renderer/src/components/tasks/OutputFieldsDisplay.test.tsx @@ -122,4 +122,24 @@ describe('OutputFieldsDisplay', () => { expect(screen.getByText('Complete Task')).toBeInTheDocument() }) + + it('renders malformed legacy output fields without crashing', () => { + render( + + ) + + expect(screen.getByDisplayValue('https://example.com/pr/123')).toBeInTheDocument() + expect(screen.getByText('pr url')).toBeInTheDocument() + expect(screen.getByPlaceholderText('Enter pr url...')).toBeInTheDocument() + }) }) diff --git a/src/renderer/src/components/tasks/OutputFieldsDisplay.tsx b/src/renderer/src/components/tasks/OutputFieldsDisplay.tsx index bf516b9..1fd9434 100644 --- a/src/renderer/src/components/tasks/OutputFieldsDisplay.tsx +++ b/src/renderer/src/components/tasks/OutputFieldsDisplay.tsx @@ -9,6 +9,12 @@ import { Label } from '@/components/ui/Label' import { shellApi } from '@/lib/ipc-client' import type { OutputField } from '@/types' +function getFieldLabel(field: OutputField): string { + if (typeof field.name === 'string' && field.name.trim()) return field.name + if (typeof field.id === 'string' && field.id.trim()) return field.id.replace(/_/g, ' ') + return 'Output' +} + function isFieldFilled(field: OutputField): boolean { const v = field.value if (v === null || v === undefined) return false @@ -68,6 +74,7 @@ export function OutputFieldsDisplay({ fields, onChange, isActive, onComplete, ta function OutputFieldInput({ field, onValueChange, taskUpdatedAt }: { field: OutputField; onValueChange: (value: unknown) => void; taskUpdatedAt?: string }) { const [localValue, setLocalValue] = useState(String(field.value ?? '')) + const fieldLabel = getFieldLabel(field) // Sync local state when field.value changes externally (e.g. agent extraction) useEffect(() => { @@ -84,13 +91,13 @@ function OutputFieldInput({ field, onValueChange, taskUpdatedAt }: { field: Outp return (