From f7c7fabd8814c0bdfce6e93451ba585e644c9341 Mon Sep 17 00:00:00 2001 From: Luke Parker <10430890+Hona@users.noreply.github.com> Date: Thu, 3 Dec 2026 18:34:23 +1000 Subject: [PATCH] fix(annotations): clip and scroll multiline line-comment drafts above footer --- apps/desktop/src/surfaces/browser/comment.rs | 11 +++++++---- features/annotations/src/line_comments/view.rs | 15 +++++++++++++-- features/annotations/src/quote/editor.rs | 7 +++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src/surfaces/browser/comment.rs b/apps/desktop/src/surfaces/browser/comment.rs index 4226d6001..13e0175f9 100644 --- a/apps/desktop/src/surfaces/browser/comment.rs +++ b/apps/desktop/src/surfaces/browser/comment.rs @@ -546,13 +546,12 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option { .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) @@ -562,6 +561,9 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option { .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::(p, col().w_full().min_h(20.0).max_h(160.0), input_field); let mentions = mention_rows::(p, &field.mention, act); let field_col = col().grow(1.0).shrink().min_w(0.0).gap(8.0).child(input).children(mentions); @@ -684,13 +686,12 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option { .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) @@ -700,6 +701,8 @@ pub fn view(s: &App, p: &Pal, tab_id: u64) -> Option { .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::(p, col().w_full().min_h(64.0).max_h(160.0), input_field); let mentions = mention_rows::(p, &field.mention, act); let field_col = col().w_full().gap(8.0).child(input).children(mentions); diff --git a/features/annotations/src/line_comments/view.rs b/features/annotations/src/line_comments/view.rs index dd8ff6061..1144330f5 100644 --- a/features/annotations/src/line_comments/view.rs +++ b/features/annotations/src/line_comments/view.rs @@ -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. @@ -263,7 +265,10 @@ fn small_button(p: &Pal, key: &str, label: &str, variant: Variant, l /// `LineCommentEditor`, default layout. fn editor_v2(s: &H, p: &Pal, spot: &Spot, draft: &Draft, submit: &str, editing: Option<&str>) -> El { - let input = field_input::(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::(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::(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(); @@ -455,6 +460,12 @@ fn editor_v1( 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::(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::(p, col().w_full().grow(1.0).shrink().min_h(0.0), field); let mut input = col() .key("field-box") .w_full() @@ -465,7 +476,7 @@ fn editor_v1( // 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::(s, p, spot, draft, V1_FIELD, opencode_i18n::t!("ui.lineComment.placeholder")).h_full()) + .child(scroll) .child(grip::(p, spot, height)); if focused { input = input.outline(1.0, 0.0, p.v2.border_focus); diff --git a/features/annotations/src/quote/editor.rs b/features/annotations/src/quote/editor.rs index e2b6f4586..0c97a55a4 100644 --- a/features/annotations/src/quote/editor.rs +++ b/features/annotations/src/quote/editor.rs @@ -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) @@ -545,10 +544,14 @@ pub fn view(s: &H, p: &Pal, cx: &mut Cx) -> Option(p, col().w_full().min_h(20.0).max_h(160.0), field); let mentions = mention_rows::(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);