add per-pane display ownership

This commit is contained in:
2026-05-27 14:30:47 +01:00
parent 63cb8a4388
commit 6d15626e05
9 changed files with 333 additions and 36 deletions

View File

@@ -15,6 +15,8 @@ const defaultClientSubscriberQueue = 256
// needing a fresh snapshot.
type clientSubscriber struct {
projectKey string
project *Project
clientID string
frames chan protocol.Frame
mu sync.Mutex
@@ -22,12 +24,18 @@ type clientSubscriber struct {
lifecycleDirty bool
}
func newClientSubscriber(projectKey string, size int) *clientSubscriber {
func newClientSubscriber(project *Project, clientID string, size int) *clientSubscriber {
if size <= 0 {
size = defaultClientSubscriberQueue
}
projectKey := ""
if project != nil {
projectKey = project.Key
}
return &clientSubscriber{
projectKey: projectKey,
project: project,
clientID: clientID,
frames: make(chan protocol.Frame, size),
snapshotRequired: make(map[string]bool),
lifecycleDirty: false,
@@ -72,7 +80,12 @@ func (s *clientSubscriber) OnChildStateChanged(id string, state IdleState) {
func (s *clientSubscriber) OnPTYOut(childID string, chunk []byte) {
cp := append([]byte(nil), chunk...)
f, err := protocol.NewFrame(protocol.FramePaneChunk, protocol.PaneChunk{PaneID: childID, Bytes: cp})
var size protocol.Size
var ownerID string
if s.project != nil {
size, ownerID, _ = s.project.PaneDisplay(childID)
}
f, err := protocol.NewFrame(protocol.FramePaneChunk, protocol.PaneChunk{PaneID: childID, Bytes: cp, Size: size, DisplayOwner: ownerID == "" || ownerID == s.clientID})
if err != nil {
return
}