From 05bbdef2123dee67cb8d7b251704d5d7a225d12b Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 26 Nov 2026 10:21:55 +0800 Subject: [PATCH 1/5] docs(cli): specify fullscreen composer click positioning --- crates/dim-cli/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/dim-cli/README.md b/crates/dim-cli/README.md index a81391e211..1272fe83e8 100644 --- a/crates/dim-cli/README.md +++ b/crates/dim-cli/README.md @@ -1103,6 +1103,7 @@ transcript target retains Shift+Tab navigation. See the | Mouse drag | Select transcript text; release copies it (OSC 52, plus `pbcopy` locally on macOS; inside tmux OSC 52 goes through passthrough, which needs `set -g allow-passthrough on`) | | Click a link | Opens it in the system browser (OSC 8 links, or a bare `http(s)://` URL); over SSH the status row shows the URL instead | | Click a task row above the composer | Opens that command's output or member conversation directly; `Esc` returns with the composer draft preserved. Press and release must hit the same cell and task without dragging; resizing or an open overlay cancels or blocks the click. Scrollback keeps keyboard-only task entry | +| Click inside the composer | Places the insertion cursor at the clicked text cell. Press and release in the same cell without dragging. | | Click the model label | Opens `/models` without discarding the draft; `Esc` returns to it. See [model label interaction](../../docs/design/model-configuration.md#scrollback-interaction) | | Click a tool header or a thought's title | Immediately toggles only that batch, codemode or call (`▸` / `▾`), or opens/closes a settled thought. Parent collapse hides children without resetting their choices. Hover and press feedback affect only the title, not detail/body rows; release must hit the same valid target without dragging. Opening holds the view in place. Output and compare text remain selectable; links and the member-conversation entry are separate actions. `/tools` changes defaults for unchosen nodes, not manual choices; thinking has its own setting | | Click an expanded thought's or tool node's body | Collapses that thought or the nearest enclosing open tool node (call, codemode or batch) after the existing 400ms multi-click window; headers and titles still respond immediately, and hover/press feedback remains on headers only. For thoughts, this covers actual body rows and internal gutter/blank cells in the main transcript, member conversation and branch side panel, not adjacent blocks, panel borders, scrollbar or page whitespace. For tools, this covers detail/body rows (including output, diffs, generic input/results, and non-foldable child rows) in the main transcript and member conversation, leaving siblings and other batches unchanged and excluding member-conversation entry rows, adjacent blocks, scrollbar and page whitespace. Drag selection, double/triple-click selection, links and member-conversation entries take priority. A new press, drag, scroll, resize, view change, mouse-off, overlay, paste or keyboard input cancels the pending click; the client revalidates the same expanded target before collapsing it, and re-anchors to its owning header when scrolled past it. Other block bodies (compaction, hook, error, member result) are not buttons. Manual choices survive redraws independently of the detail defaults; no gesture blocks input, Stop or background execution | From 7004c655100b4f9135626aaf3492a7ed2d1d7448 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 26 Nov 2026 10:26:04 +0800 Subject: [PATCH 2/5] fix(cli): place the composer cursor at the clicked text cell --- crates/dim-cli/src/ui/composer/mod.rs | 12 ++- crates/dim-cli/src/ui/render/fullscreen.rs | 100 ++++++++++----------- crates/dim-cli/src/ui/render/screen.rs | 2 + crates/dim-cli/src/ui/tui.rs | 16 ++++ docs/architecture/tui-e2e.md | 1 + scripts/tui-tmux/scenarios.mjs | 29 ++++++ 6 files changed, 108 insertions(+), 52 deletions(-) diff --git a/crates/dim-cli/src/ui/composer/mod.rs b/crates/dim-cli/src/ui/composer/mod.rs index f26c85423c..17d8270316 100644 --- a/crates/dim-cli/src/ui/composer/mod.rs +++ b/crates/dim-cli/src/ui/composer/mod.rs @@ -13,7 +13,7 @@ pub mod mentions; pub mod palette; use ratatui::buffer::Buffer; -use ratatui::layout::Rect; +use ratatui::layout::{Position, Rect}; use ratatui::style::{Modifier, Style}; use ratatui::text::{Line, Span}; use ratatui::widgets::StatefulWidgetRef; @@ -1236,6 +1236,16 @@ impl Composer { } } + pub fn click(&mut self, cell: Position, area: Rect) { + if let Some(offset) = self + .area + .buffer_pos_at_screen(cell.x, cell.y, area, self.state) + { + self.area.clear_selection(); + self.area.set_cursor(offset); + } + } + /// Rows of the input at `text_width` columns (without prompt/border), /// bounded by `max_rows`, and the cursor (column, row) inside them. pub fn render_rows( diff --git a/crates/dim-cli/src/ui/render/fullscreen.rs b/crates/dim-cli/src/ui/render/fullscreen.rs index b6b59d66fa..f5f336d1fa 100644 --- a/crates/dim-cli/src/ui/render/fullscreen.rs +++ b/crates/dim-cli/src/ui/render/fullscreen.rs @@ -30,6 +30,8 @@ use std::collections::HashMap; use std::io::Write; use std::time::{Duration, Instant}; +use ratatui::layout::{Position, Rect}; + use crate::ui::render::Frame; use crate::ui::render::panel::{clip, escape_len, strip_escapes}; use crate::ui::render::screen::scrub; @@ -139,6 +141,10 @@ pub enum MouseOutcome { Task(String), /// A click landed on the composer's model label. Models, + Composer { + cell: Position, + area: Rect, + }, /// A click landed on a branch panel thought header or expanded body. Thought { key: String, @@ -351,6 +357,7 @@ pub struct FullScreen { task_rows: HashMap, thought_rows: HashMap, model_label: Option<(usize, std::ops::Range)>, + composer: Option<(Rect, usize)>, /// Where the last press landed and the row it showed: a click counts /// only while that row still shows the same text at the release, so /// output that moves the transcript in between cannot redirect it. @@ -410,6 +417,7 @@ impl FullScreen { task_rows: HashMap::new(), thought_rows: HashMap::new(), model_label: None, + composer: None, press: None, pointer: None, hovered: None, @@ -449,6 +457,7 @@ impl FullScreen { self.task_rows.clear(); self.thought_rows.clear(); self.model_label = None; + self.composer = None; self.invalidate(); true } @@ -654,12 +663,16 @@ impl FullScreen { self.selection = None; } - /// Cancels a deferred body click, including an unreleased body press. + /// Cancels a deferred body click or an unreleased body or composer press. /// Call when disabling mouse input or changing the active view. pub fn cancel_click(&mut self) { self.pending = None; if self.press.as_ref().is_some_and(|press| { - press.body.is_some() || matches!(press.spot, MouseOutcome::Thought { .. }) + press.body.is_some() + || matches!( + press.spot, + MouseOutcome::Thought { .. } | MouseOutcome::Composer { .. } + ) }) { self.press = None; } @@ -924,6 +937,26 @@ impl FullScreen { self.pin(next); } + fn dock_action(&self, column: usize, row: usize) -> Option { + if self + .model_label + .as_ref() + .is_some_and(|(y, columns)| *y == row && columns.contains(&column)) + { + return Some(MouseOutcome::Models); + } + if column < content_width(self.size.0 as usize) + && let Some(task) = self.task_rows.get(&row) + { + return Some(MouseOutcome::Task(task.clone())); + } + let (area, skipped_rows) = self.composer?; + let dock_row = row.checked_sub(self.view_rows)? + skipped_rows; + let cell = Position::new(column as u16, u16::try_from(dock_row).ok()?); + area.contains(cell) + .then_some(MouseOutcome::Composer { cell, area }) + } + fn hover(&mut self, doc: &dyn Document) -> bool { let next = if self.overlay_open || self.selecting() { None @@ -1032,20 +1065,7 @@ impl FullScreen { || hovered || self.press.as_ref().is_some_and(|p| p.target.is_some()); self.press = None; - let action = if self - .model_label - .as_ref() - .is_some_and(|(y, columns)| *y == row && columns.contains(&column)) - { - Some(MouseOutcome::Models) - } else if column < content_width(self.size.0 as usize) - && let Some(task) = self.task_rows.get(&row) - { - Some(MouseOutcome::Task(task.clone())) - } else { - None - }; - if let Some(spot) = action { + if let Some(spot) = self.dock_action(column, row) { self.clicks = None; self.press = Some(Press { spot, @@ -1150,12 +1170,8 @@ impl FullScreen { } } MouseKind::Drag => { - if self.press.as_ref().is_some_and(|press| { - matches!(press.spot, MouseOutcome::Task(_) | MouseOutcome::Models) - }) { - self.press = None; - } let Some(selection) = self.selection else { + self.press = None; return MouseOutcome::Ignored; }; if selection.panel { @@ -1205,34 +1221,12 @@ impl FullScreen { } MouseKind::Release => { let press = self.press.take(); - if let Some(Press { - spot: MouseOutcome::Models, - cell, - .. - }) = &press - { - return if *cell == (column, row) - && self - .model_label - .as_ref() - .is_some_and(|(y, columns)| *y == row && columns.contains(&column)) - { - MouseOutcome::Models - } else { - MouseOutcome::Ignored - }; - } - if let Some(Press { - spot: MouseOutcome::Task(task), - cell, - .. - }) = &press + if let Some(press) = &press + && press.cell == (column, row) + && let Some(action) = self.dock_action(column, row) + && action == press.spot { - return if *cell == (column, row) && self.task_rows.get(&row) == Some(task) { - MouseOutcome::Task(task.clone()) - } else { - MouseOutcome::Ignored - }; + return action; } let changed = hovered || press.as_ref().is_some_and(|p| p.target.is_some()); let Some(selection) = self.selection else { @@ -1311,6 +1305,7 @@ impl FullScreen { .max(1); let dock_skip = dock.len().saturating_sub(dock_rows); self.view_rows = rows - dock_rows.min(rows); + self.composer = frame.composer.map(|area| (area, dock_skip)); let model_label = frame.model_label.as_ref().and_then(|(row, columns)| { row.checked_sub(split + dock_skip) .filter(|row| *row < dock_rows) @@ -1410,9 +1405,12 @@ impl FullScreen { if press.spot == MouseOutcome::Models { return false; } - let (_, row) = press.cell; - if let MouseOutcome::Task(task) = &press.spot { - return self.task_rows.get(&row) != Some(task); + let (column, row) = press.cell; + if matches!( + press.spot, + MouseOutcome::Task(_) | MouseOutcome::Composer { .. } + ) { + return self.dock_action(column, row).as_ref() != Some(&press.spot); } if let MouseOutcome::Thought { key, body } = &press.spot { return self.thought_rows.get(&row).is_none_or(|thought| { diff --git a/crates/dim-cli/src/ui/render/screen.rs b/crates/dim-cli/src/ui/render/screen.rs index 4e754ad3bb..7a41263195 100644 --- a/crates/dim-cli/src/ui/render/screen.rs +++ b/crates/dim-cli/src/ui/render/screen.rs @@ -43,6 +43,8 @@ pub struct Frame { pub thought_rows: Vec<(usize, std::ops::Range, String, bool)>, /// Model label row and columns in `live`, for the fullscreen model picker. pub model_label: Option<(usize, std::ops::Range)>, + /// Editable text cells relative to the start of the fullscreen dock. + pub composer: Option, /// Cursor position inside the live region (row, column), `None` hides it. pub cursor: Option<(u16, u16)>, /// Index in `live` where the dock (queue, composer, panels, status) diff --git a/crates/dim-cli/src/ui/tui.rs b/crates/dim-cli/src/ui/tui.rs index 5fd865c3d4..eb8380f550 100644 --- a/crates/dim-cli/src/ui/tui.rs +++ b/crates/dim-cli/src/ui/tui.rs @@ -4,6 +4,7 @@ //! diff (2.3). The terminal layer (2.2) guarantees the exit contract. use dim_agent_types::ROOT_BRANCH_ID; +use ratatui::layout::Rect; use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; @@ -603,6 +604,13 @@ fn run_terminal( app.run_command("models", ""); dirty = true; } + MouseOutcome::Composer { cell, area } => { + if mouse && app.prompt.is_none() && !app.composer.palette_open() { + full.clear_focus(); + app.composer.click(cell, area); + dirty = true; + } + } MouseOutcome::Thought { key, body } => { dirty |= app.click_panel_thought(&key, body); } @@ -6584,6 +6592,14 @@ impl App { } } let box_top = live.len(); + if self.fullscreen && self.prompt.is_none() && !palette_overlay { + frame.composer = Some(Rect::new( + (MARGIN + 2 + prompt_width) as u16, + (box_top + 1 - frame.dock) as u16, + text_width as u16, + rows.len() as u16, + )); + } let shell_title = shell.map(|shell| match shell { Shell::Recorded => t("! shell mode"), Shell::Private => t("!! shell mode · not sent to the model"), diff --git a/docs/architecture/tui-e2e.md b/docs/architecture/tui-e2e.md index 715007eecd..d011677e68 100644 --- a/docs/architecture/tui-e2e.md +++ b/docs/architecture/tui-e2e.md @@ -105,6 +105,7 @@ daemon. `--keep` leaves the home and raw streams in place for inspection. | terminal-modes | `resize_rewraps_history_without_losing_rows` | Resizing to 60x18 and 140x40 keeps the message and answer, rewraps rows, and draws to the new width: the capture is taken only after the product's own `CSI 3J` reflow and completed frame, tmux reports the target pane size, and the new frame is stable at that width | | terminal-modes | `resize_during_a_stream_rewraps_and_finishes` | A resize while the fixture streams repaints the live output at the new width, keeps the streamed text, and the run still finishes | | terminal-modes | `resize_during_thinking_rewraps_multiline_history` | Expanded reasoning streams in a turn sent as three lines; five resizes (100x24, 60x24, 120x40, 45x18, 100x36) keep every user line and every reasoning line, the transcript settles as a thought, and the answer still arrives | +| composer | `fullscreen_composer_click_places_the_cursor` | Click-to-insert in an ASCII draft and between wide characters in a wrapped, vertically scrolled draft | | composer | `composer_edits_multiline_and_stores_a_large_paste` | `Ctrl+J` newline editing, backspace, a five-line bracketed paste stored as an attachment, and the exact prompt text the model receives | | composer | `file_mention_inserts_a_workspace_link` | The `@` picker lists the `--cwd` workspace, inserts the chosen file, and completes a directory prefix to the file under it; the prompt carries both as absolute links | | no-session | `home_commands_without_a_session_answer_and_send_nothing` | `/export`, `/queue` and `/mcp list` run from the palette over a draft answer at home in both layouts, the draft returns to the composer after each, no command sends it, and the fixture model receives no request; `/agent` and a valued `/effort` stay with `tui_home_commands_without_a_session_answer_and_send_nothing` in CI | diff --git a/scripts/tui-tmux/scenarios.mjs b/scripts/tui-tmux/scenarios.mjs index 5b7a325301..ca6a763a48 100644 --- a/scripts/tui-tmux/scenarios.mjs +++ b/scripts/tui-tmux/scenarios.mjs @@ -503,6 +503,35 @@ const scenarios = [ await exitWith(terminal); }, }, + { + name: 'fullscreen_composer_click_places_the_cursor', + area: 'composer', + title: 'Clicking an editable cell inserts there in single-line and scrolled, wrapped drafts', + async run(tui) { + await tui.setup({respond: () => ({text: ANSWER})}); + const terminal = await tui.launch(['--fullscreen'], {cols: 40, rows: 18, waitForComposer: true}); + const click = async (text, cellOffset) => { + await terminal.waitFor(text); + const lines = terminal.capture({join: false}).split('\n'); + const row = lines.findIndex((line) => line.includes(text)); + assert(row >= 0, lines.join('\n')); + const column = lines[row].indexOf(text) + cellOffset + 1; + const report = `\x1b[<0;${column};${row + 1}`; + terminal.bytes(Buffer.from(`${report}M${report}m`)); + }; + + terminal.send('abcdef'); + await click('abcdef', 2); + terminal.send('X'); + await terminal.waitFor('abXcdef'); + + terminal.key('End', 'C-j'); + terminal.send('pad '.repeat(120) + '中界tail'); + await click('中界tail', 2); + terminal.send('Y'); + await terminal.waitFor('中Y界tail'); + }, + }, { name: 'composer_edits_multiline_and_stores_a_large_paste', area: 'composer', From 53df6fcbeb31bd1b400a711ce74d7d4ec4e01887 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 26 Nov 2026 10:28:13 +0800 Subject: [PATCH 3/5] test(cli): keep the wrapped click fixture editable --- scripts/tui-tmux/scenarios.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/tui-tmux/scenarios.mjs b/scripts/tui-tmux/scenarios.mjs index ca6a763a48..131d28bd77 100644 --- a/scripts/tui-tmux/scenarios.mjs +++ b/scripts/tui-tmux/scenarios.mjs @@ -509,7 +509,7 @@ const scenarios = [ title: 'Clicking an editable cell inserts there in single-line and scrolled, wrapped drafts', async run(tui) { await tui.setup({respond: () => ({text: ANSWER})}); - const terminal = await tui.launch(['--fullscreen'], {cols: 40, rows: 18, waitForComposer: true}); + const terminal = await tui.launch(['--fullscreen'], {cols: 28, rows: 18, waitForComposer: true}); const click = async (text, cellOffset) => { await terminal.waitFor(text); const lines = terminal.capture({join: false}).split('\n'); @@ -526,8 +526,9 @@ const scenarios = [ await terminal.waitFor('abXcdef'); terminal.key('End', 'C-j'); - terminal.send('pad '.repeat(120) + '中界tail'); + terminal.paste('pad '.repeat(45) + '中界tail'); await click('中界tail', 2); + assert(!terminal.capture().includes('abXcdef'), 'the first draft line has scrolled out of view'); terminal.send('Y'); await terminal.waitFor('中Y界tail'); }, From d99838e1299fdfe165b0d23e28627a92f466d0cd Mon Sep 17 00:00:00 2001 From: Roy Yang Date: Thu, 26 Nov 2026 03:38:08 +0000 Subject: [PATCH 4/5] fix(cli): map fullscreen composer clicks with the rendered height Record the textarea viewport before padding the fullscreen box. Exercise the scrolled click in an 80x12 pane with three background tasks. --- crates/dim-cli/src/ui/tui.rs | 12 ++++----- docs/architecture/tui-e2e.md | 1 + scripts/tui-tmux/scenarios.mjs | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/crates/dim-cli/src/ui/tui.rs b/crates/dim-cli/src/ui/tui.rs index eb8380f550..6ad8264ccc 100644 --- a/crates/dim-cli/src/ui/tui.rs +++ b/crates/dim-cli/src/ui/tui.rs @@ -6585,12 +6585,6 @@ impl App { } (cursor.1 as usize, prompt_width + cursor.0 as usize) }; - if self.fullscreen { - let minimum = FULLSCREEN_COMPOSER_ROWS.min((size.1 as usize).saturating_sub(7).max(1)); - if rows.len() < minimum { - rows.resize(minimum, String::new()); - } - } let box_top = live.len(); if self.fullscreen && self.prompt.is_none() && !palette_overlay { frame.composer = Some(Rect::new( @@ -6600,6 +6594,12 @@ impl App { rows.len() as u16, )); } + if self.fullscreen { + let minimum = FULLSCREEN_COMPOSER_ROWS.min((size.1 as usize).saturating_sub(7).max(1)); + if rows.len() < minimum { + rows.resize(minimum, String::new()); + } + } let shell_title = shell.map(|shell| match shell { Shell::Recorded => t("! shell mode"), Shell::Private => t("!! shell mode · not sent to the model"), diff --git a/docs/architecture/tui-e2e.md b/docs/architecture/tui-e2e.md index d011677e68..03b9b05487 100644 --- a/docs/architecture/tui-e2e.md +++ b/docs/architecture/tui-e2e.md @@ -106,6 +106,7 @@ daemon. `--keep` leaves the home and raw streams in place for inspection. | terminal-modes | `resize_during_a_stream_rewraps_and_finishes` | A resize while the fixture streams repaints the live output at the new width, keeps the streamed text, and the run still finishes | | terminal-modes | `resize_during_thinking_rewraps_multiline_history` | Expanded reasoning streams in a turn sent as three lines; five resizes (100x24, 60x24, 120x40, 45x18, 100x36) keep every user line and every reasoning line, the transcript settles as a thought, and the answer still arrives | | composer | `fullscreen_composer_click_places_the_cursor` | Click-to-insert in an ASCII draft and between wide characters in a wrapped, vertically scrolled draft | +| composer | `fullscreen_composer_click_with_a_clipped_task_strip` | In a short pane with three background tasks, clicking the top visible row of a wrapped draft inserts there. The textarea scrolls inside a padded composer box | | composer | `composer_edits_multiline_and_stores_a_large_paste` | `Ctrl+J` newline editing, backspace, a five-line bracketed paste stored as an attachment, and the exact prompt text the model receives | | composer | `file_mention_inserts_a_workspace_link` | The `@` picker lists the `--cwd` workspace, inserts the chosen file, and completes a directory prefix to the file under it; the prompt carries both as absolute links | | no-session | `home_commands_without_a_session_answer_and_send_nothing` | `/export`, `/queue` and `/mcp list` run from the palette over a draft answer at home in both layouts, the draft returns to the composer after each, no command sends it, and the fixture model receives no request; `/agent` and a valued `/effort` stay with `tui_home_commands_without_a_session_answer_and_send_nothing` in CI | diff --git a/scripts/tui-tmux/scenarios.mjs b/scripts/tui-tmux/scenarios.mjs index 131d28bd77..68115af03b 100644 --- a/scripts/tui-tmux/scenarios.mjs +++ b/scripts/tui-tmux/scenarios.mjs @@ -533,6 +533,55 @@ const scenarios = [ await terminal.waitFor('中Y界tail'); }, }, + { + name: 'fullscreen_composer_click_with_a_clipped_task_strip', + area: 'composer', + title: 'Clicking a wrapped draft uses the visible textarea when task rows squeeze the composer', + async run(tui) { + const tasks = ['A', 'B', 'C']; + await tui.setup({ + respond: (request) => { + if ((request.tools ?? []).length === 0) return {text: ANSWER}; + if (lastMessage(request).role === 'tool') return {text: 'Started the composer tasks.'}; + return { + toolCalls: tasks.map((name) => ({ + name: 'exec', + arguments: { + command: `sleep 60; echo composer-task-${name}`, + runInBackground: true, + title: `Composer task ${name}`, + }, + })), + }; + }, + }); + const terminal = await tui.launch(['--fullscreen'], {cols: 80, rows: 24, waitForComposer: true}); + terminal.send('start three composer tasks'); + terminal.key('Enter'); + const pending = new Set(tasks); + while (pending.size > 0) { + const command = new RegExp(`composer-task-([${[...pending].join('')}])`); + const screen = await terminal.waitFor(new RegExp(`Permission required[\\s\\S]*${command.source}`)); + pending.delete(screen.slice(screen.lastIndexOf('Permission required')).match(command)[1]); + terminal.key('y'); + } + await terminal.waitFor('3 in background'); + terminal.resize(80, 12); + + const wrappedRowWidth = 72; + terminal.paste('first'.padEnd(wrappedRowWidth, '1') + 'target'.padEnd(wrappedRowWidth, '2') + 'tail'); + await terminal.waitFor('target222'); + const lines = terminal.capture({join: false}).split('\n'); + const row = lines.findIndex((line) => line.includes('target222')); + assert(row >= 0 && lines[row + 1]?.includes('tail'), lines.join('\n')); + assert(!lines.some((line) => line.includes('first111')), lines.join('\n')); + const column = lines[row].indexOf('target') + 3; + const report = `\x1b[<0;${column};${row + 1}`; + terminal.bytes(Buffer.from(`${report}M${report}m`)); + terminal.send('X'); + await terminal.waitFor('taXrget'); + }, + }, { name: 'composer_edits_multiline_and_stores_a_large_paste', area: 'composer', From 69a43e8231ec4bd3594322497b44df697f272711 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 26 Nov 2026 12:46:18 +0800 Subject: [PATCH 5/5] test(cli): cover cancelled fullscreen composer clicks --- crates/dim-cli/src/ui/composer/mod.rs | 3 +++ docs/architecture/tui-e2e.md | 2 +- scripts/tui-tmux/scenarios.mjs | 38 +++++++++++++++++++++------ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/crates/dim-cli/src/ui/composer/mod.rs b/crates/dim-cli/src/ui/composer/mod.rs index 17d8270316..51147b92dc 100644 --- a/crates/dim-cli/src/ui/composer/mod.rs +++ b/crates/dim-cli/src/ui/composer/mod.rs @@ -1236,6 +1236,9 @@ impl Composer { } } + /// Place the cursor at `cell` and clear the selection. Both `cell` and the + /// rendered textarea `area` use screen columns and rows counted from the + /// top of the unclipped dock. Clicks outside `area` are ignored. pub fn click(&mut self, cell: Position, area: Rect) { if let Some(offset) = self .area diff --git a/docs/architecture/tui-e2e.md b/docs/architecture/tui-e2e.md index 03b9b05487..2ced6f0432 100644 --- a/docs/architecture/tui-e2e.md +++ b/docs/architecture/tui-e2e.md @@ -105,7 +105,7 @@ daemon. `--keep` leaves the home and raw streams in place for inspection. | terminal-modes | `resize_rewraps_history_without_losing_rows` | Resizing to 60x18 and 140x40 keeps the message and answer, rewraps rows, and draws to the new width: the capture is taken only after the product's own `CSI 3J` reflow and completed frame, tmux reports the target pane size, and the new frame is stable at that width | | terminal-modes | `resize_during_a_stream_rewraps_and_finishes` | A resize while the fixture streams repaints the live output at the new width, keeps the streamed text, and the run still finishes | | terminal-modes | `resize_during_thinking_rewraps_multiline_history` | Expanded reasoning streams in a turn sent as three lines; five resizes (100x24, 60x24, 120x40, 45x18, 100x36) keep every user line and every reasoning line, the transcript settles as a thought, and the answer still arrives | -| composer | `fullscreen_composer_click_places_the_cursor` | Click-to-insert in an ASCII draft and between wide characters in a wrapped, vertically scrolled draft | +| composer | `fullscreen_composer_click_places_the_cursor` | Click-to-insert in ASCII and scrolled, wrapped wide text. Releasing in another cell, dragging back to the pressed cell, or typing before release preserves the insertion point | | composer | `fullscreen_composer_click_with_a_clipped_task_strip` | In a short pane with three background tasks, clicking the top visible row of a wrapped draft inserts there. The textarea scrolls inside a padded composer box | | composer | `composer_edits_multiline_and_stores_a_large_paste` | `Ctrl+J` newline editing, backspace, a five-line bracketed paste stored as an attachment, and the exact prompt text the model receives | | composer | `file_mention_inserts_a_workspace_link` | The `@` picker lists the `--cwd` workspace, inserts the chosen file, and completes a directory prefix to the file under it; the prompt carries both as absolute links | diff --git a/scripts/tui-tmux/scenarios.mjs b/scripts/tui-tmux/scenarios.mjs index 68115af03b..a0122c0e9e 100644 --- a/scripts/tui-tmux/scenarios.mjs +++ b/scripts/tui-tmux/scenarios.mjs @@ -510,25 +510,47 @@ const scenarios = [ async run(tui) { await tui.setup({respond: () => ({text: ANSWER})}); const terminal = await tui.launch(['--fullscreen'], {cols: 28, rows: 18, waitForComposer: true}); - const click = async (text, cellOffset) => { + const cellOf = async (text, cellOffset) => { await terminal.waitFor(text); const lines = terminal.capture({join: false}).split('\n'); const row = lines.findIndex((line) => line.includes(text)); assert(row >= 0, lines.join('\n')); - const column = lines[row].indexOf(text) + cellOffset + 1; - const report = `\x1b[<0;${column};${row + 1}`; - terminal.bytes(Buffer.from(`${report}M${report}m`)); + return {column: lines[row].indexOf(text) + cellOffset + 1, row: row + 1}; + }; + const mouse = (button, {column, row}, release = false) => + terminal.bytes(Buffer.from(`\x1b[<${button};${column};${row}${release ? 'm' : 'M'}`)); + const click = (cell) => { + mouse(0, cell); + mouse(0, cell, true); }; terminal.send('abcdef'); - await click('abcdef', 2); + click(await cellOf('abcdef', 2)); terminal.send('X'); - await terminal.waitFor('abXcdef'); + const first = await cellOf('abXcdef', 0); + const second = {...first, column: first.column + 1}; + + mouse(0, first); + mouse(0, second, true); + terminal.send('1'); + await terminal.waitFor('abX1cdef'); + + mouse(0, first); + mouse(32, second); + mouse(0, first, true); + terminal.send('2'); + await terminal.waitFor('abX12cdef'); + + mouse(0, first); + terminal.send('3'); + mouse(0, first, true); + terminal.send('4'); + await terminal.waitFor('abX1234cdef'); terminal.key('End', 'C-j'); terminal.paste('pad '.repeat(45) + '中界tail'); - await click('中界tail', 2); - assert(!terminal.capture().includes('abXcdef'), 'the first draft line has scrolled out of view'); + click(await cellOf('中界tail', 2)); + assert(!terminal.capture().includes('abX1234cdef'), 'the first draft line has scrolled out of view'); terminal.send('Y'); await terminal.waitFor('中Y界tail'); },