Skip to content

fix: Refresh preview pane after resume and modal actions#288

Open
maiconpavi wants to merge 2 commits intosmtg-ai:mainfrom
maiconpavi:fix/refresh-preview-after-resume
Open

fix: Refresh preview pane after resume and modal actions#288
maiconpavi wants to merge 2 commits intosmtg-ai:mainfrom
maiconpavi:fix/refresh-preview-after-resume

Conversation

@maiconpavi
Copy link
Copy Markdown

@maiconpavi maiconpavi commented Apr 27, 2026

The preview pane keeps a cached previewState that only changes when m.instanceChanged() runs. Two lifecycle events were not triggering that call, so the pane stayed frozen on stale text until the next previewTickMsg (or until the user pressed Up/Down, which has its own explicit instanceChanged call).

  • Root cause (Resume): case keys.KeyResume in app/app.go returns tea.WindowSize() only, while the corresponding case keys.KeyCheckout (pause) calls instanceChanged() after Pause().

  • Fix (Resume): Batch m.instanceChanged() alongside tea.WindowSize() in the resume return, matching the shape used by case startInstanceMsg in the same file.

  • Root cause (Kill / confirmation modal): confirmAction's OnConfirm callback discards the tea.Msg returned by the action (_ = action()). The kill path's instanceChangedMsg{} is dropped, so the preview pane keeps the killed instance's paused fallback. The push path's error returns are dropped the same way.

  • Fix (Kill / confirmation modal): Stash the action's returned message on a new home.pendingMsg field inside OnConfirm, then drain it back into the event loop from the stateConfirm branch of handleKeyPress when the overlay dismisses. The existing case instanceChangedMsg: and case error: handlers do the rest.

Tested by:

  • Pausing and resuming an instance with c then r; preview redraws to live tmux content on the same frame instead of one tick later.
  • Pausing then killing an instance with c then D; preview redraws to the new selected instance immediately instead of staying stuck on the killed instance's paused fallback.
  • Triggering a P (push) failure; the error now appears in the err box instead of being silently swallowed.

The KeyResume handler returns without calling m.instanceChanged(),
so the preview pane keeps the cached "Session is paused. Press 'r'
to resume." fallback after the user presses r. The 100ms
previewTickMsg loop usually masks the gap, but if the event loop is
busy with anything else (metadata work, large diff stats) the stale
fallback can stay on screen long enough to be noticeable.

Batch m.instanceChanged() alongside tea.WindowSize() in the resume
return, matching the shape used by case startInstanceMsg in the same
file. The KeyCheckout (pause) handler already calls instanceChanged
after Pause(), so this aligns the resume side with the existing
pause pattern.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@maiconpavi
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

confirmAction's OnConfirm callback discarded the tea.Msg returned by
the action (_ = action()), so:

- KeyKill's instanceChangedMsg{} was dropped, leaving the preview
  pane stuck on the killed instance's paused fallback until the next
  previewTickMsg or until the user pressed Up/Down.
- KeySubmit's pushAction errors were also dropped; the user saw no
  feedback when push failed.

Stash the action's returned message on a new home.pendingMsg field
inside OnConfirm, then drain it back into the event loop from the
stateConfirm branch of handleKeyPress when the overlay dismisses.
The existing case instanceChangedMsg: and case error: handlers do
the rest.
@maiconpavi maiconpavi changed the title fix: Refresh preview pane after resume fix: Refresh preview pane after resume and modal actions Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant