Skip to content

Commit 48dbd57

Browse files
bbbuggclaude
andauthored
fix: adapt to new AI Studio login flow (#77)
* feat: adapt to new AI Studio login flow - Update target URL to new AI Studio app endpoint - Add "Continue to the app" button handler - Remove manual script injection (app has built-in WebSocket client) - Simplify initialization flow for faster startup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add robust WebSocket initialization monitoring and error recovery - Add _checkPageErrors() to detect common initialization errors - Add _waitForWebSocketInit() to monitor browser console logs - Detect "System initialization complete" for success - Detect "System initialization failed" for failure - Check for page errors every second during 60s timeout - Auto-refresh page on errors (applet failed, concurrent updates, snapshot failed) - Implement 3-retry mechanism with page refresh between attempts - Apply to both launchOrSwitchContext and attemptLightweightReconnect Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add health monitor initialization and restart logic * refactor: simplify WebSocket initialization monitoring and improve flag handling * refactor: improve WebSocket initialization flow and flag handling * refactor: enhance WebSocket flag initialization, reuse console listener, and ensure consistent flag resets * refactor: deprecate WS_PORT env variable, enforce fixed WebSocket port 9998, and update documentation * chore: remove WS_PORT customization, enforce fixed WebSocket endpoint at 127.0.0.1:9998 * refactor: replace local logger import with class-level logger in ConfigLoader * fix: correct target URL and simplify app ID validation * fix: reorder initialization flow with URL validation after popup handling * fix: skip redundant WebSocket initialization if already completed * fix: reset WebSocket flags before re-navigation to prevent stale state * fix: adjust popup handling order to ensure correct URL validation before interactions * chore: filter out expected WebGL not supported warning in logs * fix: replace page reload with navigation to target URL for improved popup handling * fix: add random mouse movement simulation during wait to enhance human-like interaction * refactor: implement navigation verification and retry mechanism for correct page loading --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9adf4f5 commit 48dbd57

6 files changed

Lines changed: 415 additions & 59 deletions

File tree

‎.env.example‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ PORT=7860
99
HOST=0.0.0.0
1010

1111
# WebSocket server port for internal browser communication
12+
# ⚠️ DEPRECATED: This environment variable is no longer supported in the current version
13+
# The WebSocket port is now fixed at 9998 and cannot be customized
1214
WS_PORT=9998
1315

1416
# ===================================

‎README.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,14 @@ sudo docker compose down
249249

250250
#### 🗒️ 其他配置
251251

252-
| 变量名 | 描述 | 默认值 |
253-
| :------------------------- | :---------------------------------------------------------------------------------- | :------- |
254-
| `STREAMING_MODE` | 流式传输模式。`real` 为真流式,`fake` 为假流式。 | `real` |
255-
| `FORCE_THINKING` | 强制为所有请求启用思考模式。 | `false` |
256-
| `FORCE_WEB_SEARCH` | 强制为所有请求启用网络搜索。 | `false` |
257-
| `FORCE_URL_CONTEXT` | 强制为所有请求启用 URL 上下文。 | `false` |
258-
| `CAMOUFOX_EXECUTABLE_PATH` | Camoufox 浏览器的可执行文件路径(支持绝对或相对路径)。仅在手动下载浏览器时需配置。 | 自动检测 |
252+
| 变量名 | 描述 | 默认值 |
253+
| :------------------------- | :---------------------------------------------------------------------------------- | :--------- |
254+
| `STREAMING_MODE` | 流式传输模式。`real` 为真流式,`fake` 为假流式。 | `real` |
255+
| `FORCE_THINKING` | 强制为所有请求启用思考模式。 | `false` |
256+
| `FORCE_WEB_SEARCH` | 强制为所有请求启用网络搜索。 | `false` |
257+
| `FORCE_URL_CONTEXT` | 强制为所有请求启用 URL 上下文。 | `false` |
258+
| `CAMOUFOX_EXECUTABLE_PATH` | Camoufox 浏览器的可执行文件路径(支持绝对或相对路径)。仅在手动下载浏览器时需配置。 | 自动检测 |
259+
| ~~`WS_PORT`~~ | ~~WebSocket 服务器端口。~~ **⚠️ 已弃用:此环境变量不再支持,端口固定为 9998。** | ~~`9998`~~ |
259260

260261
### 🧠 模型列表配置
261262

‎README_EN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ This endpoint forwards requests to the official Gemini API format endpoint.
254254
| `FORCE_WEB_SEARCH` | Force enable web search for all requests. | `false` |
255255
| `FORCE_URL_CONTEXT` | Force enable URL context for all requests. | `false` |
256256
| `CAMOUFOX_EXECUTABLE_PATH` | Path to the Camoufox browser executable (supports both absolute and relative paths). Only required if manually downloaded. | Auto-detected |
257+
| ~~`WS_PORT`~~ | ~~WebSocket server port.~~ **⚠️ Deprecated: This environment variable is no longer supported. Port is fixed at 9998.** | ~~`9998`~~ |
257258

258259
### 🧠 Model List Configuration
259260

‎scripts/client/build.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const Logger = {
9898

9999
class ConnectionManager extends EventTarget {
100100
// [BrowserManager Injection Point] Do not modify the line below.
101-
// This line is dynamically replaced by BrowserManager.js based on WS_PORT environment variable.
101+
// WebSocket endpoint is now fixed at ws://127.0.0.1:9998 and cannot be customized.
102102
constructor(endpoint = "ws://127.0.0.1:9998") {
103103
super();
104104
this.endpoint = endpoint;

0 commit comments

Comments
 (0)