[0977] 修复打开 AI 侧边栏后关闭当前标签页不立即生效 - #4541
Merged
PinkMagicFly merged 2 commits intoSep 11, 2026
Merged
Conversation
Co-Authored-By: Claude Code <noreply@anthropic.com>
kill_tabpage 的「当前标签页」判定从全局焦点视图改为视图是否附着在 窗口上:AI 侧边栏打开时焦点在聊天输入框的嵌入视图 (tmfs://chat/<sid>/input,win_tabpage 为空),按焦点判定会把正在 显示的标签误判成非当前标签,跳过 detach/attach 且 tab 栏不刷新, 导致关闭不立即生效。关闭后台标签后的强制刷新同样改取窗口实际显示 的视图(window_to_view),而非全局焦点视图。 Co-Authored-By: Claude Code <noreply@anthropic.com>
PinkMagicFly
deleted the
pigmagicfly/0977/fix-tab-close-with-chat-sidebar
branch
September 11, 2026 07:50
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.
What
修复:文档中打开 AI 侧边栏后,点击当前文档标签页的关闭按钮,标签页不能立刻关闭,必须点击其他标签页后才消失。
Why(根因)
打开 AI 侧边栏时,
sync_chat_sidebar_mode会调用focusInput()把 Qt 焦点交给聊天输入框;聊天输入框是嵌入编辑器(buffer 形如tmfs://chat/<sid>/input),其 focusInEvent 经handle_keyboard_focus→focus_on_this_editor把全局当前视图(the_view)切到该嵌入视图。该嵌入视图的win_tabpage为空,且should_update_menu对 chat input buffer 只允许重建 ICONS_MODE。kill_tabpage原来用get_current_view_safe() == u判断「关闭的是否当前标签页」。焦点在聊天输入框时该判断为 false,正在显示的标签被误判成非当前标签:win_tabpage为空,条件不满足,tab 栏不重建。于是已关闭的 tab 仍显示在 tab 栏,直到点击其他标签触发
window-set-view才消失。How
src/Texmacs/Data/new_view.cpp的kill_tabpage:is_current改为以视图是否附着在窗口上(vw->win != NULL,即正在窗口中显示)判定,不再依赖全局焦点视图。这样焦点在聊天输入框(或其他窗口)时,关闭正在显示的标签页仍会走 detach/attach 分支:window_set_view切换到本 tabpage 窗口的下一个视图并set_current_view,其resume()触发update_menus(MENU_ALL)重建 tab 栏;window_to_view (abstract_window (win_tabpage)))做 suspend/resume,修复「侧边栏焦点下关闭后台标签页 tab 栏也不刷新」的同类问题。涉及文件
src/Texmacs/Data/new_view.cpp:kill_tabpage的is_current判定与非当前标签刷新目标视图devel/0977.md:任务文档验证
gf fmt --changed-since=main:无需改动;xmake b stem:构建通过。手工验证(待确认)
GUI 行为待用户手工验证:
🤖 Generated with Claude Code