-
Notifications
You must be signed in to change notification settings - Fork 157
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
Improve history isolation #634
Conversation
After this change we will get rows: - that have the same session_id, or - have a lower id than the first command with our session_id, or - if there's no command with our session_id, take the whole history.
thanks @Hofer-Julian 🙏 that's the first time, so how would you test that in Nushell? |
ooh this is very interesting 👌 |
here are the steps i followed diff --git a/examples/demo.rs b/examples/demo.rs
index af98c0b..2f40008 100644
--- a/examples/demo.rs
+++ b/examples/demo.rs
@@ -68,7 +68,7 @@ fn main() -> std::io::Result<()> {
// Setting history_per_session to true will allow the history to be isolated to the current session
// Setting history_per_session to false will allow the history to be shared across all sessions
- let history_per_session = false;
+ let history_per_session = true;
let mut history_session_id = if history_per_session {
Reedline::create_history_session_id()
} else {
this is almost correct, right? |
Oh nice, thanks for testing. Will see if I can reproduce and fix it. |
yeah at least if you can reproduce 😋 |
I added this stuff in the original PR in order to help test the history session stuff. I'm not sure if it's still helpful or not. It's like adding 3 commands. Lines 169 to 191 in b2b8f3f
|
@amtoine I can reproduce the behavior you found, nice find! 😄 It only happens if you open two terminals at the same time. If you then start typing in both of them, the second one has access to the very first command that was typed in the first terminal. It is not the first one that is suggested, and all the other commands are still isolated. I understand why it happens. However, with the current data in |
@fdncred I think your commands continue to be as useful as they were before. Feel free to remove some of them if you question their usefulness now. |
With the one command I am wondering if this pathology is down to the hold one entry back behavior for the "ignore commands with leading space" feature? |
I think the problem is in the way I check for “old history”. I do that by finding commands that were executed before the first command with my session id. That is mostly, but not exactly the wanted behaviour as described above. The difference is that the first run command counts, not the time when the session was created. We could workaround that I think by adding e.g. adding an empty history entry when the session is started. Not sure if that is necessary though. |
I've now stored the session_timestamp in I've also noticed that it was relatively easy to enforce history_isolation for hints as well, so I've added that too: badf4d3 @amtoine maybe you can try it again and see if you can find more bugs :) As a sidenote, I've noticed two things that should be cleaned up I think:
That is outside the scope of this PR though. |
Does this always mean that there is a valid session id, or can it still be stored as none in the db?
Good job! at the end of my original changes, I was so sick of messing with it, that I was like, "land it and let someone else improve it". Thanks for doing that.
I did this mostly for testing. But it also comes into play when history.isolation is a configuration point in nushell and you reconfigure and source your config without restarting the shell. e.g. I have this keybinding in nushell for F5
I'm guessing this is my fault too. I think originally just named things whatever and then at the end went for the verbose history_session_id so there was no confusion. I'm fine with them all being named the verbose way if they're indeed all the same thing. |
It can still be stored as none. History isolation is now only present if a
That's useful to know |
@Hofer-Julian at least i do not see |
Thanks for checking @amtoine! From my side this PR is ready for review then. |
Friendly reminder to check this PR :) |
We're two days from the 0.85.0 release. The question is do we think it's stable enough and working the way it needs to in order to land a PR this close to the release? I always approach releases with an abundance of caution. I could be convinced to land it though. |
It will need (minor) adaptions for nushell as well. I am happy to provide a PR for that as soon as it is merged. Merging it would allow us to test for one release cycle (or more if needed) to see whether it is good enough to be the default. |
I'm ok with landing. What do you think @sholderbach? |
I am OK with both landing and waiting here. The changes look fine in the code and @amtoine's testing seems to have succeeded. As you @Hofer-Julian have the patch for nushell ready we could go ahead. My risk tolerance is a bit higher for the features that are currently broken anyways. At the same time both the nushell REPL and the edge cases of the SqliteHistory are undertested when it comes to any CI watching. But the Nushell change doesn't risk to introduce any panic if the timestamp is weird etc. The only folks affected would be those that explicitly use the feature. So a green light from my side. |
Thanks @Hofer-Julian. |
Depends on nushell/reedline#634 --------- Co-authored-by: WindSoilder <[email protected]>
Depends on nushell/reedline#634 --------- Co-authored-by: WindSoilder <[email protected]>
After this change (with enabled history isolation), we will get rows:
See nushell/nushell#10104 (comment) for an example of the new behavior