Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support split-view in Edge, tab-tiling in Vivaldi #608

Merged
merged 10 commits into from
Sep 25, 2024

Conversation

sidvishnoi
Copy link
Member

@sidvishnoi sidvishnoi commented Sep 17, 2024

Context

Closes #67

Why:

  • In Edge, browser.tabs.query() skips tabs in right-pane of split-view, as if it don't exist. So, we need to keep track of existing tabs in a window ourselves.
  • Similarly, we can't know which tab was last focused.
  • There's no API to tell which all tabs are visible (that can be monetized) in a Edge split-view or Vivaldi tab-tiling view.

Changes proposed in this pull request

  • Fire a TAB_FOCUSED event from content script, on load (if focused) and on focus change (if focused).
  • Use the sender.tab.id from above event to store last focused tabId for given window.
  • Store that info in newly added WindowState service.
  • Also store last focused window in above service.
  • Note: Both pages in split-mode are monetized together.
  • For Edge, if we call browser.action.setIcon() with a tabId, it'll only update the icon for the left pane. So, added a browserName value, and skip using tabId for Edge when setting icon. This will set a global icon for Edge, but other browsers stay like before.
  • Instead of relying on onActivatedTab which is buggy in Edge with split-view, rely on TAB_FOCUSED events' sender.tab.id to update icon state. Also use this last focused tab to show popup content.
  • In order to support start/stop monetizing all tabs in given view on window focus change (not same as visibilitychange, which works like before), we send IS_TAB_IN_VIEW message to content script (top frame only) to know if tab is currently visible. This way, we get all visible tabs in current window.
  • Remove IS_WM_ENABLED message as unused.
  • Made some improvements to avoid needless checking need to pause/resume on focus change when extension popup is opened.

For reviewers: Radu is on vacation so I was asked to ask you good folks instead.

To be decided

Right now, the rate of pay is decided per tab, using the global rate of pay. Now we have multiple active visible tabs getting monetized, so the effective global rate of pay is multiplied by number of active visible tabs - user is paying more than they initially set to as they're paying multiple websites at once. In future, we'll have exception lists (#146), which will again make rate of pay per site/tab.

@github-actions github-actions bot added area: content Improvements or additions to extension content script area: background Improvements or additions to extension background script labels Sep 17, 2024
Copy link

github-actions bot commented Sep 17, 2024

Extension builds preview

Name Link
Latest commit 7dda2fa
Latest job logs Run #11012866067
BadgeDownload
BadgeDownload

@sidvishnoi

This comment was marked as resolved.

@sidvishnoi

This comment was marked as outdated.

@sidvishnoi sidvishnoi changed the title fix: support split-view in Edge [WIP] fix: support split-view in Edge Sep 18, 2024
@sidvishnoi
Copy link
Member Author

Demo with Edge split view:

Screencast.from.18-09-24.06.24.06.PM.IST.webm

@sidvishnoi
Copy link
Member Author

Demo with Vivaldi tab-tiling!

Screencast.from.18-09-24.06.53.57.PM.IST.webm

@sidvishnoi sidvishnoi changed the title fix: support split-view in Edge fix: support split-view in Edge, Vivaldi Sep 18, 2024
@sidvishnoi sidvishnoi marked this pull request as ready for review September 18, 2024 13:45
@sidvishnoi sidvishnoi changed the title fix: support split-view in Edge, Vivaldi fix: support split-view in Edge, tab-tiling in Vivaldi Sep 18, 2024
@sidvishnoi sidvishnoi changed the title fix: support split-view in Edge, tab-tiling in Vivaldi feat: support split-view in Edge, tab-tiling in Vivaldi Sep 18, 2024
Copy link

@Tymmmy Tymmmy left a comment

Choose a reason for hiding this comment

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

While I wasn't able to actually run this right now to see the split view on Edge (nothing to do with you, but with my local current setup), the code looks good to me.

@Tymmmy
Copy link

Tymmmy commented Sep 22, 2024

@sidvishnoi I have to ask, is this story ready to review? Since I reviewed it and gave approval, you pushed at least 5 new commits. I am asking so that we know when to actually review?

@sidvishnoi
Copy link
Member Author

@Tymmmy The commits I pushed are things I found with more testing, and apparently, there's enough edge cases that can cause problems with Edge (Vivaldi is fine). I'll ask for a re-review tomorrow after more testing.

I would have written E2E tests for this, but there's no APIs to trigger the behavior I'm developing for here.

(7c57663 was a realization that I was thinking I'd do as a follow-up PR, but decided to add to this only as two reviews are still pending)

Copy link

@Tymmmy Tymmmy left a comment

Choose a reason for hiding this comment

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

LGTM, surprised we support Edge :)

@sidvishnoi sidvishnoi merged commit 04945e9 into main Sep 25, 2024
9 checks passed
@sidvishnoi sidvishnoi deleted the edge-split-view branch September 25, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: background Improvements or additions to extension background script area: content Improvements or additions to extension content script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WM ext browser support - Edge
3 participants