pjeby / pane-relief

Obsidian plugin for per-pane history, pane movement/navigation hotkeys, and more
237 stars 7 forks source link

menu entries "Navigate back/forward" not working #11

Closed depressiveRobot closed 1 year ago

depressiveRobot commented 2 years ago

When using your plugin, the navigation buttons in the title bar work perfectly.

However, the menu entries View -> Navigate back and View -> Navigate forward do not work.

Obsidian: v0.13.19 Pane Relief: 0.0.17 OS: macOS Monterey 12.1

pjeby commented 2 years ago

I'm on Windows and don't really have any way to test that. But my guess is that those are tied to the browser history for Electron, rather than being Obsidian menu items per se. The mouse forward/back buttons should work correctly, as well as the Obsidian keyboard commands for going forward and back.

I'm afraid I have no clue how to go about fixing this, as I didn't realize Obsidian had OS-level menus! (You are talking about the macOS menu at the top of the screen, not a menu inside Obsidian, right?)

depressiveRobot commented 2 years ago

I would like to help you fix that.

First, yes, I am talking about the macOS menu entries. There are also command palette commands with the same name: Navigate back and Navigate forward. According to my testing, the are doing the same as the macOS menu entries. I also have the same issues as described by the plugin, that's why I want to use it.

Is there any way I can help you by debugging Obsidian? Do you have an idea how can I get debug information what is triggered in Obsidian by the commands/menu entries?

pjeby commented 2 years ago

Hm. I'm on 0.13.19 and the navigate forward/back commands in Obsidian work correctly, i.e. they do the same as the buttons. Can you describe what is happening, and what you expect to happen instead? (With both the commands and the menu, and how it differs from what the buttons are doing.)

Also, how are your panes arranged, and are you using sliding panes? Which pane is active when you use the command, and what do the buttons show as the number of available forward or back pages?

depressiveRobot commented 2 years ago

In short:

Here is a short video which may be worth more than 1000 words: https://user-images.githubusercontent.com/6043497/151662318-61ac3e34-2a3d-4b4c-9956-16865c6cb0ce.mov

pjeby commented 2 years ago

Do the menu entries work without pane relief? (Try in the Help Vault, so you don't lose any history from your main.)

Also, interesting about the menu, since I didn't know Obsidian had menus on macOS. It certainly doesn't have them elsewhere. Unfortunately, I don't think there is any way for Obsidian plugins to access the menu system, because that's controlled by the main electron process, not the process where the main app runs. (It would be nice if it could - I'd love to have similar menus on Windows.) So I may not be able to override those menu options without help from the Obsidian core developers.

depressiveRobot commented 2 years ago

Yes, the menu entries have the same behavior as the buttons and the command palette commands (without Pane Relief).

pjeby commented 2 years ago

Hm. This is really weird. Neither Obsidian nor Electron appear to be creating such a menu. The default Electron viewMenu is very similar, except it's reload, force reload, toggle dev tools, then the zoom stuff and toggle full screen. That is, the Electron default menu doesn't have the minimize or navigate options, and as far as I can tell, Obsidian doesn't add them.

The only thing I can think of is if you're on a different Electron version than the code I'm looking at; can you check process.versions.electron in the dev tools window?

depressiveRobot commented 2 years ago

process.versions.electronshows: "13.6.2"

pjeby commented 2 years ago

Okay, so it must be something the Obsidian installer on Mac adds, but does in such a way that it bypasses the Obsidian command system and tells the internal browser API to do it. (Because Electron doesn't have any code to tweak the menu that way, and neither does the Windows installer.)

I don't think this is something I can fix on my side; it sounds like I'll need to ask Licat if they can change the Mac installer to forward the command from the main process to the renderer, or alternately have a way for Obsidian plugins to hook or modify the app menu in some fashion.

pjeby commented 2 years ago

Okay, so I've talked to Licat and he thinks that the thing that's doing this is fixed in Electron 16 and that Obsidian is going to that soon, so he wants to see if that fixes the problem before doing anything.

I also finally found the bit of Obsidian that does set up the menu like that, turns out I was looking in the completely wrong place, but it tells Electron to do the navigation, and Electron (at least as of v13) isn't forwarding those commands to the window.history object (which is what Pane Relief hooks into). In 16 that may have changed and so may work.

If it doesn't, then the Obsidian code setting the navigation menu will need to change, which I can't change because it would mean patching part of the code that starts Obsidian, long before plugins even start to run. So we'll have to revisit this once Obsidian is using Electron 16.

pjeby commented 2 years ago

Okay, so Obsidian is now on Electron 17 (as of the 0.13.31 installer), so can you check whether the problem still happens with that version? (Note that you need to download and reinstall, and your process.versions.electron should show 17.1.1.)

depressiveRobot commented 2 years ago

Unfortunately, it still doesn't work. Sorry. The same behavior as before: the macOS menu entries don't work. Uninstalling the plugin makes the menu entries work again.

process.versions.electron shows 17.1.1

pjeby commented 2 years ago

Just a status update; I spoke to Licat and he said they think fixing this is "definitely possible", but did not give a time frame for what release it would be in. It definitely requires an updated Obsidian core app, which is what sets up the menu items and how they communicate with the vault window.

depressiveRobot commented 2 years ago

The problem still exists with Obsidian 0.15.6., process.versions.electron shows 18.0.4.

pjeby commented 2 years ago

I've asked again for them to make the change. As far as I'm aware, it's not possible for the plugin to modify the menus as they are created by a different OS process than the one that plugins run in. But even if it is possible to change it, I don't have a Mac to implement or test it on: the Windows version of Obsidian doesn't set up any menus at all. So this relies entirely on the core devs changing the menus, or else on getting a skilled Electron+Obsidian hacker w/a Mac to come up with a way to patch the menus from the renderer process.

pjeby commented 1 year ago

If I understand correctly, this should've been fixed by the Obsidian 1.x upgrade last October, but just double-checking before I close this. Are you still having the issue? Thanks.

depressiveRobot commented 1 year ago

I can confirm that the menu entries are now working as expected 🙂

Obsidian: v1.2.8 process.versions.electron: 24.1.2

pjeby commented 1 year ago

Thanks!