perf(tui): render streaming token secara inkremental + kurangi redraw sia-sia

- fix(view): token streaming kini benar-benar tampil — sebelumnya cache
  display_lines tidak pernah di-rebuild saat pesan terakhir berubah
  (msg_count == cached_count), jadi teks AI streaming tidak pernah muncul
  sampai pesan baru/resize
- perf(view): streaming kini hanya re-render pesan TERAKHIR (splice di
  batas cached_last_start) → O(konten baru) per token, bukan O(seluruh
  history); guard cached_last_len mencegah re-render pada frame spinner
  tanpa token baru
- perf(run): skip chrono::Utc::now() + drain toasts saat tidak ada toast
- perf(misc): drain_expired_toasts tidak lagi clone seluruh daftar toast
- perf(view): render_toasts fast-path saat toasts kosong
This commit is contained in:
asepharyana
2026-08-27 22:23:28 +07:00
parent 171597ca05
commit 271721694b
5 changed files with 58 additions and 12 deletions
+6 -3
View File
@@ -112,9 +112,12 @@ fn run_loop_inner(
}
// Drain expired toasts exactly once per loop iteration (was being
// done here AND in Action::Tick before this fix).
let now_ms = chrono::Utc::now().timestamp_millis();
state.misc.drain_expired_toasts(now_ms);
// done here AND in Action::Tick before this fix). Skip the clock
// syscall + Vec scan when there are no toasts at all.
if !state.misc.toasts.is_empty() {
let now_ms = chrono::Utc::now().timestamp_millis();
state.misc.drain_expired_toasts(now_ms);
}
// Skip render when nothing has changed — avoids expensive markdown
// re-parse and layout recalculation every cycle while idle.