Skip to content

Commit 932bf5e

Browse files
committed
fix: preserve inputs when switching task type only if it was text and it goes to a text field
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 8c589fd commit 932bf5e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/components/AssistantTextProcessingForm.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,17 @@ export default {
438438
this.$refs?.translateForm?.setDefaultValues(true)
439439
this.$refs?.assistantFormInputs?.setDefaultValues(true)
440440
441-
// keep last prompt if new task type has text input
442-
if (lastInput && this.selectedTaskType?.inputShape?.input) {
443-
this.myInputs.input = lastInput
444-
}
445-
if (lastInput && this.selectedTaskType?.inputShape?.source_input) {
446-
this.myInputs.source_input = lastInput
447-
}
448-
if (lastInput && this.selectedTaskType?.inputShape?.text) {
449-
this.myInputs.text = lastInput
441+
// keep last prompt if it's a string and if the new task type has text input
442+
if (lastInput && (typeof lastInput === 'string' || lastInput instanceof String)) {
443+
if (this.selectedTaskType?.inputShape?.input && this.selectedTaskType?.inputShape?.input.type === SHAPE_TYPE_NAMES.Text) {
444+
this.myInputs.input = lastInput
445+
}
446+
if (this.selectedTaskType?.inputShape?.source_input && this.selectedTaskType?.inputShape?.source_input.type === SHAPE_TYPE_NAMES.Text) {
447+
this.myInputs.source_input = lastInput
448+
}
449+
if (this.selectedTaskType?.inputShape?.text && this.selectedTaskType?.inputShape?.text.type === SHAPE_TYPE_NAMES.Text) {
450+
this.myInputs.text = lastInput
451+
}
450452
}
451453
},
452454
onSyncSubmit() {

0 commit comments

Comments
 (0)