zed: Add --system-specs arg (#27285)

Adds the `--system-specs` flag to the Zed binary, so that users who wish
to report issues can retrieve their system specs, even if Zed is failing
to launch

Still TODO:
- [x] Test and do best effort GPU info detection on Linux
- [ ] Modify GitHub issue templates to tell users that the flag is
available if they are unable to launch Zed

Release Notes:

- Added the `--system-specs` flag to the Zed binary (not the cli!), to
retrieve the system specs we ask for in GitHub issues without needing to
open Zed
This commit is contained in:
Ben Kunkle 2025-03-21 21:56:25 -05:00 committed by GitHub
parent 85a761cb2b
commit c783fd072f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 108 additions and 9 deletions

View file

@ -5,7 +5,7 @@ use workspace::Workspace;
pub mod feedback_modal;
mod system_specs;
pub mod system_specs;
actions!(
zed,

View file

@ -1,5 +1,5 @@
use client::telemetry;
use gpui::{App, AppContext as _, Task, Window};
use gpui::{App, AppContext as _, SemanticVersion, Task, Window};
use human_bytes::human_bytes;
use release_channel::{AppCommitSha, AppVersion, ReleaseChannel};
use serde::Serialize;
@ -35,14 +35,12 @@ impl SystemSpecs {
_ => None,
};
let gpu_specs = if let Some(specs) = window.gpu_specs() {
Some(format!(
let gpu_specs = window.gpu_specs().map(|specs| {
format!(
"{} || {} || {}",
specs.device_name, specs.driver_name, specs.driver_info
))
} else {
None
};
)
});
cx.background_spawn(async move {
let os_version = telemetry::os_version();
@ -58,6 +56,37 @@ impl SystemSpecs {
}
})
}
pub fn new_stateless(
app_version: SemanticVersion,
app_commit_sha: Option<AppCommitSha>,
release_channel: ReleaseChannel,
) -> Self {
let os_name = telemetry::os_name();
let os_version = telemetry::os_version();
let system = System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::everything()),
);
let memory = system.total_memory();
let architecture = env::consts::ARCH;
let commit_sha = match release_channel {
ReleaseChannel::Dev | ReleaseChannel::Nightly => {
app_commit_sha.map(|sha| sha.0.clone())
}
_ => None,
};
Self {
app_version: app_version.to_string(),
release_channel: release_channel.display_name(),
os_name,
os_version,
memory,
architecture,
commit_sha,
gpu_specs: try_determine_available_gpus(),
}
}
}
impl Display for SystemSpecs {
@ -94,3 +123,29 @@ impl Display for SystemSpecs {
write!(f, "{system_specs}")
}
}
fn try_determine_available_gpus() -> Option<String> {
#[cfg(target_os = "linux")]
{
return std::process::Command::new("vulkaninfo")
.args(&["--summary"])
.output()
.ok()
.map(|output| {
[
"<details><summary>`vulkaninfo --summary` output</summary>",
"",
"```",
String::from_utf8_lossy(&output.stdout).as_ref(),
"```",
"</details>",
]
.join("\n")
})
.or(Some("Failed to run `vulkaninfo --summary`".to_string()));
}
#[cfg(not(target_os = "linux"))]
{
return None;
}
}