Skip to content

fix: optimize chat ID retrieval to prevent multiple concurrent requests - #6581

Merged
wxg0103 merged 1 commit into
v2from
pr@v2@fix_file
Aug 4, 2026
Merged

fix: optimize chat ID retrieval to prevent multiple concurrent requests#6581
wxg0103 merged 1 commit into
v2from
pr@v2@fix_file

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: optimize chat ID retrieval to prevent multiple concurrent requests

Copilot AI lite review requested due to automatic review settings August 4, 2026 10:04
@shaohuzhang1

Copy link
Copy Markdown
Contributor Author

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce duplicate “open chat” (openChatId) requests by deduplicating chat-id retrieval when multiple file uploads start concurrently in the AI chat input component.

Changes:

  • Add an in-flight chatIdPromise cache to reuse the same openChatId() request across concurrent uploadFile calls.
  • Reset the cached promise when the request completes (success or failure) via .finally().
Suppressed comments (1)

ui/src/components/ai-chat/component/chat-input-operate/index.vue:558

  • This promise dedupe only applies within uploadFile in this component. Other call sites can still trigger concurrent openChatId() requests (e.g. chat send path in ui/src/components/ai-chat/index.vue), so multiple /open requests and a last-writer-wins chat-id race are still possible. Consider moving the memoization into the openChatId implementation (parent) so all call sites share the same in-flight promise.
    if (!chatIdPromise) {
      chatIdPromise = props.openChatId().finally(() => {
        chatIdPromise = null
      })
    }
    chatId_context.value = await chatIdPromise

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 552 to 559
if (!chatId_context.value) {
chatId_context.value = await props.openChatId()
if (!chatIdPromise) {
chatIdPromise = props.openChatId().finally(() => {
chatIdPromise = null
})
}
chatId_context.value = await chatIdPromise
}
@wxg0103
wxg0103 merged commit b13aab7 into v2 Aug 4, 2026
5 of 7 checks passed
@wxg0103
wxg0103 deleted the pr@v2@fix_file branch August 4, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants