feat(widget): 新建对话按钮 + 修用户开 tab 被误识为 AI 开 - #47
Merged
Conversation
added 2 commits
July 10, 2026 15:01
v0.0.14 的修复只 gate 在 status ∈ {running, streaming},widget 上线
后问题回归:widget 与 sidepanel 各有 zustand 实例,widget 在跑时
broadcast status="streaming" 也同步到 sidepanel;此时用户在 session tab
上 Ctrl+click 链接 → tabs.spawned 带 openerTabId → cross-tab-events
看到 streaming → 错误归给 AI ("AI 在 #200 打开了...")。
真信号:AI 的 openTab 用 chrome.tabs.create 不带 opener,唯一会带
openerTabId 的 AI 行为是 click 工具打 target=_blank 的链接 — 发生
在 tool_running 后毫秒级内。
修:
- SessionData 加 _lastToolRunningAt 时间戳
- setStatus(tabId, "running") 顺带盖 _lastToolRunningAt = Date.now()
- cross-tab-events 的 tabs.spawned gate 改成 now - _lastToolRunningAt
< 1500ms;更严格,streaming 但无近期工具活跃时 = 用户开的
新增回归 test:streaming + stale _lastToolRunningAt(5s前)不归 AI
需求:widget 里没入口新建会话,只能去 sidepanel。
- 新增 sidepanel/chat/new-chat.ts:newChatForTab(tabId) 封装
flush → archive → prune → cascade delete → startNewSession →
clear persist,和 sidepanel header 的 [新建] 走同一条路径
- app-shell.tsx onNewChat 改为 dynamic import 共用 helper
- widget Panel header 增加 MessageSquarePlus 按钮:
- 会话有内容时 window.confirm 二次确认(避免误删)
- 复用 newChatForTab + 清 Panel 本地 input state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
两个改动打包发一版:
1. 新建对话按钮(用户直接需求)
2. 用户开 tab 被误识为 AI 开(用户抓到的问题)
v0.0.14 只 gate 在 status ∈ {running, streaming},widget 上线后回归:
widget 跑时 broadcast status="streaming" 也同步到 sidepanel,此时用户在
session tab Ctrl+click 链接 → tabs.spawned 带 openerTabId → 错归 AI。
真信号:AI 的 openTab 用 chrome.tabs.create 无 opener,唯一会带
openerTabId 的 AI 行为是 click 工具打 target=_blank 链接 — 发生在
tool_running 后毫秒级内。
修:
Test plan