zot/internal/agent/modes
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
..
telegram feat(telegram): mirror tui prompts into telegram thread 2026-04-20 09:33:03 +02:00
btw_dialog.go fix(tui): three cursor/alignment fixes in the editor and /help 2026-04-19 20:25:34 +02:00
changelog_dialog.go feat(tui): show github release notes once after upgrading 2026-04-19 16:12:13 +02:00
confirm_dialog.go fix(cli): load extensions in print and json modes too 2026-04-19 20:00:36 +02:00
dialog_frame.go fix(tui): cell-aware width math for dialog header rules + add /btw 2026-04-19 13:47:39 +02:00
help.go fix(tui): three cursor/alignment fixes in the editor and /help 2026-04-19 20:25:34 +02:00
interactive.go feat(tui): collapse multi-line pastes to a placeholder token 2026-04-21 08:47:36 +02:00
json.go feat(tui): live-stream file body during write/edit tool calls 2026-04-20 08:37:14 +02:00
jump_dialog.go tui: /jump to scroll to past turns, render cache for long transcripts 2026-04-18 12:22:16 +02:00
login_dialog.go initial commit 2026-04-17 20:36:38 +02:00
logout_dialog.go feat(auth,tui): dark login pages + /logout picker 2026-04-19 20:14:22 +02:00
model_dialog.go add telegram bot bridge 2026-04-18 09:15:46 +02:00
print.go initial commit 2026-04-17 20:36:38 +02:00
session_dialog.go fix(tui): scroll the /sessions picker when the list overflows 2026-04-20 16:11:49 +02:00
session_ops_dialog.go feat(session): /session export + import with portable .zotsession file 2026-04-20 10:04:33 +02:00
session_tree_dialog.go feat(session): /session fork + /session tree 2026-04-20 11:10:56 +02:00
skills_dialog.go feat: skills — reusable instructions discovered from SKILL.md files 2026-04-19 14:32:30 +02:00
slash_suggest.go chore(tui): reorder slash catalog 2026-04-20 11:41:45 +02:00
spinner.go tweak(tui): stable spinner phrase per turn 2026-04-20 16:00:10 +02:00
telegram_dialog.go feat(tui): /telegram connect | disconnect | status 2026-04-20 09:18:04 +02:00
update_banner.go tweak(tui): update banner emits the short domain install command 2026-04-20 17:47:58 +02:00
welcome.go tui: show binary version in the welcome banner for 1 second 2026-04-19 13:22:10 +02:00