-
Notifications
You must be signed in to change notification settings - Fork 4.1k
add branch name w/ sync function for git info #2142
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
pap-openai
wants to merge
3
commits into
main
Choose a base branch
from
pap/add_branch_name_startup
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
3 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
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
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 |
---|---|---|
|
@@ -233,6 +233,7 @@ impl HistoryCell { | |
session_id: _, | ||
history_log_id: _, | ||
history_entry_count: _, | ||
git_info, | ||
} = event; | ||
if is_first_event { | ||
let cwd_str = match relativize_to_home(&config.cwd) { | ||
|
@@ -241,14 +242,26 @@ impl HistoryCell { | |
None => config.cwd.display().to_string(), | ||
}; | ||
|
||
// Use async-collected Git info from the event if available. | ||
let branch_suffix = git_info | ||
.and_then(|g| g.branch) | ||
.map(|b| format!(" ({b})")) | ||
.unwrap_or_default(); | ||
|
||
let path_and_branch = if branch_suffix.is_empty() { | ||
format!(" {cwd_str}") | ||
} else { | ||
format!(" {cwd_str}{branch_suffix}") | ||
}; | ||
|
||
let lines: Vec<Line<'static>> = vec![ | ||
Line::from(vec![ | ||
Span::raw(">_ ").dim(), | ||
Span::styled( | ||
"You are using OpenAI Codex in", | ||
Style::default().add_modifier(Modifier::BOLD), | ||
), | ||
Span::raw(format!(" {cwd_str}")).dim(), | ||
Span::raw(path_and_branch).dim(), | ||
]), | ||
Line::from("".dim()), | ||
Line::from(" To get started, describe a task or try one of these commands:".dim()), | ||
|
@@ -883,6 +896,8 @@ impl HistoryCell { | |
} | ||
} | ||
|
||
// | ||
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. remove? |
||
|
||
impl WidgetRef for &HistoryCell { | ||
fn render_ref(&self, area: Rect, buf: &mut Buffer) { | ||
Paragraph::new(Text::from(self.plain_lines())) | ||
|
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.
I feel like we should be specifying the timeout somehow at this callsite (either updating
collect_git_info()
to take a timeout, or wrapping these calls withtokio::time::timeout
) to ensure that this runs in a bounded amount of time.One challenge is that here, we are latency-sensitive and I agre with the short timeout.
Though the other callsite in
rollout.rs
is less latency-sensitive, and arguably should be able to specify a more generous timeout.That said, from the callsite, one would expect to specify the timeout of the overall operation, whereas internally inside
collect_git_info()
,run_git_command_with_timeout()
is run twice in series, so ifcollect_git_info()
took its owntimeout
argument, arguably we should divide it by two and use the halved version for each internal call torun_git_command_with_timeout()
?I admit there's already the existing issue here that
crate::message_history::history_metadata()
should also be bound by a timeout, though I don't know what value to use (0?
) if the timeout expires before it completes.