Skip to content

Commit 8b1c4e3

Browse files
committed
release: 0.0.1.0
Merge pull request #4 from pnd280/alpha
2 parents 92ccb50 + 26aeb37 commit 8b1c4e3

File tree

24 files changed

+298
-127
lines changed

24 files changed

+298
-127
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ body:
2626
4. See error
2727
validations:
2828
required: true
29+
- type: checkboxes
30+
id: bug-confirm
31+
attributes:
32+
label: Bug confirmation
33+
description: Make sure this is not a native bug from Perplexity.ai
34+
options:
35+
- label: I am not able to reproduce the issue with the extension disabled
36+
required: true
37+
- label: I have re-installed the extension and the issue persists
38+
required: true
39+
2940
- type: textarea
3041
id: expected-behavior
3142
attributes:
@@ -54,4 +65,4 @@ body:
5465
label: Additional context
5566
description: Add any other context about the problem here.
5667
validations:
57-
required: false
68+
required: false

.github/workflows/pre-release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Create pre-release
2+
3+
on:
4+
push:
5+
branches:
6+
- alpha
7+
8+
jobs:
9+
create-alpha-release:
10+
if: startsWith(github.event.head_commit.message, 'release(alpha):')
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Extract package version
18+
id: package-version
19+
run: |
20+
VERSION=$(node -p "require('./package.json').version")
21+
echo "version=v$VERSION-alpha" >> $GITHUB_OUTPUT
22+
23+
- name: Extract release notes
24+
id: release-notes
25+
run: |
26+
COMMIT_MSG="${{ github.event.head_commit.message }}"
27+
RELEASE_NOTES=$(echo "$COMMIT_MSG" | sed -n '/^release(alpha):/,/^$/p' | sed '1d;$d')
28+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
29+
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
30+
echo "EOF" >> $GITHUB_OUTPUT
31+
shell: /usr/bin/bash -e {0}
32+
33+
- name: Create and push tag
34+
run: |
35+
git config --global user.name "GitHub Actions Bot"
36+
git config --global user.email "actions@github.com"
37+
source $GITHUB_OUTPUT
38+
git tag -a ${{steps.package-version.outputs.version}} -m "$release_notes"
39+
git push origin ${{steps.package-version.outputs.version}}
40+
41+
- name: Create Release
42+
uses: softprops/action-gh-release@v2
43+
with:
44+
body: ${{ steps.release-notes.outputs.release_notes }}
45+
prerelease: true
46+
tag_name: ${{ steps.package-version.outputs.version }}
47+
48+
permissions:
49+
contents: write

README.md

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
<a href="https://discord.gg/fxzqdkwmWx" target="_blank"><img src="https://img.shields.io/discord/1245377426331144304?logo=discord&label=discord&link=https%3A%2F%2Fdiscord.gg%2FfxzqdkwmWx" alt="Discord"></a>
1111
</div>
1212
<div align="center">
13-
<img src="https://img.shields.io/badge/CWS_Rating-5/5-blue" alt="Chrome Web Store Rating">
14-
<img src="https://img.shields.io/badge/CWS_Users-220-blue" alt="Chrome Web Store Users">
15-
<img src="https://img.shields.io/badge/MOA_Rating-5/5-orange" alt="Mozilla Add-on Rating">
16-
<img src="https://img.shields.io/badge/MOA_Users-100-orange" alt="Mozilla Add-on Users">
13+
<img src="https://img.shields.io/chrome-web-store/rating/ffppmilmeaekegkpckebkeahjgmhggpj?label=CWS%20rating" alt="Chrome Web Store Rating">
14+
<img src="https://img.shields.io/chrome-web-store/users/ffppmilmeaekegkpckebkeahjgmhggpj?label=CWS%20users" alt="Chrome Web Store Users">
15+
<img src="https://img.shields.io/badge/MAO_Rating-%23-orange" alt="Mozilla Add-on Rating">
16+
<img src="https://img.shields.io/badge/MAO_Users-%23-orange" alt="Mozilla Add-on Users">
1717
</div>
1818
</p>
1919

@@ -45,12 +45,66 @@ Perplexity.ai is famously known for its LLM-based search engine, but many may no
4545

4646
## How does it work?
4747

48-
- Read more about the [architecture](./docs/architecture.md).
48+
This is a high-level overview of the network traffic intercepting which provides the extension with the ability to alter the behavior of the host page.
49+
50+
```mermaid
51+
graph TD
52+
subgraph Browser
53+
W[perplexity.ai]
54+
CS[Content Scripts]
55+
BP[Background Page]
56+
end
57+
58+
subgraph InterceptAPIs["Intercept native APIs"]
59+
WI["Singleton Instance (Main-world)"]
60+
WI --> |Initializes| PWS[Proxy WebSocket]
61+
WI --> |Initializes| PXHR[Proxy XMLHttpRequest]
62+
WI --> AM[Active Connection Manager]
63+
WI --> ML[Message Listener]
64+
end
65+
66+
subgraph Interceptors
67+
WM["Controller (Isolated)"]
68+
WM --> MP[Message Processor]
69+
WM --> IC[Interceptor Chain]
70+
WM --> EL[Event Listeners]
71+
end
72+
73+
WI <-. "window.postMessage" .-> WM
74+
75+
W <--> |WebSocket/XHR| PWS
76+
W <--> |WebSocket/XHR| PXHR
77+
78+
PWS --> |Intercepts| AM
79+
PXHR --> |Intercepts| AM
80+
81+
AM --> |Notifies| ML
82+
ML --> |Sends Messages to| WM
83+
84+
CS <--> |Communicates| WM
85+
BP <--> |Communicates| WM
86+
87+
WM --> |Processes Messages| MP
88+
MP --> |Applies Interceptors| IC
89+
IC --> |Modifies Data| MP
90+
91+
MP --> |Sends Modified Data| AM
92+
AM --> |Sends to Webpage| W
93+
94+
WM --> |Registers| EL
95+
EL --> |Triggers Events| MP
96+
97+
classDef singleton fill:#72aefd,stroke:#333,color:#ffffff,stroke-width:2px;
98+
class WI,WM singleton;
99+
100+
```
101+
102+
[Read more](./docs/architecture.md)
49103

50104
## Installation
51105

52106
- [Chrome Web Store](https://chromewebstore.google.com/detail/complexity/ffppmilmeaekegkpckebkeahjgmhggpj)
53-
- [Mozilla Add-on](#)
107+
- Mozilla Add-on (pending review)
54108
- [Releases](#)
55109

56110
## Build from source

docs/architecture.md

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,77 @@ The following implementations are opinionated and may not be the best solution.
66

77
## Intercepting Websocket Messages
88

9-
By overriding native classes and methods, Complexity is able to intercept and modify the messages sent and received by the Perplexity.ai's websocket connection, including the fallback to long-polling.
9+
```mermaid
10+
graph TD
11+
subgraph Browser
12+
W[perplexity.ai]
13+
CS[Content Scripts]
14+
BP[Background Page]
15+
end
16+
17+
subgraph InterceptAPIs["Intercept native APIs"]
18+
WI["Singleton Instance (Main-world)"]
19+
WI --> |Initializes| PWS[Proxy WebSocket]
20+
WI --> |Initializes| PXHR[Proxy XMLHttpRequest]
21+
WI --> AM[Active Connection Manager]
22+
WI --> ML[Message Listener]
23+
end
24+
25+
subgraph Interceptors
26+
WM["Controller (Isolated)"]
27+
WM --> MP[Message Processor]
28+
WM --> IC[Interceptor Chain]
29+
WM --> EL[Event Listeners]
30+
end
31+
32+
WI <-. "window.postMessage" .-> WM
33+
34+
W <--> |WebSocket/XHR| PWS
35+
W <--> |WebSocket/XHR| PXHR
36+
37+
PWS --> |Intercepts| AM
38+
PXHR --> |Intercepts| AM
39+
40+
AM --> |Notifies| ML
41+
ML --> |Sends Messages to| WM
42+
43+
CS <--> |Communicates| WM
44+
BP <--> |Communicates| WM
45+
46+
WM --> |Processes Messages| MP
47+
MP --> |Applies Interceptors| IC
48+
IC --> |Modifies Data| MP
49+
50+
MP --> |Sends Modified Data| AM
51+
AM --> |Sends to Webpage| W
52+
53+
WM --> |Registers| EL
54+
EL --> |Triggers Events| MP
55+
56+
classDef singleton fill:#72aefd,stroke:#333,color:#ffffff,stroke-width:2px;
57+
class WI,WM singleton;
58+
59+
```
60+
61+
Some magic like switching model/focus mode on the fly, or modifying collections, is done by intercepting the messages sent and received by Perplexity.ai's websocket connection, including the fallback to long-polling.
1062

1163
## Custom DOM Mutation Observer
1264

13-
Although the all LLMs' context window on Perplexity.ai is limited to roughly 32K, a thread/convo can get infinitely long, there's no limit to how many messages can be sent. And the performance of the page will degrade as the thread grows. To have extra features, while maintaining the performance, excessive use of MutationObserver guarantees to significantly slow down the page. To tackle this, Complexity has a custom implemented MutationObserver wrapper class that applies many optimizations to keep the main thread as responsive as possible.
65+
Although all LLMs' context windows on Perplexity.ai are limited to roughly 32K, a thread/conversation can get infinitely long; there's no limit to how many messages can be sent. The performance of the page will degrade as the thread grows due to accumulated DOM mutations from MutationObserver. There have been several attempts to optimize the MutationObserver (batching, throttling, queueing, etc.), and the performance is much better than in previous iterations of Complexity.
66+
67+
It is shown that the latest version of Complexity can work well with a thread of ~50 messages (up from 20), but it is still recommended NOT to use that many messages in a thread.
1468

15-
## Communication between js contexts
69+
## Communication between JS contexts
1670

17-
Due to the restriction of the isolated context, content scripts in isolated context cannot directly access the `window` object, react fiber node data, and the Websocket class itself, which a lot of the features of Complexity rely on. Hence, Complexity implements a simple request-response communication bridge to share data between different js contexts (isolated <-> main-world) based on the `window.postMessage` API.
71+
Due to the restrictions of the isolated context, content scripts in isolated contexts cannot directly access the `window` object, React fiber node data, and the Websocket class itself, which many of Complexity's features rely on. Hence, Complexity implements a simple request-response communication bridge to share data between different JS contexts (isolated <-> main-world) based on the `window.postMessage` API.
1872

1973
## React
2074

21-
Complexity UI's is rendered using React:
75+
Complexity's UI is rendered using React:
2276

2377
- TailwindCSS for styling.
2478
- Ark-UI for headless UI components.
2579

26-
Complexity uses a combination of @tanstack/react-query and zustand for state management:
27-
28-
- @tanstack/react-query for overall async states: data fetching and internal communication between js contexts.
29-
- zustand for local states: UI states and other local states.
30-
31-
## Why there is `jquery` dependency?
80+
## Why is there `jquery` dependency?
3281

33-
- Although it is mentioned that the project uses React, `jquery` is exclusively used for direct DOM selections and manipulations of the host page. It provides much better DX than vanilla js methods.
82+
Although it is mentioned that the project uses React, `jquery` is exclusively used for direct DOM selections and manipulations of the host page. It provides a much better developer experience (DX) than vanilla JS methods.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
"esl": "eslint ./src/",
2222
"eslf": "eslint ./src/ --fix",
2323
"fmt": "prettier --write '**/*.{tsx,ts}'",
24-
"zip": "pnpm build && pnpm gulp zip",
25-
"clean-zip": "rm -rf node_modules/ && pnpm i && pnpm esl && pnpm fmt && pnpm zip"
24+
"test": "vitest run",
25+
"zip": "pnpm test && pnpm build && pnpm gulp zip",
26+
"clean-zip": "rm -rf node_modules/ && pnpm i && pnpm esl && pnpm fmt && pnpm test && pnpm zip"
2627
},
2728
"dependencies": {
2829
"@ark-ui/react": "^3.7.0",

public/img/logo-128.png

34 Bytes
Loading

public/img/logo-16.png

14 Bytes
Loading

public/img/logo-256.png

-5.08 KB
Binary file not shown.

public/img/logo-34.png

66 Bytes
Loading

public/img/logo-48.png

44 Bytes
Loading

0 commit comments

Comments
 (0)