Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip/fix 243 session saving #314

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

alphapapa
Copy link
Owner

@phil-s This is intended to fix #243. A few unrelated changes are in here, which I intend to split out before merging. But to fix the bug required more extensive changes than I...well, I kind of knew it would require a lot of minor changes, which is why I've put it off for so long.

Anyway, it seems to work now, tested in a clean config with multiple accounts. Would you mind giving the patch a quick visual inspection and letting me know if anything stands out as wrong? I'm not asking you to test it. :)

@alphapapa alphapapa marked this pull request as draft October 13, 2024 03:41
@alphapapa alphapapa self-assigned this Oct 13, 2024
@alphapapa alphapapa added bug Something isn't working enhancement New feature or request priority:A labels Oct 13, 2024
@alphapapa alphapapa added this to the v0.17 milestone Oct 13, 2024
When disconnecting from a session, we now keep the slots necessary for
reconnecting, and we persist those slots.

Previously all of the session's data was discarded after writing, so
if multiple accounts were disconnected but not at the same time, the
first session to be disconnected was forgotten.

Fixes #243.

Reported-by: formula-spectre <https://github.com/formula-spectre>
@alphapapa alphapapa force-pushed the wip/fix-243-session-saving branch from edefcb5 to df91863 Compare October 13, 2024 03:47
@phil-s
Copy link

phil-s commented Oct 13, 2024

Can do, but probably not before the end of next week, if that's ok. I've lisped a bit more than I should have today already, and the next few days aren't going to be an option.

Copy link

@phil-s phil-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for not getting around to this sooner!

Comment on lines +387 to 388
;; TODO: Should call this hook for each session with the session as argument.
(run-hooks 'ement-disconnect-hook)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO sounds sensible. Alternatively, call it for each session with ement-session let-bound to that session? Then you wouldn't need to switch to an abnormal hook. Or keep that hook as-is and add a new abnormal hook to run per-session with the argument.

Comment on lines +401 to +403
(let* ((session (buffer-local-value 'ement-session buffer))
(connectedp (and session (not (ement-session-has-synced-p session)))))
(unless (or connectedp (and any-connected-p (not session)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the not here correct?:

(connectedp (and session (not (ement-session-has-synced-p session))))

A session which hasn't synced doesn't seem connected?

Comment on lines +789 to +791
(_ (let* ((ids (mapcar #'car sessions))
(selected-id (completing-read prompt ids nil t)))
(alist-get selected-id sessions nil nil #'equal))))))))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a lot of the ement-complete-session uses could reasonably be expected to act on the session for the current room buffer. How about we make that call to completing-read specify the id for ement-session as its DEFault argument?

We'd then want to make the prompt (format "%s [%s]: " prompt id) in the case when there was a default.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also wondering whether there could be cases in practice where the user thought they were in multiple sessions, but in fact only one of them was connected, and the "don't prompt when only one session is connected" behaviour caused them to do something in the wrong session.

It might be reasonable to have a user option to say "prompt whenever there are multiple sessions, even if only one of them is connected".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request priority:A
Projects
None yet
Development

Successfully merging this pull request may close these issues.

only the last disconnected session is remembered when (ement-save-sessions) is set to t
2 participants