Fix Potential UI Deadlock
Open
good first issue
hacktoberfest
hacktoberfest-accepted
- Dominant language
- Go
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
In `app.go`, the `applyAI` function locks a mutex and then spawns a goroutine that may try to lock the same mutex inside a `fyne.Do` block. If the UI thread is waiting on the mutex, this can cause a deadlock.
**Task:**
* [ ] Move the mutex lock inside the goroutine, so the UI thread never locks the mutex directly.
**Example Fix**
```go
u.setStatus("Contacting Gemini…")
go func() {
u.mu.Lock()
snapshot := append([]model.Packet(nil), u.packets...)
u.mu.Unlock()
filtered, err := u.chat.Reply(q, snapshot)
fyne.Do(func() {
// ... update UI ...
})
}()
```
**Why:**
This prevents the UI thread from being blocked and avoids deadlocks.
Contributor guide
Assessment
This issue has not been assessed yet.