Trigger full redraw on overlay close and new turn submit
- commit
- f4d678e61e4b0a52a4b97485e12e9a9717863a59
- author
- patriceckhart · · 2026-05-10 08:59 UTC
- parent
- c01e026
- signature
- unsigned
- refs
- tag: v0.1.72
1 file · +21 -2
M internal/agent/modes/interactive.go +21 -2
| @@ -240,8 +240,9 @@ type Interactive struct { | |||
| 240 | 240 | // window down through the buffer (because scrollOffset is measured | |
| 241 | 241 | // from the bottom) and the user's reading position drifts upward | |
| 242 | 242 | // and off the top. | |
| 243 | - | prevChatLen int | |
| 244 | - | prevChatCols int | |
| 243 | + | prevChatLen int | |
| 244 | + | prevChatCols int | |
| 245 | + | prevOverlayOpen bool | |
| 245 | 246 | ||
| 246 | 247 | // chatCache stores the built transcript/status-note rows for idle | |
| 247 | 248 | // frames. Editor typing changes only the bottom input region, so | |
| @@ -938,6 +939,17 @@ func (i *Interactive) redraw() { | |||
| 938 | 939 | } else if len(dialog) == 0 && i.fileSuggest.Active(currentInput) { | |
| 939 | 940 | suggest = i.fileSuggest.Render(currentInput, i.cfg.Theme, cols) | |
| 940 | 941 | } | |
| 942 | + | ||
| 943 | + | // Detect overlay close (any dialog or slash/file suggestion popup | |
| 944 | + | // just transitioned from open to closed). Force a full redraw so | |
| 945 | + | // the rows the overlay occupied are guaranteed to be repainted | |
| 946 | + | // from the chat below, instead of the diff path leaving stale | |
| 947 | + | // dialog content behind. Equivalent to the user pressing ctrl+l. | |
| 948 | + | overlayOpen := len(dialog) > 0 || len(suggest) > 0 | |
| 949 | + | if i.prevOverlayOpen && !overlayOpen && i.rend != nil { | |
| 950 | + | i.rend.Clear() | |
| 951 | + | } | |
| 952 | + | i.prevOverlayOpen = overlayOpen | |
| 941 | 953 | if len(suggest) > 0 { | |
| 942 | 954 | // One blank row above the popup so it doesn't sit flush | |
| 943 | 955 | // against the chat / welcome content above. | |
| @@ -3115,6 +3127,13 @@ func (i *Interactive) startTurnWithImages(parent context.Context, prompt string, | |||
| 3115 | 3127 | if i.agent == nil { | |
| 3116 | 3128 | return | |
| 3117 | 3129 | } | |
| 3130 | + | // Force a full repaint when a new turn begins so any stray dialog, | |
| 3131 | + | // popup, or stale tool-progress rows don't leak into the visible | |
| 3132 | + | // chat area before the assistant starts streaming. Equivalent to | |
| 3133 | + | // the user pressing ctrl+l right before submit. | |
| 3134 | + | if i.rend != nil { | |
| 3135 | + | i.rend.Clear() | |
| 3136 | + | } | |
| 3118 | 3137 | // Pre-turn safety: if the most recent context measurement is | |
| 3119 | 3138 | // already past the auto-compact threshold, condense before | |
| 3120 | 3139 | // sending so the next outbound request stays under the limit. | |
| @@ -240,8 +240,9 @@ type Interactive struct { | |||||
| 240 | // window down through the buffer (because scrollOffset is measured | 240 | // window down through the buffer (because scrollOffset is measured | ||
| 241 | // from the bottom) and the user's reading position drifts upward | 241 | // from the bottom) and the user's reading position drifts upward | ||
| 242 | // and off the top. | 242 | // and off the top. | ||
| 243 | - | prevChatLen int | 243 | + | prevChatLen int |
| 244 | - | prevChatCols int | 244 | + | prevChatCols int |
| 245 | + | prevOverlayOpen bool | |||
| 245 | 246 | ||||
| 246 | // chatCache stores the built transcript/status-note rows for idle | 247 | // chatCache stores the built transcript/status-note rows for idle | ||
| 247 | // frames. Editor typing changes only the bottom input region, so | 248 | // frames. Editor typing changes only the bottom input region, so | ||
| @@ -938,6 +939,17 @@ func (i *Interactive) redraw() { | |||||
| 938 | } else if len(dialog) == 0 && i.fileSuggest.Active(currentInput) { | 939 | } else if len(dialog) == 0 && i.fileSuggest.Active(currentInput) { | ||
| 939 | suggest = i.fileSuggest.Render(currentInput, i.cfg.Theme, cols) | 940 | suggest = i.fileSuggest.Render(currentInput, i.cfg.Theme, cols) | ||
| 940 | } | 941 | } | ||
| 942 | + | ||||
| 943 | + | // Detect overlay close (any dialog or slash/file suggestion popup | |||
| 944 | + | // just transitioned from open to closed). Force a full redraw so | |||
| 945 | + | // the rows the overlay occupied are guaranteed to be repainted | |||
| 946 | + | // from the chat below, instead of the diff path leaving stale | |||
| 947 | + | // dialog content behind. Equivalent to the user pressing ctrl+l. | |||
| 948 | + | overlayOpen := len(dialog) > 0 || len(suggest) > 0 | |||
| 949 | + | if i.prevOverlayOpen && !overlayOpen && i.rend != nil { | |||
| 950 | + | i.rend.Clear() | |||
| 951 | + | } | |||
| 952 | + | i.prevOverlayOpen = overlayOpen | |||
| 941 | if len(suggest) > 0 { | 953 | if len(suggest) > 0 { | ||
| 942 | // One blank row above the popup so it doesn't sit flush | 954 | // One blank row above the popup so it doesn't sit flush | ||
| 943 | // against the chat / welcome content above. | 955 | // against the chat / welcome content above. | ||
| @@ -3115,6 +3127,13 @@ func (i *Interactive) startTurnWithImages(parent context.Context, prompt string, | |||||
| 3115 | if i.agent == nil { | 3127 | if i.agent == nil { | ||
| 3116 | return | 3128 | return | ||
| 3117 | } | 3129 | } | ||
| 3130 | + | // Force a full repaint when a new turn begins so any stray dialog, | |||
| 3131 | + | // popup, or stale tool-progress rows don't leak into the visible | |||
| 3132 | + | // chat area before the assistant starts streaming. Equivalent to | |||
| 3133 | + | // the user pressing ctrl+l right before submit. | |||
| 3134 | + | if i.rend != nil { | |||
| 3135 | + | i.rend.Clear() | |||
| 3136 | + | } | |||
| 3118 | // Pre-turn safety: if the most recent context measurement is | 3137 | // Pre-turn safety: if the most recent context measurement is | ||
| 3119 | // already past the auto-compact threshold, condense before | 3138 | // already past the auto-compact threshold, condense before | ||
| 3120 | // sending so the next outbound request stays under the limit. | 3139 | // sending so the next outbound request stays under the limit. | ||