Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/src/context_chips/current_prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,16 @@ impl CurrentPrompt {
output: value.as_ref(),
timed_out,
});
// GitDiffStats has two value sources that can race when entering a repo:
// this shell fallback (`git diff --shortstat HEAD`, tracked changes only)
// and a repo-status watcher that also counts untracked files. If the
// watcher attached while this fallback was in flight, drop the fallback's
// result
if matches!(chip_kind, ContextChipKind::GitDiffStats)
&& me.is_updated_externally(&chip_kind)
{
return;
}
Comment on lines +776 to +785
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


if timed_out {
if suppress_on_failure
Expand Down Expand Up @@ -1431,6 +1441,16 @@ impl CurrentPrompt {
}
}

// Repo detached, clear GitDiffStats.
if handle.is_none() {
if let Some(state) = self.states.get_mut(&ContextChipKind::GitDiffStats) {
state.clear_abort_handlers();
state.clear_cache();
}
let _ = self.update_tx.try_send(());
return;
}

if let Some(weak) = handle {
if let Some(strong) = weak.upgrade(ctx) {
self.git_repo_status = Some(weak);
Expand Down
Loading