Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions apps/desktop/src/plugin_host/ui/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use opencode_i18n::t;
use opencode_ui::dialog::DialogSize;
use opencode_ui::focus::FocusExt;
use opencode_ui::palette::{Elevate as _, Pal, kit};
use opencode_ui::style::UI_SMALL;
use opencode_ui::widgets::{BODY, DIALOG_CLOSE, Fit, button, dialog_window, sized_modal, status_dot};
use rune::{Cx, El, Key, KeyEvent, TextEdit, TextStyle, Tx, col, el, icon, row, rule, spacer, text};
use rune_kit::{ButtonVariant, TextInput};
Expand All @@ -22,13 +24,13 @@ pub const OVERLAY_ID: &str = "plugin.inspector";
const REPL_INPUT_KEY: &str = "plugin-inspector-repl-input";
const CLOSE_BTN_KEY: &str = "plugin-inspector-close";

const TITLE: TextStyle = TextStyle::new(15.0, 560.0).lh(20.0).tracking(-0.13);
const VERSION: TextStyle = TextStyle::new(12.0, 440.0).lh(16.0).mono();
const BADGE_TXT: TextStyle = TextStyle::new(11.0, 520.0).lh(14.0);
const METRIC_LABEL: TextStyle = TextStyle::new(11.0, 500.0).lh(14.0);
const TITLE: TextStyle = TextStyle::new(15.0, 530.0).lh(20.0).tracking(-0.13);
const VERSION: TextStyle = UI_SMALL.mono();
const BADGE_TXT: TextStyle = TextStyle::new(11.0, 530.0).lh(14.0);
const METRIC_LABEL: TextStyle = TextStyle::new(11.0, 440.0).lh(14.0);
const METRIC_VAL: TextStyle = TextStyle::new(12.0, 530.0).lh(16.0).mono().features("'tnum' 1");
const MONO: TextStyle = TextStyle::new(12.0, 440.0).lh(17.0).mono();
const MONO_SMALL: TextStyle = TextStyle::new(11.0, 500.0).lh(15.0).mono().features("'tnum' 1");
const MONO: TextStyle = UI_SMALL.mono().lh(18.0);
const MONO_SMALL: TextStyle = TextStyle::new(11.0, 530.0).lh(16.0).mono().features("'tnum' 1");
const SECTION_TITLE: TextStyle = TextStyle::new(12.0, 530.0).lh(16.0);

pub(crate) static PLUGIN_INSPECTOR: opencode_kernel::Slot<InspectorSlot> = opencode_kernel::Slot::new();
Expand Down Expand Up @@ -362,7 +364,7 @@ fn dialog_shell(p: &Pal, label: String, inner: El) -> El {
.label(label)
.w_full()
.h_full()
.radius(6.0)
.radius(12.0)
.fill(p.layer1)
.elevate(p.overlay)
.modal_tx(true, |s: &mut App, tx: &mut Tx| dismiss(s, tx))
Expand All @@ -376,14 +378,14 @@ fn inspector_card(p: &Pal, lp: &Plugin, session: &InspectorSession) -> El {
.key("plugin-inspector-inner")
.w_full()
.h_full()
.clip_rounded(6.0)
.clip_rounded(12.0)
.child(header(p, lp))
.child(rule(1.0, p.border))
.child(rule(0.5, p.border))
.child(metrics_strip(p, lp))
.child(rule(1.0, p.border))
.child(rule(0.5, p.border))
.children(last_error.as_deref().map(|err| error_banner(p, err)))
.child(logs_pane(p, &lp.manifest.id, &lines, last_error.is_some()))
.child(rule(1.0, p.border))
.child(rule(0.5, p.border))
.child(repl_bar(p, lp, session));
dialog_shell(p, format!("{} — {}", t!("rune.plugins.inspector.title"), lp.manifest.name), inner)
}
Expand All @@ -405,7 +407,7 @@ fn missing_card(p: &Pal, plugin_id: &str) -> El {
.center()
.padding(24.0)
.child(text(t!("rune.plugins.inspector.missing")).font(BODY).color(p.muted));
let inner = col().w_full().h_full().clip_rounded(6.0).child(head).child(rule(1.0, p.border)).child(body);
let inner = col().w_full().h_full().clip_rounded(12.0).child(head).child(rule(0.5, p.border)).child(body);
dialog_shell(p, t!("rune.plugins.inspector.title").to_owned(), inner)
}

Expand All @@ -415,14 +417,14 @@ fn header(p: &Pal, lp: &Plugin) -> El {
let (status_key, status_label, status_color) = status_meta(p, &lp.life);
let status_pill = row()
.key("plugin-inspector-status")
.h(22.0)
.pl(4.0)
.pr(8.0)
.h(20.0)
.pl(3.0)
.pr(7.0)
.gap(2.0)
.center_y()
.radius(11.0)
.radius(4.0)
.fill(p.layer2)
.border(0.5, p.border)
.box_shadow(Pal::ring_in(p.border))
.child(status_dot(p, status_key))
.child(text(status_label).font(BADGE_TXT).color(status_color));
let can_reload = matches!(lp.life, Life::Running(_) | Life::Errored { .. } | Life::Dormant);
Expand Down Expand Up @@ -456,12 +458,16 @@ fn header(p: &Pal, lp: &Plugin) -> El {
}

fn close_button(p: &Pal) -> El {
let close_label = t!("rune.plugins.inspector.close");
el().key(CLOSE_BTN_KEY)
.role("button")
.label_static(t!("rune.plugins.inspector.close"))
.label_static(close_label)
.help(close_label)
.help_keys([t!("common.key.esc")])
.size(28.0, 28.0)
.radius(6.0)
.center()
.focus_default(p)
.hover(p.hover)
.press(p.pressed)
.on_press_tx(|s: &mut App, tx: &mut Tx| dismiss(s, tx))
Expand Down Expand Up @@ -523,9 +529,9 @@ fn metric_cell(p: &Pal, id: &str, label: &'static str, value: String, grow: f32)
.px(8.0)
.py(6.0)
.gap(2.0)
.radius(5.0)
.radius(6.0)
.fill(p.layer1)
.border(0.5, p.border_muted)
.box_shadow(Pal::ring_in(p.border_muted))
.child(text(label).font(METRIC_LABEL).color(p.faint).truncate())
.child(text(value).font(METRIC_VAL).color(p.text).truncate())
}
Expand Down Expand Up @@ -575,7 +581,7 @@ fn error_banner(p: &Pal, err: &str) -> El {
// A long stack trace stays in the banner instead of crushing the logs and REPL below it.
let body = col().w_full().max_h(160.0).fill(p.layer2);
let body = session_view::scroller::scroller("plugin-inspector-error-scroll").build::<App>(p, body, content);
col().key("plugin-inspector-error-banner").w_full().child(body).child(rule(1.0, p.danger))
col().key("plugin-inspector-error-banner").w_full().child(body).child(rule(0.5, p.danger))
}

fn logs_pane(p: &Pal, plugin_id: &str, lines: &[console::Line], has_error: bool) -> El {
Expand All @@ -601,10 +607,11 @@ fn logs_pane(p: &Pal, plugin_id: &str, lines: &[console::Line], has_error: bool)
let count_pill = row()
.key("plugin-inspector-logs-count")
.h(18.0)
.px(6.0)
.px(5.0)
.center()
.radius(9.0)
.radius(4.0)
.fill(p.layer2)
.box_shadow(Pal::ring_in(p.border_muted))
.child(text(lines.len().to_string()).font(MONO_SMALL).color(p.muted));
let bar = row()
.key("plugin-inspector-logs-bar")
Expand Down Expand Up @@ -641,7 +648,7 @@ fn logs_pane(p: &Pal, plugin_id: &str, lines: &[console::Line], has_error: bool)
.grow(1.0)
.min_h(0.0)
.child(bar)
.child(rule(1.0, p.border_muted))
.child(rule(0.5, p.border_muted))
.child(scroll)
}

Expand All @@ -667,9 +674,9 @@ fn log_row(p: &Pal, idx: usize, line: &console::Line) -> El {
.px(10.0)
.py(6.0)
.gap(2.0)
.radius(5.0)
.radius(6.0)
.fill(p.bg_base)
.border(0.5, border_color)
.box_shadow(Pal::ring_in(border_color))
.child(meta)
.child(text(line.message.clone()).font(MONO).color(body_color).wrap().w_full())
}
Expand Down
49 changes: 16 additions & 33 deletions apps/desktop/src/surfaces/browser/prompts/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use browser_pane::prompts::DialogGate;
use browser_pane::{DialogKind, PermissionDecision, PermissionKind};
use opencode_i18n::t;
use rune::{El, KeyEvent, Tx, col, el, icon, row, text};
use opencode_ui::focus::FocusExt;
use rune::{Anim, El, KeyEvent, Tx, col, el, icon, row, text};
use rune_kit::{ButtonVariant, TextInput};
use rune_theme_opencode::icons as ic;
use session_view::palette::Elevate;
Expand Down Expand Up @@ -153,7 +154,7 @@ pub fn view_bars(s: &App, p: &Pal, tab_id: u64) -> Vec<El> {
.child(text(notice).font(UI_SMALL).color(p.text).grow(1.0).shrink().min_w(0.0).wrap())
.child(actions),
)
.child(el().w_full().h(1.0).fill(p.border_muted)),
.child(el().w_full().h(0.5).fill(p.border_muted)),
);
}

Expand Down Expand Up @@ -189,7 +190,7 @@ pub fn view_bars(s: &App, p: &Pal, tab_id: u64) -> Vec<El> {
})
.build(k)
.key("browser-popup-open");
let close_btn = sized_dismiss_btn(p, "browser-popup-dismiss", t!("common.close"), 20.0, 4.0, move |app: &mut App| {
let close_btn = dismiss_icon_btn(p, "browser-popup-dismiss", t!("common.close"), move |app: &mut App| {
app.workspace_panes.browser.host.dismiss_blocked_popup(tab_id);
});
let lines = col()
Expand All @@ -212,7 +213,7 @@ pub fn view_bars(s: &App, p: &Pal, tab_id: u64) -> Vec<El> {
.child(row().w_full().gap(12.0).center_y().child(lines).child(open_btn).child(close_btn))
.children(target),
)
.child(el().w_full().h(1.0).fill(p.border_muted)),
.child(el().w_full().h(0.5).fill(p.border_muted)),
);
}

Expand Down Expand Up @@ -279,8 +280,7 @@ pub fn view_bars(s: &App, p: &Pal, tab_id: u64) -> Vec<El> {
.child(perm_btn(k, t!("rune.browser.prompt.block"), ButtonVariant::Ghost, "browser-perm-block", tab_id, req_id, PermissionDecision::BlockOnce))
.child(perm_btn(k, t!("rune.browser.prompt.allowOnce"), ButtonVariant::Contrast, "browser-perm-allow-once", tab_id, req_id, PermissionDecision::AllowOnce));
}
// Official's dismiss is `IconButton size="large"` (28 pt, `prompts.tsx:557-563`) and keeps nothing.
let close_btn = sized_dismiss_btn(p, "browser-perm-dismiss", t!("rune.browser.prompt.dismiss"), 28.0, 6.0, move |app: &mut App| {
let close_btn = dismiss_icon_btn(p, "browser-perm-dismiss", t!("rune.browser.prompt.dismiss"), move |app: &mut App| {
app.workspace_panes.browser.host.answer_permission(tab_id, req_id, PermissionDecision::Dismiss);
});
actions = actions.child(close_btn);
Expand All @@ -304,7 +304,7 @@ pub fn view_bars(s: &App, p: &Pal, tab_id: u64) -> Vec<El> {
.child(msg_col)
.child(actions),
)
.child(el().w_full().h(1.0).fill(p.border_muted)),
.child(el().w_full().h(0.5).fill(p.border_muted)),
);
}

Expand Down Expand Up @@ -381,6 +381,8 @@ pub fn view_modal(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.key(PROMPT_STOP_KEY)
.role("checkbox")
.focusable(true)
.focus_default(p)
.radius(4.0)
.label_static(t!("rune.browser.prompt.stop"))
.gap(8.0)
.center_y()
Expand All @@ -395,7 +397,7 @@ pub fn view_modal(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.border(1.0, if checked { p.q.submit } else { p.border })
.fill(if checked { p.q.submit } else { p.bg_base })
.center()
.children(checked.then(|| icon(&ic::CHECK, 10.0).color(p.q.submit_text))),
.children(checked.then(|| icon(&ic::CHECK_SMALL, 12.0).color(p.q.submit_text))),
)
.child(text(t!("rune.browser.prompt.stop")).font(UI_SMALL).color(p.muted).wrap().grow(1.0).shrink().min_w(0.0));
start = start.child(toggle);
Expand Down Expand Up @@ -579,35 +581,16 @@ fn dismiss_icon_btn(p: &Pal, key: &'static str, label: &'static str, on_press: i
.role("button")
.focusable(true)
.label_static(label)
.w(24.0)
.h(24.0)
.help(label)
.size(24.0, 24.0)
.radius(4.0)
.center()
.focus_default(p)
.hover(p.hover)
.press(p.pressed)
.hover_motion(Anim::INSTANT, Anim::INSTANT)
.on_press(on_press)
.child(icon(&ic::CLOSE, 12.0).color(p.icon_muted))
}

/// Official's ghost-muted `IconButton` with its 16 pt `close` icon: `side` 20 (small) or 28 (large).
fn sized_dismiss_btn(
p: &Pal,
key: &'static str,
label: &'static str,
side: f32,
radius: f32,
on_press: impl Fn(&mut App) + 'static,
) -> El {
el().key(key)
.role("button")
.focusable(true)
.label_static(label)
.w(side)
.h(side)
.radius(radius)
.center()
.hover(p.hover)
.on_press(on_press)
.child(icon(&ic::CLOSE, 16.0).color(p.icon_muted))
.child(icon(&ic::XMARK_SMALL, 16.0).color(p.icon_muted))
}

/// The blocked pop-up's destination row: a web address's host whole, then the rest cut short
Expand Down
Loading
Loading