arya2004 / arya2004/fynewire

Fix Potential UI Deadlock

Open
#2 2 comments 0 reactions 1 assignee Claimed by @Suthar345Piyush View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.