Compare commits

..
12 Commits
Author SHA1 Message Date
TomZz a89d15d255 feat: add title bar style option (native vs integrated)
Introduced a new configuration setting allowing users to choose between:
1. Native: Standard OS title bar with the tab bar rendered below it.
2. Integrated: Custom title bar with Mac-style controls and embedded tabs.

Updated:
- ConfigFile/Store to include title_bar_style (defaulting to Native).
- localization files for English and Chinese with 'Restart required' hints.
- Settings dialog with a new dropdown in the Appearance group.
- Startup and UI logic to handle conditional title bar and tab bar rendering.
- UI now uses the title bar style detected at startup to ensure consistency
  until the application is restarted.
- Restored Windows app icon loading in startup.rs.
- Fixed Native mode layout to match previous standard behavior.
2026-06-18 13:31:51 +08:00
TomZz b5a068541d feat: implement fully custom title bar with mac-style controls
Replaced gpui-component's TitleBar with a self-drawn one that provides:
1. Mac-style traffic light window controls on the left.
2. App session and split pane buttons on the right.
3. Tab bar in the middle with robust flex-shrink and overflow-hidden
   logic to prevent it from squeezing the side buttons when many tabs
   are open.
2026-06-18 13:10:27 +08:00
TomZz 7be0c420e1 chore: release v0.4.6 2026-06-18 08:20:33 +08:00
TomZz 62028c7921 feat: replace native title bar with custom TitleBar and integrate tab bar
This commit removes the native OS title bar and introduces a cross-platform custom title bar using gpui-component's TitleBar. To optimize vertical screen space, the tab bar has been relocated into the newly created custom title bar.

Fixes #37
2026-06-18 08:18:00 +08:00
TomZz 56a6ef98b7 feat: add tooltips for sidebar and tab bar buttons 2026-06-18 07:58:50 +08:00
TomZz caa8a58561 fix: correctly reset active_dialog in session selector and ssh dialog 2026-06-18 00:41:53 +08:00
TomZz 6150bd410b fix: correctly reset active_dialog when manually closing transfers dialog 2026-06-17 07:05:09 +08:00
TomZz f55c3a8470 chore: bump version to v0.4.5 and update documentation 2026-06-17 06:23:07 +08:00
TomZz 7ae44ab9a7 ci: automate homebrew cask release for macos 2026-06-17 05:59:05 +08:00
TomZz 9c43b2dde7 chore: release v0.4.4 2026-06-17 05:00:51 +08:00
TomZz e6134bc0d1 fix: sftp panel status bar layout bug, update localized strings and add Open Transfer History shortcut 2026-06-17 04:58:27 +08:00
TomZz 96cd85a8d3 feat: persist sidebar and sftp panel visibility states 2026-06-17 03:00:44 +08:00
15 changed files with 637 additions and 173 deletions
+86 -5
View File
@@ -12,7 +12,7 @@ on:
workflow_dispatch:
permissions:
contents: write # needed to create / update the GitHub Release
contents: write # needed to create / update the GitHub Release
jobs:
build:
@@ -26,15 +26,15 @@ jobs:
target: x86_64-pc-windows-msvc
name: windows-x86_64
bin: ashell.exe
- os: ubuntu-22.04 # build on the oldest supported runner for broader glibc compatibility
- os: ubuntu-22.04 # build on the oldest supported runner for broader glibc compatibility
target: x86_64-unknown-linux-gnu
name: linux-x86_64
bin: ashell
- os: macos-14 # Apple Silicon
- os: macos-14 # Apple Silicon
target: aarch64-apple-darwin
name: macos-aarch64
bin: ashell
- os: macos-14 # Intel (cross-compiled from Apple Silicon to avoid queue delays)
- os: macos-14 # Intel (cross-compiled from Apple Silicon to avoid queue delays)
target: x86_64-apple-darwin
name: macos-x86_64
bin: ashell
@@ -80,7 +80,7 @@ jobs:
# Note: We build the bundle manually here rather than running
# scripts/package-macos-app.sh, because that script runs `cargo build`
# without respecting the `--target` flag from the matrix.
APP="ashell.app"
CONTENTS="$APP/Contents"
mkdir -p "$CONTENTS/MacOS" "$CONTENTS/Resources"
@@ -168,3 +168,84 @@ jobs:
files: dist/**/*
generate_release_notes: true
fail_on_unmatched_files: true
cask:
name: Update Homebrew Cask
needs: publish
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Homebrew Tap
uses: actions/checkout@v4
with:
repository: rust-kotlin/homebrew-taps
token: ${{ secrets.TAP_GITHUB_TOKEN }}
path: tap
- name: Download all macOS artifacts
uses: actions/download-artifact@v4
with:
pattern: macos-*
path: dist
- name: Update Cask
run: |
VERSION=${GITHUB_REF#refs/tags/v}
SHA_ARM=$(sha256sum dist/macos-aarch64/*.zip | cut -d' ' -f1)
SHA_INTEL=$(sha256sum dist/macos-x86_64/*.zip | cut -d' ' -f1)
mkdir -p tap/Casks
CASK_FILE="tap/Casks/ashell.rb"
cat > "$CASK_FILE" <<EOF
cask "ashell" do
version "${VERSION}"
on_arm do
sha256 "${SHA_ARM}"
url "https://github.com/rust-kotlin/ashell/releases/download/v#{version}/ashell-v#{version}-macos-aarch64.zip"
end
on_intel do
sha256 "${SHA_INTEL}"
url "https://github.com/rust-kotlin/ashell/releases/download/v#{version}/ashell-v#{version}-macos-x86_64.zip"
end
name "ashell"
desc "ashell is a modern, fast, GPUI Component-based desktop terminal client written in Rust."
homepage "https://github.com/rust-kotlin/ashell"
app "ashell.app"
postflight do
puts "Removing quarantine flag from ashell.app..."
system_command "/usr/bin/xattr",
args: ["-rd", "com.apple.quarantine", "#{appdir}/ashell.app"],
sudo: true
end
caveats <<~EOS
ashell uses ad-hoc signing. The installation includes a postflight script
that removes the 'com.apple.quarantine' attribute from the application
to allow it to run. This will require your administrator password.
ashell 采用本地签名。安装程序包含一个后置脚本,用于移除应用程序的
'com.apple.quarantine' 属性以允许其运行。这需要您的管理员密码。
EOS
end
EOF
# Remove the 10 leading spaces added for YAML formatting
sed -i 's/^ //' "$CASK_FILE"
- name: Commit and Push
run: |
VERSION=${GITHUB_REF#refs/tags/v}
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if [[ -n $(git status -s) ]]; then
git add Casks/ashell.rb
git commit -m "chore: bump ashell to v${VERSION}"
git push
else
echo "No changes to commit"
fi
Generated
+1 -1
View File
@@ -303,7 +303,7 @@ dependencies = [
[[package]]
name = "ashell"
version = "0.4.3"
version = "0.4.6"
dependencies = [
"alacritty_terminal",
"anyhow",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "ashell"
version = "0.4.3"
version = "0.4.6"
edition = "2024"
authors = ["ashell contributors"]
description = "A GPUI Component based SSH and local terminal client"
+22 -2
View File
@@ -24,8 +24,28 @@ You can download the latest pre-compiled releases for macOS, Windows, and Linux
## Mac Installation Guide
After downloading, please unzip the file and move `ashell.app` to your **Applications** folder.
Since the app uses ad-hoc signing, macOS may warn that the app is "damaged" upon first launch. If this happens, open Terminal and run the following command:
### Method 1: Homebrew (Recommended)
If you use [Homebrew](https://brew.sh/), you can install it quickly with:
```bash
brew install rust-kotlin/taps/ashell --cask
```
To update the app:
```bash
brew update
brew upgrade ashell --cask
```
> **Note**: Since the app uses ad-hoc signing, the Homebrew installation or update includes a postflight script to automatically handle the quarantine flag. This will require you to enter your administrator password for authorization.
### Method 2: Manual Download
1. Download and unzip from the [Releases page](https://github.com/rust-kotlin/ashell/releases/latest).
2. Move `ashell.app` to your **Applications** folder.
3. Since the app uses ad-hoc signing, macOS may warn that the app is "damaged" upon first launch. If this happens, open Terminal and run:
```bash
sudo xattr -cr /Applications/ashell.app
+22 -2
View File
@@ -24,8 +24,28 @@ v0.4 在 v0.3 打下的基础上,重点带来了更完整的工作区操作能
## Mac 安装指南
下载并解压后,请先将 `ashell.app` 拖入或移动到 **应用程序 (Applications)** 目录。
由于应用采用本地签名,初次启动时如果系统提示“App 已损坏,无法打开”,请打开终端(Terminal)并执行以下命令:
### 方法 1: Homebrew 安装 (推荐)
如果您使用 [Homebrew](https://brew.sh/),可以通过以下命令快速安装:
```bash
brew install rust-kotlin/taps/ashell --cask
```
更新应用:
```bash
brew update
brew upgrade ashell --cask
```
> **注意**: 由于应用采用本地签名,Homebrew 在安装或更新过程中会执行一个后置脚本来自动处理隔离属性(quarantine flag),这需要您输入管理员密码以授权。
### 方法 2: 手动下载
1. 从 [Releases 页面](https://github.com/rust-kotlin/ashell/releases/latest) 下载并解压。
2. 将 `ashell.app` 拖入或移动到 **应用程序 (Applications)** 目录。
3. 由于应用采用本地签名,初次启动时如果系统提示“App 已损坏,无法打开”,请打开终端(Terminal)并执行以下命令:
```bash
sudo xattr -cr /Applications/ashell.app
+9
View File
@@ -136,6 +136,11 @@ transfers_limit: " (Max 100 records)"
press_new_key: "Press new key..."
settings_open_settings: "Open Settings"
settings_open_session: "Open Session"
settings_open_transfers: "Open Transfer History"
files_downloading: "%{count} files downloading"
files_uploading: "%{count} files uploading"
panel_minimize: "Minimize Panel"
panel_expand: "Expand Panel"
settings_new_ssh: "New SSH"
settings_toggle_sidebar: "Toggle Sidebar"
settings_toggle_sftp_zoom: "Toggle SFTP Zoom"
@@ -149,3 +154,7 @@ settings_split_pane_up: "Split Pane Up"
settings_split_pane_down: "Split Pane Down"
settings_close_pane: "Close Pane"
keybind_conflict: '"%{key}" is already used by "%{action}", please choose another key'
title_bar_style: "Title Bar Style"
title_bar_native: "Native"
title_bar_integrated: "Integrated"
restart_hint: " (Restart required)"
+10 -2
View File
@@ -23,7 +23,6 @@ system_path_warning: "警告:您即将删除系统关键路径!这可能会
delete_success: "成功删除 %{count} 个项"
delete_failed: "删除失败: %{err}"
deleting_paths: "正在删除 %{count} 个项..."
cancel: "取消"
confirm: "确认"
local_terminal: "本地终端"
open_local_shell_tab: "打开一个新的本地终端页面"
@@ -139,6 +138,11 @@ transfers_limit: " (最多保留 100 条)"
press_new_key: "请按下新的快捷键..."
settings_open_settings: "打开设置"
settings_open_session: "打开会话"
settings_open_transfers: "打开传输历史"
files_downloading: "%{count} 个文件正在下载"
files_uploading: "%{count} 个文件正在上传"
panel_minimize: "折叠面板"
panel_expand: "展开面板"
settings_new_ssh: "新建 SSH"
settings_toggle_sidebar: "缩放侧边栏"
settings_toggle_sftp_zoom: "缩放 SFTP 面板"
@@ -151,4 +155,8 @@ settings_split_pane_right: "向右拆分面板"
settings_split_pane_up: "向上拆分面板"
settings_split_pane_down: "向下拆分面板"
settings_close_pane: "关闭当前面板"
keybind_conflict: "\"%{key}\" 已被「%{action}」使用,请选择其他快捷键"
keybind_conflict: '"%{key}" 已被「%{action}」使用,请选择其他快捷键'
title_bar_style: "标题栏样式"
title_bar_native: "原生"
title_bar_integrated: "融合"
restart_hint: " (修改后重启生效)"
+111 -4
View File
@@ -21,6 +21,11 @@ use crate::{Ashell, session::config::AuthMethod, system::format_bytes};
impl Ashell {
pub(crate) fn show_ssh_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.active_dialog.is_some() {
return;
}
self.active_dialog = Some(crate::app::DialogKind::NewSsh);
let view = cx.entity();
let session_name_input = self.session_name_input.clone();
let host_input = self.host_input.clone();
@@ -37,6 +42,15 @@ impl Ashell {
.title(t!("new_ssh_connection"))
.w(px(520.))
.overlay_closable(true)
.on_close({
let view = view.clone();
move |_, _, cx| {
view.update(cx, |this, cx| {
this.active_dialog = None;
cx.notify();
});
}
})
.content({
let view = view.clone();
let session_name_input = session_name_input.clone();
@@ -146,7 +160,11 @@ impl Ashell {
.child(
Button::new("connect-ssh-cancel")
.label(t!("cancel").to_string())
.on_click(|_, window, cx| window.close_dialog(cx)),
.on_click(window.listener_for(&view, |this, _, window, cx| {
this.active_dialog = None;
window.close_dialog(cx);
cx.notify();
})),
)
.child(
Button::new("connect-ssh-confirm")
@@ -173,6 +191,11 @@ impl Ashell {
});
}
pub(crate) fn show_selector_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.active_dialog.is_some() {
return;
}
self.active_dialog = Some(crate::app::DialogKind::SessionSelector);
let view = cx.entity();
let selector_focus_handle = self.selector_focus_handle.clone();
let deferred_selector_focus_handle = selector_focus_handle.clone();
@@ -183,6 +206,15 @@ impl Ashell {
dialog
.title(t!("open_session").to_string())
.w(px(520.))
.on_close({
let view = view.clone();
move |_, _, cx| {
view.update(cx, |this, cx| {
this.active_dialog = None;
cx.notify();
});
}
})
.on_ok({
let view = view.clone();
move |_, window, cx| {
@@ -231,8 +263,10 @@ impl Ashell {
.on_mouse_down(
MouseButton::Left,
window.listener_for(&view, |this, _, window, cx| {
this.active_dialog = None;
this.open_local(cx);
window.close_dialog(cx);
cx.notify();
}),
)
.child(
@@ -273,8 +307,10 @@ impl Ashell {
.on_mouse_down(
MouseButton::Left,
window.listener_for(&view, |this, _, window, cx| {
this.active_dialog = None;
window.close_dialog(cx);
this.open_new_ssh_dialog(window, cx);
cx.notify();
}),
)
.child(
@@ -342,11 +378,13 @@ impl Ashell {
window.listener_for(
&view,
move |this, _, window, cx| {
this.active_dialog = None;
this.connect_saved_session(
connect_id.clone(),
cx,
);
window.close_dialog(cx);
cx.notify();
},
),
)
@@ -405,9 +443,26 @@ impl Ashell {
});
}
pub(crate) fn show_transfers_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.active_dialog.is_some() {
return;
}
self.active_dialog = Some(crate::app::DialogKind::Transfers);
let view = cx.entity();
window.open_dialog(cx, move |dialog: Dialog, _window, _| {
dialog.w(px(600.)).close_button(false).content({
dialog
.w(px(600.))
.close_button(false)
.on_close({
let view = view.clone();
move |_, _, cx| {
view.update(cx, |this, cx| {
this.active_dialog = None;
cx.notify();
});
}
})
.content({
let view = view.clone();
move |content, window, cx| {
let can_clear = view.read(cx).transfers.iter().any(|t| {
@@ -468,9 +523,11 @@ impl Ashell {
.small()
.ghost()
.icon(IconName::Close)
.on_click(|_, window, cx| {
.on_click(window.listener_for(&view, |this, _, window, cx| {
this.active_dialog = None;
window.close_dialog(cx);
}),
cx.notify();
})),
),
);
@@ -997,6 +1054,11 @@ impl Ashell {
});
}
pub(crate) fn show_settings_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.active_dialog.is_some() {
return;
}
self.active_dialog = Some(crate::app::DialogKind::Settings);
let view = cx.entity();
// Unbind all workspace keys so they don't interfere with keybinding recording
@@ -1013,6 +1075,7 @@ impl Ashell {
move |_, _window, cx| {
// Re-register all workspace keys when closing settings
view.update(cx, |this, cx| {
this.active_dialog = None;
this.keybinds_suspended = false;
this.recording_action = None;
this.keybind_error = None;
@@ -1234,6 +1297,50 @@ impl Ashell {
})
)
)
.item(
SettingItem::new(
format!("{}{}", t!("title_bar_style"), t!("restart_hint")),
SettingField::render({
let view = view_clone_for_general.clone();
move |_, _window, cx| {
let current_style = view.read(cx).config.title_bar_style();
Button::new("title-bar-style-dropdown")
.small()
.label(match current_style {
crate::session::config::TitleBarStyle::Native => t!("title_bar_native").to_string(),
crate::session::config::TitleBarStyle::Integrated => t!("title_bar_integrated").to_string(),
})
.dropdown_menu_with_anchor(Anchor::BottomRight, {
let view = view.clone();
move |mut menu, window, cx| {
let current_style = view.read(cx).config.title_bar_style();
menu = menu.min_w(160.)
.item(
PopupMenuItem::new(t!("title_bar_native").to_string())
.checked(current_style == crate::session::config::TitleBarStyle::Native)
.on_click(window.listener_for(&view, |this, _, _, cx| {
this.config.set_title_bar_style(crate::session::config::TitleBarStyle::Native);
let _ = this.config.save();
cx.notify();
}))
)
.item(
PopupMenuItem::new(t!("title_bar_integrated").to_string())
.checked(current_style == crate::session::config::TitleBarStyle::Integrated)
.on_click(window.listener_for(&view, |this, _, _, cx| {
this.config.set_title_bar_style(crate::session::config::TitleBarStyle::Integrated);
let _ = this.config.save();
cx.notify();
}))
);
menu
}
})
.into_any_element()
}
})
)
)
)
.group(
SettingGroup::new()
+9 -1
View File
@@ -16,6 +16,7 @@ gpui::actions!(
[
OpenSettings,
OpenSession,
OpenTransfers,
NewSsh,
ToggleSidebar,
ToggleSftpZoom,
@@ -51,6 +52,11 @@ pub(crate) const WORKSPACE_ACTIONS: &[WorkspaceAction] = &[
label_key: "settings_open_session",
default_suffix: "o",
},
WorkspaceAction {
id: "OpenTransfers",
label_key: "settings_open_transfers",
default_suffix: "t",
},
WorkspaceAction {
id: "NewSsh",
label_key: "settings_new_ssh",
@@ -198,6 +204,7 @@ pub(crate) fn unbind_all_workspace_keys(cx: &mut App, config: &ConfigStore) {
unbind_action!("OpenSettings", crate::OpenSettings);
unbind_action!("OpenSession", crate::OpenSession);
unbind_action!("OpenTransfers", crate::OpenTransfers);
unbind_action!("NewSsh", crate::NewSsh);
unbind_action!("ToggleSidebar", crate::ToggleSidebar);
unbind_action!("ToggleSftpZoom", crate::ToggleSftpZoom);
@@ -252,6 +259,7 @@ fn bind_workspace_actions(cx: &mut App, config: &ConfigStore) {
bind_action!("OpenSettings", crate::OpenSettings);
bind_action!("OpenSession", crate::OpenSession);
bind_action!("OpenTransfers", crate::OpenTransfers);
bind_action!("NewSsh", crate::NewSsh);
bind_action!("ToggleSidebar", crate::ToggleSidebar);
bind_action!("ToggleSftpZoom", crate::ToggleSftpZoom);
@@ -273,7 +281,7 @@ impl KeybindingsPage {
let groups = [
(
"settings_group_keybind_general",
vec!["OpenSettings", "OpenSession", "NewSsh"],
vec!["OpenSettings", "OpenSession", "OpenTransfers", "NewSsh"],
),
(
"settings_group_keybind_zoom",
+13 -1
View File
@@ -189,6 +189,14 @@ impl ScrollbarHandle for TerminalScrollbarHandle {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum DialogKind {
Settings,
SessionSelector,
Transfers,
NewSsh,
}
pub(crate) struct Ashell {
pub(crate) focus_handle: FocusHandle,
pub(crate) selector_focus_handle: FocusHandle,
@@ -250,8 +258,10 @@ pub(crate) struct Ashell {
pub(crate) prev_monitoring_size: Option<Pixels>,
pub(crate) status: SharedString,
pub(crate) config: ConfigStore,
pub(crate) active_title_bar_style: crate::session::config::TitleBarStyle,
pub(crate) system_sampler: SystemSampler,
pub(crate) recording_action: Option<String>,
pub(crate) active_dialog: Option<DialogKind>,
/// Error message when a recorded keybinding conflicts with another
pub(crate) keybind_error: Option<(String, String)>, // (action_id, error_message)
/// Whether workspace keybindings are currently suspended (during settings)
@@ -469,13 +479,15 @@ impl Ashell {
dragging_splitter: None,
drag_split_origin: None,
sftp_panel_minimized: false,
sidebar_collapsed: false,
sidebar_collapsed: config.sidebar_collapsed(),
collapsed_saved_scroll_handle: gpui::ScrollHandle::new(),
prev_monitoring_size: None,
status: "ready".into(),
active_title_bar_style: config.title_bar_style(),
config,
system_sampler,
recording_action: None,
active_dialog: None,
keybind_error: None,
keybinds_suspended: false,
system,
+36 -2
View File
@@ -176,14 +176,23 @@ pub(crate) fn sync_macos_launch_environment() {
pub(crate) fn sync_macos_launch_environment() {}
pub(crate) fn open_main_window(cx: &mut App) {
let config = ConfigStore::load().unwrap_or_else(|_| ConfigStore::in_memory());
let mut window_options = WindowOptions::default();
if config.title_bar_style() == crate::session::config::TitleBarStyle::Integrated {
window_options.titlebar = Some(gpui::TitlebarOptions {
title: None,
appears_transparent: true,
traffic_light_position: Some(gpui::point(px(9.0), px(9.0))),
});
}
#[cfg(not(target_os = "macos"))]
if let Ok(img) = image::load_from_memory(include_bytes!("../../assets/icons/ashell.png")) {
window_options.icon = Some(std::sync::Arc::new(img.into_rgba8()));
}
let config = ConfigStore::load().unwrap_or_else(|_| ConfigStore::in_memory());
if let Some(bounds) = config.window_bounds() {
window_options.window_bounds = Some(match bounds {
crate::session::config::SavedWindowBounds::Fullscreen {
@@ -239,6 +248,20 @@ pub(crate) fn open_main_window(cx: &mut App) {
let view = cx.new(|cx| Ashell::new(window, cx));
tracing::info!("[ui] main application window opened");
let focus_handle = view.read(cx).focus_handle.clone();
window.focus(&focus_handle, cx);
let sftp_minimized = view.read(cx).config.sftp_panel_minimized();
if sftp_minimized {
window.defer(cx, {
let view = view.clone();
move |window, cx| {
view.update(cx, |this, cx| {
this.toggle_sftp_minimized(window, cx);
});
}
});
}
let workspace_panels_clone = view.read(cx).workspace_panels.clone();
let body_panels_clone = view.read(cx).body_panels.clone();
@@ -283,13 +306,24 @@ pub(crate) fn open_main_window(cx: &mut App) {
.iter()
.map(|s| s.into())
.collect();
let body_sizes: Vec<f32> = body_panels_clone
let mut body_sizes: Vec<f32> = body_panels_clone
.read(cx)
.sizes()
.iter()
.map(|s| s.into())
.collect();
if view_clone.read(cx).sftp_panel_minimized {
if let Some(prev) = view_clone.read(cx).prev_monitoring_size {
if body_sizes.len() > 1 {
body_sizes[1] = prev.into();
}
}
}
config.set_layout_state(Some(saved_bounds), Some(workspace_sizes), Some(body_sizes));
config.set_sidebar_collapsed(view_clone.read(cx).sidebar_collapsed);
config.set_sftp_panel_minimized(view_clone.read(cx).sftp_panel_minimized);
let _ = config.save();
true
});
+273 -150
View File
@@ -1,12 +1,12 @@
use gpui::{
Context, ElementId, Focusable as _, FontWeight, Hsla, InteractiveElement as _, IntoElement,
MouseButton, MouseDownEvent, ParentElement as _, PathBuilder, Pixels, Render,
StatefulInteractiveElement as _, Styled as _, Window, canvas, div, point,
prelude::FluentBuilder as _, px, rems, uniform_list,
StatefulInteractiveElement as _, Styled as _, Window, WindowControlArea, canvas, div, hsla,
point, prelude::FluentBuilder as _, px, rems, uniform_list,
};
use gpui_component::{
ActiveTheme, Disableable as _, ElementExt, Icon, IconName, Root, Size, Sizable as _,
button::{Button, ButtonVariants as _},
ActiveTheme, Disableable as _, ElementExt, Icon, IconName, InteractiveElementExt as _, Root,
Size, Sizable as _, button::{Button, ButtonVariants as _},
checkbox::Checkbox,
h_flex,
input::Input,
@@ -108,6 +108,9 @@ impl Ashell {
},
);
}
self.config
.set_sftp_panel_minimized(self.sftp_panel_minimized);
let _ = self.config.save();
cx.notify();
}
@@ -157,10 +160,10 @@ impl Ashell {
};
let label = match kind {
crate::terminal::TransferType::Download => {
format!("{} files downloading", active.len())
t!("files_downloading", count = active.len()).to_string()
}
crate::terminal::TransferType::Upload => {
format!("{} files uploading", active.len())
t!("files_uploading", count = active.len()).to_string()
}
};
match pct {
@@ -283,7 +286,6 @@ impl Ashell {
})),
)
});
let Some(sftp) = active_sftp else {
let mut outer = v_flex()
.gap_0()
@@ -376,13 +378,17 @@ impl Ashell {
);
}
this.child(content)
.on_click(cx.listener(|this, _, window, cx| {
this.show_transfers_dialog(window, cx);
}))
})
.when(!has_transfers, |this| {
this.icon(IconName::ArrowDown)
})
.on_click(cx.listener(|this, _, window, cx| {
this.show_transfers_dialog(window, cx);
})),
.label(t!("transfers").to_string())
.on_click(cx.listener(|this, _, window, cx| {
this.show_transfers_dialog(window, cx);
}))
}),
)
.child(
Button::new("sftp-minimize-toggle")
@@ -393,6 +399,11 @@ impl Ashell {
} else {
IconName::ChevronDown
})
.label(if self.sftp_panel_minimized {
t!("panel_expand").to_string()
} else {
t!("panel_minimize").to_string()
})
.on_click(cx.listener(|this, _, window, cx| {
this.toggle_sftp_minimized(window, cx);
})),
@@ -785,11 +796,14 @@ impl Ashell {
})
.when(!has_transfers, |this| {
this.icon(IconName::ArrowDown)
.label(t!("transfers").to_string())
})
.on_click(cx.listener(|this, _, window, cx| {
this.show_transfers_dialog(window, cx);
})),
)
.child(
Button::new("sftp-minimize-toggle")
.ghost()
@@ -799,10 +813,17 @@ impl Ashell {
} else {
IconName::ChevronDown
})
.label(if self.sftp_panel_minimized {
t!("panel_expand").to_string()
} else {
t!("panel_minimize").to_string()
})
.on_click(cx.listener(|this, _, window, cx| {
this.toggle_sftp_minimized(window, cx);
})),
),
);
outer.into_any_element()
@@ -1520,8 +1541,11 @@ impl Ashell {
Button::new("sidebar-collapse-toggle")
.ghost()
.icon(IconName::PanelLeftClose)
.tooltip(t!("settings_toggle_sidebar").to_string())
.on_click(cx.listener(|this, _, _, cx| {
this.sidebar_collapsed = true;
this.config.set_sidebar_collapsed(true);
let _ = this.config.save();
cx.notify();
})),
)
@@ -1529,6 +1553,7 @@ impl Ashell {
Button::new("sidebar-settings")
.ghost()
.icon(IconName::Settings)
.tooltip(t!("settings_open_settings").to_string())
.on_click(cx.listener(|this, _, window, cx| {
this.show_settings_dialog(window, cx)
})),
@@ -1749,8 +1774,11 @@ impl Ashell {
Button::new("sidebar-expand-toggle")
.ghost()
.icon(IconName::PanelLeftOpen)
.tooltip(t!("settings_toggle_sidebar").to_string())
.on_click(cx.listener(|this, _, _, cx| {
this.sidebar_collapsed = false;
this.config.set_sidebar_collapsed(false);
let _ = this.config.save();
cx.notify();
})),
),
@@ -1868,6 +1896,58 @@ impl Ashell {
)
}
fn render_window_controls(&self, window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
let is_macos = cfg!(target_os = "macos");
let is_fullscreen = window.is_fullscreen();
h_flex()
.flex_none()
.items_center()
.px_3()
.gap_2()
.when(!is_macos || is_fullscreen, |this| {
this.child(
div()
.id("window-close")
.size(px(12.))
.rounded_full()
.bg(hsla(0.0, 0.8, 0.4, 1.0)) // Red
.on_click(|_, window, _| window.remove_window())
.hover(|s| s.bg(hsla(0.0, 0.8, 0.5, 1.0)))
.active(|s| s.bg(hsla(0.0, 0.8, 0.3, 1.0))),
)
.child(
div()
.id("window-minimize")
.size(px(12.))
.rounded_full()
.bg(hsla(0.12, 0.8, 0.4, 1.0)) // Yellow
.on_click(|_, window, _| window.minimize_window())
.hover(|s| s.bg(hsla(0.12, 0.8, 0.5, 1.0)))
.active(|s| s.bg(hsla(0.12, 0.8, 0.3, 1.0))),
)
.child(
div()
.id("window-maximize")
.size(px(12.))
.rounded_full()
.bg(hsla(0.33, 0.8, 0.4, 1.0)) // Green
.on_click(|_, window, _| {
if window.is_fullscreen() {
window.toggle_fullscreen();
} else {
window.zoom_window();
}
})
.hover(|s| s.bg(hsla(0.33, 0.8, 0.5, 1.0)))
.active(|s| s.bg(hsla(0.33, 0.8, 0.3, 1.0))),
)
})
.when(is_macos, |this| {
this.when(!is_fullscreen, |this| this.w(px(80.)))
})
}
fn render_tab_bar(&self, cx: &mut Context<Self>) -> impl IntoElement {
let active_tab_index = self
.active_tab
@@ -1891,147 +1971,131 @@ impl Ashell {
(g.id.clone(), g.title.clone(), pane_ids)
})
.collect();
v_flex()
.h(px(32.))
.w_full()
.flex_none()
.bg(cx.theme().tab_bar)
h_flex()
.flex_1()
.min_w(px(0.))
.h_full()
.items_center()
.gap_2()
.child(
div()
.flex_1()
.min_w(px(0.))
.h_full()
.overflow_x_hidden()
.child({
TabBar::new("ashell-tab-bar")
.track_scroll(&self.tabs_scroll_handle)
.selected_index(selected)
.children(groups_data.iter().enumerate().map(
|(ix, (group_id, title, pane_ids))| {
let gid = group_id.clone();
let label = if pane_ids.len() > 1 {
format!("{} ({})", title, pane_ids.len())
} else {
title.clone()
};
let close_id = if self.active_group.as_ref() == Some(&gid) {
self.active_tab.clone().unwrap_or_else(|| {
pane_ids.first().cloned().unwrap_or_default()
})
} else {
pane_ids.first().cloned().unwrap_or_default()
};
let dot_color = pane_ids
.first()
.and_then(|id| self.tabs.iter().find(|t| t.id == *id))
.map(|tab| {
if tab.connected {
cx.theme().success
} else {
cx.theme().danger
}
})
.unwrap_or(cx.theme().success);
Tab::new()
.min_w(px(80.))
.prefix(div().w(px(5.)).h(px(32.)).bg(dot_color))
.child(
div()
.when(ix == selected, |this| {
this.font_weight(FontWeight::BOLD)
.text_color(cx.theme().primary)
.text_base()
})
.child(label),
)
.on_click(cx.listener(move |this, _, window, cx| {
this.activate_group(gid.clone(), window, cx)
}))
.suffix(
Button::new(("tab-close", ix))
.ghost()
.xsmall()
.icon(IconName::Close)
.mr(px(5.))
.on_mouse_down(MouseButton::Left, |_, window, cx| {
window.prevent_default();
cx.stop_propagation();
})
.on_click(cx.listener(move |this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
if !close_id.is_empty() {
this.close_tab(close_id.clone(), cx)
}
})),
)
},
))
.last_empty_space(div().w_3())
.w_full()
.h_full()
}),
)
.child(
h_flex()
.h_full()
.w_full()
.flex_none()
.items_center()
.gap_2()
.gap_1()
.pr(px(6.))
.child(
div()
.flex_1()
.min_w(px(0.))
.h_full()
.overflow_x_hidden()
.child({
TabBar::new("ashell-tab-bar")
.track_scroll(&self.tabs_scroll_handle)
.selected_index(selected)
.children(groups_data.iter().enumerate().map(
|(ix, (group_id, title, pane_ids))| {
let gid = group_id.clone();
let label = if pane_ids.len() > 1 {
format!("{} ({})", title, pane_ids.len())
} else {
title.clone()
};
let close_id = if self.active_group.as_ref()
== Some(&gid)
{
self.active_tab.clone().unwrap_or_else(|| {
pane_ids.first().cloned().unwrap_or_default()
})
} else {
pane_ids.first().cloned().unwrap_or_default()
};
let dot_color = pane_ids
.first()
.and_then(|id| {
self.tabs.iter().find(|t| t.id == *id)
})
.map(|tab| {
if tab.connected {
cx.theme().success
} else {
cx.theme().danger
}
})
.unwrap_or(cx.theme().success);
Tab::new()
.min_w(px(80.))
.prefix(div().w(px(5.)).h(px(32.)).bg(dot_color))
.child(
div()
.when(ix == selected, |this| {
this.font_weight(FontWeight::BOLD)
.text_color(cx.theme().primary)
.text_base()
})
.child(label),
)
.on_click(cx.listener(
move |this, _, window, cx| {
this.activate_group(gid.clone(), window, cx)
},
))
.suffix(
Button::new(("tab-close", ix))
.ghost()
.xsmall()
.icon(IconName::Close)
.mr(px(5.))
.on_mouse_down(
MouseButton::Left,
|_, window, cx| {
window.prevent_default();
cx.stop_propagation();
},
)
.on_click(cx.listener(
move |this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
if !close_id.is_empty() {
this.close_tab(
close_id.clone(),
cx,
)
}
},
)),
)
},
))
.last_empty_space(div().w_3())
.w_full()
.h_full()
}),
Button::new("open-selector")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::Plus)
.tooltip(t!("settings_open_session").to_string())
.on_click(cx.listener(|this, _, window, cx| {
this.show_selector_dialog(window, cx)
})),
)
.child(
h_flex()
.flex_none()
.items_center()
.gap_1()
.pr(px(6.))
.child(
Button::new("open-selector")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::Plus)
.on_click(cx.listener(|this, _, window, cx| {
this.show_selector_dialog(window, cx)
})),
)
.child(
Button::new("split-horizontal")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::PanelBottom)
.on_click(cx.listener(|this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
this.split_current_pane("down", cx);
})),
)
.child(
Button::new("split-vertical")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::PanelRight)
.on_click(cx.listener(|this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
this.split_current_pane("right", cx);
})),
),
Button::new("split-horizontal")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::PanelBottom)
.tooltip(t!("settings_split_pane_down").to_string())
.on_click(cx.listener(|this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
this.split_current_pane("down", cx);
})),
)
.child(
Button::new("split-vertical")
.secondary()
.small()
.rounded(px(999.))
.icon(IconName::PanelRight)
.tooltip(t!("settings_split_pane_right").to_string())
.on_click(cx.listener(|this, _, window, cx| {
window.prevent_default();
cx.stop_propagation();
this.split_current_pane("right", cx);
})),
),
)
}
@@ -2400,7 +2464,21 @@ impl Render for Ashell {
.size_full()
.relative()
.overflow_hidden()
.child(self.render_tab_bar(cx))
.when(
self.active_title_bar_style == crate::session::config::TitleBarStyle::Native,
|this| {
this.child(
div()
.flex_none()
.h(px(32.))
.w_full()
.bg(cx.theme().tab_bar)
.border_b_1()
.border_color(cx.theme().border)
.child(self.render_tab_bar(cx)),
)
},
)
.child(body_panel),
),
)
@@ -2421,7 +2499,21 @@ impl Render for Ashell {
.size_full()
.relative()
.overflow_hidden()
.child(self.render_tab_bar(cx))
.when(
self.active_title_bar_style == crate::session::config::TitleBarStyle::Native,
|this| {
this.child(
div()
.flex_none()
.h(px(32.))
.w_full()
.bg(cx.theme().tab_bar)
.border_b_1()
.border_color(cx.theme().border)
.child(self.render_tab_bar(cx)),
)
},
)
.child(body_panel),
);
@@ -2432,7 +2524,7 @@ impl Render for Ashell {
.into_any_element()
};
div()
v_flex()
.id("ashell-root")
.size_full()
.bg(cx.theme().background)
@@ -2440,9 +2532,12 @@ impl Render for Ashell {
.font_family(self.ui_font_family.clone())
.on_action(cx.listener(|this, _: &crate::OpenSettings, window, cx| this.show_settings_dialog(window, cx)))
.on_action(cx.listener(|this, _: &crate::OpenSession, window, cx| this.show_selector_dialog(window, cx)))
.on_action(cx.listener(|this, _: &crate::OpenTransfers, window, cx| this.show_transfers_dialog(window, cx)))
.on_action(cx.listener(|this, _: &crate::NewSsh, window, cx| this.show_ssh_dialog(window, cx)))
.on_action(cx.listener(|this, _: &crate::ToggleSidebar, _, cx| {
this.sidebar_collapsed = !this.sidebar_collapsed;
this.config.set_sidebar_collapsed(this.sidebar_collapsed);
let _ = this.config.save();
cx.notify();
}))
.on_action(cx.listener(|this, _: &crate::ToggleSftpZoom, window, cx| {
@@ -2461,7 +2556,35 @@ impl Render for Ashell {
this.close_tab(active_id, cx);
}
}))
.child(workspace)
.when(self.active_title_bar_style == crate::session::config::TitleBarStyle::Integrated, |this| {
this.child(
div()
.id("title-bar")
.flex()
.items_center()
.h(px(34.))
.w_full()
.bg(cx.theme().tab_bar)
.on_double_click(|_, window, _| {
#[cfg(target_os = "macos")]
window.titlebar_double_click();
#[cfg(not(target_os = "macos"))]
window.zoom_window();
})
.child(self.render_window_controls(window, cx))
.child(
div()
.flex_1()
.min_w(px(0.))
.h_full()
.window_control_area(WindowControlArea::Drag)
.child(self.render_tab_bar(cx)),
),
)
})
.child(
div().flex_1().min_h_0().child(workspace),
)
.children(Root::render_dialog_layer(window, cx))
.children(Root::render_sheet_layer(window, cx))
.when_some(self.sftp_context_menu.clone(), |this, menu| {
+2 -2
View File
@@ -16,8 +16,8 @@ gpui::actions!(ashell_terminal, [TerminalTabKey, TerminalBacktabKey]);
pub(crate) use app::keybinding_recorder::{
ClosePane, FocusPaneDown, FocusPaneLeft, FocusPaneRight, FocusPaneUp, NewSsh, OpenSession,
OpenSettings, SplitPaneDown, SplitPaneLeft, SplitPaneRight, SplitPaneUp, ToggleSftpZoom,
ToggleSidebar,
OpenSettings, OpenTransfers, SplitPaneDown, SplitPaneLeft, SplitPaneRight, SplitPaneUp,
ToggleSftpZoom, ToggleSidebar,
};
pub(crate) use app::{
+38
View File
@@ -98,6 +98,14 @@ pub enum SavedWindowBounds {
},
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
#[serde(rename_all = "lowercase")]
pub enum TitleBarStyle {
#[default]
Native,
Integrated,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ConfigFile {
#[serde(default = "default_follow_system_theme")]
@@ -121,6 +129,8 @@ pub struct ConfigFile {
#[serde(default = "default_terminal_font_family")]
pub terminal_font_family: String,
#[serde(default)]
pub title_bar_style: TitleBarStyle,
#[serde(default)]
pub sessions: Vec<Session>,
#[serde(default)]
pub window_bounds: Option<SavedWindowBounds>,
@@ -135,6 +145,10 @@ pub struct ConfigFile {
#[serde(default = "default_monitoring_position")]
pub monitoring_position: String,
#[serde(default)]
pub sidebar_collapsed: bool,
#[serde(default)]
pub sftp_panel_minimized: bool,
#[serde(default)]
pub key_bindings: std::collections::HashMap<String, String>,
}
@@ -402,6 +416,14 @@ impl ConfigStore {
self.cache.terminal_font_family = family.to_string();
}
pub fn title_bar_style(&self) -> TitleBarStyle {
self.cache.title_bar_style
}
pub fn set_title_bar_style(&mut self, style: TitleBarStyle) {
self.cache.title_bar_style = style;
}
pub fn show_hidden_files(&self) -> bool {
self.cache.show_hidden_files
}
@@ -410,6 +432,22 @@ impl ConfigStore {
self.cache.show_hidden_files = val;
}
pub fn sidebar_collapsed(&self) -> bool {
self.cache.sidebar_collapsed
}
pub fn set_sidebar_collapsed(&mut self, val: bool) {
self.cache.sidebar_collapsed = val;
}
pub fn sftp_panel_minimized(&self) -> bool {
self.cache.sftp_panel_minimized
}
pub fn set_sftp_panel_minimized(&mut self, val: bool) {
self.cache.sftp_panel_minimized = val;
}
pub fn get(&self, id: &str) -> Option<&Session> {
self.cache.sessions.iter().find(|s| s.id == id)
}
+4
View File
@@ -113,7 +113,9 @@ impl Ashell {
self.open_ssh_session(session, cx);
self.editing_session_id = None;
self.active_dialog = None;
window.close_dialog(cx);
cx.notify();
}
pub(crate) fn set_input_value(
@@ -368,6 +370,7 @@ impl Ashell {
return;
};
self.active_dialog = None;
match entry {
SelectorEntry::Local => {
self.open_local(cx);
@@ -382,6 +385,7 @@ impl Ashell {
window.close_dialog(cx);
}
}
cx.notify();
}
pub(crate) fn on_selector_key_down(