If there are multiple sessions in the list it's not the most recently used one that is in the top of the list and selected. It's actually sorted the other way around (at least for me, maybe the order is simply undefined). To fix the session order I get the expected result (the most recently used session selected) by simply replacing gtk_list_store_append() with gtk_list_store_prepend() in xfsm_chooser_set_sessions(). But I don't know how the list of sessions sent to this function is supposed to be sorted. Is it perhaps better to fix it in the caller? Or perhaps assume the list is unsorted and sort it on access time before adding the sessions to the list store?
As far as I can tell it simply loads them from top to bottom from the rc file which I think - as far as I can tell from the code - is unsorted. The "last access time" is stored and available in the function that loads the sessions, so instead of gtk_list_store_append you'd have to implement g_list_store_insert_sorted with a compare_func that sorts by ATIME.
Created attachment 8942 Fix With this patch the sorting is done in settings_list_sessions_populate(), which is also used by the session editor. Perhaps another sorting is preferred in that case (but for now I guess this sorting is no worse than unsorted at least). In that case the function sort_sessions_on_atime() could be called from xfsm_chooser_set_sessions() instead.
Magnus Bergman referenced this bugreport in commit 436c09d51f8c3ae5beffd3aad536bc1c99935222 Sort saved sessions by most recently used (Bug #15338) https://git.xfce.org/xfce/xfce4-session/commit?id=436c09d51f8c3ae5beffd3aad536bc1c99935222
I finally got around to looking at this. Thanks for the patch!