Skip to content
Open
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
25 changes: 13 additions & 12 deletions products/maka/terminal-shell/tests/real_host/desktop_new_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,16 @@ impl Desktop {
.await
}

async fn finish_turn(&self, reply: ModelRequest) {
self.control("Stop response").await;
self.wait("the provider reply did not finish", reply.finish())
.await;
self.until("the response did not finish in the workbench", || {
self.controls("Stop response").is_empty().then_some(())
})
.await;
}

async fn restart(
mut self,
fixture: &Fixture,
Expand Down Expand Up @@ -1653,9 +1663,7 @@ async fn desktop_quotes_a_message_into_the_current_session() {
let indented_reply = " indented_first_line();\nCACHE_INVALIDATION_RULE";
let mut reply = desktop.request(&mut fixture).await;
reply.delta(indented_reply).await;
desktop
.wait("the reply did not finish", reply.finish())
.await;
desktop.finish_turn(reply).await;
let listed = desktop.sessions().await.len();

// Select only the second word of a multi-word user message and right-click on the
Expand Down Expand Up @@ -1763,9 +1771,7 @@ async fn desktop_quotes_a_message_into_the_current_session() {
})
.await;
follow_up.delta("Here is a concrete example.").await;
desktop
.wait("the follow-up reply did not finish", follow_up.finish())
.await;
desktop.finish_turn(follow_up).await;

// A single-line user message with a session-reference token renders via read-only
// SkillInput. Selecting one word inside it and clicking Quote selection must quote only
Expand All @@ -1775,12 +1781,7 @@ async fn desktop_quotes_a_message_into_the_current_session() {
desktop.press("Send message").await;
let mut token_reply = desktop.request(&mut fixture).await;
token_reply.delta("Checked.").await;
desktop
.wait(
"the token-message reply did not finish",
token_reply.finish(),
)
.await;
desktop.finish_turn(token_reply).await;
// Wait until the third reply's actions are laid out and scrolled into place before
// sampling the token user message's screen position.
desktop
Expand Down
80 changes: 49 additions & 31 deletions third-party/nsh/crates/nsh-platform-windows/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2022,14 +2022,17 @@ fn down(
return;
};
let touch = key != Key::Mouse;
if let Some(view) = chain(&hit.view).into_iter().find(|view| {
let state = view.state();
focusable(&state)
}) {
crate::text_input::focus_view(surface, &view);
}
let mut focus_target = chain(&hit.view)
.into_iter()
.find(|view| focusable(&view.state()));
let mut focus_hit = || {
if let Some(view) = focus_target.take() {
crate::text_input::focus_view(surface, &view);
}
};
let mut item = None;
if let Some(native) = hit.item.take() {
focus_hit();
let hosted = Item::Hosted(hit.view.clone(), native);
if hosted.send(surface, PointerKind::Down, (x, y), clicks, modifiers) {
item = Some(hosted);
Expand All @@ -2052,6 +2055,7 @@ fn down(
})
.flatten();
if let Some(view) = thumb {
focus_hit();
let input = &surface.input;
if input.pointers.borrow().is_empty() {
input.js_block.set(false);
Expand Down Expand Up @@ -2099,35 +2103,11 @@ fn down(
None
};
if let Some(c) = candidate {
focus_hit();
c.send(surface, PointerKind::Down, (x, y), clicks, modifiers);
item = Some(c);
}
}
// The press gives the keyboard focus to the stop it is on (the view or
// its nearest focusable ancestor), as a click does on a desktop; a
// hosted item (a video's controls, a component's window) or a field
// keeps the keys for itself.
match &item {
Some(Item::Input(_)) => {}
Some(Item::Hosted(..)) => {
crate::keyboard::blur_window(surface, crate::app_window::window_of(surface, &hit.view))
}
_ => {
if let Some(target) = crate::keyboard::focus_target(surface, &hit.view) {
crate::keyboard::focus_pointer(surface, &target);
} else if !matches!(item, Some(Item::Text(_) | Item::Area(..)))
&& let Some(field) = crate::text_input::focused(surface)
{
// A press on no stop (blank space) leaves the field of its
// window, as one on a stop does: the field is drawn here,
// not a system control that would lose the focus to the
// click itself. A press that starts a text selection keeps
// the field focused, so Ctrl+C copies the selection around
// a chat's composer (copy-selection-windows.test.tsx).
crate::text_input::blur(&field);
}
}
}
let native = matches!(item, Some(Item::Hosted(..) | Item::Input(_)));
let selects = matches!(item, Some(Item::Text(_) | Item::Area(..)));
let input = &surface.input;
Expand Down Expand Up @@ -2207,6 +2187,41 @@ fn down(
mode: Mode::Idle,
moved: false,
};
let mut focus = |p: &Pointer| {
focus_hit();
match &p.item {
Some(Item::Input(_)) => {}
Some(Item::Hosted(..)) => crate::keyboard::blur_window(
surface,
crate::app_window::window_of(surface, &p.target),
),
_ => {
if let Some(target) = crate::keyboard::focus_target(surface, &p.target) {
crate::keyboard::focus_pointer(surface, &target);
} else if !matches!(p.item, Some(Item::Text(_) | Item::Area(..)))
&& let Some(field) = crate::text_input::focused(surface)
{
// A press on no stop (blank space) leaves the field of its
// window, as one on a stop does: the field is drawn here,
// not a system control that would lose the focus to the
// click itself. A press that starts a text selection keeps
// the field focused, so Ctrl+C copies the selection around
// a chat's composer (copy-selection-windows.test.tsx).
crate::text_input::blur(&field);
}
}
}
};
// A mouse-down listener can capture the field's selection before the
// default focus transfer blurs it. Native items handle their own down.
let focus_after_press = !touch
&& p.item.is_none()
&& p.press
.as_ref()
.is_some_and(|press| press.events.contains(EventKind::PressDown));
if !focus_after_press {
focus(&p);
}
p.velocity.add(time, point(Points(x), Points(y)));
if p.reporting {
report(surface, TouchPhase::Start, &p, None);
Expand Down Expand Up @@ -2245,6 +2260,9 @@ fn down(
});
}
}
if focus_after_press {
focus(&p);
}
put(surface, p);
}

Expand Down