-
Notifications
You must be signed in to change notification settings - Fork 1
add tech review panel for AI branch diff #10
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
Open
R0MADEV
wants to merge
9
commits into
main
Choose a base branch
from
feat/tech-review-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c892ae
feat: added tech review panel for AI branch diff
R0MADEV e61806b
feat: redesigned review panel as branch selector + PR comment
R0MADEV ebb6ed0
feat: added per-file inline comment button in review panel
R0MADEV 0d2d9a0
fix: strip remote prefix before passing branch to gh CLI
R0MADEV 8fc50d3
feat: PR link opens in browser from review panel
R0MADEV e155ef6
fix: use PR number for comments, show clickable link after sending
R0MADEV 40f05f7
feat: inline review comments on specific file+line via GitHub API
R0MADEV 01f1f4f
feat: per-line comment button in diff, posts inline review comment
R0MADEV a30e3af
fix: range selection using mousemove+elementFromPoint instead of poin…
R0MADEV 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
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 |
|---|---|---|
|
|
@@ -303,6 +303,13 @@ fn current_branch(path: &str) -> Result<String, String> { | |
| Ok(branch) | ||
| } | ||
|
|
||
| #[tauri::command] | ||
| pub async fn git_current_branch(path: String) -> Result<String, String> { | ||
| tauri::async_runtime::spawn_blocking(move || current_branch(&path)) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| fn backup_ref_for(path: &str) -> Result<String, String> { | ||
| Ok(format!("refs/bento/backups/{}", current_branch(path)?)) | ||
| } | ||
|
|
@@ -536,6 +543,27 @@ pub async fn git_remote_branches(repo: String) -> Result<Vec<String>, String> { | |
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Lists branches from ALL remotes with full remote/branch format (e.g. "daimoxd/feat/foo"). | ||
| #[tauri::command] | ||
| pub async fn git_all_remote_branches(repo: String) -> Result<Vec<String>, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| if !is_git_repo(&repo) { | ||
| return Err("not a git repository".into()); | ||
| } | ||
| let raw = git_output( | ||
| &repo, | ||
| &["for-each-ref", "--format=%(refname:short)", "refs/remotes"], | ||
| )?; | ||
| Ok(raw | ||
| .lines() | ||
| .filter(|line| !line.ends_with("/HEAD") && is_safe_branch(line)) | ||
| .map(str::to_string) | ||
| .collect()) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| #[tauri::command] | ||
| pub async fn git_worktree_add( | ||
| repo: String, | ||
|
|
@@ -667,6 +695,27 @@ pub async fn git_diff(path: String) -> Result<String, String> { | |
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Accumulated diff of all commits on the current branch vs <base> (three-dot range). | ||
| #[tauri::command] | ||
| pub async fn git_branch_diff(path: String, base: String) -> Result<String, String> { | ||
| if !is_safe_branch(&base) { | ||
| return Err(format!("unsafe base branch: {base}")); | ||
| } | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| if !is_git_repo(&path) { | ||
| return Err("not a git repository".into()); | ||
| } | ||
| // Try local ref first, fall back to origin/ prefix for remote-only branches | ||
| let result = git_output(&path, &["diff", &format!("{base}...HEAD")]); | ||
| if result.is_ok() { | ||
| return result; | ||
| } | ||
| git_output(&path, &["diff", &format!("origin/{base}...HEAD")]) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Validates that a commit message is non-empty (trust boundary: frontend input). | ||
| fn is_valid_message(msg: &str) -> bool { | ||
| !msg.trim().is_empty() | ||
|
|
@@ -949,6 +998,104 @@ pub async fn git_pr_status(path: String) -> Result<Option<PrStatus>, String> { | |
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Diff between any two git refs (e.g. "origin/main" vs "origin/feat/foo"). | ||
| #[tauri::command] | ||
| pub async fn git_ref_diff(path: String, base: String, target: String) -> Result<String, String> { | ||
| if !is_safe_branch(&base) { return Err(format!("unsafe base: {base}")); } | ||
| if !is_safe_branch(&target) { return Err(format!("unsafe target: {target}")); } | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| if !is_git_repo(&path) { return Err("not a git repository".into()); } | ||
| git_output(&path, &["diff", &format!("{base}...{target}")]) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
Comment on lines
+1002
to
+1012
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. este bloque There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hola xdd soy otro tests desde otra cuenta xd |
||
|
|
||
| // Returns basic PR info (number, title, url) for any branch via gh CLI. | ||
| #[tauri::command] | ||
| pub async fn gh_pr_view_branch(path: String, branch: String) -> Result<Option<serde_json::Value>, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| let out = Command::new("gh") | ||
| .current_dir(&path) | ||
| .args(["pr", "view", &branch, "--json", "number,title,url"]) | ||
| .output(); | ||
| let Ok(out) = out else { return Ok(None); }; | ||
| if !out.status.success() || out.stdout.is_empty() { return Ok(None); } | ||
| serde_json::from_slice::<serde_json::Value>(&out.stdout).map(Some).map_err(|e| e.to_string()) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Posts a comment on the PR and returns its URL. | ||
| #[tauri::command] | ||
| pub async fn gh_pr_comment(path: String, branch: String, body: String) -> Result<String, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| let out = Command::new("gh") | ||
| .current_dir(&path) | ||
| .args(["pr", "comment", &branch, "--body", &body, "--json", "url", "--jq", ".url"]) | ||
| .output() | ||
| .map_err(|e| e.to_string())?; | ||
| if !out.status.success() { | ||
| return Err(String::from_utf8_lossy(&out.stderr).trim().to_string()); | ||
| } | ||
| Ok(String::from_utf8_lossy(&out.stdout).trim().to_string()) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Resolves a git ref to its full SHA. | ||
| #[tauri::command] | ||
| pub async fn git_rev_parse(path: String, reference: String) -> Result<String, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| git_output(&path, &["rev-parse", &reference]).map(|s| s.trim().to_string()) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| // Posts an inline review comment on a specific file+line via gh api. | ||
| #[tauri::command] | ||
| pub async fn gh_pr_inline_comment( | ||
| path: String, | ||
| pr_number: u64, | ||
| commit_id: String, | ||
| file: String, | ||
| line: u64, | ||
| start_line: Option<u64>, | ||
| body: String, | ||
| ) -> Result<String, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
| let endpoint = format!("repos/{{owner}}/{{repo}}/pulls/{pr_number}/comments"); | ||
| let mut args = vec![ | ||
| "api".to_string(), endpoint, | ||
| "-f".to_string(), format!("body={body}"), | ||
| "-f".to_string(), format!("commit_id={commit_id}"), | ||
| "-f".to_string(), format!("path={file}"), | ||
| "-F".to_string(), format!("line={line}"), | ||
| "-f".to_string(), "side=RIGHT".to_string(), | ||
| ]; | ||
| if let Some(sl) = start_line { | ||
| if sl < line { | ||
| args.extend(["-F".to_string(), format!("start_line={sl}"), "-f".to_string(), "start_side=RIGHT".to_string()]); | ||
| } | ||
| } | ||
| args.extend(["--jq".to_string(), ".html_url".to_string()]); | ||
| let out = Command::new("gh") | ||
| .current_dir(&path) | ||
| .args(&args) | ||
| .output() | ||
| .map_err(|e| e.to_string())?; | ||
| if !out.status.success() { | ||
| return Err(String::from_utf8_lossy(&out.stderr).trim().to_string()); | ||
| } | ||
| Ok(String::from_utf8_lossy(&out.stdout).trim().to_string()) | ||
| }) | ||
| .await | ||
| .map_err(|e| e.to_string())? | ||
| } | ||
|
|
||
| #[tauri::command] | ||
| pub async fn git_push(path: String, force_with_lease: Option<bool>) -> Result<String, String> { | ||
| tauri::async_runtime::spawn_blocking(move || { | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jelllo