Merge pull request #94 from Sakyvo/pr/terminal-network-proxy
feat(gpui): terminal network proxy toggle for new sessions
This commit is contained in:
4 files changed
+25
-1
No files matched your search
@@ -159,6 +159,13 @@ impl SettingsPane {
|
||||
.child(div().h(px(PROXY_TEST_GAP)).w_full().flex_shrink_0())
|
||||
.child(self.proxy_mode_row(cx))
|
||||
.when(custom, |page| page.child(self.proxy_address_row(cx)))
|
||||
.child(self.switch_row(
|
||||
"terminal_proxy",
|
||||
"系统代理",
|
||||
"启用时,新建终端的 HTTP(S)_PROXY 会接入系统代理。",
|
||||
self.runtime.terminal_proxy,
|
||||
cx,
|
||||
))
|
||||
}
|
||||
|
||||
fn proxy_test_banner(&self, cx: &mut Context<Self>) -> gpui::Div {
|
||||
|
||||
@@ -2166,6 +2166,7 @@ impl SettingsPane {
|
||||
"copy_on_select" => flag!(copy_on_select),
|
||||
"multiline_paste_confirm" => flag!(multiline_paste_confirm),
|
||||
"tab_close_visible" => flag!(tab_close_visible),
|
||||
"terminal_proxy" => flag!(terminal_proxy),
|
||||
"powerline" => flag!(powerline),
|
||||
"ghost" => flag!(ghost),
|
||||
"cjk_bold_regular" => flag!(cjk_bold_regular),
|
||||
@@ -2201,7 +2202,8 @@ impl SettingsPane {
|
||||
}
|
||||
}
|
||||
|
||||
fn switch_row(
|
||||
/// 斗隔 union 里 network_settings.rs 也用它。
|
||||
pub(super) fn switch_row(
|
||||
&self,
|
||||
key: &'static str,
|
||||
label: &'static str,
|
||||
|
||||
@@ -94,6 +94,16 @@ pub(super) fn local_options(
|
||||
if let Err(error) = tty::refresh_environment(&mut options) {
|
||||
log::warn!("Could not refresh the Windows environment for a new pane: {error}");
|
||||
}
|
||||
// 终端网络代理开启时,把当前系统代理同步给新会话(HTTP(S)_PROXY 变量),
|
||||
// 让会话里的 curl/git/npm 等不必重复设。系统代理探不到则什么都不做。
|
||||
// 放在环境重建之后:注入值作为 pane 专属覆盖,不被注册表快照冲掉。
|
||||
#[cfg(windows)]
|
||||
if ::nebula_settings::RuntimeSettings::load().terminal_proxy
|
||||
&& let Some((url, _)) = crate::ssh_proxy::probe_system_proxy()
|
||||
{
|
||||
options.env.insert("HTTP_PROXY".into(), url.clone());
|
||||
options.env.insert("HTTPS_PROXY".into(), url);
|
||||
}
|
||||
// WSL tab 的命令边界(OSC 133;D/A)与 cwd(OSC 7):来宾登录 shell 默认
|
||||
// 不发,Agent 生命周期、目录树与 Git 视图都会失去来宾侧事实。只对
|
||||
// `wsl.exe` 启动生效,见 [`crate::shell_detect::wsl_cwd_report_env`]。
|
||||
|
||||
@@ -1013,6 +1013,9 @@ pub struct RuntimeSettings {
|
||||
pub multiline_paste_confirm: bool,
|
||||
/// 标签页关闭按钮(叉号)是否渲染:关 = 不渲染,仍可用中键关闭。
|
||||
pub tab_close_visible: bool,
|
||||
/// 终端网络代理:新会话启动时把当前系统代理写入 HTTP_PROXY/HTTPS_PROXY。
|
||||
/// 上游默认关 (false) —— fork 侧另起本地 commit 翻成默认开。
|
||||
pub terminal_proxy: bool,
|
||||
pub powerline: bool,
|
||||
/// 默认 shell 的原始 id(`shell=` 原文:powershell/bash/cmd/pwsh/WSL
|
||||
/// 发行版等)。解析归 shell 检测层,这里只做持久化往返。
|
||||
@@ -1156,6 +1159,7 @@ impl RuntimeSettings {
|
||||
copy_on_select: raw.bool_on("copy_on_select").unwrap_or(false),
|
||||
multiline_paste_confirm: raw.bool_on("multiline_paste_confirm").unwrap_or(true),
|
||||
tab_close_visible: raw.bool_on("tab_close_visible").unwrap_or(true),
|
||||
terminal_proxy: raw.bool_on("terminal_proxy").unwrap_or(false),
|
||||
powerline: raw.bool_on("powerline").unwrap_or(true),
|
||||
shell: raw.value("shell").or_else(|| raw.value("executor")).map(str::to_owned),
|
||||
startup_directory: raw.value("startup_directory").map(str::to_owned),
|
||||
@@ -1429,6 +1433,7 @@ mod tests {
|
||||
assert!(!settings.copy_on_select);
|
||||
assert!(settings.multiline_paste_confirm, "多行粘贴确认默认开(上游兼容)");
|
||||
assert!(settings.tab_close_visible, "标签关闭按钮默认可见(上游兼容)");
|
||||
assert!(!settings.terminal_proxy, "终端网络代理上游默认关(兼容)");
|
||||
assert!(settings.powerline);
|
||||
assert!(settings.ghost);
|
||||
assert_eq!(settings.accept, AcceptKeyName::Both);
|
||||
|
||||
Reference in new issue
Block a user