Skip to content

Fix: Select files when using "Open in folder" from Chromium browsers - #18784

Open
0x5bfa wants to merge 1 commit into
files-community:mainfrom
0x5bfa:selectitem
Open

Fix: Select files when using "Open in folder" from Chromium browsers#18784
0x5bfa wants to merge 1 commit into
files-community:mainfrom
0x5bfa:selectitem

Conversation

@0x5bfa

@0x5bfa 0x5bfa commented Jul 30, 2026

Copy link
Copy Markdown
Member

Resolved / Related Issues

What we had done previously

The launcher had only handled:

  • Retrieving the target folder path
  • Searching for existing shell windows
  • Launching the app with files-dev:?cmd=... -directory if none found
  • Calling IShellWindows::RegisterPending and OnNavigate

However, Chromium browsers call windows.storage!SHOpenFolderAndSelectItems, which calls SHOpenOrGetFolderView, which then calls IShellView::SelectItem, meaning it requires a shell view. I also discovered that SHOpenOrGetFolderView calls IWebBrowserApp::get_Document then it calls IServiceProvider::QueryService with IID_IFolderView and IID_IShellView.

https://github.com/chromium/chromium/blob/d86b833661437c96234c43b172f83561e583ee0d/chrome/browser/platform_util_win.cc#L73-L85

What I have implemented

flowchart LR
    A[Edge / Chrome]
    B[SHOpenFolderAndSelectItems]
    C[RegisterPending / Register]
    D[IWebBrowserApp::get_Document]
    E[IServiceProvider::QueryService]
    F[IShellView::SelectItem]
    G[Files -select]

    A --> B -->|Launch the launcher| C --> D --> E --> F -->|Launch Files with -select| G
Loading

Steps used to test these changes

  1. Open Files app
  2. Open a Chromium browser (I've tested this only for Edge and Chrome)
  3. Click "Open in folder" in Downloads
  4. Confirm the target item is selected as the Explorer does

Copilot AI review requested due to automatic review settings July 30, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Windows “Open in folder” launcher integration so that when Chromium-based browsers call SHOpenFolderAndSelectItems, Files can provide the necessary shell-view hooks (e.g., IWebBrowserApp::get_DocumentIServiceProvider::QueryServiceIShellView::SelectItem) and ultimately launch Files with -select so the target item is scrolled to and selected (matching File Explorer behavior).

Changes:

  • Extend OpenInFolder to implement IWebBrowserApp, IServiceProvider, and IShellView so the shell can call SelectItem and provide the selected item back to the launcher.
  • Register the launcher window with IShellWindows::RegisterPending + Register, and trigger OnNavigate to support shell navigation/select flows.
  • Adjust launcher window creation to use a cloaked, non-activating tool window (instead of a message-only window) to better participate in shell window registration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Files.App.Launcher/OpenInFolder.h Adds COM interface surface (IWebBrowserApp/IServiceProvider/IShellView) and new state needed to support selection callbacks.
src/Files.App.Launcher/OpenInFolder.cpp Implements COM methods, registers with IShellWindows, and captures selection via IShellView::SelectItem to drive Files -select.
src/Files.App.Launcher/FilesLauncher.cpp Updates hidden window creation/attributes and adjusts the selection-vs-fallback flow when launching Files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Files.App.Launcher/FilesLauncher.cpp Outdated
Comment thread src/Files.App.Launcher/OpenInFolder.cpp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ab61fc6fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Files.App.Launcher/OpenInFolder.cpp Outdated
Comment thread src/Files.App.Launcher/FilesLauncher.cpp Outdated
Comment thread src/Files.App.Launcher/OpenInFolder.cpp Outdated
@yair100
yair100 requested a review from gave92 July 31, 2026 03:13
@yair100 yair100 added the ready for review Pull requests that are ready for review label Jul 31, 2026
@yair100

yair100 commented Jul 31, 2026

Copy link
Copy Markdown
Member

@0x5bfa this is working on my end. I tested with Edge, Task Manager, and GitHub Desktop.

Josh65-2201
Josh65-2201 previously approved these changes Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Select and scroll to file when opening file/folder location from other programs

4 participants