Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/development/gpui.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Windows 平台层负责 HWND、窗口显隐和系统事件,宿主管理托盘

[`tray-flyouts.json`](../../tools/window-probe/steps/tray-flyouts.json) 捕获组件页、悬停卡片与快捷面板(含新版本入口)的深浅主题画面,以及设置页指向组件页的卡片。改用 `--live` 可核对面板中的实时曲线。真实托盘的悬停与右键单击由 Shell 发起,测试实例不创建托盘图标。

[`tray-reopen.json`](../../tools/window-probe/steps/tray-reopen.json) 在隐藏的主窗口上检查卡片直接切换到快捷面板、再次单击关闭及重新打开,并覆盖关闭窗口动画的情况。`inspectLayout.tray` 同时记录浮窗的原生可见状态与采样状态,确认面板打开时保持前台采样节拍,关闭后恢复后台节拍。

[`process-visibility.json`](../../tools/window-probe/steps/process-visibility.json) 注入含 Windows 组件、普通进程及无所属进程连接的样本,核对三种进程视图、连接筛选、设置页规则编辑与小窗口布局。模拟快照实例的 `formValues` 设置已打开表单的输入,随后通过实际键盘路径保存或取消;`inspectLayout.visibility` 输出开关状态与列表中的 PID。

[`process-users.json`](../../tools/window-probe/steps/process-users.json) 用 `sample` 控制改写模拟快照的 `sessions` 与各进程的会话编号,核对单用户时不分组、第二个用户登录后自动分组、三种视图、分类与用户组的折叠、搜索、隐藏系统进程、同一程序在两个用户组内各占一行,以及“始终分组”“不分组”优先于登录用户数。`inspectLayout.userGroups` 输出所选模式、登录用户数、是否分组及各分组行的标题、进程数与展开状态。同一文件还用 `pointer` 的 `context` 事件在分组行上按下右键,核对弹出的菜单:当前用户可注销,其他用户在标准权限下不可选,“系统”分组只有折叠,分类标题不弹出菜单;用 `data` 把 `info.elevated` 设为真后注销其他用户,经确认对话框,再用 `resolve` 给出 `sign_out_user` 的成功与拒绝访问两种结果。模拟快照不发出任何命令,不会注销真实会话。`inspectLayout` 的 `dialog.title` 为对话框标题,`toasts` 为当前显示的通知文字。
Expand Down
1 change: 1 addition & 0 deletions src-gpui/src/frontend/test_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ impl Desktop {
"users":model::UserGroups::new(values(&self.snapshot["sessions"])).users(),
"headings":self.rows.iter().filter(|row|row.user.is_some()).map(|row|json!({"key":row.key,"title":row.title,"count":row.raw["entryCount"],"expanded":row.expanded})).collect::<Vec<_>>()},
"dialog":self.dialog_test_state(),
"tray":self.tray_test_state(cx),
"toasts":self.ui.toasts.iter().filter(|toast| toast.leaving.is_none()).map(|toast| toast.text.as_str()).collect::<Vec<_>>(),
"diagnosticCopy":if self.options.fixture.is_some() { self.data.get("diagnosticCopy") } else { None },
"diagnosticCopyReady":self.options.fixture.is_some() && self.data.contains_key("diagnosticCopy"),
Expand Down
34 changes: 34 additions & 0 deletions src-gpui/src/frontend/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,20 @@ impl Flyout {
crate::shell::dismiss_on_foreground(None);
set_alpha(self.hwnd, Some(0));
let hwnd = self.hwnd;
// Shown again before the deferred steps ran: without a fade, a right
// click closes the card and opens the panel in the same window within
// one frame. Hiding it then would leave the panel open but unseen.
let this = cx.weak_entity();
let reshown = move |cx: &App| {
this.upgrade()
.is_some_and(|flyout| flyout.read(cx).phase != Phase::Hidden)
};
let reshown_closed = reshown.clone();
// Hidden after this frame: the window is busy drawing now.
window.defer(cx, move |window, cx| {
if reshown(cx) {
return;
}
unsafe {
let _ = SetWindowPos(
hwnd,
Expand All @@ -483,6 +495,9 @@ impl Flyout {
});
let desktop = self.desktop.clone();
cx.defer(move |cx| {
if reshown_closed(cx) {
return;
}
let _ = desktop.update(cx, |desktop, _| desktop.tray_closed(kind, was_shown));
});
}
Expand Down Expand Up @@ -1066,6 +1081,25 @@ impl Render for Flyout {
}

impl Desktop {
pub(in crate::frontend) fn tray_test_state(&self, cx: &App) -> Value {
let sampling_shown = self.host.get_window("main").is_some_and(|window| {
window.hwnd().is_ok_and(|hwnd| {
crate::shell::sampling_state(hwnd) == argus_app::sampler::WindowState::Shown
})
});
let Some(open) = &self.tray.open else {
return json!({"visible":false,"panel":false,"samplingShown":sampling_shown});
};
let flyout = open.flyout.read(cx);
json!({
"visible":unsafe { windows::Win32::UI::WindowsAndMessaging::IsWindowVisible(flyout.hwnd).as_bool() },
"panel":flyout.showing(Some(Kind::Panel)),
"card":flyout.showing(Some(Kind::Card)),
"animated":flyout.fade,
"samplingShown":sampling_shown,
})
}

/// What the flyouts show now.
fn tray_readings(&self) -> Readings {
let sys = &self.snapshot["system"];
Expand Down
16 changes: 16 additions & 0 deletions tools/window-probe/steps/tray-reopen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"window": [1100, 760],
"steps": [
{"control":{"page":"components","windowMotion":"off","pointerOutside":true},"wait":700,"inspect":"layout","label":"motion-off","expect":{"animations.window":false}},
{"probe":"hide","wait":300},
{"control":{"trayFlyout":"card"},"wait":900,"inspect":"layout","label":"card","expect":{"tray.card":true,"tray.visible":true,"tray.animated":false,"tray.samplingShown":true},"captureFlyout":"card"},
{"control":{"trayFlyout":"panel"},"wait":900,"inspect":"layout","label":"card-to-panel","expect":{"tray.panel":true,"tray.visible":true,"tray.samplingShown":true},"captureFlyout":"panel"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reproduce the close-and-reopen sequence in the regression test

With window motion off, this step calls tray_panel directly through src-gpui/src/frontend/test_control.rs:24–30, replacing the card without closing it first. The real right-click path in src-gpui/src/shell.rs:1241–1246 closes the card before requesting the panel, which is what queues the stale deferred hide. Consequently, this regression test never exercises the new guards and can pass with the original bug intact. Add a test control that closes the card and opens the panel within the same effect cycle, and use it for the card-to-panel cases.

Useful? React with 👍 / 👎.

{"control":{"trayFlyout":"panel"},"wait":700,"inspect":"layout","label":"panel-closed","expect":{"tray.panel":false,"tray.visible":false,"tray.samplingShown":false}},
{"control":{"trayFlyout":"panel"},"wait":900,"inspect":"layout","label":"panel-reopened","expect":{"tray.panel":true,"tray.visible":true,"tray.samplingShown":true}},
{"control":{"trayFlyout":"close"},"wait":700,"inspect":"layout","label":"closed","expect":{"tray.visible":false,"tray.samplingShown":false}},
{"control":{"theme":"light","windowMotion":"on"},"wait":300},
{"control":{"trayFlyout":"card"},"wait":900},
{"control":{"trayFlyout":"panel"},"wait":900,"inspect":"layout","label":"motion-on-panel","expect":{"tray.panel":true,"tray.visible":true,"tray.samplingShown":true},"captureFlyout":"panel-light"},
{"control":{"trayFlyout":"close"},"wait":700,"inspect":"layout","label":"motion-on-closed","expect":{"tray.visible":false,"tray.samplingShown":false}}
]
}
Loading