AIStudio2API
AIStudio2API copied to clipboard
[Bug] CodeDialog.vue crashes with TypeError when switching to interactions protocol after previously selecting an openai-* language
发生了什么 / What happened
Summary
In web/src/playground/CodeDialog.vue:18-24:
const language = ref<string>(props.options[0]!.value)
const option = computed(() => props.options.find((item) => item.value === language.value)!)
const text = computed(() => props.code(option.value.value))
// ...
watch(
() => (open.value ? ([text.value, option.value.highlight] as const) : undefined),
Trigger & Consequence
In web/src/playground/GetCodeDialog.vue:77-81, options filters out openai-* entries when session.settings.protocol === 'interactions'.
- Open
GetCodeDialogundergeminioropenaiprotocol and select anopenai-*language (language.valuebecomes e.g.'openai-python'). - Close the dialog (keeping
CodeDialogmounted), switch protocol tointeractions, and reopen the dialog. props.options.find(...)returnsundefined, sooption.value.value(line20) andoption.value.highlight(line24) throw an uncaughtTypeError: Cannot read properties of undefined, breaking the dialog.
Suggested Fix
Fallback to the first available option when language.value is no longer present in props.options:
const option = computed(
() => props.options.find((item) => item.value === language.value) ?? props.options[0]!,
)
版本 / Version
v0.3.14
每人最多同时打开 3 个 Issue,这个 Issue 已自动关闭。请等已有的 Issue 处理完再提,或把内容补充到已有的 Issue 里。
Each user can have at most 3 open issues at a time, so this one was closed automatically. Please wait until your existing issues are resolved, or add this to one of them.