Skip to content

fix(tui): detach recalled history when removing an attachment or deleting in vim - #7143

Merged
Hmbown merged 3 commits into
codewhale-hq:mainfrom
Lstarsky0:fix/composer-edits-detach-history
Oct 30, 2026
Merged

Hmbown merged 3 commits into
codewhale-hq:mainfrom
Lstarsky0:fix/composer-edits-detach-history

Conversation

@Lstarsky0

Copy link
Copy Markdown
Contributor

What and why

After Up recalls an entry from prompt history, an edit is supposed to detach it: the note on insert_str explains that otherwise "the next Up/Down silently discards" the edit. Typing, Backspace and Delete, the word and line deletes, and kill and yank clear it, and e7e0a4d did the same for paste and the external editor. Among the edits that remove text, three don't: removing a selected attachment, and vim Normal-mode x and dd. After any of them, Up/Down carry on from the old index, and going back to that entry brings it back as it was saved.

Launch composer, TERM_PROGRAM=iTerm.app, one key at a time, with a history of first entry and a two-line entry that carries an image attachment. Type draft, Up to recall the attachment entry, Up, Home, Up to select the attachment, then Backspace (status: Removed attachment: shots/a.png). Before:

Backspace  ❯ what is in this picture
Up         ❯ first entry
Down         [Attached image: shots/a.png]
           ❯ what is in this picture

After:

Backspace  ❯ what is in this picture
Up           [Attached image: shots/a.png]
           ❯ what is in this picture
Down       ❯ what is in this picture

With composer_vim_mode = "vim" and a history of first entry, second entry: k, 0, x gives econd entry. Then k, j showed first entry and second entry as saved; now k recalls second entry and j comes back to econd entry. dd on the second line of a recalled two / lines entry leaves two; k, j brought back two / lines and now come back to two.

Each of the three now calls clear_input_history_navigation() like the other deletes. For the attachment it goes after the check that one is selected, because every Backspace and Delete calls remove_selected_composer_attachment first. As with typing into a recalled entry, the draft from before the first Up (draft above) is no longer what Down returns to; the edited entry is.

Issue

No-Issue: removing an attachment or vim x/dd on a recalled history entry is undone by the next Up/Down; I searched and found no issue for it

How I tested it

  • Ran a debug build of this change and one of main at 3690f9c in a pseudo-terminal with an empty HOME, a seeded composer_history.jsonl and TERM_PROGRAM=iTerm.app, sending one key at a time on the launch composer; the rows above come from those runs.
  • cargo nextest run -p codewhale-tui --lib: 13908 of 13912 passed, with the 477 vim, composer, attachment and history tests among them. The 4 failures are plugin import tests (three in plugins_dsh_tests, plus plugins_skill_tests::dsh_packages_import_through_the_reviewed_install_and_update_flow, all "composition reviewer is unavailable"); the same 4 fail on main at 3690f9c without this change.
  • cargo fmt --all -- --check, cargo clippy -p codewhale-tui --all-targets --all-features with CI's flags (also on 1.99), cargo check -p codewhale-tui --all-targets and cargo +1.89.0 check -p codewhale-tui: clean.

Checklist

  • One focused change, on 3690f9c; it merges cleanly into current main
  • cargo fmt --all passes, and tests cover new or changed behavior
  • If this adds or changes a user-facing feature, I updated its docs and its row in docs/features.toml (cargo test -p codewhale-tui --test feature_registry checks it) — n/a

…ting in vim

Removing a selected attachment, vim `x` and vim `dd` edited the composer
without clearing the recalled history entry, so the next Up/Down went on
from the stale index and silently brought the original entry back. The
other deletes already clear it (see the note on insert_str).

Signed-off-by: Lstarsky0 <59827030+Lstarsky0@users.noreply.github.com>
@Lstarsky0
Lstarsky0 requested a review from Hmbown as a code owner October 29, 2026 09:54

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added the contribution-gate Author not yet in .github/APPROVED_CONTRIBUTORS; a maintainer grants access with /lgtm label Oct 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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 ⚠️ Failed 2026-10-29T10:02:36.237795Z
We couldn’t complete this review. Comment @codex review to try again.
4694475 PR opened
ℹ️ 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.

@Hmbown
Hmbown enabled auto-merge (squash) October 29, 2026 12:11

@Hmbown Hmbown 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.

thank you so much - help on the up / down arrow behavior is soooo appreciated!

@Hmbown
Hmbown merged commit 287b5eb into codewhale-hq:main Oct 30, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution-gate Author not yet in .github/APPROVED_CONTRIBUTORS; a maintainer grants access with /lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants