Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restore after export #1274

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.sourcegraph.cody.initialization.EndOfTrialNotificationScheduler
import com.sourcegraph.cody.vscode.CancellationToken
import com.sourcegraph.common.CodyBundle
import com.sourcegraph.common.NotificationGroups
import java.util.UUID
import java.util.concurrent.TimeUnit

class ExportChatsBackgroundable(
Expand All @@ -40,6 +41,7 @@ class ExportChatsBackgroundable(
.filter { it.internalId != null }
.filter { chat -> if (internalId != null) chat.internalId == internalId else true }

var dummyInternalId = UUID.randomUUID().toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it also work for restore all?
Or, in other words, we just need one dummyInternalId or one per restored chat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need one per chat and that's what I do here (see line 58)

chats.forEachIndexed { index, chatState ->
val chatMessages =
chatState.messages.map { message ->
Expand All @@ -53,7 +55,8 @@ class ExportChatsBackgroundable(
ChatMessage(speaker = parsed, message.text)
}

restoreChatSession(agent, chatMessages, chatModelProvider = null, chatState.internalId!!)
dummyInternalId = UUID.randomUUID().toString()
restoreChatSession(agent, chatMessages, chatModelProvider = null, dummyInternalId)
indicator.fraction = ((index + 1.0) / (chats.size + 1.0))

if (indicator.isCanceled) {
Expand All @@ -68,7 +71,7 @@ class ExportChatsBackgroundable(

if (result != null) {
if (internalId != null) {
val singleChatHistory = result.find { it.chatID == internalId }
val singleChatHistory = result.find { it.chatID == dummyInternalId }
if (singleChatHistory != null) {
onSuccess.invoke(singleChatHistory)
} else {
Expand Down
Loading