-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cmd+Enter keybinding for Send to Agent in code review #10295
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
base: aloke/cursor_and_placeholder
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -397,6 +397,7 @@ pub enum CodeReviewAction { | |||||||||||||
| OpenCreatePrDialog, | ||||||||||||||
| ViewPr(String), | ||||||||||||||
| PublishBranch, | ||||||||||||||
| SubmitComments, | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| pub struct FileState { | ||||||||||||||
|
|
@@ -1272,7 +1273,6 @@ impl CodeReviewView { | |||||||||||||
| Menu::new() | ||||||||||||||
| .prevent_interaction_with_other_elements() | ||||||||||||||
| .with_drop_shadow() | ||||||||||||||
| .with_width(140.) | ||||||||||||||
| }); | ||||||||||||||
| ctx.subscribe_to_view(&git_operations_menu, |me, _, event, ctx| match event { | ||||||||||||||
| MenuEvent::ItemSelected | MenuEvent::Close { .. } => { | ||||||||||||||
|
|
@@ -6719,9 +6719,8 @@ impl CodeReviewView { | |||||||||||||
| // `has_upstream` controls the label/icon on the push-chained | ||||||||||||||
| // intent (Commit and push vs Commit and publish). | ||||||||||||||
| let diff_state = self.diff_state_model.as_ref(ctx); | ||||||||||||||
| let allow_create_pr = diff_state.pr_info().is_none() | ||||||||||||||
| && !diff_state.is_pr_info_refreshing() | ||||||||||||||
| && !diff_state.is_on_main_branch(); | ||||||||||||||
| let allow_create_pr = | ||||||||||||||
| diff_state.pr_info().is_none() && !diff_state.is_on_main_branch(); | ||||||||||||||
| let has_upstream = diff_state.upstream_ref().is_some(); | ||||||||||||||
| ctx.add_typed_action_view(|ctx| { | ||||||||||||||
| GitDialog::new_for_commit( | ||||||||||||||
|
|
@@ -6774,7 +6773,6 @@ impl CodeReviewView { | |||||||||||||
| let has_uncommitted_changes = self.has_uncommitted_changes(app); | ||||||||||||||
| let has_upstream = diff_state.upstream_ref().is_some(); | ||||||||||||||
| let has_local_commits = !diff_state.unpushed_commits().is_empty(); | ||||||||||||||
| let is_pr_info_refreshing = diff_state.is_pr_info_refreshing(); | ||||||||||||||
| // False when upstream == main (e.g. after `git checkout -b feature origin/master`), | ||||||||||||||
| // which means the branch hasn't been pushed to its own remote ref yet. | ||||||||||||||
| let upstream_differs_from_main = diff_state.upstream_differs_from_main(); | ||||||||||||||
|
|
@@ -6787,11 +6785,7 @@ impl CodeReviewView { | |||||||||||||
| PrimaryGitActionMode::Push | ||||||||||||||
| } else if diff_state.pr_info().is_some() { | ||||||||||||||
| PrimaryGitActionMode::ViewPr | ||||||||||||||
| } else if !is_pr_info_refreshing | ||||||||||||||
| && has_upstream | ||||||||||||||
| && !diff_state.is_on_main_branch() | ||||||||||||||
| && upstream_differs_from_main | ||||||||||||||
| { | ||||||||||||||
| } else if has_upstream && !diff_state.is_on_main_branch() && upstream_differs_from_main { | ||||||||||||||
| PrimaryGitActionMode::CreatePr | ||||||||||||||
| } else { | ||||||||||||||
| // Nothing actionable — show Commit disabled. | ||||||||||||||
|
|
@@ -6828,7 +6822,6 @@ impl CodeReviewView { | |||||||||||||
| button.set_label("Push", ctx); | ||||||||||||||
| button.set_icon(Some(Icon::ArrowUp), ctx); | ||||||||||||||
| button.set_disabled(false, ctx); | ||||||||||||||
| button.clear_tooltip(ctx); | ||||||||||||||
| button.set_on_click( | ||||||||||||||
| |ctx| ctx.dispatch_typed_action(CodeReviewAction::OpenPushDialog), | ||||||||||||||
| ctx, | ||||||||||||||
|
|
@@ -6844,7 +6837,6 @@ impl CodeReviewView { | |||||||||||||
| button.set_label("Create PR", ctx); | ||||||||||||||
| button.set_icon(Some(Icon::Github), ctx); | ||||||||||||||
| button.set_disabled(false, ctx); | ||||||||||||||
| button.clear_tooltip(ctx); | ||||||||||||||
| button.set_on_click( | ||||||||||||||
| |ctx| ctx.dispatch_typed_action(CodeReviewAction::OpenCreatePrDialog), | ||||||||||||||
| ctx, | ||||||||||||||
|
|
@@ -6853,21 +6845,15 @@ impl CodeReviewView { | |||||||||||||
| }); | ||||||||||||||
| } | ||||||||||||||
| PrimaryGitActionMode::ViewPr => { | ||||||||||||||
| let diff_state = self.diff_state_model.as_ref(ctx); | ||||||||||||||
| let pr_info = diff_state.pr_info().cloned(); | ||||||||||||||
| let is_pr_info_refreshing = diff_state.is_pr_info_refreshing(); | ||||||||||||||
| let pr_info = self.diff_state_model.as_ref(ctx).pr_info().cloned(); | ||||||||||||||
| if let Some(pr_info) = pr_info { | ||||||||||||||
| let url = pr_info.url.clone(); | ||||||||||||||
| let number = pr_info.number; | ||||||||||||||
| let label = format!("PR #{number}"); | ||||||||||||||
| self.git_primary_action_button.update(ctx, |button, ctx| { | ||||||||||||||
| button.set_label(label, ctx); | ||||||||||||||
| button.set_icon(Some(Icon::Github), ctx); | ||||||||||||||
| button.set_disabled(is_pr_info_refreshing, ctx); | ||||||||||||||
| button.set_tooltip( | ||||||||||||||
| is_pr_info_refreshing.then_some("Refreshing PR info"), | ||||||||||||||
| ctx, | ||||||||||||||
| ); | ||||||||||||||
| button.set_disabled(false, ctx); | ||||||||||||||
| button.set_on_click( | ||||||||||||||
| move |ctx| { | ||||||||||||||
| ctx.dispatch_typed_action(CodeReviewAction::ViewPr(url.clone())) | ||||||||||||||
|
|
@@ -6883,7 +6869,6 @@ impl CodeReviewView { | |||||||||||||
| button.set_label("Publish", ctx); | ||||||||||||||
| button.set_icon(Some(Icon::UploadCloud), ctx); | ||||||||||||||
| button.set_disabled(false, ctx); | ||||||||||||||
| button.clear_tooltip(ctx); | ||||||||||||||
| button.set_on_click( | ||||||||||||||
| |ctx| ctx.dispatch_typed_action(CodeReviewAction::PublishBranch), | ||||||||||||||
| ctx, | ||||||||||||||
|
|
@@ -6932,12 +6917,10 @@ impl CodeReviewView { | |||||||||||||
| /// (e.g. a worktree branch whose tracking was auto-set to origin/master). | ||||||||||||||
| fn pr_menu_item(&self, app: &AppContext) -> MenuItem<CodeReviewAction> { | ||||||||||||||
| let diff_state = self.diff_state_model.as_ref(app); | ||||||||||||||
| let is_pr_info_refreshing = diff_state.is_pr_info_refreshing(); | ||||||||||||||
| if let Some(pr_info) = diff_state.pr_info().cloned() { | ||||||||||||||
| MenuItemFields::new(format!("PR #{}", pr_info.number)) | ||||||||||||||
| .with_icon(Icon::Github) | ||||||||||||||
| .with_on_select_action(CodeReviewAction::ViewPr(pr_info.url)) | ||||||||||||||
| .with_disabled(is_pr_info_refreshing) | ||||||||||||||
| .into_item() | ||||||||||||||
| } else { | ||||||||||||||
| let is_on_main = diff_state.is_on_main_branch(); | ||||||||||||||
|
|
@@ -6946,12 +6929,7 @@ impl CodeReviewView { | |||||||||||||
| MenuItemFields::new("Create PR") | ||||||||||||||
| .with_icon(Icon::Github) | ||||||||||||||
| .with_on_select_action(CodeReviewAction::OpenCreatePrDialog) | ||||||||||||||
| .with_disabled( | ||||||||||||||
| is_pr_info_refreshing | ||||||||||||||
| || is_on_main | ||||||||||||||
| || !has_upstream | ||||||||||||||
| || !upstream_differs_from_main, | ||||||||||||||
| ) | ||||||||||||||
| .with_disabled(is_on_main || !has_upstream || !upstream_differs_from_main) | ||||||||||||||
| .into_item() | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -7748,6 +7726,10 @@ impl TypedActionView for CodeReviewView { | |||||||||||||
| }); | ||||||||||||||
| ctx.notify(); | ||||||||||||||
| } | ||||||||||||||
| CodeReviewAction::SubmitComments => { | ||||||||||||||
| self.handle_submit_review_with_comments(ctx); | ||||||||||||||
|
Contributor
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.
|
||||||||||||||
| ctx.focus_self(); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -7819,11 +7801,7 @@ impl BackingView for CodeReviewView { | |||||||||||||
| AppContext::show_native_platform_modal(ctx, dialog); | ||||||||||||||
| } else if cfg!(all( | ||||||||||||||
| not(target_family = "wasm"), | ||||||||||||||
| any( | ||||||||||||||
| target_os = "linux", | ||||||||||||||
| target_os = "freebsd", | ||||||||||||||
| target_os = "windows" | ||||||||||||||
| ) | ||||||||||||||
| any(target_os = "linux", target_os = "windows") | ||||||||||||||
|
Contributor
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.
Suggested change
|
||||||||||||||
| )) { | ||||||||||||||
| // Find the workspace to show the Warp-native modal | ||||||||||||||
| if let Some(workspace) = ctx | ||||||||||||||
|
|
||||||||||||||
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.
is_pr_info_refreshinglets the primary button show Create PR while PR discovery is still in flight, so a branch with an existing PR can open the create dialog before refresh completes. Keep the refresh guard here and in the matching Create PR paths.