Skip to content

fix: prevent UI deadlock in GitHub widget - #2117

Merged
Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-fix-github-widget-deadlock
Jul 24, 2026
Merged

Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-fix-github-widget-deadlock

Conversation

@Seanstoppable

@Seanstoppable Seanstoppable commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The GitHub widget can freeze the UI due to HTTP calls happening in the display/rendering path. When keyboard handlers (h/l/r) trigger content(), it calls myPullRequests() → individualPRs() which makes N sequential HTTP requests, blocking the tview event loop. Combined with context.Background() (no timeouts) and a blocking RedrawChan send, this can lock up the entire UI.

Fix

  • Move HTTP out of content(): Repo.Refresh() now pre-fetches and caches all display data (CachedMyPullRequests, CachedMyReviewRequests, CachedCustomQueries). content() reads only cached fields — zero network calls.
  • Add context timeouts: All API calls use context.WithTimeout(30s) instead of context.Background().
  • Non-blocking RedrawChan: Redraw() and ShowHelp() use select/default to avoid goroutine stalls when the channel buffer is full.
  • Fix nil dereference: repo == nil check moved before any method calls on repo.

Testing

Tested with enableStatus: true and multiple repositories. Source switching (h/l) is now instant and manual refresh (r) no longer freezes the UI.

Move all HTTP calls out of the display/content path into Refresh(),
so that keyboard handlers and tview draw operations never block on
network I/O. This fixes the UI freeze that occurs when:

- The GitHub API is slow or unresponsive
- enableStatus is true (N sequential HTTP calls per PR)
- Multiple widgets compete for the single-buffered redrawChan

Changes:
- github_repo.go: Add context.WithTimeout (30s) to all API calls,
  pre-compute and cache review requests, pull requests, and custom
  query results during Refresh()
- display.go: content() now reads only cached fields (zero HTTP)
- widget.go: Pass settings (username, enableStatus, customQueries)
  to Repo.Refresh() so it can pre-fetch everything
- text_widget.go: Make RedrawChan send non-blocking to prevent
  goroutine stalls when the channel buffer is full
- base.go: Same non-blocking fix for ShowHelp()
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-fix-github-widget-deadlock branch from f8740f1 to 4dd1c7c Compare July 23, 2026 03:12
@Seanstoppable
Seanstoppable merged commit 342b41f into wtfutil:trunk Jul 24, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-fix-github-widget-deadlock branch July 24, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址