Reduce idle screenshot churn with change-driven SSE
Emit dashboard activity updates only when terminal screen content actually changes, and tighten screenshot 304 fast-path behavior to avoid stale not-modified responses after newer activity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -50,6 +50,7 @@ type Tracker struct {
|
||||
screen *te.DiffScreen
|
||||
stream *te.ByteStream
|
||||
changeCounter uint64
|
||||
lastActivityCounter uint64
|
||||
lastSnapshotCounter uint64
|
||||
}
|
||||
|
||||
@@ -125,6 +126,16 @@ func (t *Tracker) Snapshot() Snapshot {
|
||||
return snapshot
|
||||
}
|
||||
|
||||
func (t *Tracker) ConsumeActivityChanged() bool {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.changeCounter > t.lastActivityCounter {
|
||||
t.lastActivityCounter = t.changeCounter
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func colorToString(color te.Color) string {
|
||||
if color.Name != "" {
|
||||
name := strings.ToLower(strings.TrimPrefix(color.Name, "#"))
|
||||
|
||||
Reference in New Issue
Block a user