The contents of the session were already overwritten, when you started up the TUI programs in the first place. You can see that that is the case.
When a TUI program, that uses
ncurses and suchlike to present its textual user interface, starts up, it clears the screen. At that point, everything that is on the screen has been overwritten.
What you're missing, and what you don't know the name for, is the idea of terminals that have an alternate screen buffer. When such a TUI program as these starts up, it issues the escape sequence to switch to the terminal's alternate screen buffer, if it has one. All of its output then goes onto that buffer. When the program exits, or suspends itself, it issues the escape sequence to restore the primary screen buffer, which has remained untouched whilst the TUI program has displayed its user interface on the alternate buffer.
For terminals that don't have alternate screen buffers, there's no escape sequence to issue, and the full-screen user interface overwrites what was previously on the terminal.
Programs look these escape sequences up in the
termcap databases. In the
terminfo world the terminal capabilities are named
rmcup. In the
termcap world they are named
te. As documented they make no mention of screen buffers.
Instead they talk of entering and exiting "cursor addressing mode". The notion is that a TUI program that presents a full-screen interface like this is operating in cursor addressing mode where the program really doesn't need the terminal to scroll; whereas a TUI program that just outputs scrolling lines of text is not. So one switches into and out of this mode. (In the real world, things are not so clear cut. For example: Modern shells such as the Z Shell move the cursor about for line editing, menu completion, and
$RPROMPT; but don't switch to the alternate screen buffer, don't have a fully-fledged full screen user interface, and operate in terms of scrolling.)
The capabilities thus usually do more than just switch buffers.
smcup also contains the escape sequence for saving the current cursor position, and
rmcup the escape sequence for restoring it, as well, if the terminal has such escape sequences.
Your problem is one of two things:
termcap database on your FreeBSD system doesn't have
ti entries for your particular terminal type, because the entry is incomplete.
- You aren't using the right terminal type for your terminal emulator in the first place.
The terminal type is taken from your
TERM environment variable, on the server end. Its value denotes an entry in the
termcap database. So ensure that your
TERM environment variable names an entry in
/etc/termcap with the capabilities that match those of your (local) terminal emulator. If there's no entry matching your terminal emulator that contains
te, then you'll have to simply add such an entry.