Bug 452637 - Action "Open Terminal" ignores path context of interacted folder
Summary: Action "Open Terminal" ignores path context of interacted folder
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 21.12.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-04-15 04:23 UTC by Brennan Kinney
Modified: 2022-05-02 20:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brennan Kinney 2022-04-15 04:23:56 UTC
SUMMARY

Since 2021 releases have dropped the Konsole "Open Terminal Here" service in favor of a generic internal alternative "Open Terminal" in Dolphin.

The new service opens a terminal at the views location, but ignores the context of the location for any sub-location interacted with (folder, or via details view many nested levels deep), requiring explicit navigation afterwards, or workarounds such as opening a new tab/window to use the context menu action.

This seems like a regression, but may be intentional to support other terminals than Konsole. However Konsole is opening at the view location, thus it seems the UX regression is fixable.


STEPS TO REPRODUCE
1. Right-click a folder and choose "Actions => Open Terminal".
2. Terminal window opens at the views set location, not the sub-directory that was interacted with.


OBSERVED RESULT

Terminal window opens at the views set location, not the sub-directory that was interacted with.


EXPECTED RESULT

Terminal window opens at the location of the interacted sub-directory.

Especially useful in the "Details" view mode for a project overview, when expanding multiple levels deep I should be able to open applications such as a terminal without having to navigate or open a new view tab to perform the action (current workaround).


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: ArchLinux, X11 with kernel 5.15.28
KDE Plasma Version: 5.24.3
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.3


ADDITIONAL INFORMATION

This used to be possibly prior to Konsole 20.12 from what I understand. Here is the commit that caused the regression in favor of Dolphin's internal service replacement:
https://invent.kde.org/utilities/konsole/-/commit/7cfe7bb380613d37427b76cc026027e547221f9e

Presently, Dolphin uses the service action `open_terminal` internally that calls the following to launch the system terminal (instead of previously hard-coded Konsole from `konsolehere.desktop` service:
https://invent.kde.org/system/dolphin/-/blob/3ebe3975a65d6e81fbda260d6df1806a7f82e142/src/dolphinmainwindow.cpp#L1088

The functionality appears to have been introduced with this MR by developer Alexander Lohnau:
https://invent.kde.org/system/dolphin/-/merge_requests/81

In the referenced Reddit thread for that MR, a user attempts to adapt the Konsole shipped service to their preferred Terminal app Tilix, and discovered an issue with differing options to open the terminal at the expected path:

> Changing "--workdir %f" to "--working-directory %f" fixed the issue.

I am not familiar with how Dolphin is launching the `open_terminal` action beyond the point I referenced earlier. I assume that calls code from another project that was difficult to search for via the Gitlab UI. Hopefully this is not a concern that would block this request from being feasible.

If it would be possible to address this regression, so that the service could open at the expected location being interacted with, not the views top-level location, that would be fantastic :)


WORKAROUND:

The present workaround is to disable the internal Dolphin service, and restore the previous Konsole shipped service instead (altering it for alternative terminal if necessary like with Tilix above). The full issue and workaround solution was discussed recently here:

https://www.reddit.com/r/kde/comments/u1mdic/how_to_restore_dolphin_action_open_terminal_here/

With the original `konsolehere.desktop` service located here:
https://invent.kde.org/utilities/konsole/-/blob/release/20.12/desktop/konsolehere.desktop

Place it's contents in `/usr/share/kservices5/ServiceMenus/konsolehere.desktop` and the service is restored under actions.
Comment 1 oioi555x 2022-04-16 10:06:26 UTC
I have submitted a patch that allows you to achieve equivalent functionality without resorting to `konsolehere.desktop`.
https://invent.kde.org/system/dolphin/-/merge_requests/378

Thank you for your detailed investigation. :)
Comment 2 Brennan Kinney 2022-04-17 01:15:17 UTC
(In reply to oioi555x from comment #1)
> I have submitted a patch that allows you to achieve equivalent functionality without resorting to `konsolehere.desktop`.

That's great, thank you!

Regarding the discussion on Gitlab, my input would be:

- Don't show the option "Open Terminal Here" for multiple selection, or disable it. A separate feature request could be made should users want that functionality. It'd be unclear if it should be separate terminal instances, or single window with tabs (but that'd likely depend upon the terminal being opened). Opening as new tabs to an existing window would be undesirable though.
- If you do opt to open multiple windows, I agree with the confirmation prompt to avoid mistakes, it's a very annoying UX otherwise (Get New Things has been throwing an API error dialog at times when it fetches content to load, and can spam the error excessively at times).
Comment 3 Nate Graham 2022-05-02 20:25:29 UTC
Git commit 9b5f56980bc4d2f399a6b828c94b23f3626c9d21 by Nate Graham, on behalf of oioi 555.
Committed on 02/05/2022 at 20:25.
Pushed by ngraham into branch 'master'.

Re-add "Open Terminal Here" feature

This is equivalent to the "Open Terminal Here" feature that existed until Version 20.12.  

If the user has selected folders, replace "Open Terminal" in the context menu with "Open Terminal Here".  
When more than 5 folders are selected, a modal window will ask the user if they are sure they want to
open all 6 or more terminal windows.

In Detail View, users can also select a file, 
which will open a terminal at the location of that file.
FIXED-IN: 22.08

M  +2    -2    src/dolphincontextmenu.cpp
M  +48   -1    src/dolphinmainwindow.cpp
M  +6    -0    src/dolphinmainwindow.h
M  +2    -1    src/dolphinpart.rc
M  +2    -1    src/dolphinui.rc
M  +2    -2    src/settings/contextmenu/contextmenusettingspage.cpp
M  +1    -1    src/settings/dolphinsettingsdialog.cpp

https://invent.kde.org/system/dolphin/commit/9b5f56980bc4d2f399a6b828c94b23f3626c9d21