Skip to content

TUI deadlocks when answering a held peer message (Allow/Deny) #1099

Open

Description

@PierrunoYT

Found in the 2026-09-28 code audit (finding N-4).

Where: internal/tui/peer_messages.go:122-125, called synchronously from resolvePermissionWithReason at internal/tui/model.go:4402. Sink wired at internal/tui/run.go:34-45; coalesce.go:59-68 forwards to program.Send.

Problem: The decide closure calls m.runtimeMessageSink(peerDecisionMsg{...}) inside Update. In bubbletea v2.0.9 Send blocks on the unbuffered p.msgs channel, and the only reader is the event loop, which is currently running Update. Pressing Allow or Deny on a held cross-session message hangs the program, and Ctrl+C queues on the same channel. Tests install a capturing sink (peer_messages_test.go:135, :181), so they cannot see it.

Suggested fix: return a tea.Cmd that yields peerDecisionMsg instead of calling the sink from Update. Consider a debug guard against sink calls on the Update goroutine.

Tests: a regression test that drives Allow/Deny through a real tea.Program (or a blocking sink) rather than a capturing sink.

Activity

  1. Vasanthdev2004 commented on Oct 12, 2026

    @Vasanthdev2004
    Collaborator

    Confirmed on main (bb3346a8). decide runs from resolvePermissionWithReason, the key handler, so it runs inside Update. It calls runtimeMessageSink(peerDecisionMsg{...}), which for any non-text message goes straight through the coalescer to program.Send, and that waits on the unbuffered channel the event loop reads. #883 (not merged yet) adds an ordered forwarder for the same freeze on the peer service's held-release callback, but this path doesn't go through it either. Approving.

    Shape: return the decision from the permission resolution as a tea.Cmd instead of calling the sink, which is the Bubble Tea way to emit a message from Update. The regression test should drive Allow and Deny through something that blocks the way program.Send does, either a real tea.Program or a sink that blocks until Update returns; the capturing sinks in the current tests can't see it.

  2. added
    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions