Heads up: The SessionManager class will go away

99 views
Skip to first unread message

Edward K. Ream

unread,
Jun 29, 2023, 6:06:37 PM6/29/23
to leo-editor

Leo no longer supports --session-restore and --session-save. LM.scanOptions lists them as obsolete.


But the SessionManager class still exists. SM.load_session is the culprit behind #3404. It would be straightforward to fix this method, but I shall retire the entire class instead.


The SessionManager supports six session-* commands. The commands allow you to specify a set of files to open at startup. But listing the desired files (in a shell script or .cmd file) is simple and good.


Summary


The session-* commands are absurd solutions to a non-existent problem. This class significantly complicates Leo's startup logic. The entire SessionManager class must go. Félix take note :-)


As a side effect, Leo will no longer write ~/.leo/leo.session


Your comments are welcome. Good luck arguing for this class :-)


Edward

Mike Hodson

unread,
Jun 29, 2023, 8:22:16 PM6/29/23
to leo-e...@googlegroups.com
Out of curiosity why is the function of a session considered obsolete? 

This is what I have needed forever, a proper reloading session that automatically saves and does not lose data, regardless if I might have three drafts open that have yet to be saved to disk.

The instant I create a new document, there should be a state file saved on the disk, that keeps the state of the open draft and relates it to an open session.

If my power fails two seconds later I expect to be able to load Leo up and get the exact point where I left off.

I haven't used Leo seriously for the last 5 years because of this lack of functionality.

Mike


--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/5480a75d-ada7-4bb0-8a4b-b27c8fe5486an%40googlegroups.com.

Jacob Peck

unread,
Jun 29, 2023, 8:39:50 PM6/29/23
to leo-e...@googlegroups.com
I would argue that Edward’s solution of ‘just list the files you want to open in a script’ to totally not capture the essence of the session.  The whole point of sessions to me is to keep the flow of what I was doing last.  It’s more than a set of static leo files.  It’s the set of leo files I was working on *last* that’s important, not whatever ones I hardcode into a script.  I use Leo for dozens of reasons, which fluctuate all the time.  I’m going to seriously lose a lot of joy if I have to constantly hunt down which files I was working on last.  Yes, the recent files list helps, but it’s still a lot of unnecessary end-user friction to have to manually open them all up on each start up.

Just my $0.02.

Jake

On Jun 29, 2023, at 8:22 PM, Mike Hodson <mys...@gmail.com> wrote:



Thomas Passin

unread,
Jun 29, 2023, 9:42:13 PM6/29/23
to leo-editor
I will second this desire.  I really like being able to restart Leo and pick up right where I left off.  I think that has been a very positive trait of Leo.  In fact, it gives the user - or at least me - a sense that Leo is especially well engineered and that user needs have been carefully thought about.  OTOH, leosession only captured the state of the outlines when Leo exits, but not (I think) when an outline is closed and then reopened in a later Leo session.  That would be valuable.  Why couldn't the outline itself store that data when it's closed?  It could be a backwards compatible change to the outline's file format.

Edward K. Ream

unread,
Jun 30, 2023, 3:45:17 AM6/30/23
to leo-editor
On Thursday, June 29, 2023 at 5:06:37 PM UTC-5 Edward K. Ream wrote:

The session-* commands are absurd solutions to a non-existent problem. This class significantly complicates Leo's startup logic. The entire SessionManager class must go. Félix take note :-)


The session-* commands are absurd solutions to a non-existent problem. This class significantly complicates Leo's startup logic. The entire SessionManager class must go. Félix take note :-)


Thanks to all who have commented.


Yes, Leo could have "real" sessions. When no files appear on the command line, Leo could reload the open outlines when Leo last closed. Issue #3408 tells how. It's easy! It's on the list for Leo 6.7.4.


But nothing in leoSessions.py gives Leo such sessions. The SessionManager class and the session-* commands must go.


Edward

jkn

unread,
Jun 30, 2023, 3:55:05 AM6/30/23
to leo-editor
I'm not 100% clear what the revised functionality you propose would be ... but as one of (the) main people who requested some sort of session management, a few years back, I would strongly dislike losing this feature.

I routinely start Leo with a set of files (four or five), previously saved via session-snapshot-load and session-snapshot-save. Unless I'm misunderstanding you, loss of this feature would be a serious blow to my leo productivity.

Jon N

Edward K. Ream

unread,
Jun 30, 2023, 4:12:44 AM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 2:55 AM jkn <jkn...@nicorp.f9.co.uk> wrote:

I routinely start Leo with a set of files (four or five), previously saved via session-snapshot-load and session-snapshot-save. Unless I'm misunderstanding you, loss of this feature would be a serious blow to my leo productivity.

I see: session-snapshot-load and session-snapshot-save are less toxic than the other session-* commands.

Would #3408 work for you? In effect, #3404 would do these commands automatically.

Edward

Edward K. Ream

unread,
Jun 30, 2023, 4:20:54 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 3:12:44 AM UTC-5 Edward K. Ream wrote:

> Would #3408 work for you? In effect, #3404 would do these commands automatically.

If "fluid" sessions don't work for you the obvious workflow is to create .sh/.cmd files starting Leo with specified sets of outlines.

session-snapshot-load and session-snapshot-save can only ever save one set of outlines, so these two commands are much less flexible than .sh/.cmd files.

Edward

Edward K. Ream

unread,
Jun 30, 2023, 4:34:58 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 2:45:17 AM UTC-5 Edward K. Ream wrote:

But nothing in leoSessions.py gives Leo such [real] sessions. The SessionManager class and the session-* commands must go.


Big sigh. It does not seem wise to the retire the SessionManager class as part of PR #3215. So the PR must fix SM.load_session for now.

I'll wait and see whether #3408 (real sessions) will satisfy everyone. If so I'll retire leoSessions.py as part of the PR for #3408.

Edward

jkn

unread,
Jun 30, 2023, 5:39:52 AM6/30/23
to leo-editor
starting Leo via different sets of (for me) .sh files, for different 'session sets of files' seems pretty cheesy in this day & age - sorry.

I haven't yet taken a look at #3408, I will do so asap.

Thanks, Jon N

Edward K. Ream

unread,
Jun 30, 2023, 5:51:15 AM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 4:39 AM jkn <jkn...@nicorp.f9.co.uk> wrote:
starting Leo via different sets of (for me) .sh files, for different 'session sets of files' seems pretty cheesy in this day & age - sorry.

No worries. PR #3215 (the massive PR) now supports real sessions!!!  With minimal changes to leoSessions.py!

In other words:

- #3408 is complete!
- leoSession.leo can remain with only small changes to SM.get_session and SM.load_session.
- All the session-* commands should work. Some will work better :-)

Edward

jkn

unread,
Jun 30, 2023, 6:04:54 AM6/30/23
to leo-editor
FWIW I can't really tell what #3408 will actually *do*. "Real Sessions" sounds great, but what is written there is more about the coding. I would like to better understand when the user experience will be at the end of this.

(sorry if I seem like an ungrateful consumer of terrific free SW).

FWIW, conversation titles like 'The SessionManager will go away' probably cause people to go "what?! Why?! When?!", which might not be what you want...

Jon N

Edward K. Ream

unread,
Jun 30, 2023, 8:41:08 AM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 5:04 AM jkn <jkn...@nicorp.f9.co.uk> wrote:
FWIW I can't really tell what #3408 will actually *do*. "Real Sessions" sounds great, but what is written there is more about the coding. I would like to better understand when the user experience will be at the end of this.

The idea, now fully realized in PR #3215, is this:

1. On exit, Leo always saves a list of open outlines (automatic session-snapshot-save).
2. When you open Leo without specifying any files Leo opens the saved list of outlines (automatic session-snapshot-load).

This scheme is what I understand to be real sessions. It's not exactly equivalent to manually doing session-snapshot-load because Leo always overwrites the previously saved session.

Please try this all out.

Edward

Thomas Passin

unread,
Jun 30, 2023, 8:54:48 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 8:41:08 AM UTC-4 Edward K. Ream wrote:
1. On exit, Leo always saves a list of open outlines (automatic session-snapshot-save).
2. When you open Leo without specifying any files Leo opens the saved list of outlines (automatic session-snapshot-load).

I think this is exactly what is wanted most of the time, especially if each of the session-loaded outlines gets navigated to the focus when Leo was last closed.

The trouble with having the user build and specify the contents of specially named sessions is that it's not only a nuisance to do, one quickly forgets what each session contains.

Edward K. Ream

unread,
Jun 30, 2023, 9:00:13 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 7:54:48 AM UTC-5 Thomas wrote:

I think this is exactly what is wanted most of the time, especially if each of the session-loaded outlines gets navigated to the focus when Leo was last closed.

The trouble with having the user build and specify the contents of specially named sessions is that it's not only a nuisance to do, one quickly forgets what each session contains.

Thanks Thomas. That's how I see things too.

Edward

Edward K. Ream

unread,
Jun 30, 2023, 9:02:51 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 5:04:54 AM UTC-5 jkn wrote:

titles like 'The SessionManager will go away' probably cause people to go "what?! Why?! When?!", which might not be what you want...

Hehe. It was exactly what I wanted--to get everyone's attention.

I'm particularly glad I got your attention.

Edward

Thomas Passin

unread,
Jun 30, 2023, 9:17:54 AM6/30/23
to leo-editor
I actually do use the equivalent of custom temporary sessions sometimes, but the way I do it is to use the command line.  I usually keep Leo open

Thomas Passin

unread,
Jun 30, 2023, 9:28:07 AM6/30/23
to leo-editor
Sorry, posted by mistake before I was finished.

I actually do use the equivalent of custom temporary sessions sometimes, but the way I do it is to use the command line.  I usually keep a Leo window open all the time with maybe 5 or 6 outlines open (at a minimum, the workbook, my bookmarks manager, and whatever outline I want to work with).  Sometimes I launch another copy with one or two outlines specified on the command line.  Those command lines, in a second console, serve as de facto sessions.  They are easy to bring back via the command line history, and I can have several.  As long as the first instance of Leo stays open until after those other ones are closed, then the session having the first Leo instance's outlines will get reloaded the next time I start Leo.

I use a different theme for the second Leo window so I can tell them apart without needing to guess. 

This has been working well for me.  

Edward K. Ream

unread,
Jun 30, 2023, 9:52:38 AM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 8:28 AM Thomas Passin wrote:

>> I actually do use the equivalent of custom temporary sessions sometimes, but the way I do it is to use the command line.  I usually keep a Leo window open all the time with maybe 5 or 6 outlines open (at a minimum, the workbook, my bookmarks manager, and whatever outline I want to work with).  Sometimes I launch another copy with one or two outlines specified on the command line.  Those command lines, in a second console, serve as de facto sessions.  They are easy to bring back via the command line history, and I can have several.  As long as the first instance of Leo stays open until after those other ones are closed, then the session having the first Leo instance's outlines will get reloaded the next time I start Leo.

> I use a different theme for the second Leo window so I can tell them apart without needing to guess. 
> This has been working well for me. 

Thanks Thomas. I think many Leonistas will enjoy dead-simple sessions.

Edward

jkn

unread,
Jun 30, 2023, 9:53:48 AM6/30/23
to leo-editor

Hi Edward

On Friday, June 30, 2023 at 1:41:08 PM UTC+1 Edward K. Ream wrote:
On Fri, Jun 30, 2023 at 5:04 AM jkn <jkn...@nicorp.f9.co.uk> wrote:
FWIW I can't really tell what #3408 will actually *do*. "Real Sessions" sounds great, but what is written there is more about the coding. I would like to better understand when the user experience will be at the end of this.

The idea, now fully realized in PR #3215, is this:

1. On exit, Leo always saves a list of open outlines (automatic session-snapshot-save).
2. When you open Leo without specifying any files Leo opens the saved list of outlines (automatic session-snapshot-load).

That sounds reasonable enough. Might it be worth making (1) alterable via an @setting variable?

I can just see some scenario where you have a usual set of sessions saved, but want to have a 'scratch' session with a different set, or just one file or something.

FWIW I rarely use session-snapshot-load, just when I change my 'default' session setup. So I would no longer need to do this.

I'll attempt to give this a try soon.

    Thanks
    Jon

Edward K. Ream

unread,
Jun 30, 2023, 10:01:24 AM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 8:53 AM jkn wrote:

The idea, now fully realized in PR #3215, is this:

1. On exit, Leo always saves a list of open outlines (automatic session-snapshot-save).
2. When you open Leo without specifying any files Leo opens the saved list of outlines (automatic session-snapshot-load).

That sounds reasonable enough. Might it be worth making (1) alterable via an @setting variable?

I'd rather not :-)
I can just see some scenario where you have a usual set of sessions saved, but want to have a 'scratch' session with a different set, or just one file or something.

Well, the "usual set" implies that a script file would work. For example, I use scripts with names like 'e' (my personal outline), 't' (test.leo', 'd' (LeoDocs.leo) and 's' (leoPy.leo).

Yes. I could just always type 'leo', but that's two too many letters!
FWIW I rarely use session-snapshot-load, just when I change my 'default' session setup. So I would no longer need to do this.

As you say, there is a very slight advantage to doing session save/load manually, but I don't think the advantage is worth yet another setting!

I'll attempt to give this a try soon.

Great. Please tell us about your experience.

Edward

Thomas Passin

unread,
Jun 30, 2023, 11:44:45 AM6/30/23
to leo-editor
On Friday, June 30, 2023 at 10:01:24 AM UTC-4 Edward K. Ream wrote:
The idea, now fully realized in PR #3215, is this:

1. On exit, Leo always saves a list of open outlines (automatic session-snapshot-save).
2. When you open Leo without specifying any files Leo opens the saved list of outlines (automatic session-snapshot-load).

I just cycled Leo several time with this morning's update to PR3215.  My workbook remains intact, and the other session outlines re-opened.  (Not at the first launch:  only the workbook opened, not a surprise, I suppose).  So that's good.  I suppose when I switch back to devel I'll be at risk of losing the workbook, but I do have a backup if that happens. 

jkn

unread,
Jun 30, 2023, 11:54:54 AM6/30/23
to leo-editor
FWIW I usually run Leo from a direct desktop shortcut - having different command files to run with different command-line parameters is something ... unusual. I only ever do it if I have had a crash and am trying to see what is going on. Having a series of batch/sh files seems very ... 1990s to me...

Edward K. Ream

unread,
Jun 30, 2023, 12:35:12 PM6/30/23
to leo-e...@googlegroups.com

On Fri, Jun 30, 2023 at 10:44 AM Thomas Passin <tbp1...@gmail.com> wrote:

I just cycled Leo several time with this morning's update to PR3215.  My workbook remains intact, and the other session outlines re-opened.  (Not at the first launch:  only the workbook opened, not a surprise, I suppose).

Thanks for the testing!
 
I suppose when I switch back to devel I'll be at risk of losing the workbook, but I do have a backup if that happens. 

I doubt it. The failure was latent in devel. It took a seemingly-unrelated failure concerning (new) gnxs for data to be lost.

Edward

Edward K. Ream

unread,
Jun 30, 2023, 12:35:59 PM6/30/23
to leo-e...@googlegroups.com
On Fri, Jun 30, 2023 at 10:54 AM jkn <jkn...@nicorp.f9.co.uk> wrote:
FWIW I usually run Leo from a direct desktop shortcut - having different command files to run with different command-line parameters is something ... unusual. I only ever do it if I have had a crash and am trying to see what is going on. Having a series of batch/sh files seems very ... 1990s to me...

Whatever works :-)

Edward
Reply all
Reply to author
Forward
0 new messages