wong2 Profile picture
Jul 4, 2023 9 tweets 3 min read Read on X
Have you ever wondered how the Bing chat sidebar in the Edge browser works? Let's discover it through reverse engineering! 🧵
First, it's important to note that the chat interface inside the sidebar is actually a web page. This allows us to inspect it using developer tools. Image
The page is embedded through an iframe in two layers: the built-in "discover-chat" page contains a "shell" page, which in turn contains the "chat" page (or the "compose" page).
So how does this web page obtain information about the currently browsed page? This web page must communicate with the browser in some way.
As it turns out, the "chat" page and "discover-chat" page exchange messages via window.postMessage
When users visit a url or switch tabs, the browser sends a `TabStripModelChange` message to the chat page, so it learns about the current viewing page. Then it will try to get the cotent of the web page via the followin ways:
1. Request an API called `/sydneyzeroturn` with the web page url, which returns the text content of the web page. I suspect this is fetched from the Bing search engine crawled data.
2. Sometimes the above API returns empty content for the web page, perhaps because the page hasn't been crawled, the chat page will request the content by sending a `Page.GetData` message to the browser. The browser will send back the text content it renders for the web page.
Then when you chat with Bing about the web page, Bing will send the full text content of the current page to the conversation API. And AI will answer your question based on the context you provided.
That's all, we now know why the sidebar Bing chat can chat about the current web page!
Based on the above knowledge, I've built a browser extension that replicates the Bing sidebar in Chrome, you can install it at: https://t.co/S9LHWDPqGYchrome.google.com/webstore/detai…
@threadreaderapp unroll

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with wong2

wong2 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(