Fix (race): mutex chatbody
This commit is contained in:
14
popups.go
14
popups.go
@@ -50,7 +50,7 @@ func showModelSelectionPopup() {
|
||||
// Find the current model index to set as selected
|
||||
currentModelIndex := -1
|
||||
for i, model := range modelList {
|
||||
if strings.TrimPrefix(model, models.LoadedMark) == chatBody.Model {
|
||||
if strings.TrimPrefix(model, models.LoadedMark) == chatBody.GetModel() {
|
||||
currentModelIndex = i
|
||||
}
|
||||
modelListWidget.AddItem(model, "", 0, nil)
|
||||
@@ -61,8 +61,8 @@ func showModelSelectionPopup() {
|
||||
}
|
||||
modelListWidget.SetSelectedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
|
||||
modelName := strings.TrimPrefix(mainText, models.LoadedMark)
|
||||
chatBody.Model = modelName
|
||||
cfg.CurrentModel = chatBody.Model
|
||||
chatBody.SetModel(modelName)
|
||||
cfg.CurrentModel = chatBody.GetModel()
|
||||
pages.RemovePage("modelSelectionPopup")
|
||||
app.SetFocus(textArea)
|
||||
updateCachedModelColor()
|
||||
@@ -156,9 +156,9 @@ func showAPILinkSelectionPopup() {
|
||||
}
|
||||
newModelList := getModelListForAPI(cfg.CurrentAPI)
|
||||
// Ensure chatBody.Model is in the new list; if not, set to first available model
|
||||
if len(newModelList) > 0 && !slices.Contains(newModelList, chatBody.Model) {
|
||||
chatBody.Model = strings.TrimPrefix(newModelList[0], models.LoadedMark)
|
||||
cfg.CurrentModel = chatBody.Model
|
||||
if len(newModelList) > 0 && !slices.Contains(newModelList, chatBody.GetModel()) {
|
||||
chatBody.SetModel(strings.TrimPrefix(newModelList[0], models.LoadedMark))
|
||||
cfg.CurrentModel = chatBody.GetModel()
|
||||
updateToolCapabilities()
|
||||
}
|
||||
pages.RemovePage("apiLinkSelectionPopup")
|
||||
@@ -229,7 +229,7 @@ func showUserRoleSelectionPopup() {
|
||||
// Update the user role in config
|
||||
cfg.WriteNextMsgAs = mainText
|
||||
// role got switch, update textview with character specific context for user
|
||||
filtered := filterMessagesForCharacter(chatBody.Messages, mainText)
|
||||
filtered := filterMessagesForCharacter(chatBody.GetMessages(), mainText)
|
||||
textView.SetText(chatToText(filtered, cfg.ShowSys))
|
||||
// Remove the popup page
|
||||
pages.RemovePage("userRoleSelectionPopup")
|
||||
|
||||
Reference in New Issue
Block a user