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

Revert "fix(bash): avoid unexpected atuin history start for keybindings" #1727

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

ellie
Copy link
Member

@ellie ellie commented Feb 17, 2024

Reverts #1509

cc @akinomyoga

Looks like this is causing some of the "bash not recording commands" issues, from what I've managed to replicate. I'd rather take inaccurate timings vs missed commands :/

@ellie ellie merged commit 032ca19 into main Feb 17, 2024
15 checks passed
@ellie ellie deleted the revert-1509-fix1003-2 branch February 17, 2024 09:48
@akinomyoga
Copy link
Contributor

I submitted a proper fix to rcaloras/bash-preexec#152.

@ellie
Copy link
Member Author

ellie commented Feb 17, 2024

Great!

Does that fix mean we don't need this patch at all? I'm probably going to need to release v18.0.2 shortly

@akinomyoga
Copy link
Contributor

Does that fix mean we don't need this patch at all?

Yes, after the PR is merged, we shouldn't need this revert patch.

As explained in rcaloras/bash-preexec#152, the problem is that preexec is called for the keybinding and passes the previous command. This behavior of bash-preexec caused overwriting the entry of the previous command and produced 0s duration. #1509 originally tried to fix the problem at Atuin's side (as at that time, I haven't thought about the possibility that it is possible to fix it at bash-preexec's side). Now that we reverted #1509, I guess we start to have the 0s-duration issue again.

Let me look at the behavior more closely. Maybe I'll submit a rework of #1509.

@ellie
Copy link
Member Author

ellie commented Feb 17, 2024

Yes, after the PR is merged, we shouldn't need this revert patch.

I'm afraid we will still need it, as we have no way of ensuring existing users upgrade.

I guess we start to have the 0s-duration issue again.

In my testing so far, without this revert, we don't really record history at all. I'd rather have the 0-s duration than not record history

@akinomyoga
Copy link
Contributor

In my testing so far, without this revert, we don't really record history at all.

Let me check the behavior. As far as I look at the change in #1509, I don't quite get why removing this part would fix the problem.

@akinomyoga
Copy link
Contributor

As far as I test the latest main after this revert, the problem doesn't seem to be solved. Hmm.

In the first place, since bash-preexec doesn't pass the command to Atuin at all, there doesn't seem to be a way for Atuin to get the command. If the command is added to Atuin's history with Atuin of the current main with the current bash-preexec, it's a mystery to me where Atuin got the command.

@akinomyoga
Copy link
Contributor

akinomyoga commented Feb 17, 2024

Ah, OK. I think you started and canceled the Atuin history search at every line in the testing. In that case, the command is added to Atuin's history before the Atuin history search is started. In that use pattern, the problem doesn't arise indeed.

However, in the use case where the Atuin history search is called now and then, the commands are still randomly added or missing.

@ellie
Copy link
Member Author

ellie commented Feb 17, 2024

Hmmm I'm sorry, I think you're right. Perhaps this revert was a little hasty 🙈

The behaviour that does seem consistent, and not random, is that

  1. A command after cancelling an Atuin search is not recorded
  2. A command after accepting an atuin search is recorded

Try running a bunch in a series between accepting/cancelling a search and you'll see that the first isn't recorded depending on whether you've accepted or cancelled

Edit: this happens before/after the revert, so I'll un-revert it.

@akinomyoga
Copy link
Contributor

akinomyoga commented Feb 17, 2024

I'm now preparing a rework of #1509. I'll submit it soon. Could you take a look at the reworked version after I submit it?

@ellie
Copy link
Member Author

ellie commented Feb 17, 2024

I'm now preparing a rework of #1509. I'll submit it soon. Could you take a look at the reworked version after I submit it?

Of course! I've undone the revert as it was a red-herring.

I've also just checked v17.2.1, and the behaviour I've described in my previous comments occurs there too

akinomyoga added a commit to akinomyoga/atuin that referenced this pull request Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

atuinsh#1509
atuinsh#1727
atuinsh#1728
akinomyoga added a commit to akinomyoga/atuin that referenced this pull request Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

atuinsh#1509
atuinsh#1727
atuinsh#1728
akinomyoga added a commit to akinomyoga/atuin that referenced this pull request Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

atuinsh#1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
atuinsh#1003 (comment)
atuinsh#1727
atuinsh#1728
akinomyoga added a commit to akinomyoga/atuin that referenced this pull request Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

atuinsh#1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
atuinsh#1003 (comment)
atuinsh#1727
atuinsh#1728
akinomyoga added a commit to akinomyoga/atuin that referenced this pull request Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec event caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

atuinsh#1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
atuinsh#1003 (comment)
atuinsh#1727
atuinsh#1728
ellie pushed a commit that referenced this pull request Feb 17, 2024
In GitHub #1509, we blocked the unintended preexec event caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

#1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
#1003 (comment)
#1727
#1728
ellie pushed a commit that referenced this pull request Feb 26, 2024
In GitHub #1509, we blocked the unintended preexec event caused by the
keybinding of Atuin.  However, with that fix, the preexec event for
the intended user command is still missing.  In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).

References:

#1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
#1003 (comment)
#1727
#1728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants