Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions shell-plugin/lib/dispatcher.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ function forge-accept-line() {
# Add the original command to history before transformation
print -s -- "$original_buffer"

# CRITICAL: Move cursor to end so output doesn't overwrite
# Don't clear BUFFER yet - let _forge_reset do that after action completes
# This keeps buffer state consistent if Ctrl+C is pressed
CURSOR=${#BUFFER}
zle redisplay
# CRITICAL: clear and invalidate the active ZLE prompt before writing output.
# Otherwise RPROMPT/text from the old prompt can remain on wrapped rows and
# the command output can run underneath it, which looks like clipping.
BUFFER=""
CURSOR=0
zle -I

# Handle aliases - convert to their actual agent names
case "$user_action" in
Expand Down
14 changes: 11 additions & 3 deletions shell-plugin/lib/helpers.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,20 @@ function _forge_select_model_pair_global() {
}

function _forge_reset() {
# Clear buffer and reset cursor position
BUFFER=""
CURSOR=0
# Force widget redraw and prompt reset
# Output may finish without a trailing newline. If ZLE accepts an empty line
# from that position, RPROMPT can be painted on top of the final output row.
# Move to a clean line before accepting the empty buffer so the next prompt
# is always rendered below Forge output.
print -r -- "" >/dev/tty

# Do not accept an empty command line here. accept-line asks ZLE to render the
# next prompt from inside the widget; with right prompts (p10k/RPROMPT) that
# repaint can still target the last output row and hide the tail of output.
# Invalidating the display is enough: the widget returns and zsh redraws the
# prompt naturally on the clean line above.
zle -I
zle reset-prompt
}

# Helper function to print messages with consistent formatting based on log level
Expand Down