Skip to content
Merged
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
11 changes: 7 additions & 4 deletions apps/desktop/src/surfaces/browser/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,12 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.help_above(),
);

let input = session_view::style::field(draft, FIELD)
let input_field = session_view::style::field(draft, FIELD)
.key("browser-comment-field")
.label_static(opencode_i18n::t!("rune.browser.comment.label"))
.color(p.text)
.w_full()
.min_h(20.0)
.max_h(160.0)
.placeholder(opencode_i18n::t!("plugin.browser.comment.placeholder"), p.faint)
.caret(p.text, p.selection)
.selection_style(p.field_selection)
Expand All @@ -562,6 +561,9 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.on_edit(on_edit_draft)
.on_input_change(on_input_change)
.on_input_key(on_input_key);
let input = session_view::scroller::scroller("browser-comment-field-scroll")
.stable_gutter()
.build::<App>(p, col().w_full().min_h(20.0).max_h(160.0), input_field);
let mentions = mention_rows::<App>(p, &field.mention, act);
let field_col = col().grow(1.0).shrink().min_w(0.0).gap(8.0).child(input).children(mentions);

Expand Down Expand Up @@ -684,13 +686,12 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.min_w(0.0),
);

let input = session_view::style::field(draft, NOTE_FIELD)
let input_field = session_view::style::field(draft, NOTE_FIELD)
.key("browser-note-field")
.label_static(opencode_i18n::t!("plugin.browser.page.add"))
.color(p.text)
.w_full()
.min_h(64.0)
.max_h(160.0)
.placeholder(opencode_i18n::t!("rune.browser.page.placeholder"), p.faint)
.caret(p.text, p.selection)
.selection_style(p.field_selection)
Expand All @@ -700,6 +701,8 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option<El> {
.on_edit(on_edit_draft)
.on_input_change(on_input_change)
.on_input_key(on_input_key);
let input = session_view::scroller::scroller("browser-note-field-scroll")
.build::<App>(p, col().w_full().min_h(64.0).max_h(160.0), input_field);
let mentions = mention_rows::<App>(p, &field.mention, act);
let field_col = col().w_full().gap(8.0).child(input).children(mentions);

Expand Down
15 changes: 13 additions & 2 deletions features/annotations/src/line_comments/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use crate::quote::comment::{self as field, FieldEvent, FieldKey};

/// `line-comment-v2-textarea` and `-text`: 13 at 440 on `--line-height-compact`.
const V2_TEXT: TextStyle = TextStyle::new(13.0, 440.0).lh(16.0).tracking(-0.04);
/// The v2 field's height: four 16 pt lines (`rows={4}`, `packages/ui/src/data-display/line-comment/line-comment.tsx:311`).
const V2_FIELD_H: f32 = 4.0 * 16.0;
/// `line-comment-text` (v1): `--font-size-base` on `--line-height-x-large`.
const V1_TEXT: TextStyle = TextStyle::new(14.0, 440.0).lh(25.2);
/// `line-comment-label`, `-editor-label`, `-action` and `-textarea` (v1): 13 on 19.5.
Expand Down Expand Up @@ -263,7 +265,10 @@ fn small_button<H: 'static>(p: &Pal, key: &str, label: &str, variant: Variant, l

/// `LineCommentEditor`, default layout.
fn editor_v2<H: LineCommentsHost + 'static>(s: &H, p: &Pal, spot: &Spot, draft: &Draft, submit: &str, editing: Option<&str>) -> El {
let input = field_input::<H>(s, p, spot, draft, V2_TEXT, opencode_i18n::t!("ui.lineComment.contextPlaceholder")).h(64.0);
// Scrollable four-line textarea (`packages/ui/src/data-display/line-comment/line-comment.tsx:311`,
// `line-comment.css:131-147`): clips and scrolls inside 64 pt so long drafts never cover the footer.
let field = field_input::<H>(s, p, spot, draft, V2_TEXT, opencode_i18n::t!("ui.lineComment.contextPlaceholder")).min_h(V2_FIELD_H);
let input = session_view::scroller::scroller("line-comment-v2-scroll").build::<H>(p, col().w_full().h(V2_FIELD_H), field);
let can = !draft.text.text.trim().is_empty();
let alt = draft.field.alternate;
let can_send = s.can_send_comment();
Expand Down Expand Up @@ -455,6 +460,12 @@ fn editor_v1<H: LineCommentsHost + 'static>(
let field_bg = if p.dark { hex("#1c1c1c") } else { hex("#f8f8f8") };
let border = if p.dark { Color::WHITE.alpha(0.1) } else { Color::BLACK.alpha(0.1) };
let height = draft.height.unwrap_or(V1_FIELD_H);
// Scrollable textarea inside `field-box` (`packages/session-ui/src/components/line-comment.tsx:287`,
// `line-comment-styles.ts:154-166`): clips and scrolls within the resizable box above the actions row.
let inner_h = (height - 16.0).max(0.0);
let field = field_input::<H>(s, p, spot, draft, V1_FIELD, opencode_i18n::t!("ui.lineComment.placeholder")).min_h(inner_h);
let scroll = session_view::scroller::scroller("line-comment-v1-scroll")
.build::<H>(p, col().w_full().grow(1.0).shrink().min_h(0.0), field);
let mut input = col()
.key("field-box")
.w_full()
Expand All @@ -465,7 +476,7 @@ fn editor_v1<H: LineCommentsHost + 'static>(
// Focused, the border turns `border-focus` with a 1 px outline of it just outside: an
// outline, not a shadow, still marks focus in a contrast theme (opencode#65100).
.box_shadow(rune::Shadow { spread: 1.0, color: if focused { p.v2.border_focus } else { border }, inset: true, ..rune::Shadow::default() })
.child(field_input::<H>(s, p, spot, draft, V1_FIELD, opencode_i18n::t!("ui.lineComment.placeholder")).h_full())
.child(scroll)
.child(grip::<H>(p, spot, height));
if focused {
input = input.outline(1.0, 0.0, p.v2.border_focus);
Expand Down
7 changes: 5 additions & 2 deletions features/annotations/src/quote/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ fn input_shell(host: &dyn QuoteHost, p: &Pal, draft: &TextEdit) -> El {
.color(p.text)
.w_full()
.min_h(20.0)
.max_h(160.0)
.placeholder(opencode_i18n::t!("session.quote.optionalCommentPlaceholder"), p.faint)
.caret(p.text, p.selection)
.selection_style(p.field_selection)
Expand Down Expand Up @@ -545,10 +544,14 @@ pub fn view<H: QuoteHost + 'static>(s: &H, p: &Pal, cx: &mut Cx<H>) -> Option<El

let size = [layout.width, measured.unwrap_or(0.0)];
let preview = preview_shell(p, &quote.text, layout.preview_lines);
let input = input_shell(s, p, draft)
let field = input_shell(s, p, draft)
.on_edit(|s: &mut H| on_edit_draft(s))
.on_input_change(|s: &mut H, tx: &mut Tx| on_input_change(s, tx))
.on_input_key(|s: &mut H, ev, tx| on_input_key(s, ev, tx));
// `packages/ui/src/data-display/line-comment/line-comment.css:209-219`: grows to 160 pt, then scrolls.
let input = session_view::scroller::scroller("quote-comment-field-scroll")
.stable_gutter()
.build::<H>(p, col().w_full().min_h(20.0).max_h(160.0), field);
let mentions = mention_rows::<H>(p, &f.mention, Rc::new(|s: &mut H, e: FieldEvent, tx: &mut Tx| on_field_event(s, e, tx)));
let field_col = col().key("line-comment-field").grow(1.0).shrink().min_w(0.0).child(input).children(mentions);
let (action_el, enabled) = action_shell(s, p, draft.text.trim().is_empty(), f.alternate, sending, key);
Expand Down
Loading