Skip to repository content77 lines · 2.9 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T03:10:19.253Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
agent_panel_onboarding_content.rs
1use std::sync::Arc;
2
3use gpui::{Entity, IntoElement, ParentElement};
4use language_model::{LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID};
5use ui::prelude::*;
6
7use crate::{AgentPanelOnboardingCard, ApiKeysWithProviders, ApiKeysWithoutProviders};
8
9pub struct AgentPanelOnboarding {
10 has_configured_providers: bool,
11 configured_providers: Entity<ApiKeysWithProviders>,
12 continue_to_agent: Arc<dyn Fn(&mut Window, &mut App)>,
13}
14
15impl AgentPanelOnboarding {
16 pub fn new(
17 continue_to_agent: impl Fn(&mut Window, &mut App) + 'static,
18 cx: &mut Context<Self>,
19 ) -> Self {
20 cx.subscribe(
21 &LanguageModelRegistry::global(cx),
22 |this: &mut Self, _registry, event: &language_model::Event, cx| match event {
23 language_model::Event::ProviderStateChanged(_)
24 | language_model::Event::AddedProvider(_)
25 | language_model::Event::RemovedProvider(_)
26 | language_model::Event::ProvidersChanged => {
27 this.has_configured_providers = Self::has_configured_providers(cx)
28 }
29 _ => {}
30 },
31 )
32 .detach();
33
34 Self {
35 has_configured_providers: Self::has_configured_providers(cx),
36 configured_providers: cx.new(ApiKeysWithProviders::new),
37 continue_to_agent: Arc::new(continue_to_agent),
38 }
39 }
40
41 fn has_configured_providers(cx: &App) -> bool {
42 LanguageModelRegistry::read_global(cx)
43 .visible_providers()
44 .iter()
45 .any(|provider| provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID)
46 }
47}
48
49impl Render for AgentPanelOnboarding {
50 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
51 AgentPanelOnboardingCard::new()
52 .child(
53 v_flex()
54 .gap_1()
55 .child(Headline::new("Connect an AI provider"))
56 .child(
57 Label::new(
58 "Omega uses providers and credentials you configure directly. Choose an existing provider or add one in Agent Settings.",
59 )
60 .color(Color::Muted),
61 ),
62 )
63 .when(self.has_configured_providers, |this| {
64 let continue_to_agent = self.continue_to_agent.clone();
65 this.child(self.configured_providers.clone()).child(
66 Button::new("continue-to-agent", "Continue")
67 .full_width()
68 .style(ButtonStyle::Filled)
69 .on_click(move |_, window, cx| continue_to_agent(window, cx)),
70 )
71 })
72 .when(!self.has_configured_providers, |this| {
73 this.child(ApiKeysWithoutProviders::new())
74 })
75 }
76}
77