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 PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Ghostty is the bar for what the terminal does. ELYTerminal owns its engine on `a

- A list of sessions. Each row: title, then the working directory, home as `~`.
- New session (+ and Cmd-T), close (row's ×, Cmd-W), select (press, Cmd-1…9, Ctrl-Tab and Ctrl-Shift-Tab).
- A right press on a row opens a menu at the pointer: Duplicate session opens a session of the shell that row runs, in the folder it last reported, right after it and shown; Close session closes the row. A shell that reports no folder, as cmd does, duplicates into the folder it started in.
- A drag on a row moves it to another place in the list, and the session shown stays shown.
- Rename: a double press on a row's title opens a field in its place; Enter keeps the name, Escape drops it. The name shows in the row, the terminal's header and the window's title over the program's own until renamed again; an empty name gives the title back to the program.
- A session whose program ends closes its row. The last row closing closes the window.
- A bell in a hidden session marks its row.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The app writes its log to stderr. `RUST_LOG=elyterminal=debug` writes more; `tra
- A scrollbar along the terminal's right edge scrolls its history, even while a program takes the wheel.
- Shell integration for zsh, bash, fish and PowerShell: each prompt reports its folder and title, and OSC 133 marks each prompt, each command and its exit status.
- Ely peeks over the window's top edge, or up from its bottom left when the window leaves her no room above it, and moves all the time: she breathes, sways and blinks. She follows your sessions: she hops when a program waits on you, shakes at an error, cheers a finish, reads along while a program works, and dozes when all is calm for long. Press her and she winks, waking her from a doze. Drag her along the edge to move her. Settings › Terminal › Ely turns her off.
- Sessions: new, close and switch. A bell marks a hidden session's row and makes no sound. A row's mark shows what its programs report through OSC 7501, OSC 9;4 or herdr: waiting on you, an error, work with its progress, done or idle, else a failed last command. The mark is 3 by 3 dots: work ripples and waiting dips while they last. Hover over the mark lists each report.
- Sessions: new, close and switch. A right press on a row duplicates it, in the shell it runs and the folder it last reported, or closes it, and a drag moves a row to another place. A bell marks a hidden session's row and makes no sound. A row's mark shows what its programs report through OSC 7501, OSC 9;4 or herdr: waiting on you, an error, work with its progress, done or idle, else a failed last command. The mark is 3 by 3 dots: work ripples and waiting dips while they last. Hover over the mark lists each report.
- Notifications: while the window is in the background or the session hidden, a session that starts waiting, finishes or fails, and a program's OSC 9, 777 or 99, post a system notification, one a session every 3 seconds at most; a press shows the session. On macOS only the app bundle posts them, not `cargo run`.
- Cmd-Up and Cmd-Down, Ctrl-Shift-Up and Ctrl-Shift-Down off macOS, jump to the prompt before or after the view's top.
- A button at each end of the title bar hides or shows its side column, and a drag on the border between a side column and the terminal resizes it; the window opens as it was left, at the size and widths it was left at. On Windows and Linux a gear beside the right one opens Settings.
Expand Down
5 changes: 5 additions & 0 deletions TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ Progress truth. Top to bottom, one at a time. A task is ticked only after its co
## 33. Release

- [x] T64 Release v0.1.7 with T59 to T63, T65 and T66: version 0.1.7; the macOS disk image, the Windows zip and the Linux tarball, each from its script; the notes list what changed in English and Chinese.

## 34. Sessions: a right press, and a drag

- [x] T67 A right press on a session's row opens a menu, which the owner asked for: Duplicate session opens a session of the shell that row runs, in the folder it last reported, right after the row and shown, so a PowerShell session opens PowerShell and a cmd session cmd; Close session closes the row. The shell a session starts is kept on it; a shell that reports no folder, as cmd does, duplicates into the folder it started in. The owner right-pressed a PowerShell row and Duplicate session opened a PowerShell session in the same folder; check, clippy and the 239 tests pass on Windows with the GNU target, since this machine has no MSVC.
- [x] T68 A drag on a session's row moves it to another place in the list, which the owner asked for: the held row follows the pointer, the others glide aside, and the session shown stays shown. The owner dragged rows on Windows and the list kept the order; `workspace::reorder::tests` keeps the shown index on its row as rows cross it either way.
37 changes: 24 additions & 13 deletions src/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ use ely_gpui_component::{
buttons::{ButtonVariant, IconButton},
forms::{Input, TextInput},
lists::ListItem,
menus::ContextMenu,
primitives::{Icon, IconName, Tooltip},
theme::{ActiveTheme, ControlSize, IconSize},
};
use gpui::{AnyElement, App, Entity, SharedString, Subscription, div, prelude::*, rems};
use gpui::{
AnyElement, App, Entity, IntoElement, SharedString, Subscription, div, prelude::*, rems,
};

use crate::{
term::{Kind, Record, Records, State, TerminalView},
workspace::{TITLE, Workspace},
};

mod menu;
pub mod orb;

use orb::Look;
Expand All @@ -32,6 +36,8 @@ pub struct Session {
pub editing: Option<(Entity<TextInput>, Subscription)>,
/// The folder it reports, else the one it started in.
pub folder: PathBuf,
/// The program it runs, as its path; empty for the login shell.
pub shell: String,
/// Its shell has integration, or it reported a folder anyway.
pub reports: bool,
/// A bell rang while it was hidden.
Expand Down Expand Up @@ -113,7 +119,7 @@ pub fn row(
home: Option<&Path>,
now: Instant,
cx: &App,
) -> ListItem {
) -> impl IntoElement {
let terminal = session.terminal.read(cx);
let pid = terminal.pid() as usize;
let (select, close) = (workspace.clone(), workspace.clone());
Expand Down Expand Up @@ -148,17 +154,22 @@ pub fn row(
let bell = session
.bell
.then(|| Icon::new(IconName::Bell).color(cx.theme().colors.warning));
if mark.is_none() && bell.is_none() {
return item;
}
item.leading(
div()
.flex()
.items_center()
.gap_1()
.children(mark)
.children(bell),
)
let item = if mark.is_none() && bell.is_none() {
item
} else {
item.leading(
div()
.flex()
.items_center()
.gap_1()
.children(mark)
.children(bell),
)
};
let id = session.terminal.entity_id();
ContextMenu::new(("session-menu", pid), menu::row(workspace, id))
.w_full()
.child(item)
}

/// The field a session's row renames it with; Escape drops what it holds.
Expand Down
36 changes: 36 additions & 0 deletions src/sessions/menu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use ely_gpui_component::{
menus::{Menu, MenuItem},
primitives::IconName,
};
use gpui::{Entity, EntityId};

use crate::workspace::Workspace;

/// What a right press on the row of session `id` offers.
pub fn row(workspace: &Entity<Workspace>, id: EntityId) -> Menu {
let (duplicate, close) = (workspace.clone(), workspace.clone());
Menu::new()
.item(
MenuItem::new("Duplicate session")
.icon(IconName::Copy)
.on_click(move |window, cx| {
duplicate.update(cx, |this, cx| this.duplicate(id, window, cx))
}),
)
.separator()
.item(
MenuItem::new("Close session")
.icon(IconName::X)
.on_click(move |window, cx| {
close.update(cx, |this, cx| {
let found = this
.sessions()
.iter()
.position(|session| session.terminal.entity_id() == id);
if let Some(index) = found {
this.close(index, window, cx);
}
})
}),
)
}
55 changes: 21 additions & 34 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Instant;

use ely_gpui_component::{
buttons::{ButtonVariant, IconButton, SegmentedControl},
lists::List,
motion::Reorder,
primitives::{FocusScope, IconName},
shell::{ColumnShell, ResizeBorder, ShellColumn},
theme::ControlSize,
Expand All @@ -20,16 +20,14 @@ use crate::{
git::panel::{Acted, GitPanel},
menus,
sessions::{self, Session, orb},
settings::{PanelTab, Settings, SettingsStore, StartIn, window::OpenSettings},
term::{
Events, Launch, Pty, TerminalView, config,
shell::{ShellIntegration, launch},
spawn,
},
settings::{PanelTab, Settings, SettingsStore, window::OpenSettings},
term::{Events, Launch, Pty, TerminalView},
};

mod events;
mod rename;
mod reorder;
mod session;
mod widths;

use widths::{Dragged, Side};
Expand Down Expand Up @@ -152,6 +150,10 @@ impl Workspace {
let events = cx.subscribe_in(&terminal, window, move |this, _, event, window, cx| {
this.session_event(id, event, window, cx)
});
let shell = launch
.program
.as_ref()
.map_or_else(String::new, |(program, _)| program.clone());
let pid = terminal.read(cx).pid();
log::info!("app: session {pid} opens in {}", launch.cwd.display());
self.sessions.push(Session {
Expand All @@ -160,6 +162,7 @@ impl Workspace {
name: String::new(),
editing: None,
folder: launch.cwd,
shell,
reports: launch.reports,
bell: false,
waiting: false,
Expand Down Expand Up @@ -193,31 +196,6 @@ impl Workspace {
});
}

/// A session of the shell the settings name, in home or the shown session's folder.
fn new_session(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let Some(home) = dirs::home_dir() else {
log::error!("app: no home folder, so no new session");
return;
};
let settings = SettingsStore::get(cx);
let folder = match settings.start_in {
StartIn::Home => home,
StartIn::Session => self
.sessions
.get(self.active)
.map_or(home, |session| session.folder.clone()),
};
let started = launch(&settings.shell, folder, &cx.global::<ShellIntegration>().0)
.and_then(|launch| Ok((spawn(&launch, (80, 24), (8, 16), config(settings))?, launch)));
match started {
Ok(((pty, events), launch)) => {
self.add(pty, events, launch, window, cx);
self.select(self.sessions.len() - 1, window, cx);
}
Err(error) => log::error!("app: no new session: {error:#}"),
}
}

/// Shows session `index`, clears its bell and its waiting mark, and gives its terminal the keys.
pub fn select(&mut self, index: usize, window: &mut Window, cx: &mut Context<Self>) {
if index >= self.sessions.len() {
Expand Down Expand Up @@ -387,9 +365,18 @@ impl Render for Workspace {
let home = dirs::home_dir();
let rows = self.sessions.iter().enumerate().map(|(index, session)| {
let active = index == self.active;
sessions::row(&workspace, index, session, active, home.as_deref(), now, cx)
let pid = session.terminal.read(cx).pid();
let row =
sessions::row(&workspace, index, session, active, home.as_deref(), now, cx);
(pid.to_string(), row)
});
let list = List::new().children(rows);
let dragged = workspace.clone();
let list = rows.fold(
Reorder::new("session-rows").on_reorder(move |from, to, _, cx| {
dragged.update(cx, |this, cx| this.reorder(from, to, cx))
}),
|list, (key, row)| list.row(key, div().pb_0p5().child(row)),
);
let new = IconButton::new("new-session", IconName::Plus)
.variant(ButtonVariant::Ghost)
.size(ControlSize::Sm)
Expand Down
49 changes: 49 additions & 0 deletions src/workspace/reorder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use gpui::Context;

use super::Workspace;

/// The session shown once session `from` moves to place `to`.
pub fn after_move(active: usize, from: usize, to: usize) -> usize {
if active == from {
to
} else if from < active && active <= to {
active - 1
} else if to <= active && active < from {
active + 1
} else {
active
}
}

impl Workspace {
/// Moves session `from` to place `to`, both inside the list.
pub(super) fn move_session(&mut self, from: usize, to: usize) {
let moved = self.sessions.remove(from);
self.sessions.insert(to, moved);
self.active = after_move(self.active, from, to);
}

/// Moves session `from` to place `to`, as a drag asks.
pub fn reorder(&mut self, from: usize, to: usize, cx: &mut Context<Self>) {
if from == to || from >= self.sessions.len() || to >= self.sessions.len() {
return;
}
log::info!("app: session {} moves to {}", from + 1, to + 1);
self.move_session(from, to);
cx.notify();
}
}

#[cfg(test)]
mod tests {
use super::after_move;

#[test]
fn the_shown_session_follows_its_row() {
assert_eq!(after_move(2, 2, 0), 0, "the shown row moved");
assert_eq!(after_move(2, 0, 3), 1, "a row below it went up");
assert_eq!(after_move(2, 3, 0), 3, "a row above it went down");
assert_eq!(after_move(3, 1, 0), 3, "a move below it leaves it");
assert_eq!(after_move(0, 2, 3), 0, "a move below the shown one");
}
}
74 changes: 74 additions & 0 deletions src/workspace/session.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
use std::path::PathBuf;

use gpui::{Context, EntityId, Window};

use super::Workspace;
use crate::{
settings::{SettingsStore, StartIn},
term::{
config,
shell::{ShellIntegration, launch},
spawn,
},
};

impl Workspace {
/// A session of the shell the settings name, in home or the shown session's folder.
pub(super) fn new_session(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let Some(home) = dirs::home_dir() else {
log::error!("app: no home folder, so no new session");
return;
};
let settings = SettingsStore::get(cx);
let folder = match settings.start_in {
StartIn::Home => home,
StartIn::Session => self
.sessions
.get(self.active)
.map_or(home, |session| session.folder.clone()),
};
let shell = settings.shell.clone();
self.open(&shell, folder, None, window, cx);
}

/// Session `id` again: the shell it runs, in the folder it last reported.
pub fn duplicate(&mut self, id: EntityId, window: &mut Window, cx: &mut Context<Self>) {
let Some((shell, folder, index)) = self
.sessions
.iter()
.enumerate()
.find(|(_, session)| session.terminal.entity_id() == id)
.map(|(index, session)| (session.shell.clone(), session.folder.clone(), index))
else {
log::error!("app: there is no session {id:?} to duplicate");
return;
};
log::info!("app: session {id:?} duplicates into {}", folder.display());
self.open(&shell, folder, Some(index + 1), window, cx);
}

/// A session of `shell` in `folder`, at `at` or the list's end, and shown.
fn open(
&mut self,
shell: &str,
folder: PathBuf,
at: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
let settings = SettingsStore::get(cx);
let started = launch(shell, folder, &cx.global::<ShellIntegration>().0)
.and_then(|launch| Ok((spawn(&launch, (80, 24), (8, 16), config(settings))?, launch)));
match started {
Ok(((pty, events), launch)) => {
self.add(pty, events, launch, window, cx);
let last = self.sessions.len() - 1;
if let Some(at) = at {
self.move_session(last, at);
}
self.select(at.map_or(last, |at| at.min(last)), window, cx);
}
Err(error) => log::error!("app: no new session: {error:#}"),
}
}
}
2 changes: 2 additions & 0 deletions tasks/acceptance.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ What no check reached: no real KWin drew the blur; of Wayland desktops, only Hyp
| New (+, Cmd-T), close (×, Cmd-W), select (press, Cmd-1…9, Ctrl-Tab) | T12 | 2026-10-15: + opened session 2, a press showed session 1 again | Pass |
| A program's end closes its row; the last row closes the window | T12 | T12 review | Pass |
| A bell in a hidden session marks its row | T12 | T12 review | Pass |
| A right press on a row opens a menu at the pointer: Duplicate session opens the shell's session in the reported folder, right after it and shown; Close session closes the row | T67 | 2026-10-21: the owner right-pressed a PowerShell session's row on Windows and Duplicate session opened a PowerShell session in the same folder; Close session runs the `close()` the row's × runs; the shell is kept from `Launch.program`, so `launch` gives the same program and its integration back; `cargo check --all-targets`, `clippy -D warnings` and `cargo test` (239 pass) on the GNU target, the only one this machine can link | Pass |
| A drag on a row moves it to another place, and the session shown stays shown | T68 | 2026-10-21: the owner dragged rows on Windows and the list kept the order; `workspace::reorder::tests`: `the_shown_session_follows_its_row` keeps the shown index on its row while rows cross it either way; Ely's `Reorder` holds the drag and measures the rows; check, clippy and test pass on the GNU target | Pass |

## 8. Right panel: Files

Expand Down