Skip to content

fix(cli): position the fullscreen composer cursor on click - #2210

Merged
yyhhyyyyyy merged 5 commits into
mainfrom
dimagent/2179-composer-click
Nov 26, 2026
Merged

yyhhyyyyyy merged 5 commits into
mainfrom
dimagent/2179-composer-click

Conversation

@zerob13

@zerob13 zerob13 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2179. This PR covers fullscreen. The scrollback change is in #2211.

Summary

A left click inside the fullscreen composer places the insertion cursor in the draft. The next keystroke edits the clicked location.

Before click      abcdef|
Click on c        ab|cdef
Type X            abX|cdef

The fullscreen dock maps the press and release to the same editable cell. The textarea maps that cell to a buffer position using its rendered width and scroll state. This keeps wrapped rows, wide characters and attachment boundaries consistent with keyboard editing. The gesture is documented in the native CLI guide.

Design rule checklist

  • Scope, commands and results, handover, Timeline callbacks, infrastructure, core mechanisms, batches and context — N/A. The terminal client owns its editable draft and cursor.
  • Plugin state, cross-language faces, loader configuration and mechanism requirements — N/A. The fullscreen renderer and the existing textarea handle this gesture locally.
  • Timeline facts and Session notices — N/A. Cursor movement is local to one terminal.

Documentation

The CLI guide documents the gesture and the tmux suite inventory lists both regression scenarios. ADRs and service contracts are unaffected.

Verification

  • On the base implementation the tmux scenario produced abcdefX. On the PR it produces abXcdef and inserts between two wide characters in a wrapped draft whose first line has scrolled out of view.
  • The committed fullscreen composer scenarios passed on macOS arm64 with tmux 3.8. They cover release in another cell, drag followed by release at the starting cell, and typing between press and release. In an 80×12 pane with three background tasks, clicking the top visible wrapped row produces taXrget in that row.
  • To run both, build the CLI and App Server, then run node scripts/tui-tmux/run.mjs fullscreen_composer_click_places_the_cursor fullscreen_composer_click_with_a_clipped_task_strip.
  • cargo test --locked -p dim-cli --lib passed all 823 tests. CLI Clippy (all targets), Rust formatting, ADR checks and the Node script tests passed.
  • The local tmux suite passed 29 of 32 scenarios on the base and 31 of 34 on the PR. The same three existing scenarios failed on both: home_commands_without_a_session_answer_and_send_nothing and slash_palette_lists_curated_commands_and_settings wait for a command menu title while the screen shows Suggestions. member_conversation_and_stop_all waits for the initial member prompt while the visible pane shows streaming output.

@zerob13
zerob13 marked this pull request as ready for review November 26, 2026 02:46

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix stays in the fullscreen client. The dock maps the visible click through its clipped rows and preserves the model/task hit targets; the same-cell release then uses the textarea's existing width, scroll and element-boundary mapping rather than introducing a second cursor algorithm. Drag and view changes invalidate the pending click.

The checks for this head passed. The PR's tmux report and regression cover ASCII insertion and a wide-character boundary in a scrolled, wrapped draft. I did not independently run the tmux scenario.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one P2 mapping bug; the rest is small.

The PR makes a left click in the fullscreen composer move the insertion cursor to the clicked cell. The dock maps the press and release through its clipped rows, and the textarea reuses its rendered width, scroll and element boundaries. Scope, the CLI guide row and the new tmux scenario match that goal.

P2: the composer rect stores the padded box height, not the height the textarea rendered with. See the inline comment on crates/dim-cli/src/ui/tui.rs:6600 for the reproduction and the fix. In a fullscreen composer squeezed by task rows, a click can land one wrapped line above the clicked row, which defeats the feature.

Two P3s: Composer::click has no contract comment for its mixed coordinate space, and the new scenario does not exercise the release-in-another-cell and drag cancellation that the new README row promises. Details inline.

Cross-PR: #2211 is stacked on this branch and reuses Composer::click and the frame.composer contract, so the height fix should be carried into it. #1881 and #2197 touch crates/dim-cli/src/ui/tui.rs in unrelated hunks. origin/main has not changed the seven files since the merge base, so the PR merges cleanly.

CI: all required checks pass on 53df6fc (ci-ok, macos-native, scripts, verify (linux), windows-cli). I did not run the tmux suite locally; the additional checks reported in the PR body (drag, release in another cell, typing between press and release, model picker, shell prefix) are not committed and remain unverified.

Comment thread crates/dim-cli/src/ui/tui.rs Resolved
Comment thread crates/dim-cli/src/ui/composer/mod.rs Resolved
Comment thread scripts/tui-tmux/scenarios.mjs Resolved
Record the textarea viewport before padding the fullscreen box. Exercise the scrolled click in an 80x12 pane with three background tasks.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at d99838e. The new commit fixes the P2 mapping bug. The two P3s stay small and do not block.

The PR places the fullscreen composer cursor at the clicked text cell. The dock maps the press and release through its clipped rows, and the textarea maps the cell with its rendered width and scroll. Scope, the CLI guide row and the tmux scenarios match that goal.

P2, fixed and withdrawn: frame.composer now records rows.len() before the box padding block (crates/dim-cli/src/ui/tui.rs:6588-6601), so the rect height is the textarea viewport height that render_rows used, not the padded box height. In the added 80x12 scenario the draft wraps to three lines at 72 columns (the scrollbar takes the last of the 73), the viewport is two rows, and the box is padded to three. At the previous head the click used height 3, effective_scroll(3, 3 lines, ...) returned 0, and the top painted row mapped to the hidden first line. At this head it uses height 2, effective_scroll(2, 3 lines, 1) returns 1, and the same row maps to the visible second line, where the scenario's taXrget wait succeeds. Width, scrollbar decision and wrapping now use the same height, so the squeezed, wrapped and wide-character cases agree. The padded rows below the textarea are no longer clickable; that matches the "clicked text cell" wording and the tui-e2e row. The arithmetic is the evidence here; I did not run the tmux suite.

P3, still open and not blocking: Composer::click has no contract comment for its mixed coordinate space (crates/dim-cli/src/ui/composer/mod.rs:1239-1247). cell.x is a screen column, cell.y is relative to the dock origin, and a cell outside area is a no-op (crates/dim-cli/src/ui/render/fullscreen.rs:953-957, crates/dim-cli/src/ui/render/screen.rs:46-47). PR #2211 is stacked on this branch and reuses both click and frame.composer. Failure scenario: a later caller passes a screen-relative area or a screen-relative cell.y and the cursor lands on the wrong row. Fix: document the space, the outside-area no-op and the selection clear here, or in #2211 before that one merges.

P3, still open and not blocking: both composer scenarios send press and release in the same cell (scripts/tui-tmux/scenarios.mjs:509-521 and 537-584). The new scenario covers the clipped-height fix, not the same-cell and no-drag rules. The composer branch of cancel_click (crates/dim-cli/src/ui/render/fullscreen.rs:666-679), the Drag clear (fullscreen.rs:1172-1176) and the Release same-cell comparison (fullscreen.rs:1222-1233) remain untested. Failure scenario: a regression that accepts a release in another cell or after a drag still passes both scenarios. Fix: after the first click, press a composer cell, release on another cell or drag, type, and assert the insertion stays at the original cursor. Carry it to #2211 or a follow-up.

P3 note: the body says Fixes #2179, but this PR implements only the fullscreen half; #2211's body says it adds the scrollback half and is stacked here. AGENTS.md asks for Refs #N when a PR only advances an issue. Failure scenario: #2210 merges first, GitHub closes #2179, and scrollback still has the reported bug. Use Refs #2179, or merge the stack together.

Cross-PR:

  • #2211 is based on 53df6fc and needs a rebase. Merging it onto d99838e auto-merges the Rust code but conflicts in docs/architecture/tui-e2e.md and scripts/tui-tmux/scenarios.mjs because both add a composer row and a scenario at the same point. Resolve by ordering the new rows and cases. Its scrollback path uses frame.composer without the fullscreen padding, so the new height semantics are correct there.
  • #1881 touches tui.rs at different hunks (2478 and 2752 plus tests) and is dirty against main for its own docs/design/plugins/Report.md conflict, not with this PR. #2174 and #2206 do not touch dim-cli. #2197 touches other tui.rs regions. They merge cleanly with this head. Main has not changed the seven files since the branch point.

Verification: CI on d99838e is green (ci-ok, verify (linux), windows-cli, scripts, macos-native). I ran node --test scripts/tui-tmux.test.mjs (6 passed), node --check on the two tmux scripts, and run.mjs --list (34 scenarios) with isolated HOME, TMPDIR and XDG under the review data directory. I did not build the CLI or run the tmux suite, so the new scenario's own pass is not reproduced here. The body's suite counts (29/32 and 30/33) predate the second scenario; please report the new scenario's run on this head.

Withdrawn: the P2 padded-height finding. The two P3s stay open and do not block.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 69a43e8. The delta fixes the three P3s from the previous review and I found no new defect. CI is green.

The PR places the fullscreen composer cursor at the clicked text cell. The dock maps the press and release through its clipped rows, and the textarea maps the cell with its rendered width and scroll.

Delta review

  • The caller contract is now documented (crates/dim-cli/src/ui/composer/mod.rs:1239-1241): cell.x is a screen column, cell.y and the rows of area are counted from the top of the unclipped dock, clicks outside area do nothing, and the textarea selection is cleared. The producer agrees: dock_action builds the same dock-relative row (crates/dim-cli/src/ui/render/fullscreen.rs:953-957) and frame.composer uses box_top + 1 - frame.dock (crates/dim-cli/src/ui/tui.rs:6590-6595). The README row (crates/dim-cli/README.md:1106) and the suite row (docs/architecture/tui-e2e.md:108) do not contradict it.
  • The reworked scenario (scripts/tui-tmux/scenarios.mjs:533-548) matches the implementation. The SGR encodings decode as Press, Release and Drag (crates/dim-cli/src/ui/terminal/input.rs:492-499). A usable click requires the release cell and the dock action to equal the press (crates/dim-cli/src/ui/render/fullscreen.rs:1222-1230), so press at a and release at b leaves the cursor after X and typing 1 yields abX1cdef. A Drag cancels the composer press (fullscreen.rs:980-985 and 1172-1176), so release at the pressed cell does not click and 2 yields abX12cdef. A key event cancels the pending press (crates/dim-cli/src/ui/tui.rs:536-542 with fullscreen.rs:668-679), so release after typing does not click and 4 yields abX1234cdef. I traced each expected string against the state left by the previous step; none is self-inconsistent or satisfied by a later state.
  • The added characters keep the draft at 11 cells under the 21-cell composer text width at 28 columns, so the following wide-character click keeps its geometry. The 187-character paste wraps past the seven-row textarea viewport (MAX_INPUT_ROWS at crates/dim-cli/src/ui/composer/mod.rs:31, the clamp at 1254-1262), so the first line is scrolled out and the click maps through effective_scroll with the same height (tui.rs:6588-6602). The assertion at scenarios.mjs:553 and the final 中Y界tail wait follow.

P2 from round 1 remains fixed and this delta does not change it: frame.composer records rows.len() before the box padding (tui.rs:6594 versus 6597-6602), so the click height equals the height render_rows rendered with.

Withdrawn P3s

  1. Contract comment for click: fixed at crates/dim-cli/src/ui/composer/mod.rs:1239-1241.
  2. Cross-cell release, drag and typing coverage: fixed at scripts/tui-tmux/scenarios.mjs:533-548.
  3. Fixes #2179 versus Refs: the body now starts with Refs #2179. This PR covers fullscreen. The scrollback change is in #2211. No action needed.

Cross-PR

  • #2211 (ae694e9, based on 53df6fc) conflicts with 69a43e8 in docs/architecture/tui-e2e.md and scripts/tui-tmux/scenarios.mjs when merged together: both add a composer row and a scenario at the same place. It merges cleanly with main. Merge #2210 first, then rebase #2211; the rebase should take this PR's updated inventory row and cancel sequences.
  • #2214 (7451429; 25f270b also checked), #2197 (5fa7a0f; 38d10fe also checked), #2206 (496d4d2), #2174 (1ed1352) and #2212 (cdba6df) merge cleanly with this head and with main. This PR merges cleanly with main (c68dad5).
  • #1881 (ff9825d) conflicts with main and with this head only in docs/design/plugins/Report.md, which this PR does not touch. It is pre-existing, not introduced here.
  • #2172 is a closed issue, not a PR.

Verification

  • CI at 69a43e8: all required checks pass (ci-ok, verify (linux), windows-cli, scripts, macos-native); acp-registry, dependencies, static-checks and web are skipped.
  • Ran with isolated HOME, TMPDIR and XDG and LC_ALL=en_US.UTF-8: node --test scripts/tui-tmux.test.mjs (6 passed), node --check scripts/tui-tmux/scenarios.mjs, and node scripts/tui-tmux/run.mjs --list (34 scenarios: 30 static plus 4 generated; base 32). The body's 32 base and 34 head counts match the tree.
  • The tmux suite itself is unverified here: tmux is not installed (not on PATH, and no /opt/homebrew/bin/tmux, /usr/local/bin/tmux or /usr/bin/tmux), so the runner's preflight cannot start and building the CLI would not enable a run. I did not reproduce the author's 31/34 report; the scenario arithmetic above is static.

No inline comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants