-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Always set/save options when exiting transient #287
Comments
I think Transient should provide a mechanism to accomplish this. Adding such functionality out-of-the-box, will take some time, not so much because it is hard to implement, but to allow for the realization, that the first impulse maybe wasn't all that great after all. There are also many open questions. For example, should we allow per-package and/or per-menu customization? Should individual prefixes be able to override the user preference, if it would be "wrong" (and how to avoid an arms race)? Should saving become a task to be handled by the "pre commands" (I don't think that is feasible, but thinking about it would still be beneficial)? How does this interact with menus that implement their own "automatic persistence" (e.g., So for the time being, you'll have to implement a good enough approach yourself.
It's a major design goal to be able to use "regular commands", without them having to be modified, so this indeed is undesirable. That being said, if a command should consume the transient arguments, then it must use something like I am wondering (and wouldn't be able to tell, without looking at it in detail), whether commands that don't even consume arguments, should be able to remember arguments. The initial response (karthink/gptel#94 (comment)) to the request to "always save", seems to have been "make the do-it command also save", which is in line with that reasoning. But by your account that's what users are asking for; "always" save, for "predictability". One aspect I'll have to think about more, is that one persons "consistency" is another's "does completely useless things". I think there is value in providing the "consistent" behavior as an option, but it shouldn't come at the cost of not being able to do the "right (IMO)" thing.
That's a feature, isn't it? If the abort command no longer aborts, but instead saves, then how do you abort, if you really want to abort (e.g., because you changed some arguments, and realize that you have made some mistakes, and want to discard them to go back to what you had before)?
I'll probably add (define-advice transient--post-exit (:before (&optional command) gptel-persist)
(let ((command (or command this-command)))
(when (and gptel-persist-transient
(string-prefix-p "gptel-" (symbol-name command)))
(transient-save)))) This should give you the general idea, but it will require tweaking. Quoting from karthink/gptel#327 (where you quote from karthink/gptel#291 (comment) ;)
Looking at the screenshot at https://github.com/karthink/gptel/wiki#save-transient-flags, I get the impression, that the jarring bit could be, that you did not manage setting expectations well. In Magit it is quit obvious which commands set a variable and which set a command line argument. Due to past experience setting variables in configuration files and using argument on the command line, I would think, it is quite intuitive that they behave differently in Transient as well. But that assumes that one is able to tell the difference. I am not saying you should rush to achieve that, (e.g., by prefixing all the argument keys with So you see, it is quite complex, so for now, play with the given advice function, maybe tweak it a bit, and post the result on the wiki. |
Another place where this could be implemented is As it is, users can already get to such (automatically) saved values, using (And maybe that's all very much in line with how LLM themselves work. There's a difference between training and using. Contrary to what users might expect, they don't learn from the interactions you are having with them. If you want to to "recall" past conversations, you have to (explicitly, I assume) provide that context, and there's a limit to how much context you can provide. 😁.) |
@tarsius thank you for the detailed, informative and thoughtful response! Persisting transient optionsI tried both methods, and while neither one is ideal, I can work with these until you decide if you want to add a Transient feature for it.
Method 0: Save explicitly
I hadn't considered that. I think I can provide a This suffix will have to be shown in the menu, unfortunately, as it might be silently rebound to Method 1: Advise
|
If your question is about enabling per-package/per-menu customization of all Transient options, then I'm not sure. This is a whole can of worms! But if you meant customization of auto-saving options specifically, the simplest solution would be to follow Transient's lead in other configuration settings --
I don't follow. If option persistence is offered as an option (and disabled by default), then everyone can make Transient do the "right" thing for them, can't they? This is excepting the granularity issue, where switching this on for all Transients (or none) may not make sense.
That's great! No pressure though, I understand that changes made in a hurry exact a heavy price over time. I will use a workaround for now.
Yeah, there's no analog to command line vs config options in
The screenshot on the wiki is out of date, this is what it looks like: Right now all the persistent parameters in gptel-menu (which are instances of
Definitely some irony to be mined there. 🙂 Reflecting the behavior of the LLMs in the interface used to access them reminds me of when LLM APIs were first made available last year. There were many simple LLM clients announcing that they were dogfood-ed -- an LLM client written by an LLM! How novel. It looks like this novelty wore off as people quickly reached the limit of this approach. |
Thanks for the detailed reply. I can't work on this now, but the provided information should help a lot getting up to speed, when I return. |
The pre-command (or another slot) is definitely a good level of granularity of configuration. Not all values provide a good user experience when they are remembered. Tangentially, I recently I used the The real issue I think is the granularity of the infix persistence. Right now transient's persistence will save / set the entire transient? Having automatic set / save on an infix would thus clobber any other infix without The As a package developer, sometimes it makes sense to just put By the looks of it, @karthink has made use of A face value specific for values that are "sticky" would be helpful to show the user which settings must be set/saved versus which ones are automatically persisting to some degree. Even when we are doing completely custom persistence, this is important for UX. |
I use a Transient menu for configuring options provided by gptel, an LLM interaction package. One request I get quite often from users [1, 2] is to automatically persist all options (transient switches, flags, options etc) between invocations of the menu. Right now only the menu items backed by the
transient-lisp-variable
class (or its child classes I define) are automatically persistent.Essentially, they want
transient-set
/C-x s
to be run automatically whenever the menu exits. Is there some way to do this in Transient? Here are a couple of things I've tried:Add
(transient-set)
inside all suffixes: This has two downsides. (i) Some of the suffixes are regular elisp functions that can be called from outside the transient menu as well, I have to guard against that, and (ii)(transient-set)
does not run when they quit the menu, withC-g
orq
. So they can't invoke the menu to set some options and quit without calling a suffix.Try running
(transient-set)
intransient-exit-hook
(before removing it from the hook). This doesn't work since the hook runs after the transient has already exited. Specifically, this hook is called after(setq transient-current-prefix nil)
runs, so it fails.Is there a way to do this using Transient? My apologies if this is covered in another issue or the manual -- I tried searching for a few different things. I imagine that adding a
transient-pre-exit-hook
should make this possible, but maybe there's a way to do it after the transient exits as well, since the value ofgptel-menu
(the transient prefix in question) is stored somewhere?The text was updated successfully, but these errors were encountered: