Skip to content

Placeholder: composer undo follow-up - #11

Draft
astral303 wants to merge 9 commits into
fix/tui-composer-undo-redofrom
fix/tui-composer-undo-redo-with-paste-burst-grouping
Draft

astral303 wants to merge 9 commits into
fix/tui-composer-undo-redofrom
fix/tui-composer-undo-redo-with-paste-burst-grouping

Conversation

@astral303

@astral303 astral303 commented Aug 16, 2026 •

Copy link
Copy Markdown
Owner

Status

This pull request is intentionally empty.

The paste-burst grouping work originally carried here was folded into #10 so the unified composer history is correct as a standalone change. The empty commit preserves this branch and PR as a placeholder for later composer-undo follow-up work without maintaining a second implementation or temporary history model.

@astral303
astral303 force-pushed the fix/tui-composer-undo-redo-with-paste-burst-grouping branch from 09447e6 to 5ce8a50 Compare August 16, 2026 20:30
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch from 4534617 to 0036105 Compare August 16, 2026 20:30
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo-with-paste-burst-grouping branch from 5ce8a50 to 9fa720a Compare August 16, 2026 23:56
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch from 0398516 to 4f06916 Compare August 21, 2026 18:00
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo-with-paste-burst-grouping branch 2 times, most recently from fdad0dc to ad9d565 Compare August 23, 2026 21:56
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch 2 times, most recently from 43bb812 to d2fa1db Compare August 25, 2026 17:46
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo-with-paste-burst-grouping branch from ad9d565 to 675fa98 Compare August 25, 2026 17:46
Composer edits can now be reversed as complete draft states without losing
cursor placement, paste payloads, mentions, or attachments.

- Replace the private `ComposerDraft` with
  `EditableDraft { content, cursor }`. Comparing `EditableDraftContent`
  separately prevents cursor-only motion from recording an edit or
  invalidating redo, while restored drafts retain their cursor.
- Rename the existing cross-screen `ComposerDraftSnapshot` to
  `StartupDraftSnapshot`. It carries startup history and activity state and
  is not an undo record.
- Keep bounded undo and redo history on `ChatComposer`, with 100-entry and
  32 MiB limits, and clear it when submission, recall, or programmatic
  replacement starts a new draft lifecycle.
- Add composer-scoped shortcuts, using Ctrl+Z on Windows and Alt+Z on Unix
  so terminal job control remains available.
- Cover complete-state restoration, edit order, Ctrl+C recovery, redo
  divergence, lifecycle resets, keymap fallback, and history limits.
Nested key handlers can now tell the outer dispatcher when they already
changed undo history, and retained-byte accounting fails loudly if it drifts.

- Rename the internal revision to `mutation_epoch` and advance it for every
  record, clear, undo, and redo. An unchanged epoch leaves the outer
  dispatcher responsible for recording the edit.
- Route pops, limit eviction, and stack clearing through checked byte removal
  instead of saturating subtraction, so corruption cannot silently weaken
  the memory cap.
- Derive fallback conflict detection from typed default undo and redo bindings
  while retaining exact terminal compatibility aliases.
- Cover duplicate outer recording after a nested history mutation and
  retained-byte underflow.
Shell-style Up/Down now reuses an adjacent undo or redo state when the
recalled draft has the same complete content. Unrelated prompts still
establish a new baseline, so navigation itself never becomes an undo step.

- Carry Older/Newer through HistoryNavigation so cached and asynchronous
  recall share one transition. Rename HistorySearchDirection because it
  already serves normal navigation.
- Compare complete EditableDraftContent but restore the exact stored
  snapshot, preserving cursor and rich state without a second buffer.
- Cover Ctrl+C -> Up -> Ctrl+Z, symmetric Down/redo, unrelated and
  equal-text rich-state mismatches, and asynchronous lookup.
Vim commands and ordinary composer edits now share one bounded undo/redo lineage, so undo can cross mode switches without maintaining two stacks.

- Keep Vim state as a pending transaction coordinator and commit complete commands or insert sessions into ComposerUndoHistory.
- Route Vim u and composer undo/redo through the same rich-draft restoration path while preserving repeat and search state.
- Suppress ordinary per-key records when Vim completion owns the action boundary, preventing duplicate history entries.
- Cover mixed-mode traversal, mode switches, and active insert-session undo alongside the upstream Vim behavior.
Retro-captured paste bursts no longer leave per-character undo records that
can resurrect only part of the paste.

- Remove the detector-reported number of provisional edit records when an
  existing retro-capture path reclassifies typed characters as one paste,
  then let the normal paste flush record the final action once.
- Advance the history mutation epoch during removal so the outer dispatcher
  does not recreate a discarded entry.
- Keep paste thresholds, timing, and terminal support unchanged.
- Cover whole-paste undo and redo through the existing detector.
Retro-capture now validates the exact undo suffix before removing provisional
entries, so a stale detector count cannot consume older history.

- Pair the detector count with the complete pre-capture `EditableDraft` and
  require the first candidate suffix entry to match it. A missing or stale
  boundary leaves history unchanged.
- Centralize textarea removal, history validation, and paste-buffer seeding in
  one transition shared by the ASCII and non-ASCII capture paths.
- Advance the mutation epoch only after validated removal, keeping the outer
  dispatch transaction coherent.
- Cover invalid boundaries, preservation of an older undo entry, non-ASCII
  retro-capture, and a second undo that cannot resurrect the paste prefix.
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo-with-paste-burst-grouping branch from 675fa98 to daf618e Compare September 1, 2026 14:33
@astral303 astral303 changed the title Group recognized paste bursts into one undo step Add non-Vim composer undo and unify history across modes, grouping recognized paste bursts into one undo step Sep 1, 2026
@astral303 astral303 added the code-reviewed Code review completed label Sep 1, 2026
Unified undo now preserves existing keymaps and history navigation while
grouping detected paste bursts without assuming per-key history exists.

- Prune only the new undo/redo defaults when an overlapping configured chord
  owns their prefix, and keep snapshots independent of platform modifiers.
- Restore history-recalled drafts at the navigation boundary and move
  cross-component coordination into a focused module.
- Let active Vim transactions own retro-capture; fall back to ordinary input
  when provisional history is unavailable, with regressions for both paths.
Paste-burst grouping now lands atomically in PR #10 because the core undo PR
must be correct on its own. This empty commit keeps the stacked branch and PR
available for later follow-up work without carrying a second implementation.
@astral303 astral303 changed the title Add non-Vim composer undo and unify history across modes, grouping recognized paste bursts into one undo step Placeholder: composer undo follow-up Sep 1, 2026
@astral303
astral303 marked this pull request as draft September 1, 2026 23:23
Advance the placeholder head after its stacked base moved so GitHub recomputes
the intentionally empty comparison against the updated PR #10 branch.
@astral303 astral303 closed this Sep 1, 2026
@astral303 astral303 reopened this Sep 1, 2026
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch 3 times, most recently from 39bf86e to 9754f2a Compare September 4, 2026 00:47
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch 2 times, most recently from 09a14ea to ca8421c Compare September 10, 2026 02:55
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch from ca8421c to bfee594 Compare September 18, 2026 03:32
@astral303
astral303 force-pushed the fix/tui-composer-undo-redo branch 2 times, most recently from a9156d1 to 8b23268 Compare October 3, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviewed Code review completed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant