Skip to content

fix(home): 连接快速打开点一次不再新建两个会话(#461) - #462

Merged
feigeCode merged 1 commit into
devfrom
fix/quick-open-duplicate-ssh-session
Oct 25, 2026
Merged

feigeCode merged 1 commit into
devfrom
fix/quick-open-duplicate-ssh-session

Conversation

@feigeCode

@feigeCode feigeCode commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

问题

关联 #461。

在标签栏点「+」打开「打开连接」对话框,选中一台服务器点击一行后,一次点击会新建 两个 SSH 会话(已有 2 个标签时点一次变成 4 个)。

根因

ConnectionQuickOpenDelegate::render_item 给行 ListItem 挂了 on_click 打开连接;而 gpui-component 的 List 在 render_list_item 里给外层行容器注册了内建点击处理:

this.selected_index = Some(ix);
this.on_action_confirm(&Confirm { .. }, window, cx)  // → delegate.confirm

confirm 里又打开了一次连接。gpui 的鼠标事件在 bubble 阶段按注册逆序逐个触发命中的 listener,只有 stop_propagation() 才中断,因此同一次鼠标抬起同时触发了行内 on_click 与 confirm,创建两条 ssh-terminal-* 标签。window.close_dialog 只改 Root 状态、不会重建当次 dispatch 的 listener 表,拦不住第二次打开。

修复

  • 删除 render_item 中行的打开回调,以及只被它使用的 parent / connection_for_open 绑定;行点击与键盘回车统一只走 confirm 一条路径。
  • 补回归测试 quick_open_rows_open_connections_only_through_confirm:断言行渲染路径不得出现 open_connection_from_quick,且 confirm 必须仍然打开连接。

行内「保存为连接」按钮的 stop_propagation() 保持不变。

验证

  • cargo test -p main quick_open → 5 passed; 0 failed(含新增回归测试)
  • rustfmt --edition 2024 --check main/src/home/home_connection_quick_open.rs → 通过
  • 交互层面:点击行/回车均只创建一条会话;「保存为连接」仍只弹保存表单,不额外打开连接。

连接快速打开对话框的列表行自己挂了 on_click 打开连接,而 List 内建的
行点击处理也会走 set_selected_index → confirm,confirm 里同样打开一次。
一次鼠标点击先后触发这两条路径,于是同一台服务器被连开两个 SSH 会话
(已有 2 个标签时点「+」新建,直接变成 4 个)。

现在删掉行内的打开回调(以及只被它使用的绑定),点击和键盘回车统一只走
confirm;同时补一条源码级回归测试,锁住「行渲染不得直接打开连接」。
@feigeCode
feigeCode merged commit bb56427 into dev Oct 25, 2026
7 checks passed
@feigeCode
feigeCode deleted the fix/quick-open-duplicate-ssh-session branch October 25, 2026 01:42
feigeCode added a commit that referenced this pull request Oct 25, 2026
把 origin/dev(15e41c0f7,62 个提交)合进本分支,带进:
- 快捷打开一次建两个 SSH 会话的修复(#461/#462)
- 个人同步导出凭据引用归一化、git 同步冲突「应用」修复
- 跨块拖选覆盖表格/分隔线的高亮、PostgreSQL 字符列默认值补引号
- 连接级 AI 访问策略(migration 20261022000001_connection_ai_access)
- v0.21.1 发布与 changelog 更新

冲突只三处,解法:
- AGENTS.md:两侧都是纯新增,取并集(本分支 6 条经验 + dev 的 GUI spawn npx 一条)
- crates/ai_chat_view/locales/ai_chat_view.yml:保留 search_branch / search_model,
  dev 的 search_models 随其手写模型搜索框一并弃用
- crates/ai_chat_view/src/input/agent_input.rs:模型下拉保留本分支的组件库 Select
  (自带搜索框、虚拟滚动、键盘导航,是 dev 手写 Popover+搜索框的超集),删掉
  dev 侧的 model_search_input/model_search_needs_reset、MODEL_MENU_* 常量、
  filter_model_options/model_option_matches 及其单测
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant