Skip to content

Commit a5afebe

Browse files
grokifyclaude
andcommitted
fix(desktop): scroll to bottom when user types to prevent stuck scrollback
When the user scrolled up in the terminal's scrollback buffer and then typed (e.g., responding "Yes" to Claude Code), the view could remain showing old content instead of auto-scrolling to follow new output. Added scrollToBottom() method that snaps the view to the latest output whenever the user presses a key. This ensures the user always sees the response after typing input. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1aa712e commit a5afebe

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

apps/desktop/Sources/PlexusOneDesktop/Views/AppTerminalView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ class AppTerminalView: LocalProcessTerminalView {
2222
// The parent class layout() handles this
2323
}
2424

25+
// MARK: - Scrolling
26+
27+
/// Scroll the terminal view to show the latest output (bottom of buffer)
28+
/// Call this when the user sends input to ensure they see the response
29+
func scrollToBottom() {
30+
// Only scroll if we're not already at the bottom
31+
// scrollPosition 1.0 = bottom, 0.0 = top
32+
if scrollPosition < 1.0 {
33+
scroll(toPosition: 1.0)
34+
}
35+
}
36+
2537
// MARK: - Mouse Wheel Event Handling
2638

2739
/// Send mouse wheel event to terminal application (e.g., tmux with mouse mode)

apps/desktop/Sources/PlexusOneDesktop/Views/TerminalViewRepresentable.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class TerminalContainerView: NSView {
6464
terminalView.mouseDown(with: event)
6565
}
6666

67+
override func keyDown(with event: NSEvent) {
68+
// When user types, ensure we're showing the latest output
69+
// This prevents "stuck in scrollback" issues where old content is visible
70+
terminalView.scrollToBottom()
71+
// Forward to terminal for processing
72+
terminalView.keyDown(with: event)
73+
}
74+
6775
/// Check if this terminal has focus and notify if changed
6876
func updateFocusState() {
6977
let isFocused = window?.firstResponder === terminalView

0 commit comments

Comments
 (0)