Skip to repository content78 lines · 2.2 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T03:58:39.346Z 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
active_file_name.rs
1use gpui::{
2 App, Context, Empty, EventEmitter, IntoElement, ParentElement, Render, SharedString, Window,
3};
4use settings::Settings;
5use ui::{Button, Tooltip, prelude::*};
6use util::paths::PathStyle;
7
8use crate::{
9 HideStatusItem, StatusItemView, item::ItemHandle, workspace_settings::StatusBarSettings,
10};
11
12pub struct ActiveFileName {
13 project_path: Option<SharedString>,
14 full_path: Option<SharedString>,
15}
16
17impl ActiveFileName {
18 pub fn new() -> Self {
19 Self {
20 project_path: None,
21 full_path: None,
22 }
23 }
24}
25
26impl Render for ActiveFileName {
27 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
28 if !StatusBarSettings::get_global(cx).show_active_file {
29 return Empty.into_any_element();
30 }
31
32 let Some(project_path) = self.project_path.clone() else {
33 return Empty.into_any_element();
34 };
35
36 let tooltip_text = self
37 .full_path
38 .clone()
39 .unwrap_or_else(|| project_path.clone());
40
41 div()
42 .child(
43 Button::new("active-file-name-button", project_path)
44 .label_size(LabelSize::Small)
45 .tooltip(Tooltip::text(tooltip_text)),
46 )
47 .into_any_element()
48 }
49}
50
51impl EventEmitter<crate::ToolbarItemEvent> for ActiveFileName {}
52
53impl StatusItemView for ActiveFileName {
54 fn set_active_pane_item(
55 &mut self,
56 active_pane_item: Option<&dyn ItemHandle>,
57 _window: &mut Window,
58 cx: &mut Context<Self>,
59 ) {
60 if let Some(item) = active_pane_item {
61 self.project_path = item
62 .project_path(cx)
63 .map(|path| path.path.display(PathStyle::local()).into_owned().into());
64 self.full_path = item.tab_tooltip_text(cx);
65 } else {
66 self.project_path = None;
67 self.full_path = None;
68 }
69 cx.notify();
70 }
71
72 fn hide_setting(&self, _: &App) -> Option<HideStatusItem> {
73 Some(HideStatusItem::new(|settings| {
74 settings.status_bar.get_or_insert_default().show_active_file = Some(false);
75 }))
76 }
77}
78