logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree with a 3-file patch applied (no upstream history). Patch (crates/gpui_linux/src/linux/wayland/): - serial.rs: add SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; add latest_serial_of() - window.rs: activate() uses keyboard-enter serial (Mutter focus gate) Mutter honors window activation only when the token carries the keyboard- focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial. See docs/tray-window-focus-wayland.md in logiguard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
27
crates/project_benchmarks/Cargo.toml
Normal file
27
crates/project_benchmarks/Cargo.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
[package]
|
||||
name = "project_benchmarks"
|
||||
version = "0.1.0"
|
||||
publish.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
askpass.workspace = true
|
||||
clap.workspace = true
|
||||
client.workspace = true
|
||||
futures.workspace = true
|
||||
gpui.workspace = true
|
||||
gpui_platform.workspace = true
|
||||
http_client = { workspace = true, features = ["test-support"]}
|
||||
language.workspace = true
|
||||
node_runtime.workspace = true
|
||||
project.workspace = true
|
||||
release_channel.workspace = true
|
||||
remote = { workspace = true, features = ["build-remote-server-binary"] }
|
||||
rpassword = "7.4"
|
||||
semver.workspace = true
|
||||
settings.workspace = true
|
||||
watch.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
1
crates/project_benchmarks/LICENSE-GPL
Symbolic link
1
crates/project_benchmarks/LICENSE-GPL
Symbolic link
@@ -0,0 +1 @@
|
||||
../../LICENSE-GPL
|
||||
236
crates/project_benchmarks/src/main.rs
Normal file
236
crates/project_benchmarks/src/main.rs
Normal file
@@ -0,0 +1,236 @@
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use askpass::EncryptedPassword;
|
||||
use clap::Parser;
|
||||
use client::{Client, UserStore};
|
||||
use futures::channel::oneshot;
|
||||
use gpui::AppContext as _;
|
||||
use gpui::TaskExt;
|
||||
use http_client::FakeHttpClient;
|
||||
use language::LanguageRegistry;
|
||||
use node_runtime::NodeRuntime;
|
||||
use project::{
|
||||
Project, RealFs,
|
||||
search::{SearchQuery, SearchResult},
|
||||
};
|
||||
use release_channel::ReleaseChannel;
|
||||
use remote::{ConnectionIdentifier, RemoteClientDelegate, SshConnectionOptions};
|
||||
use semver::Version;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
/// List of worktrees to run the search against.
|
||||
worktrees: Vec<String>,
|
||||
#[clap(short)]
|
||||
query: Option<String>,
|
||||
/// Askpass socket for SSH authentication
|
||||
#[clap(long)]
|
||||
askpass: Option<String>,
|
||||
/// Treat query as a regex.
|
||||
#[clap(short, long)]
|
||||
regex: bool,
|
||||
/// Matches have to be standalone words.
|
||||
#[clap(long)]
|
||||
whole_word: bool,
|
||||
/// Make matching case-sensitive.
|
||||
#[clap(long, default_value_t = false)]
|
||||
case_sensitive: bool,
|
||||
/// Include gitignored files in the search.
|
||||
#[clap(long)]
|
||||
include_ignored: bool,
|
||||
#[clap(long)]
|
||||
ssh: Option<String>,
|
||||
}
|
||||
|
||||
struct BenchmarkRemoteClient;
|
||||
impl RemoteClientDelegate for BenchmarkRemoteClient {
|
||||
fn ask_password(
|
||||
&self,
|
||||
prompt: String,
|
||||
tx: oneshot::Sender<EncryptedPassword>,
|
||||
_cx: &mut gpui::AsyncApp,
|
||||
) {
|
||||
eprintln!("SSH asking for password: {}", prompt);
|
||||
match rpassword::prompt_password(&prompt) {
|
||||
Ok(password) => match EncryptedPassword::try_from(password.as_ref()) {
|
||||
Ok(encrypted) => {
|
||||
if tx.send(encrypted).is_err() {
|
||||
eprintln!("Failed to send password");
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("Failed to encrypt password: {e}"),
|
||||
},
|
||||
Err(e) => eprintln!("Failed to read password: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_download_url(
|
||||
&self,
|
||||
_platform: remote::RemotePlatform,
|
||||
_release_channel: ReleaseChannel,
|
||||
_version: Option<Version>,
|
||||
_cx: &mut gpui::AsyncApp,
|
||||
) -> gpui::Task<gpui::Result<Option<String>>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn download_server_binary_locally(
|
||||
&self,
|
||||
_platform: remote::RemotePlatform,
|
||||
_release_channel: ReleaseChannel,
|
||||
_version: Option<Version>,
|
||||
_cx: &mut gpui::AsyncApp,
|
||||
) -> gpui::Task<gpui::Result<std::path::PathBuf>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_status(&self, status: Option<&str>, _: &mut gpui::AsyncApp) {
|
||||
if let Some(status) = status {
|
||||
println!("SSH status: {status}");
|
||||
}
|
||||
}
|
||||
}
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
let args = Args::parse();
|
||||
|
||||
if let Some(socket) = &args.askpass {
|
||||
askpass::main(socket);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let query_str = args
|
||||
.query
|
||||
.ok_or_else(|| anyhow!("-q/--query is required"))?;
|
||||
let query = if args.regex {
|
||||
SearchQuery::regex(
|
||||
query_str,
|
||||
args.whole_word,
|
||||
args.case_sensitive,
|
||||
args.include_ignored,
|
||||
false,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
false,
|
||||
None,
|
||||
)
|
||||
} else {
|
||||
SearchQuery::text(
|
||||
query_str,
|
||||
args.whole_word,
|
||||
args.case_sensitive,
|
||||
args.include_ignored,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
false,
|
||||
None,
|
||||
)
|
||||
}?;
|
||||
gpui_platform::headless().run(|cx| {
|
||||
release_channel::init_test(semver::Version::new(0, 0, 0), ReleaseChannel::Dev, cx);
|
||||
settings::init(cx);
|
||||
let client = Client::production(cx);
|
||||
let http_client = FakeHttpClient::with_200_response();
|
||||
let (_, rx) = watch::channel(None);
|
||||
let node = NodeRuntime::new(http_client, None, rx);
|
||||
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
|
||||
let registry = Arc::new(LanguageRegistry::new(cx.background_executor().clone()));
|
||||
let fs = Arc::new(RealFs::new(None, cx.background_executor().clone()));
|
||||
|
||||
|
||||
|
||||
cx.spawn(async move |cx| {
|
||||
let project = if let Some(ssh_target) = args.ssh {
|
||||
println!("Setting up SSH connection for {}", &ssh_target);
|
||||
let ssh_connection_options = SshConnectionOptions::parse_command_line(&ssh_target)?;
|
||||
|
||||
let connection_options = remote::RemoteConnectionOptions::from(ssh_connection_options);
|
||||
let delegate = Arc::new(BenchmarkRemoteClient);
|
||||
let remote_connection = remote::connect(connection_options.clone(), delegate.clone(), cx).await.unwrap();
|
||||
|
||||
let (_tx, rx) = oneshot::channel();
|
||||
let remote_client = cx.update(|cx| remote::RemoteClient::new(ConnectionIdentifier::setup(), remote_connection, rx, delegate.clone(), cx )).await?.ok_or_else(|| anyhow!("ssh initialization returned None"))?;
|
||||
|
||||
cx.update(|cx| Project::remote(remote_client, client, node, user_store, registry, fs, false, cx))
|
||||
} else {
|
||||
println!("Setting up local project");
|
||||
cx.update(|cx| Project::local(
|
||||
client,
|
||||
node,
|
||||
user_store,
|
||||
registry,
|
||||
fs,
|
||||
Some(Default::default()),
|
||||
project::LocalProjectFlags {
|
||||
init_worktree_trust: false,
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
))
|
||||
};
|
||||
println!("Loading worktrees");
|
||||
let worktrees = project.update(cx, |this, cx| {
|
||||
args.worktrees
|
||||
.into_iter()
|
||||
.map(|worktree| this.find_or_create_worktree(worktree, true, cx))
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
let worktrees = futures::future::join_all(worktrees)
|
||||
.await
|
||||
.into_iter()
|
||||
.collect::<Result<Vec<_>, anyhow::Error>>()?;
|
||||
|
||||
for (worktree, _) in &worktrees {
|
||||
let scan_complete = worktree
|
||||
.update(cx, |this, _| {
|
||||
if let Some(local) = this.as_local() {
|
||||
Some(local.scan_complete())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
if let Some(scan_complete) = scan_complete {
|
||||
scan_complete.await;
|
||||
} else {
|
||||
cx.background_executor().timer(Duration::from_secs(10)).await;
|
||||
}
|
||||
|
||||
}
|
||||
println!("Worktrees loaded");
|
||||
|
||||
println!("Starting a project search");
|
||||
let timer = std::time::Instant::now();
|
||||
let mut first_match = None;
|
||||
let matches = project.update(cx, |this, cx| this.search(query, cx));
|
||||
let mut matched_files = 0;
|
||||
let mut matched_chunks = 0;
|
||||
while let Ok(match_result) = matches.rx.recv().await {
|
||||
if first_match.is_none() {
|
||||
let time = timer.elapsed();
|
||||
first_match = Some(time);
|
||||
println!("First match found after {time:?}");
|
||||
}
|
||||
match match_result {
|
||||
SearchResult::Buffer { ranges, .. } => {
|
||||
matched_files += 1;
|
||||
matched_chunks += ranges.len();
|
||||
}
|
||||
SearchResult::LimitReached => break,
|
||||
SearchResult::WaitingForScan | SearchResult::Searching => continue,
|
||||
}
|
||||
}
|
||||
let elapsed = timer.elapsed();
|
||||
println!(
|
||||
"Finished project search after {elapsed:?}. Matched {matched_files} files and {matched_chunks} excerpts"
|
||||
);
|
||||
drop(project);
|
||||
cx.update(|cx| cx.quit());
|
||||
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user