-
Notifications
You must be signed in to change notification settings - Fork 0
Select repo, run goal, edit code in worktrees, and push to GitHub #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| //! Repository selection + local environment checks (desktop only). | ||
| //! | ||
| //! These commands back the Start screen's "select a repo" flow and the provider | ||
| //! onboarding panel: a native folder picker, a fast "is this a git repo?" probe, | ||
| //! and detection of which coding/CLI tools are installed. They run in the | ||
| //! trusted Rust shell (not the webview) so they can touch the filesystem and | ||
| //! PATH directly; the engine still re-validates a selected repo server-side | ||
| //! before a run starts. | ||
|
|
||
| use std::collections::HashMap; | ||
| use std::path::Path; | ||
| use std::process::Command; | ||
|
|
||
| use tauri::AppHandle; | ||
| use tauri_plugin_dialog::DialogExt; | ||
|
|
||
| /// Opens the native folder picker and returns the chosen absolute path (or | ||
| /// `None` if the user cancelled). Blocking is fine here: Tauri runs command | ||
| /// handlers off the main thread, and the picker is modal by design. | ||
| #[tauri::command] | ||
| pub fn pick_directory(app: AppHandle) -> Result<Option<String>, String> { | ||
| let picked = app.dialog().file().blocking_pick_folder(); | ||
| Ok(picked | ||
| .and_then(|p| p.into_path().ok()) | ||
| .map(|p| p.to_string_lossy().to_string())) | ||
| } | ||
|
|
||
| /// True when `path` is inside a git working tree. Mirrors the engine's | ||
| /// `isGitRepo` so the UI can validate a selection before a run is started. | ||
| #[tauri::command] | ||
| pub fn check_git_repo(path: String) -> bool { | ||
| Command::new("git") | ||
| .args(["-C", &path, "rev-parse", "--is-inside-work-tree"]) | ||
| .output() | ||
| .map(|o| o.status.success() && String::from_utf8_lossy(&o.stdout).trim() == "true") | ||
| .unwrap_or(false) | ||
| } | ||
|
|
||
| /// For each requested tool name, reports whether it is found on PATH. Used by | ||
| /// the provider-onboarding panel to show "installed / missing" for tools like | ||
| /// `codex`, `kiro`, and `gh`. | ||
| #[tauri::command] | ||
| pub fn which_commands(names: Vec<String>) -> HashMap<String, bool> { | ||
| names | ||
| .into_iter() | ||
| .map(|n| { | ||
| let found = is_on_path(&n); | ||
| (n, found) | ||
| }) | ||
| .collect() | ||
| } | ||
|
|
||
| /// Resolves whether `name` exists as an executable on PATH, without running it. | ||
| /// On Windows it also tries the usual executable extensions (PATHEXT). | ||
| fn is_on_path(name: &str) -> bool { | ||
| // An explicit path (contains a separator) is checked directly. | ||
| if name.contains('/') || name.contains('\\') { | ||
| return is_executable(Path::new(name)); | ||
| } | ||
| let Some(paths) = std::env::var_os("PATH") else { | ||
| return false; | ||
| }; | ||
| let exts: Vec<String> = if cfg!(windows) { | ||
| std::env::var("PATHEXT") | ||
| .unwrap_or_else(|_| ".EXE;.CMD;.BAT;.COM".to_string()) | ||
| .split(';') | ||
| .map(|s| s.to_string()) | ||
| .collect() | ||
| } else { | ||
| vec![String::new()] | ||
| }; | ||
| for dir in std::env::split_paths(&paths) { | ||
| for ext in &exts { | ||
| let candidate = dir.join(format!("{name}{ext}")); | ||
| if is_executable(&candidate) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| false | ||
| } | ||
|
|
||
| /// True when `path` is a regular file that is actually executable. On Unix a | ||
| /// plain readable file on PATH is not runnable, so we check the exec bits; | ||
| /// elsewhere (Windows) file existence plus a PATHEXT extension is sufficient. | ||
| fn is_executable(path: &Path) -> bool { | ||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::fs::PermissionsExt; | ||
| std::fs::metadata(path) | ||
| .map(|m| m.is_file() && (m.permissions().mode() & 0o111) != 0) | ||
| .unwrap_or(false) | ||
| } | ||
| #[cfg(not(unix))] | ||
| { | ||
| path.is_file() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.