zot/internal/tui
patriceckhart 51fd11fce6 feat(tui): collapse multi-line pastes to a placeholder token
A 200-line paste (log, stack trace, config blob) used to expand
the editor to 200 visible rows, burying the rest of the tui and
making the prompt awkward to edit. Now a paste of 3+ lines is
replaced in the editor with a short token like

  [pasted text #1 +56 lines]

while the full body is stashed behind the scenes and expanded
back in right before the turn goes to the agent. Single-line
and two-line pastes fall through to the old inline insert path
(drag-dropped file paths, short snippets) so those still work
as before.

Implementation

  Editor gained two private fields:
    - pastes   map[int]string   full bodies keyed by id
    - pasteSeq int               monotonic id counter

  KeyPaste branch: on content with >= 2 newlines, allocates the
  next id, stores the raw body, inserts the placeholder token
  at the cursor. Everything else stays on the existing
  quotePastedFilePaths path.

  Editor.Value()       returns what's visible (placeholder).
  Editor.SubmitValue() new method: runs pastePlaceholderRE over
                       the visible text and swaps each match
                       for its stored body. Called once at
                       submit time; non-destructive so history
                       recall (up-arrow) still shows the
                       placeholder form, not the replay.

  Editor.Clear()       drops the pastes map + resets pasteSeq
                       so ids from a previous turn can't leak.

  SetValue()           same reset: pastes map is tied to the
                       visible text and a SetValue replaces it.

  interactive.go       the one caller that reads the editor to
                       build a prompt now reads Value() for the
                       history entry and SubmitValue() for the
                       string that goes to the agent.

Tests

  paste_collapse_test.go covers:
    - placeholder shape + SubmitValue expansion
    - single-line and two-line pastes skip the collapse path
    - two separate pastes get distinct ids, both expand
    - Clear() resets the map + counter

  Tweaked the pre-existing TestEditorCursorAfterMultilinePaste
  and TestEditorCursorAfterLongPasteWithWrap to use Editor.Insert
  directly so they keep testing wrap / cursor math rather than
  accidentally exercising the new collapse path.
2026-04-21 08:47:36 +02:00
..
editor.go feat(tui): collapse multi-line pastes to a placeholder token 2026-04-21 08:47:36 +02:00
highlight.go chore: scrub stray "pi" references from source comments 2026-04-19 17:06:45 +02:00
image.go fix ci: portable syscall.Select via x/sys/unix; gofmt pass 2026-04-18 10:55:42 +02:00
input.go add collapsible code blocks 2026-04-18 10:30:29 +02:00
markdown.go feat(tui): context diffs + framed tool blocks + paced streaming 2026-04-20 15:50:39 +02:00
partialjson.go feat(tui): live-stream file body during write/edit tool calls 2026-04-20 08:37:14 +02:00
partialjson_test.go feat(tui): live-stream file body during write/edit tool calls 2026-04-20 08:37:14 +02:00
paste_collapse_test.go feat(tui): collapse multi-line pastes to a placeholder token 2026-04-21 08:47:36 +02:00
quote_paste_test.go tui: quote drag-dropped file paths in the input editor 2026-04-19 13:01:37 +02:00
render.go tui: quote drag-dropped file paths in the input editor 2026-04-19 13:01:37 +02:00
resize_unix.go fix ci: portable syscall.Select via x/sys/unix; gofmt pass 2026-04-18 10:55:42 +02:00
resize_windows.go initial commit 2026-04-17 20:36:38 +02:00
statusbar_test.go feat(ext): phase 4 - full-event interception, arg rewrites, /reload-ext 2026-04-19 17:02:04 +02:00
terminal.go initial commit 2026-04-17 20:36:38 +02:00
theme.go fix ci: portable syscall.Select via x/sys/unix; gofmt pass 2026-04-18 10:55:42 +02:00
view.go tweak(tui): ctrl+c no longer interrupts a running turn 2026-04-20 18:23:59 +02:00
wrap_test.go feat(tui): collapse multi-line pastes to a placeholder token 2026-04-21 08:47:36 +02:00