DeepSeek-Reasonix icon indicating copy to clipboard operation
DeepSeek-Reasonix copied to clipboard

fix(tui): forceGotoBottom scrolls regardless of transcript length change (#4797)

Open liaoyl830 opened this issue 5 months ago • 0 comments

Summary

Fixes #4797

When switching sessions, replayActiveBranch() sets forceGotoBottom=true to pin the viewport to the latest message. However, GotoBottom() was guarded inside a conditional that only fires when the transcript length changes. If the new session had the same number of lines, the viewport stayed at the intermediate scroll position.

Root Cause

In internal/cli/chat_tui.go's Update() wrapper, the scroll-to-bottom logic (if wasAtBottom || cm.forceGotoBottom) was inside the if len(cm.transcript) != prevLines || ... block. When session switch produced a transcript of equal length, the block was skipped entirely and GotoBottom() never ran.

Fix

Move the forceGotoBottom check outside the transcript-change conditional so it always triggers scroll-to-bottom, regardless of content length.

Tests

  • Added TestForceGotoBottomScrollsToBottom — verifies viewport scrolls to bottom when forceGotoBottom is set, even with unchanged transcript length

liaoyl830 avatar Jun 20 '26 13:06 liaoyl830