Image Browser with Context Aware Media Source

I setup a site with a media source that fires a snippet on the basePath and baseUrl settings like /assets/images/[[!get_context_key]] to restrict the file folder based on the context and also based on which users have access to the context.

With restricted users they only see a single context and therefore only get a single file tree. With higher level manager users they can see all contexts and the file tree opens to a context’s sub folder depending on which context the resource is in. This works as expected with the regular MODx TV image picker, and it works in Redactor’s image selector for restricted users.

But, the problem I’m having is that for manager users the image picker in Redactor opens the MODx browser displaying the proper context’s folder tree in the left column, but then displaying files from the web context in the right column. If folders happen to match up between the two contexts it is confusing because you might have missing files and it injects a ‘web’ url, but also when clicking on a folder in the context that doesn’t exist in the web context it gives an error.

Any idea why it might be displaying web context files no matter what, instead of following the folder tree that is being displayed?

NOTE: Content Blocks has the same problem when calling the MODx image browser.

Another note. I’m guessing part of this might be caused from my snippet that has a fall back to the web context when managers are using the Global Media Browser or the Files tab tree. So maybe Redactor’s file retrieval is requesting without a resource ID or context reference and confusing the snippet somehow, leading to the fall back. But, the left folder tree is correct, so I don’t know.

I’m wondering how I might make an exception for Redactor/Content Blocks file request in the snippet so it returns the proper context, or else fix Redactor if it is a bug.