Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

feat(keymap): give ThinkTerm's own commands action names

RoversX47126db0adc6
diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs
index 18a22932..67403082 100644
--- a/config/src/keyassignment.rs
+++ b/config/src/keyassignment.rs
@@ -645,6 +645,19 @@ pub enum KeyAssignment {
/// `OpenSshHosts`, which toggles the page: this one only ever opens.
AddRemoteHost,
ToggleLiveOverview,
+ /// The sidebar's search button: the command palette, opened already
+ /// inside its thread group.
+ OpenThreadSearch,
+ /// Show or hide the left sidebar, as its toggle button does.
+ ToggleWorkspaceSidebar,
+ /// Show or hide the right sidebar, as its toggle button does.
+ ToggleRightSidebar,
+ /// Start a thread in the project the sidebar has active, as its New
+ /// Thread button does.
+ CreateWorkspaceThreadInActiveProject,
+ /// Move to the Space before (negative) or after this window's, in the
+ /// order a sidebar swipe moves through them.
+ ActivateSpaceRelative(isize),
/// Open the right sidebar on this plugin's panel and give it the
/// keyboard -- in its first field, if it has one. Pressed again while
/// the panel has it, the keyboard goes back to the terminal.
diff --git a/wezterm-gui/src/commands.rs b/wezterm-gui/src/commands.rs
index 41bdb701..f7d5ac74 100644
--- a/wezterm-gui/src/commands.rs
+++ b/wezterm-gui/src/commands.rs
@@ -804,6 +804,68 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Comm
menubar: &["Shell"],
icon: Some("cod_multiple_windows"),
},
+ OpenThreadSearch => CommandDef {
+ brief: "Find Thread".into(),
+ doc: "Searches every saved thread and jumps to the one picked".into(),
+ keys: vec![
+ // Off macOS Ctrl+P is the shell's previous command, so the
+ // shortcut is macOS only. Its synthesized Ctrl+Shift+P
+ // variants lose to the palette's, which is registered first.
+ #[cfg(target_os = "macos")]
+ (Modifiers::SUPER, "p".into()),
+ ],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["Shell"],
+ icon: Some("cod_search"),
+ },
+ ToggleWorkspaceSidebar => CommandDef {
+ brief: "Toggle Left Sidebar".into(),
+ doc: "Shows or hides the left sidebar".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["View"],
+ icon: Some("cod_layout_sidebar_left"),
+ },
+ ToggleRightSidebar => CommandDef {
+ brief: "Toggle Right Sidebar".into(),
+ doc: "Shows or hides the right sidebar".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["View"],
+ icon: Some("cod_layout_sidebar_right"),
+ },
+ CreateWorkspaceThreadInActiveProject => CommandDef {
+ brief: "New Thread".into(),
+ doc: "Starts a thread in the project the sidebar has active".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["Shell"],
+ icon: Some("cod_add"),
+ },
+ ActivateSpaceRelative(-1) => CommandDef {
+ brief: "Previous Space".into(),
+ doc: "Moves this window to the Space before it, as a sidebar swipe does".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["Window"],
+ icon: Some("md_chevron_left"),
+ },
+ ActivateSpaceRelative(1) => CommandDef {
+ brief: "Next Space".into(),
+ doc: "Moves this window to the Space after it, as a sidebar swipe does".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["Window"],
+ icon: Some("md_chevron_right"),
+ },
+ ActivateSpaceRelative(n) => CommandDef {
+ brief: format!("Move {n} Spaces").into(),
+ doc: "Moves this window that many Spaces along, as sidebar swipes do".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &[],
+ icon: None,
+ },
SpawnWindow => CommandDef {
brief: "New Window".into(),
doc: "Launches the default program into a new window".into(),
@@ -2395,6 +2457,7 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
QuitApplication,
QuitAndStopSessionServer,
// ----------------- Shell
+ CreateWorkspaceThreadInActiveProject,
ToggleLiveOverview,
OpenSshHosts,
AddRemoteHost,
@@ -2428,7 +2491,11 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
ActivateCopyMode,
ClearKeyTableStack,
ActivateCommandPalette,
+ // After the palette: its ⌘P's synthesized Ctrl+Shift+P must lose.
+ OpenThreadSearch,
// ----------------- View
+ ToggleWorkspaceSidebar,
+ ToggleRightSidebar,
DecreaseFontSize,
IncreaseFontSize,
ResetFontSize,
@@ -2496,6 +2563,8 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
ActivateWindow(9),
ActivateWindowRelative(-1),
ActivateWindowRelative(1),
+ ActivateSpaceRelative(-1),
+ ActivateSpaceRelative(1),
MoveTabRelative(-1),
MoveTabRelative(1),
AdjustPaneSize(PaneDirection::Left, 1),
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 864feb8c..5fe01bdb 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -6621,6 +6621,42 @@ impl TermWindow {
self.switch_space_to_thread(space_id, None, window);
}
+ /// Move `delta` Spaces along, stepping the way sidebar swipes do: a Space
+ /// a swipe would skip is skipped, and the walk stops at either end.
+ pub(crate) fn activate_space_relative(&mut self, delta: isize, window: &Window) {
+ let spaces = crate::workspace_threads::spaces_for_window(self.space_owner_id);
+ let mut target = self.active_space_id.clone();
+ for _ in 0..delta.unsigned_abs() {
+ let (previous, next) =
+ crate::workspace_threads::adjacent_swipe_space_ids(&spaces, &target);
+ match if delta < 0 { previous } else { next } {
+ Some(id) => target = id,
+ None => break,
+ }
+ }
+ if target != self.active_space_id {
+ self.switch_space(target, window);
+ }
+ }
+
+ /// The project the sidebar's New Thread button starts a thread in.
+ pub(crate) fn workspace_sidebar_active_project_id(&self) -> Option<String> {
+ let mux = Mux::get();
+ let active_workspace = self
+ .current_mux_workspace()
+ .unwrap_or_else(|| mux.active_workspace());
+ crate::workspace_threads::view_for_current_project(
+ self.workspace_sidebar_space_id(),
+ &active_workspace,
+ &mux.iter_workspaces(),
+ self.workspace_sidebar_show_archived,
+ )
+ .projects
+ .into_iter()
+ .find(|project| project.is_active)
+ .map(|project| project.id)
+ }
+
/// Switch this window to another Space, activating `preferred_thread`
/// when given (a notification jump) instead of the Space's recorded
/// active thread — starting both activations can leave the window on the
@@ -10973,6 +11009,33 @@ impl TermWindow {
ToggleLiveOverview => {
self.toggle_live_overview_view();
}
+ OpenThreadSearch => {
+ self.open_thread_search();
+ }
+ ToggleWorkspaceSidebar => {
+ self.toggle_workspace_sidebar();
+ if let Some(window) = window.as_ref() {
+ self.reflow_workspace_sidebar(window);
+ }
+ }
+ ToggleRightSidebar => {
+ self.toggle_right_sidebar();
+ if let Some(window) = window.as_ref() {
+ self.reflow_right_sidebar(window);
+ }
+ }
+ CreateWorkspaceThreadInActiveProject => {
+ if let (Some(window), Some(project_id)) =
+ (window.as_ref(), self.workspace_sidebar_active_project_id())
+ {
+ self.create_workspace_thread(&project_id, window);
+ }
+ }
+ ActivateSpaceRelative(delta) => {
+ if let Some(window) = window.as_ref() {
+ self.activate_space_relative(*delta, window);
+ }
+ }
ActivateCommandPalette => {
self.toggle_command_palette();
}
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 17481ae0..6ab1ac95 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -4603,7 +4603,7 @@ impl super::TermWindow {
}
}
- fn reflow_workspace_sidebar(&mut self, context: &dyn WindowOps) {
+ pub(crate) fn reflow_workspace_sidebar(&mut self, context: &dyn WindowOps) {
if let Some(window) = self.window.as_ref().cloned() {
let dimensions = self.dimensions;
self.apply_dimensions(&dimensions, None, &window);
@@ -4611,7 +4611,7 @@ impl super::TermWindow {
context.invalidate();
}
- fn reflow_right_sidebar(&mut self, context: &dyn WindowOps) {
+ pub(crate) fn reflow_right_sidebar(&mut self, context: &dyn WindowOps) {
if let Some(window) = self.window.as_ref().cloned() {
let dimensions = self.dimensions;
self.apply_dimensions(&dimensions, None, &window);