Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:39:06.456Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

preview_view.rs

82 lines · 3.1 KB · rust
1use std::time::Instant;
2
3use ui::{SpinnerLabel, div, prelude::*};
4
5use crate::CsvPreviewView;
6
7impl Render for CsvPreviewView {
8    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
9        let theme = cx.theme();
10        let row_height = window.pixel_snap(window.line_height());
11        if row_height != self.row_height {
12            self.row_height = row_height;
13            // Font size (rem size, buffer font override, ...) changed since the list was last
14            // measured: existing rows and unmeasured-item height hints are now the wrong size.
15            // Unlike `reset_with_uniform_height`, this preserves scroll position and keeps each
16            // item's prior size as a hint rather than dropping straight to a fresh guess.
17            self.list_state.remeasure();
18        }
19        let render_prep_start = Instant::now();
20        let table_with_settings = v_flex()
21            .size_full()
22            .bg(theme.colors().editor_background)
23            .track_focus(&self.focus_handle)
24            .child(self.render_settings_panel(window, cx))
25            .child({
26                let is_parsing = self.is_parsing;
27                if is_parsing || self.engine.contents.number_of_cols == 0 {
28                    div()
29                        .flex()
30                        .items_center()
31                        .justify_center()
32                        .h_32()
33                        .text_ui(cx)
34                        .font_buffer(cx)
35                        .text_color(cx.theme().colors().text_muted)
36                        .when(is_parsing, |div| {
37                            div.child(
38                                h_flex()
39                                    .gap_2()
40                                    .child(SpinnerLabel::new())
41                                    .child("Loading…"),
42                            )
43                        })
44                        .when(!is_parsing, |div| div.child("No CSV content to display"))
45                        .into_any_element()
46                } else {
47                    self.create_table(&self.column_widths.widths, cx)
48                }
49            });
50
51        let render_prep_duration = render_prep_start.elapsed();
52        self.performance_metrics.timings.insert(
53            "render_prep",
54            (render_prep_duration, std::time::Instant::now()),
55        );
56
57        let div = div()
58            .relative()
59            .w_full()
60            .h_full()
61            .child(table_with_settings);
62
63        #[cfg(feature = "dev-tools")]
64        let show_perf_metrics_overlay = self.settings.show_perf_metrics_overlay;
65
66        #[cfg(feature = "dev-tools")]
67        let div = div.when(show_perf_metrics_overlay, |div| {
68            div.child(self.render_performance_metrics_overlay(cx))
69        });
70
71        #[cfg(feature = "dev-tools")]
72        if !show_perf_metrics_overlay {
73            self.performance_metrics.rendered_indices.clear();
74        }
75
76        #[cfg(not(feature = "dev-tools"))]
77        self.performance_metrics.rendered_indices.clear();
78
79        div
80    }
81}
82
Served at tenant.openagents/omega Member data and write actions are omitted.