desktop
desktop copied to clipboard
feat: Add Air Traffic Control for automatic link routing to workspaces, b=no-bug, c=workspaces
Air Traffic Control – Automatic External-Link Routing
I’ve been itching to move from Arc Browser to Zen for daily work, but I couldn’t live without Arc’s Air Traffic Control feature, so I decided to add it to Zen.
This is my very first contribution to the project, so please excuse any mistakes.
What’s inside ?
| Area | File(s) | Purpose |
|---|---|---|
| Core engine | src/zen/modules/ZenAirTrafficControl.mjs |
Stores routing rules, persists them to prefs, and decides which workspace a URL belongs in. |
| Browser glue | src/zen/modules/ZenAirTrafficControlIntegration.mjs |
Hooks BrowserDOMWindow.openURI, asks the engine, then opens/relocates the tab in the right workspace. |
| Preferences UI | browser/components/preferences/zen-air-traffic-control.{xhtml,js,css} |
Lets users add / edit / disable rules from Settings. |
How it works
- Rule definition
Users will create patterns (e.g.*.github.com,*/jira/*) in the Preferences UI. - Engine decision
ZenAirTrafficControl.routeURL()returns{ workspaceId }when a rule matches. - Tab handling
The integration layer intercepts the external open, creates the tab, and moves it to the workspace – all in the same window, so no flash-of-new-window.
Performance note – the integration keeps a small “duplicate-URL” throttle to avoid processing the same link twice in a second.
Screenshots
Main interface. I added it to the Tab Management section of Preferences
When importing, you can map routes from one workspace to another.
Missing Things
Localization (l10n)
Localized strings are not yet wired up; I'm actually not sure how that process works.
Documentation
I'll create a PR in https://github.com/zen-browser/docs if/when this PR is merged.
BTW, @mauro-balades, there's a bug with the tests where I'm getting FAIL A promise chain failed to handle a rejection: [fluent] Missing message in locale en-US: category-zen-marketplace - stack: (No stack available.). There's a missing translation for a tooltip. To get past that, I hacked that xhtml file to use a different translation. I tried manually adding one to the en-US fluent file but it didn't seem to work. Need some guidance what I should do.
Should be just a warning, no?
Should be just a warning, no?
It actually fails the run. For example:
@meenie in that case, if you are going to make a PR for l10n packs, also add this one 🙏🏽
@meenie how is it going? Need help with anything?
@mr-cheffy, sorry, work has been busy :). I'll try and finish this up to today. I see you pinged another person asking about adding the affordance to open up the ATC model in the context menu but haven't heard back yet. I'll go ahead and make the change as it's pretty easy to change again.
Oh.. I misread the names 😅
Thanks a lot for such incredible amounts of patience and a great feature being introduced
Just a quick question, are there any plans to implement synchronization (as with workspaces) in this PR? Or will it be done in another PR? In any case, thanks for adding this feature.
In a separate pr imo would be better. Also, @meenie could we please call it 'Control Flow'? You know.. in order to not have the same names
Nice, that this is coming as a native feature, I specifically developed an extension for this found here.
Good work!
Just a quick check: what happens when an external link is routed to a workspace with default container A, but within Zen links to that domain have been configured to open in container B (e.g. using the widely used Firefox multi-account containers extension) ?
especially combined with this option:
@Propheticus, that is a very good question... I don't normally use Firefox so I wasn't aware of this. I will look into it!
Sorry all for the delay. My regular work has been rather all-consuming. I plan on finishing this up this weekend!
@meenie I just wanted to come check on this PR. How is it coming along locally?
I worked on it this weekend and almost finished. It took me a long time to figure out how to get the dialog stuff working. I need to fix the e2e tests and an issue with the dialog box opening up with a random width that for the life of me I can't figure out how to change lol.
Again, sorry for the delay but it's coming very soon!
Here's a sneak preview:
Context Menu Item
The new settings dialog
Looking great! Is the control flow thing an actual window or just created to look like one?
@Anoms12, it's an actual window. Using openDialog. I did look into using the same modal as the one that shows when you do cmd+q, but it was too limiting and ran into even more issues. This was a more encapsulated approach.
@meenie okay cool! Last question, the text says external applications, so are tabs opened with the URL bar not affected?
@Anoms12, that's correct.
This is coming together nicely!
A functional question:
- Can you define a 'catch all' / default workspace when no rule matches or would that simply be a regex
.*rule? - Related to that example regex: what happens in case two or more conflicting rules match? Does the rule with the highest specificity win, does the order matter, ...?
@Propheticus, great questions :).
- I suppose ya, you could just do
.*for a catch-all rule! I do see that Arc does have a default you can configure, though... Looks like I missed something 🤦🏻♂️. I'm going to skip that for now and make it a fast follow. - I have not introduced ordering, so the first rule found by creation date (oldest to newest) will be used. That's how it works in Arc and I never ran into an issue with overlapping rules because the sites I route between my person and work profiles never clashed anyway. You could easily add re-ordering to this later on, but I figured it was a bit of a scope creep so decided against it.
2. because the sites I route between my person and work profiles never clashed anyway
Agree. I can't imagine a lot of rules would conflict. Better make sure I create that catch all regex last then ;)
@Propheticus, to answer you question from a little over a week ago, I'm not sure that extension will be very compatible with Zen in the first place. Zen introduces Spaces which inside there you can configure profiles (i.e. containers and profiles are the same thing in Zen). I'm not a Firefox user as of yet, so I'm not totally confident in this assumption. With that said, though, I think Control Flow would flash with that extension for sure and really, using Zen and Control Flow would negate the need for this extension, right?
@meenie The 'profiles' naming of that menu item is misleading i.m.o. Zen (like Firefox) also knows the concept of profiles. Those are ~all encompassing. Within a profile live all the settings, extensions, site caches/cookies, etc. A container is containing cookies/sessions; so you can log into the same site with 2 accounts if you use different container tabs. Tabs in different container don't 'see' each other.
The extension is compatible and I have been using it for a while now.
Using Zen and Control Flow would negate the need for this extension, right?
While control flow manages incoming links opened externally and directs them to the correct workspace, the multi-account containers extension (also) manages links opened from within and opens them in the configured container tab.
If the container ('profile') assignment becomes more tightly coupled to workspaces and control flow also manages internally opened newtabs/links, then the extension would become obsolete.
@Anoms12, that's correct.
@meenie I might be crazy here but I could see genuine use in having an option for this to apply to the URL bar too. I feel that it would help with making sure each space keeps the use the user gives it, and help with organizing your tabs. If you have a different perspective I would love to hear it.
@Anoms12, I feel pretty dumb right now. I thought Arc didn't do that, but it definitely does. When you click on a link in one space and it's routed to another, it will switch spaces with that tab. Same thing with using the option to open the link in a new tab, but in this scenario Arc doesn't switch, it just shows an alert saying it opened the link in another space. I will definitely make sure that Control Flow will do the same. Thanks a ton for catching that!
@Propheticus, okay, looking into containers a bit more and also how Zen works and I am now realizing that each Workspace in Zen actually uses the same exact Profile! Meaning it shares your extensions, browser history, saved passwords, etc. I had no idea! I have yet to move over to this browser from Arc. In Arc, you can assign different chrome profiles to different spaces to keep them fully separate but that does not seem to be the case with Zen, correct?
@meenie oh I thought Arc did what you already have, I didn't realize it worked across spaces (I am on windows), but thank you so much for being willing to add that! (Might want to update that text too, as it would be misleading) not to add more to your plate but do you have an ETA for this PR? I am really excited for this as I am bad at organization, so I do not use my spaces too well.
@Propheticus, okay, looking into containers a bit more and also how Zen works and I am now realizing that each Workspace in Zen actually uses the same exact Profile! Meaning it shares your extensions, browser history, saved passwords, etc. I had no idea! I have yet to move over to this browser from Arc. In Arc, you can assign different chrome profiles to different spaces to keep them fully separate but that does not seem to be the case with Zen, correct?
I know I am not him, but this is correct. Only cookies are divided with containers on Zen.
This page might be of interest to you.
@Anoms12, if you asked me this question before all the realizations about this project I've had today, I would have said this evening I'd have it merged in lol. But now I need to go through and update some things and make sure I haven't broken anything. It's probably going to be a few more days. Also, once it's merged, I have no idea what the release process/schedule is for Zen. That's up to the maintainers.