Repository navigation
feat(tui): /export and /copy (#463) - #568
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
Part of #463. /copy sends the last assistant answer as an OSC 52 sequence (base64 payload only, 64 KiB cap); /export writes the transcript as .html or .jsonl under the workspace (jailed, never overwrites).
Replace the note that the format was written from memory with the sources read on 2026-11-11 (Ghostty and foot documentation) and say plainly that xterm's own ctlseqs page was not read directly. Also record that a payload that is not valid base64 clears the clipboard in some terminals, which is why the module never sends an empty or invalid one.
ajianaz
force-pushed
the
feat/463-export-copy
branch
from
November 11, 2026 07:34
60032c9 to
de81d04
Compare
ajianaz
added a commit
that referenced
this pull request
Nov 11, 2026
[tui.keys] in the user config rebinds ten convenience actions (tool output, reasoning, model picker, cycle model, cycle thinking, newline, queue follow-up, pop queue, history) to a key spec or a list; the default keymap is the keys the TUI always had. y, n, Esc, Ctrl+C, Enter, Backspace, Tab and every bare character are never rebindable, and at an approval prompt only y, n, Esc and Ctrl+C act whatever the keymap says. A project config cannot set keys (ignored with a warning), and an invalid keymap falls back to the default with one startup note. Closes #463 with #567, #568 and #569.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 1 of #463 (later TUI polish): the TUI commands
/export [path](HTML or JSONL) and/copy(last answer). Part of #463; the issue stays open for themes and keybindings (/forkand/treemerged in #567).Why
A terminal session should be able to hand its transcript or its last answer to the user without a native clipboard dependency (the TUI has none, decision of #560) and without weakening the guarantees that provider text never reaches the terminal as escape sequences and that the session log is append-only.
Changes
/copy: the host returns the last assistant answer (HostCmd::LastAnswer->HostReply::Answer(Option<String>), newest non-empty assistant message in the log). The TUI sends it as one OSC 52 sequence,ESC ] 52 ; c ; <base64> BEL, built inclipboard::osc52and written inclipboard::emitonly. The payload is base64 only, so answer text cannot inject escape bytes. Cap: 64 KiB of raw answer; above it the note points to/export. With no answer, nothing is sent. The note says what was attempted (sent N characters to the terminal clipboard; needs OSC 52 support, tmux needs set -g set-clipboard on) and never that it worked./export [path](HostCmd::Export->HostReply::Path, newtole-cli/src/export.rs): format by extension..jsonlis the entries exactly as stored, one JSON object per line, read from the in-memory replay (the session file is not touched)..htmlis a self-contained page: all text escaped, no script, no external resource,<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'">, light and dark. Other extensions are refused with the supported list. Default path:<workspace>/.tole/exports/<session id>.html(only that directory is created, level by level with a jail check each time)..., outside absolute paths and symlinked directories refused); the file is opened withcreate_new, so an existing file or a symlink at the target (dangling or not) is never overwritten or followed; created0600on Unix./imageand the other commands (one rule for every command;/exportcould read safely during a turn but would be the only command that did).TuiSession::with_workspace(wired from the resolved workspace root intui_command),last_answer,export.docs/tui.md(commands table, new section including the secrets warning, Not implemented, host seam), CHANGELOGUnreleased, README status line,docs/epics.md, and a shortdocs/threat-model.mdsection.clipboard.rsheader: the Ghostty and foot documentation both giveESC ] 52 ; Pc ; Pd ST, withcfor the clipboard andPdas base64. Ghostty documents that aPdthat is not valid base64 clears the clipboard, which is why an empty or invalid payload is never sent. xterm's own ctlseqs page was not read directly (its host is outside the session network allowlist); the xterm side rests on search excerpts of that document and on the charmbraceletx/ansidocs, which list both theSTand theBELterminator. BEL is kept for the widest compatibility, and the e2e test pins the exact bytes.developafter feat(tui): /fork and /tree over session forks (#463) #567 merged. Both PRs had raised theCOMMANDStable inmenu.rsfrom 9 to 11 entries, so the merged table has 13; git could not flag that as a conflict and the build failed until the last commit (fix(tui): size the command table ...) corrected the length. The other conflicts (tui_e2e.rs, CHANGELOG, README status line,docs/epics.md) kept the entries of both PRs.Testing
developat05fd947:cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warningsandcargo check -p tole-cli --no-default-featuresclean;cargo test --workspace: 1282 passed, 0 failed.ESC/BEL/]52;text cannot break out), size cap (at cap allowed, over refused), command parsing and notes with a fake host, HTML escaping (<script>alert(1)</script>,"onload="), CSP meta, no<script, JSONL equals the stored entries, overwrite refusal, jail refusals (../x.html, outside absolute, symlinked dir, file symlink target,.tolesymlink), unknown extension, host-level test that the session file is unchanged.crates/tole-cli/tests/tui_e2e.rs:/copy(the OSC 52 sequence with the right base64, also for an answer containing ESC/CR, no raw bytes on the pty, no claim of success) and/export(file written, refused on the second run,../escape.htmlrefused,.jsonlexport). The existingtui_never_passes_escape_sequences_from_provider_textstill passes.create_newwith create+truncate (4 failed), emitting raw text instead of base64 (3 clipboard unit tests failed).corais not available in this environment, so the staged diff was reviewed by hand (escape injection, path handling, error paths); the CI Cora Review is the gate.