makecindy / makecindy/cindy

RSB popup 投递缓冲:订阅者缺席窗口丢失一次性 OAuth URL(#742 follow-up)

Open
#1,094 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 现象

RSB popup(OAuth 授权 URL)从 main 进程到 renderer 的投递是一次性 `send()`,没有 ack/缓冲。订阅者短暂缺席的窗口内到达的 popup 会被静默丢弃——而 OAuth 授权 URL 通常只出现一次,丢了登录流程原地卡死。

#742 review 期间由 Codex 确认的两个丢失窗口(均已回复"技术正确、超出该 PR 范围"):

1. **路由切换**:归属等待(5s)期间用户离开 chat 路由,`MainLayout` 停止渲染 `RightSidebarShell`;host resolver 仍返回未销毁的主窗口 WebContents,但 preload 扇出已无订阅者(PR #742 thread @ webview-security.ts:492,2026-07-30T09:37Z)。
2. **detach/reattach 竞态**:侧栏 detach 过程中投递,`RsbWindowController.getHostWebContents()` 在 `winRef` 出现即返回新 WebContents,不校验 controller 的 `ready` 标志——新 host 的 preload 可能尚未注册 popup 扇出(同 PR thread,2026-07-30T11:06Z)。

## 已查到的根因

`sendBrowserPopup`(apps/desktop/src/main/webview-security.ts)发送时刻经注入的 host resolver 解析当前宿主(#742 已做),但"宿主 WebContents 存活" ≠ "renderer 订阅者就绪"。popupRouter(renderer)虽已窗口级常驻,仍覆盖不了 Shell 未挂载/preload 未注册的窗口期。

## 期望方案(二选一或组合)

- **main 侧缓冲 + ready 握手**:RsbWindowController 暴露 ready 事件;renderer popupRouter 订阅建立后向 main 发一次 ready ping;main 在无就绪订阅者时把 payload 入队,收到 ping 后 flush(带 TTL 防泄漏)。
- **preload 层事件缓冲**:preload 扇出在无监听者时缓存最近 N 条,`onRsbBrowserPopup` 注册时补发。

## 验收标准

- 归属等待期间切走 chat 路由再切回,popup tab 仍被创建并加载 OAuth URL;
- detach 侧栏过程中触发 popup,新窗口就绪后 popup 不丢;
- 缓冲有上限与 TTL,不因无人订阅无限堆积。

## 参考

- PR #742(已合并,3212866)及其中 webview-security.ts:492 两条 resolved threads 的讨论。

Contributor guide

Open the contributing guide

Research direction

Start with apps/desktop/src/main/webview-security.ts, especially sendBrowserPopup and the host resolver, then inspect RsbWindowController readiness and the renderer popupRouter around PR #742. Trace the route-switch and detach/reattach windows before choosing a buffering and ready-handshake design. Done means both OAuth popup scenarios survive, with bounded buffering and TTL cleanup.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, typescript
Domain
authentication, desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.