Clear the current status display without resetting state (sync version). This is used when transitioning between display modes (e.g., streaming to tool). Unlike _finish_display(), this doesn't print a newline afterward. Note: For async contexts, prefer _clear_current_displa
(self)
| 552 | self._last_status = "" |
| 553 | |
| 554 | def _clear_current_display(self) -> None: |
| 555 | """Clear the current status display without resetting state (sync version). |
| 556 | |
| 557 | This is used when transitioning between display modes (e.g., streaming to tool). |
| 558 | Unlike _finish_display(), this doesn't print a newline afterward. |
| 559 | |
| 560 | Note: For async contexts, prefer _clear_current_display_async() to properly |
| 561 | coordinate with the render lock. |
| 562 | """ |
| 563 | from chuk_term.ui.terminal import clear_lines, move_cursor_up |
| 564 | |
| 565 | if self._last_line_count > 0: |
| 566 | # Move to first line if needed |
| 567 | if self._last_line_count > 1: |
| 568 | move_cursor_up(self._last_line_count - 1) |
| 569 | sys.stdout.write("\r") |
| 570 | sys.stdout.flush() |
| 571 | |
| 572 | # Clear all lines |
| 573 | clear_lines(self._last_line_count) |
| 574 | |
| 575 | # Reset display state (but keep other state intact) |
| 576 | self._last_line_count = 0 |
| 577 | self._last_status = "" |
| 578 | |
| 579 | def _finish_display(self) -> None: |
| 580 | """Finish the live display and prepare for normal output. |
no outgoing calls