fix(tui): guard prompt submit against concurrent invocation (#26972)
This commit is contained in:
parent
8030a6c187
commit
74aa735e6a
1 changed files with 115 additions and 0 deletions
|
|
@ -989,7 +989,24 @@ export function Prompt(props: PromptProps) {
|
|||
}
|
||||
})
|
||||
|
||||
let submitting = false
|
||||
async function submit() {
|
||||
// Prevent overlapping invocations (e.g. a double-pressed Enter, or the
|
||||
// input's native onSubmit racing another dispatch). Without this guard,
|
||||
// a second call slips past the empty-input check before the first call
|
||||
// clears `store.prompt.input`, then awaits its own `session.create` and
|
||||
// ultimately reads the now-empty store — sending a phantom empty prompt
|
||||
// to a freshly created session.
|
||||
if (submitting) return false
|
||||
submitting = true
|
||||
try {
|
||||
return await submitInner()
|
||||
} finally {
|
||||
submitting = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitInner() {
|
||||
setWarpNotice(undefined)
|
||||
|
||||
// IME: double-defer may fire before onContentChange flushes the last
|
||||
|
|
|
|||
Loading…
Reference in a new issue