Skip to content

Sonny composer: Shift-Enter starts a line; mouse selection to type over or delete - #297

Merged
lydakis merged 3 commits into
mainfrom
claude/project-thread-z2u3dt
Oct 29, 2026
Merged

lydakis merged 3 commits into
mainfrom
claude/project-thread-z2u3dt

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

Shift-Enter. The composer already matched Shift-Enter, but Sonny never asked the terminal to report it, so it came in as a plain Enter. Sonny now asks for the kitty keyboard protocol the way Codex does (codex-rs/tui/src/tui/keyboard_modes.rs): unambiguous escape codes plus alternate keys, and no release events (CSI > 5 u). The main and alternate screens each keep their own stack, so every push is popped on the screen it was made on: at startup and exit, in own_screen when switching to or from the full screen, and around a side chat. Herdr passes this through, since it tracks each pane's kitty flags and encodes keys with Ghostty's encoder. A terminal that doesn't know the protocol ignores it, and Alt-Enter and Ctrl-J still work there.

Selecting in the composer works on the full screen, like Codex's composer (bottom_pane/textarea/mouse.rs):

  • A click puts the cursor there. A drag selects and copies, as the conversation already does. Two clicks select a word and three select a line.
  • Typing replaces the selection, and Backspace or Delete removes it. Ctrl-W, Ctrl-U and Ctrl-K cut it so Ctrl-Y can paste it back. Left and Right go to the ends of the selection, and Esc drops it.
  • Ctrl-C copies the selection instead of throwing away the draft.

The selection lives in prompt::Prompt as an anchor that runs to the cursor. The draw records where the composer's rows are, so a click can find its character even when the composer is scrolled.

selection

Testing

  • cargo test -p sonny: 317 passed. New tests cover typing over and deleting a selection, moving off it, finding the clicked character, word and line, and an app test for Shift-Enter followed by drag, Backspace, double-click and typing. cargo clippy and cargo fmt are clean.
  • Live check: ran the real sonny in a pty against a local daemon and rendered the screen. CSI 13;2u started a new line. Dragging over "two" and pressing Backspace left one three. Double-clicking "three" and typing replaced it. Pushes and pops balanced (3 of each).

… to type over or delete

Sonny matched Shift-Enter but never asked the terminal to report it, so
it arrived as a plain Enter. It now pushes the kitty keyboard protocol's
flags as Codex does (unambiguous escape codes, alternate keys, no release
events) and pops them on the screen each push was made on: main,
alternate, and around a side chat.

On the full screen the composer takes the mouse, as Codex's does: a
click places the cursor, a drag selects and copies, two clicks select a
word and three a line. Typing replaces the selection, Backspace/Delete
delete it, Ctrl-W/U/K cut it for Ctrl-Y, Left/Right go to its ends, Esc
lets go, and Ctrl-C copies it rather than discarding the draft.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD6xFctbdWaQRSN9Ab
@lydakis lydakis self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T23:40:52.360936Z 9fbde03 New commits
🔒 Security Review ✅ Completed 2026-10-28T23:41:53.863770Z 9fbde03 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f968d8501c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/main.rs Resolved
A press that moves the cursor can scroll a long draft; the release then
resolved against the new rows and selected the lines between. The gesture
now keeps the composer's drawn place from the press until the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD6xFctbdWaQRSN9Ab

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f4b09cef1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/main.rs Resolved
A drag on a long draft scrolled the composer to follow the cursor, so
the pointer moved over other text than it selected. The composer now
draws from the row the press found until the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD6xFctbdWaQRSN9Ab
@lydakis
lydakis merged commit d5b9657 into main Oct 29, 2026
3 checks passed
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.

2 participants