voelin-gpui: VOELIN_DEMO_SERVER, the logged Move to my channel, and what a click costs

- VOELIN_DEMO_SERVER=<0..2> puts another sample server on screen: the second
  is observed and the third is not connected, both with empty trees, which is
  how the pictures of an empty server are made.
- The person's context menu offers Move to my channel; the engine has no
  command to move another client, so the action is logged.
- A test that holds what the caches cannot save: pressing and releasing a
  clickable element refresh the window, so a click renders every pane, and a
  hover renders only the pane the pointer is over.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-28 00:14:46 +03:00
1 parent 26302bcdde
commit aa640cf2b0
5 files changed
+119 -4

No files matched your search

+66 -3
View File
@@ -18,9 +18,10 @@ use crate::dev::Page;
use crate::meter::Counters;
use crate::shell::actions::{
AddServer, CancelChannelPassword, CancelServerForm, ConnectVoice, DeleteServer,
DisconnectVoice, EditChannel, EditServer, Invite, JoinChannel, OpenClient, OpenMember,
OpenSearch, OpenSettings, PushToTalk, SaveAndConnect, SaveServer, SearchMembers, SelectChannel,
SelectServer, SetInputMuted, SetOutputMuted, SubmitChannelPassword, ToggleChannel,
DisconnectVoice, EditChannel, EditServer, Invite, JoinChannel, MoveClient, OpenClient,
OpenMember, OpenSearch, OpenSettings, PushToTalk, SaveAndConnect, SaveServer, SearchMembers,
SelectChannel, SelectServer, SetInputMuted, SetOutputMuted, SubmitChannelPassword,
ToggleChannel,
};
use crate::shell::{
ChannelPassword, ChannelTree, Emptiness, MainPanel, MemberCardView, MembersPane, ServerForm,
@@ -313,6 +314,13 @@ impl MainView {
);
}
fn move_client(&mut self, action: &MoveClient, _: &mut Window, _: &mut Context<Self>) {
tracing::info!(
client = action.client,
"moving a client needs a command the engine does not have yet"
);
}
fn search_members(&mut self, action: &SearchMembers, _: &mut Window, cx: &mut Context<Self>) {
self.app.update(cx, |app, cx| app.search_members(action.text.clone(), cx));
}
@@ -446,6 +454,7 @@ impl Render for MainView {
.on_action(cx.listener(Self::toggle_channel))
.on_action(cx.listener(Self::edit_channel))
.on_action(cx.listener(Self::open_client))
.on_action(cx.listener(Self::move_client))
.on_action(cx.listener(Self::search_members))
.on_action(cx.listener(Self::open_member))
.on_action(cx.listener(Self::submit_channel_password))
@@ -521,6 +530,7 @@ mod tests {
use crate::backend::testing::TempDir;
use crate::dev::Switches;
use crate::pictures::PictureKey;
use crate::shell::actions::{EditChannel, MoveClient, OpenClient};
use crate::shell::{RailView, TreeEvent};
use crate::theme::Choice;
use crate::window_bounds;
@@ -1428,6 +1438,59 @@ mod tests {
assert!(cx.update(|_, cx| crate::pictures::is_cached(&second, cx)), "the new one is drawn");
}
/// What the context menus offer that has no slice yet (the channel editor,
/// a person's volume dialog, moving a client) is logged and sends nothing.
#[gpui::test]
fn the_menu_entries_of_later_slices_are_logged_and_send_nothing(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
shell.app.read_with(cx, |app, _| app.take_sent());
cx.dispatch_action(EditChannel { channel: 2 });
cx.dispatch_action(OpenClient { client: 3 });
cx.dispatch_action(MoveClient { client: 3 });
frame(cx);
assert!(shell.app.read_with(cx, |app, _| app.take_sent()).is_empty());
// A click on a person is the volume dialog's: logged too, and not on us.
click(cx, "tree-client-3");
click(cx, "tree-client-1");
assert!(shell.app.read_with(cx, |app, _| app.take_sent()).is_empty());
}
/// What the caches cannot save: GPUI refreshes the window (every view renders
/// again, cached ones too) when a clickable element is pressed and when it is
/// released, so a click renders every pane; a pointer that moves onto another
/// row renders only the pane that holds the row.
#[gpui::test]
fn a_click_renders_every_pane_and_a_hover_only_the_pane_it_is_over(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
let panes = &shell.counters.panes;
let seen = || {
[&panes.rail, &panes.topbar, &panes.sidebar, &panes.tree, &panes.main, &panes.members]
.map(|pane| pane.get())
};
let before = seen();
click(cx, "tree-channel-6");
let after = seen();
assert!(
before.iter().zip(&after).all(|(before, after)| after > before),
"every pane: {before:?} -> {after:?}"
);
// A pointer onto a row of the tree: the tree, and nothing cached beside it.
let before = seen();
let position = at(cx, "tree-channel-8").expect("a row").center();
cx.simulate_mouse_move(position, None, Default::default());
frame(cx);
let after = seen();
assert_eq!(after[3], before[3] + 1, "the tree: {before:?} -> {after:?}");
assert_eq!(
[after[0], after[1], after[4], after[5]],
[before[0], before[1], before[4], before[5]],
"not the rail, the top bar, the main area or the members panel"
);
}
/// The plus of the rail opens the form; Save with an address adds the
/// server, selects it and closes the form.
#[gpui::test]