Skip to content

fix(tui): prevent crash when /rewind picker triggers session remount#466

Open
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-421-rewind-picker-crash
Open

fix(tui): prevent crash when /rewind picker triggers session remount#466
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-421-rewind-picker-crash

Conversation

@Kailigithub
Copy link
Copy Markdown
Contributor

When /rewind is invoked via the picker in the TUI, the callback
(_do_rewind) truncates session messages and calls
_remount_current_session(), which removes all widgets from the
#messages container. Back in _collapse_choice(), the anchor widget
reference (msg._hint_widget / msg._body_widget) still exists but is
now detached, causing a crash when trying to container.mount(after=anchor).

Fix: Add a guard after the on_select callback that checks
anchor.is_mounted. If the callback already rebuilt the UI (anchor is
detached), return early to avoid operating on detached widgets.

For normal callbacks that don't remount, the anchor widgets remain
mounted and the guard is a no-op — behavior is unchanged.

Closes #421

When /rewind is invoked via the picker, the callback (_do_rewind)
truncates session messages and calls _remount_current_session(), which
removes all widgets from the container. Back in _collapse_choice(), the
anchor widget reference still exists but is now detached, causing a
crash on mount(after=anchor).

Add a guard that checks is_mounted on the anchor widget after the
on_select callback. If the callback already rebuilt the UI, return
early to avoid operating on detached widgets.

Closes lsdefine#421
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.

Bug: /rewind via picker crashes TUI (orphaned widget mount after _remount_current_session)

1 participant