xfce4-terminal remembers only history of one tab when restoring saved session

Bug #1550898 reported by Jarno Suni
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
xfce4-terminal
Confirmed
Low
xfce4-terminal (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I expect it to remember history of each tab.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: xfce4-terminal 0.6.3-1ubuntu1
ProcVersionSignature: Ubuntu 3.13.0-79.123-lowlatency 3.13.11-ckt33
Uname: Linux 3.13.0-79-lowlatency x86_64
ApportVersion: 2.14.1-0ubuntu3.19
Architecture: amd64
CurrentDesktop: XFCE
Date: Sun Feb 28 11:58:43 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-09-21 (525 days ago)
InstallationMedia: Ubuntu-Studio 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.1)
SourcePackage: xfce4-terminal
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Jarno Suni (jarnos) wrote :
Revision history for this message
In , Jarno Suni (jarnos) wrote :

I expect history to be the same as at the time of closing the terminal together with session.

Jarno Suni (jarnos)
tags: added: xenial
Changed in xfce4-terminal:
importance: Unknown → Low
status: Unknown → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote : Re: Remembers only history of one tab when restoring saved session

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xfce4-terminal (Ubuntu):
status: New → Confirmed
A. Denton (aquina)
summary: - Remembers only history of one tab when restoring saved session
+ xfce4-terminal remembers only history of one tab when restoring saved
+ session
Revision history for this message
Theo Linkspfeifer (lastonestanding) wrote :

I have tested this in 18.04, and it seems to work fine. The history of both tabs was stored and could be accessed in both tabs.

Can you confirm that?

Revision history for this message
Theo Linkspfeifer (lastonestanding) wrote :

I could not find the exact commit, but I assume that one of the various tab related changes has fixed this issue.

Closing this report.

Changed in xfce4-terminal (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
In , Boris-astardzhiev (boris-astardzhiev) wrote :

Created attachment 9553
Restore scrollback history on save session

I've always wanted xfce4-terminals to preserve scrollback history across reboots/logouts.
Sometimes I omit powering off my machine only due to the fact that I will lose history across terminals as I have many of them. Unfortunately this is not green at all. Moreover if I do shutdown my machine the next day it's pretty hard to restart my work the way it was prior to shutdown. Yes, there are instruments like tmux/screen (and yes I use them myself) but they may be a burden for ordinary users.

Please consider the following patch. It basically does:
1) Scrollback history is saved across logouts/reboots if enabled via xfce4-terminal's preferences and if 'Save session for future logins' is checked.
2) Environment variable TAB_ID is exported in every terminal screen. It's a 16 character version of a SHA256 checksum. A seed identical to role-id is used for the generation of the checksum.
3) Scrollbacks are private to the user itself. They're stored in ~/.cache/xfce4/terminal/. They're GZIP compressed as well. Saving is done immediately on logging out which is tied to the 'save-session' event.
4) On logging in and after restoration scrollback files are deleted.
5) Since such histories may expose sensitive data everything is configurable and can be disabled thus no scrollback files will be saved at all.
6) It's up to the user to decide what fits him/her best and if this violates security or other implications user can omit using it.

As a future work, I think shell history may be tied per terminal. When time permits I can go and investigate this idea further. I think this will be a nice add-on to this feature.

Please share your opinions and provide some code review if you're positively inclined to incorporating this feature.

Regards,
Boris

Revision history for this message
In , Igor Zakharov (f2404) wrote :

Hi Boris, thanks for your effort and putting together a patch, that's greatly appreciated!

The feature itself, however... I'm not quite sure it should be implemented as part of the terminal. I think security concerns are very high with this kind of a feature. Even if the feature is disabled by default, I could totally see a user, having enabled it once and forgotten about that, find their sensitive data in jeopardy some day.

In fact, I'm pretty sure I've seen a request like for gnome-terminal/vte that has been declined. I cannot seem to find it right now for some reason, though.

Revision history for this message
In , Boris-astardzhiev (boris-astardzhiev) wrote :

Hello,
Igor,

Thanks for the reply.

//The feature itself, however... I'm not quite sure it should be implemented as part of the terminal.
Here's my point of view and what made me put some effort and get involved in writing this feature in xfce4-terminal itself.
I use tmux with plugins like resurrect and continuum to have this feature and yet it's not as convenient as I would like (mouse capturing on purpose or not, clipboard...clipboards over ssh are not the same as on desktop machine and many many more nagging hurdles). Yet tmux is super and I will continue using it.
But In my opinion tmux costs lots of efforts to setup whereas when done in the terminal as done in the patch users can optionally configure it and take full advantage and optimize their work across day to day reboots without setting up any additional tools. It may sound laughable but I don't shutdown any machines because time is precious to resurrect terminals and their history and details and continue working after a reboot. Now I can easily continue working having a brief history where I'd stopped prior to the reboot. This improves organization. There are lots of terminals out there and yet none has this feature and I consider it valuable as it ease transition across day to day reboots. To me this makes xfce4-terminal not just a terminal like anyone else out there but a terminal with a better user experience. I think I saw this feature in a OSX environment and thought to myself - I will have this on my linux deskop and here it is. I don't claim however it's the best approach to writing it. I'm open to reviews and suggestions however.

//I think security concerns are very high with this kind of a feature.
I can't but agree with you here and yet..

//Even if the feature is disabled by default, I could totally see a user, having enabled it once and forgotten about that, find their sensitive data in jeopardy some day.
Saving data is done only across saving a session - i.e logging out/a reboot/a shutdown. Nothing is persisted at all if the save session option is not checked on the logout menu. More over it can be fully disabled from the preferences menu as you'd seen in the patch.
It's just my point of view that if user wants to use it then let it be this way.
Moreover files are gzip compressed and given 600 permissions hence only the user itself can read it.
Well, if home directory gets compromised that's another story but it's not just these files in there.
As a matter of facts encrypting home directories is very common these days.
Bash history for example is totally visible as well and it's enabled by default.

What I put emphasis here is that it's configurable and it's up to user's decision whether or not to use it. For sure disabled by default is the right approach.

//In fact, I'm pretty sure I've seen a request like for gnome-terminal/vte that has been declined. I cannot seem to find it right now for some reason, though.
I'm interested in this topic and yet optimizing working process and user experience matter as well.

I would like you to not take this reply as something offensive it's just my point of view and my attempt to make user (my) life easier.

Best regards

Revision history for this message
In , Jarno Suni (jarnos) wrote :

Boris, your patch sound good. I did not try it yet, because I am not used to building Xfce software from source.

Another approach is that terminal has its own session management independent of xfce session like many web browsers do, so it would remember tabs, current directories and history for each tab. Possibly user could save several sessions and open them. Maybe that would not work well together with xfce session, though.

Revision history for this message
In , Jarno Suni (jarnos) wrote :

(In reply to Boris Astardzhiev from comment #1)

> As a future work, I think shell history may be tied per terminal. When time
> permits I can go and investigate this idea further. I think this will be a
> nice add-on to this feature.

Why not tie history per terminal tab? I guess shells HISTFILE variable could be used for that.

Revision history for this message
In , Boris-astardzhiev (boris-astardzhiev) wrote :

Hello Jarno,

> Boris, your patch sound good. I did not try it yet, because I am not used to building Xfce software from source.
> Another approach is that terminal has its own session management independent of xfce session like
> many web browsers do, so it would remember tabs, current directories and history for each tab.
> Possibly user could save several sessions and open them. Maybe that would not work well together
> with xfce session, though.

Thanks for the reply. To be honest I've tried to rely as much as possible on existing code.

> Why not tie history per terminal tab? I guess shells HISTFILE variable could be used for that.
Thanks for the idea. I tried it further and at first glance it seems to work pretty well - now I have shell history per terminal/tab along with the scrollback history and all of this is restored across reboots. And this by simply adding a small snippet to .bashrc:

PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
if [ ! -z "$TAB_ID" ]; then
    HISTFILE_DIR=$HOME/shell_history
    HISTFILE_ARCHIVE_DIR=$HISTFILE_DIR/archive
    mkdir -m 700 -p $HISTFILE_DIR
    mkdir -m 700 -p $HISTFILE_ARCHIVE_DIR
    HISTFILE_DEST=$HISTFILE_DIR/$TAB_ID
    HISTFILE_ARCHIVE_DEST=$HISTFILE_ARCHIVE_DIR/$TAB_ID

    function pop_shell_history {
        if [ -f "$HISTFILE_ARCHIVE_DEST" ]; then
            # revive from archive
            mv $HISTFILE_ARCHIVE_DEST $HISTFILE_DEST
        elif [ ! -f $HISTFILE_DEST ]; then
            # combine history from all existing tabs
            # or we'll start with an empty list but
            # it's slightly better to have history from
            # recent tabs
            for hist in $(find $HISTFILE_DIR -maxdepth 1 -type f)
            do
               cat $hist >> $HISTFILE_DEST
            done
        fi
        HISTFILE=$HISTFILE_DEST
    }
    # peek at archive
    pop_shell_history

    function push_shell_history {
        history -a; mv $HISTFILE_DEST $HISTFILE_ARCHIVE_DIR
    }

    # on exit save shell history in the archive
    trap push_shell_history EXIT
fi

A rough edge is that archive are not deleted if a terminal is closed.
This may be easily adapted to other shells.
Apart from the edges it's nice to fully restore your workspace across reboots!
No engineer throws workspace at the end of the day just to start from scratch tomorrow.

Regards

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.