Skip to content
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

assistant2: Suggest current file as context #22526

Merged
merged 7 commits into from
Jan 2, 2025
Merged

Conversation

agu-z
Copy link
Contributor

@agu-z agu-z commented Dec 31, 2024

Suggest adding the current file as context in the new assistant panel.

CleanShot.2024-12-31.at.19.11.24.mp4

Note: This doesn't include suggesting the current thread in the inline assistant.

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 31, 2024
Comment on lines +96 to +97
if self.workspace_active_pane_id != new_active_item_id {
self.suggested_context = Self::suggested_file(active_item, cx);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, workspace emits the ActiveItemChanged event many times when the active item changes.

Comment on lines +49 to +56
pub fn contains_project_entry(&self, entry_id: ProjectEntryId) -> bool {
self.context.iter().any(|probe| match probe.kind {
ContextKind::File(probe_entry_id) => probe_entry_id == entry_id,
ContextKind::Directory => false,
ContextKind::FetchedUrl => false,
ContextKind::Thread => false,
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the linear search should be ok for the current usage, but we may want to consider an alternative approach if we use this to filter file_context_picker entries later.

@agu-z agu-z added this pull request to the merge queue Jan 2, 2025
Merged via the queue into main with commit 59b5b9a Jan 2, 2025
15 checks passed
@agu-z agu-z deleted the ai-panel-suggest-ctx branch January 2, 2025 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant