mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-09 18:08:31 -10:00
* fix(tui): cache settled alt-screen transcript * fix(tui): invalidate settled alt-screen cache on in-place status row updates setDoctorStatusRow, setSandboxSetupStatusRow, and setCompactStatusRow all mutate an already-flushed transcript row in place (m.transcript[i] = row) without invalidating the alt-screen settled cache. Since none of frontier, width, or row count change on such an update, settleTranscript's rebuild guard never fires and the View fast path serves the stale cached snapshot - e.g. the doctor connectivity spinner freezes on its first frame. Zero altScreenSettledWidth on the in-place path, mirroring the existing pattern in toggleTranscriptRow, so the next settle rebuilds the cache. Addresses PR #647 review feedback from Vasanthdev2004. * fix(tui): invalidate settled transcript cache * fix(tui): invalidate settled file selection cards
39 lines
920 B
Go
39 lines
920 B
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func benchmarkIssue561Model(turns int) model {
|
|
m := transcriptViewTestModel()
|
|
m.altScreen = true
|
|
for i := 0; i < turns; i++ {
|
|
m.transcript = append(m.transcript,
|
|
transcriptRow{kind: rowUser, text: fmt.Sprintf("question %d", i)},
|
|
transcriptRow{kind: rowAssistant, text: fmt.Sprintf("answer %d", i), final: true},
|
|
)
|
|
}
|
|
m, _ = m.settleTranscript()
|
|
return m
|
|
}
|
|
|
|
func BenchmarkIssue561SettledAltScreen(b *testing.B) {
|
|
m := benchmarkIssue561Model(5000)
|
|
width := m.chatColumnWidth()
|
|
if m.altScreenSettledFrontier != m.flushed || m.altScreenSettledWidth != width {
|
|
b.Fatalf(
|
|
"settled cache miss before benchmark: frontier=%d flushed=%d width=%d wantWidth=%d",
|
|
m.altScreenSettledFrontier,
|
|
m.flushed,
|
|
m.altScreenSettledWidth,
|
|
width,
|
|
)
|
|
}
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = m.transcriptBodyItems(width, "", false)
|
|
}
|
|
}
|