assistant2: Wire up context for terminal inline assist (#22108)

This PR updates up the context picker for the terminal's inline assist.

Release Notes:

- N/A

Co-authored-by: Richard <richard@zed.dev>
Co-authored-by: Agus <agus@zed.dev>
This commit is contained in:
Marshall Bowers 2024-12-16 16:22:16 -05:00 committed by GitHub
parent 84392fbc2f
commit 92fb38acb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 98 additions and 68 deletions

View file

@ -221,19 +221,19 @@ impl InlineAssistant {
.map_or(false, |provider| provider.is_authenticated(cx))
};
let thread_store = workspace
.panel::<AssistantPanel>(cx)
.map(|assistant_panel| assistant_panel.read(cx).thread_store().downgrade());
let handle_assist = |cx: &mut ViewContext<Workspace>| match inline_assist_target {
InlineAssistTarget::Editor(active_editor) => {
InlineAssistant::update_global(cx, |assistant, cx| {
let thread_store = workspace
.panel::<AssistantPanel>(cx)
.map(|assistant_panel| assistant_panel.read(cx).thread_store().downgrade());
assistant.assist(&active_editor, cx.view().downgrade(), thread_store, cx)
})
}
InlineAssistTarget::Terminal(active_terminal) => {
TerminalInlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist(&active_terminal, cx.view().downgrade(), cx)
assistant.assist(&active_terminal, cx.view().downgrade(), thread_store, cx)
})
}
};