Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7f42e86
desktop: cap the playing-row bars to 30 fps instead of repainting eve…
and2049 Nov 12, 2026
434adc0
desktop: render the sidebar, main area, right panel and playback bar …
and2049 Nov 12, 2026
6f44387
desktop: move the titlebar and window frame into views/chrome.rs
and2049 Nov 12, 2026
01a2a3f
desktop: move the library sidebar into views/sidebar.rs
and2049 Nov 12, 2026
f9360d2
desktop: move drag payloads and the drag preview into views/drag.rs
and2049 Nov 12, 2026
cff98ba
desktop: move the track list, its header and the sort menu into views…
and2049 Nov 12, 2026
7101e6b
desktop: move the queue and recently played lists into views/queue.rs
and2049 Nov 12, 2026
e175b07
desktop: move the artist views into views/artist.rs
and2049 Nov 12, 2026
76a829a
desktop: move lyric rendering into views/lyrics.rs
and2049 Nov 12, 2026
5d8b551
desktop: move the immersive view into views/immersive.rs
and2049 Nov 12, 2026
0f47457
desktop: move the home view into views/home.rs
and2049 Nov 12, 2026
b205c7b
desktop: move the context menus into views/menus.rs
and2049 Nov 12, 2026
ca0ff08
desktop: move the setup screen into views/setup.rs
and2049 Nov 12, 2026
0443035
desktop: move the search results list into views/search.rs
and2049 Nov 12, 2026
1246e21
desktop: move the theme picker into views/modals/theme.rs
and2049 Nov 12, 2026
709b573
desktop: move the keyboard help into views/modals/help.rs
and2049 Nov 12, 2026
7d7f889
desktop: move the settings modal into views/modals/settings.rs
and2049 Nov 12, 2026
9eff4de
desktop: move the device picker into views/modals/device.rs
and2049 Nov 12, 2026
017d5cb
desktop: move the add-to-playlist modal into views/modals/playlist_ad…
and2049 Nov 12, 2026
7b68ca1
desktop: move the prompt modal into views/modals/prompt.rs
and2049 Nov 12, 2026
d54c205
desktop: describe views.rs as the shared helpers its submodules build on
and2049 Nov 12, 2026
acafea7
desktop: move the text field editing helpers into text_input.rs
and2049 Nov 12, 2026
5917c87
desktop: move the playback bar into playback_bar.rs
and2049 Nov 12, 2026
09f7ff9
desktop: move list selection and activation into app/selection.rs
and2049 Nov 12, 2026
b86bd75
desktop: move panel toggles, overlays and pane resizing into app/pane…
and2049 Nov 12, 2026
f1a676f
desktop: move theme picking and appearance sync into app/themes.rs
and2049 Nov 12, 2026
a9ad985
desktop: move context and track menu actions into app/menus.rs
and2049 Nov 12, 2026
138e98c
desktop: move view navigation and history into app/navigation.rs
and2049 Nov 12, 2026
fad4800
desktop: move settings actions into app/settings.rs
and2049 Nov 12, 2026
8e7a30d
desktop: move the update flow into app/updates.rs
and2049 Nov 12, 2026
0b6cb2f
desktop: move the command bar, filter and text-entry key handling int…
and2049 Nov 12, 2026
ae6f460
desktop: move playback controls and scrubbing into app/playback.rs
and2049 Nov 12, 2026
c1fa329
desktop: move the drag-scroll, playing-bars and paste-chord definitio…
and2049 Nov 12, 2026
b526d2f
desktop: move the window's render into app/render.rs
and2049 Nov 12, 2026
8ee5fa4
desktop: split the window's render into named pieces
and2049 Nov 12, 2026
c208823
desktop: split the settings modal into a controls kit and one functio…
and2049 Nov 12, 2026
ccc0b86
desktop: split the sidebar into its links, tabs and library rows
and2049 Nov 12, 2026
dfa93e5
desktop: split the playback bar into its card, caption, visualizer an…
and2049 Nov 12, 2026
62add9b
desktop: split the artist page into its header and row builders
and2049 Nov 12, 2026
8dbb467
desktop: split the track list into its header, row builder and row ha…
and2049 Nov 12, 2026
aed68d1
desktop: split the search results into their header, rows and song row
and2049 Nov 12, 2026
8985375
desktop: split the theme picker into its swatches, mode bar, scheme t…
and2049 Nov 12, 2026
38b0455
desktop: move the worker bridge and periodic tick out of EchoApp::new
and2049 Nov 12, 2026
5da4e98
desktop: split main into the panic log, keymap and tray listener
and2049 Nov 12, 2026
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
14 changes: 14 additions & 0 deletions crates/echo-desktop/src/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! What `EchoApp` does in response to input, one submodule per concern.

use super::*;

mod command;
mod menus;
mod navigation;
mod panels;
mod playback;
mod render;
mod selection;
mod settings;
mod themes;
mod updates;
332 changes: 332 additions & 0 deletions crates/echo-desktop/src/app/command.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,332 @@
use super::*;

impl EchoApp {
/// Apply a sort from the picker by running the matching `:sort` command, so picker behavior
/// cannot drift from the command.
pub(crate) fn apply_sort(&mut self, arg: &str, cx: &mut Context<Self>) {
self.sort_menu_open = false;
if let Some(event) = echo_core::commands::run(&mut self.state, &format!("sort {arg}")) {
self.dispatch(event);
}
cx.notify();
}

/// Consume the pending vim count, defaulting to a single step.
pub(crate) fn take_count(&mut self) -> isize {
self.pending_count.take().unwrap_or(1).max(1) as isize
}

pub(crate) fn open_command(
&mut self,
prefill: &str,
window: &mut Window,
cx: &mut Context<Self>,
) {
echo_core::commands::clear_suggestions(&mut self.state);
self.state.ui.mode = AppMode::Command;
self.state.ui.command_buffer = prefill.to_string();
self.state.ui.status_message = None;
window.focus(&self.command_focus.clone(), cx);
cx.notify();
}

pub(crate) fn open_filter(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.state.ui.mode = AppMode::Search;
self.state.ui.search_query.clear();
self.state.ui.search_matches.clear();
self.state.ui.status_message = None;
window.focus(&self.command_focus.clone(), cx);
cx.notify();
}

/// `e` in the sidebar: prefill `:rename` with the selected playlist/folder name.
pub(crate) fn rename_prompt(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.state.ui.active_view != ActiveView::Library {
return;
}
let Some(node) = self
.state
.data
.library_view
.get(self.state.ui.selected_playlist_index)
else {
return;
};
let name = match node {
echo_core::models::LibraryNode::Playlist { playlist, .. } => playlist.name.clone(),
echo_core::models::LibraryNode::Folder(f) => f.name.clone(),
// Spotify's folders keep the name Spotify gives them.
echo_core::models::LibraryNode::SpotifyFolder { .. } => return,
};
self.open_command(&format!("rename {name}"), window, cx);
}

fn handle_command_key(
&mut self,
event: &gpui::KeyDownEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
match event.keystroke.key.as_str() {
"enter" => {
if let Some(event) = echo_core::commands::submit(&mut self.state) {
self.dispatch(event);
}
window.focus(&self.focus_handle.clone(), cx);
// `:q` and friends land here.
if !self.state.ui.is_running {
cx.quit();
}
}
"escape" => {
echo_core::commands::clear_suggestions(&mut self.state);
self.state.ui.mode = AppMode::Normal;
self.state.ui.command_buffer.clear();
window.focus(&self.focus_handle.clone(), cx);
}
"tab" => {
echo_core::commands::cycle_suggestion(
&mut self.state,
!event.keystroke.modifiers.shift,
);
}
"backspace" => {
echo_core::commands::clear_suggestions(&mut self.state);
self.state.ui.command_buffer.pop();
}
"v" if is_paste_chord(&event.keystroke.modifiers) => {
if let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) {
echo_core::commands::clear_suggestions(&mut self.state);
self.state
.ui
.command_buffer
.extend(text.chars().filter(|c| *c != '\r' && *c != '\n'));
}
}
_ => {
if let Some(text) = event.keystroke.key_char.as_deref() {
echo_core::commands::clear_suggestions(&mut self.state);
self.state.ui.command_buffer.push_str(text);
}
}
}
cx.notify();
}

fn handle_filter_key(
&mut self,
event: &gpui::KeyDownEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
match event.keystroke.key.as_str() {
"enter" => {
self.state.ui.mode = AppMode::Normal;
if !self.state.ui.search_matches.is_empty() {
self.state.ui.selected_track_index = self.state.ui.search_matches[0];
self.scroll_to_selected_track();
}
window.focus(&self.focus_handle.clone(), cx);
}
"escape" => {
self.state.ui.mode = AppMode::Normal;
self.state.ui.search_query.clear();
self.state.ui.search_matches.clear();
window.focus(&self.focus_handle.clone(), cx);
}
"backspace" => {
self.state.ui.search_query.pop();
echo_core::intent::update_search_matches(&mut self.state);
self.scroll_to_selected_track();
}
"v" if is_paste_chord(&event.keystroke.modifiers) => {
if let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) {
self.state
.ui
.search_query
.extend(text.chars().filter(|c| *c != '\r' && *c != '\n'));
echo_core::intent::update_search_matches(&mut self.state);
self.scroll_to_selected_track();
}
}
_ => {
if let Some(text) = event.keystroke.key_char.as_deref() {
self.state.ui.search_query.push_str(text);
echo_core::intent::update_search_matches(&mut self.state);
self.scroll_to_selected_track();
}
}
}
cx.notify();
}

/// The `:`/`/` bar. Rendered only while one of the two modes is active; carries the
/// search key context so plain letters type instead of triggering list bindings.
pub(crate) fn render_command_bar(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
let theme = &self.state.ui.active_theme;
let palette = DesktopPalette::resolve(theme);
let fg = theme.text.gpui(WINDOW_FG());
let muted = theme.text_muted.gpui(WINDOW_FG());
let accent = theme.primary.gpui(WINDOW_FG());

let is_command = self.state.ui.mode == AppMode::Command;
let prefix: SharedString = if is_command { ":" } else { "/" }.into();
let buffer = if is_command {
self.state.ui.command_buffer.clone()
} else {
self.state.ui.search_query.clone()
};
let suggestions = self.state.ui.command_suggestions.clone();
let selected_suggestion = self.state.ui.command_suggestion_index;
let match_hint: Option<SharedString> = (!is_command
&& !self.state.ui.search_query.is_empty())
.then(|| format!("{} matches", self.state.ui.search_matches.len()).into());

div()
.id("command-bar")
.key_context(SEARCH_CONTEXT)
.track_focus(&self.command_focus)
.on_key_down(cx.listener(|this, event: &gpui::KeyDownEvent, window, cx| {
if this.state.ui.mode == AppMode::Command {
this.handle_command_key(event, window, cx);
} else {
this.handle_filter_key(event, window, cx);
}
}))
.flex_none()
.flex()
.flex_col()
.gap_1()
.px_4()
.py_1()
.border_t_1()
.border_color(palette.border)
.when(is_command && !suggestions.is_empty(), |el| {
el.child(
div().flex().flex_row().gap_2().overflow_hidden().children(
suggestions
.into_iter()
.enumerate()
.map(|(index, suggestion)| {
let selected = selected_suggestion == Some(index);
div()
.px_2()
.rounded_sm()
.text_xs()
.map(|el| {
if selected {
el.bg(palette.row_selected).text_color(fg)
} else {
el.text_color(muted)
}
})
.child(SharedString::from(suggestion))
}),
),
)
})
.child(
div()
.flex()
.flex_row()
.items_center()
.gap_1()
.child(div().text_sm().text_color(accent).child(prefix))
.child(
div()
.text_sm()
.text_color(fg)
.child(SharedString::from(format!("{buffer}▏"))),
)
.when_some(match_hint, |el, hint| {
el.child(div().flex_grow(1.0))
.child(div().text_xs().text_color(muted).child(hint))
}),
)
}

/// Typing for the two setup fields. Credentials are pasted more often than typed, so
/// ctrl-v pulls from the clipboard (with whitespace stripped).
pub(crate) fn handle_setup_key(
&mut self,
secret: bool,
event: &gpui::KeyDownEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
let field = if secret {
&mut self.state.ui.setup_client_secret
} else {
&mut self.state.ui.setup_client_id
};
match event.keystroke.key.as_str() {
"enter" => {
if let Some(event) = echo_core::intent::submit_setup_credentials(&mut self.state) {
self.dispatch(event);
}
}
"tab" => {
let target = if secret {
self.setup_id_focus.clone()
} else {
self.setup_secret_focus.clone()
};
window.focus(&target, cx);
}
"escape" => window.focus(&self.focus_handle.clone(), cx),
"backspace" => {
field.pop();
}
"v" if is_paste_chord(&event.keystroke.modifiers) => {
if let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) {
field.extend(text.chars().filter(|c| !c.is_whitespace()));
}
}
_ => {
if let Some(text) = event.keystroke.key_char.as_deref() {
field.push_str(text);
}
}
}
cx.notify();
}

/// Enter/escape and typing for the search box, which owns key handling while focused.
pub(crate) fn handle_search_key(
&mut self,
event: &gpui::KeyDownEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
match event.keystroke.key.as_str() {
"enter" => {
let query = self.search_input.clone();
if let Some(event) = echo_core::intent::global_search(&mut self.state, &query) {
self.dispatch(event);
}
window.focus(&self.focus_handle, cx);
}
"escape" => {
if self.search_input.is_empty() {
window.focus(&self.focus_handle, cx);
} else {
self.search_input.clear();
self.search_cursor = 0;
}
}
// Spaces are kept — unlike the credential fields, a query is words — but newlines
// are dropped so a copied line does not smuggle one into the search term.
"v" if is_paste_chord(&event.keystroke.modifiers) => {
if let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) {
let filtered: String =
text.chars().filter(|c| *c != '\r' && *c != '\n').collect();
insert_at_cursor(&mut self.search_input, &mut self.search_cursor, &filtered);
}
}
_ => {
apply_text_edit(&mut self.search_input, &mut self.search_cursor, event);
}
}
cx.notify();
}
}
Loading
Loading