[PR #2868] tui: scope permission events to active session; eliminate cross-session churn #10472

Closed
opened 2026-02-16 18:15:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/2868

State: closed
Merged: No


Summary

This PR eliminates unnecessary CPU usage and animation stutter caused by cross-session permission events in the TUI.

Changes

Permission event scoping: Gate permission.updated and permission.replied events to only trigger re-renders for the active session or its parent, preventing background sessions from causing UI churn.

Spinner optimization: Editor spinner only animates for permissions relevant to the active session, eliminating perpetual idle animation from unrelated sessions.

Permission queue deduplication: De-duplicate permission queue by ID and clean queue on session switch.

Event stream scoping: Stream events scoped by project worktree with fallback.

Performance Impact

  • Before: Background CPU usage and animation stutter from unrelated sessions
  • After: Clean animations and minimal CPU when inactive

Files Changed

  • packages/tui/cmd/opencode/main.go - Event stream scoping
  • packages/tui/internal/components/chat/editor.go - Spinner scoping
  • packages/tui/internal/components/chat/messages.go - Permission event filtering
  • packages/tui/internal/tui/tui.go - Permission queue management
  • packages/tui/internal/util/ide.go - Cleanup

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2868 **State:** closed **Merged:** No --- ## Summary This PR eliminates unnecessary CPU usage and animation stutter caused by cross-session permission events in the TUI. ### Changes **Permission event scoping**: Gate `permission.updated` and `permission.replied` events to only trigger re-renders for the active session or its parent, preventing background sessions from causing UI churn. **Spinner optimization**: Editor spinner only animates for permissions relevant to the active session, eliminating perpetual idle animation from unrelated sessions. **Permission queue deduplication**: De-duplicate permission queue by ID and clean queue on session switch. **Event stream scoping**: Stream events scoped by project worktree with fallback. ### Performance Impact - **Before**: Background CPU usage and animation stutter from unrelated sessions - **After**: Clean animations and minimal CPU when inactive ### Files Changed - `packages/tui/cmd/opencode/main.go` - Event stream scoping - `packages/tui/internal/components/chat/editor.go` - Spinner scoping - `packages/tui/internal/components/chat/messages.go` - Permission event filtering - `packages/tui/internal/tui/tui.go` - Permission queue management - `packages/tui/internal/util/ide.go` - Cleanup 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:15:08 -05:00
yindo closed this issue 2026-02-16 18:15:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10472