Cell - Ta Changes
A pi package that comes with Ta (on by default; turn it off in Settings → Extensions of the web client): which files each reply changed. When a reply ends, a pill stays above the message box, "N files changed +added −removed" (for the last reply of the conversation that changed files; it goes once they are taken back). It opens to a list above it of the files (name, directory, lines added and removed; files Ta created are marked "new"); a click on a file opens its diff in the workbench on the right (before and after, read-only). "Undo the changes of this reply" at the bottom of the list puts the files back as they were before the reply, and removes those Ta created.
It has three parts, none of which changes the core of Ta:
- pi extension (
pi.extensions,web-src/extension.ts→extension/index.mjs): before theeditorwritetool (also a nested call in a codemode script) writes a file the first time in a reply, it reads what the file holds. When the reply ends (agent_settled, also when it is stopped), it compares each file before and after and sends ata-changescustom message that the conversation does not show (display: false), whosedetailshold the files, their lines added and removed, and the hashes of their contents before and after. The message is for people: the extension leaves it out of what the model reads, in thecontextevent. Files are read and written throughfilesof the answer toTA_HOST_EVENT(the files of the session's execution environment), sossh://directories work as well. - Host (
pi.host,web-src/host.ts→host/index.mjs): keeps the contents before and after by their hash (<agentDir>/changes/<first two>/<hash>; the same contents once; what was not used for 30 days is removed when ta serve starts), and serves the page:latestfor the last change set on the branch of a conversation,readfor contents,revertto undo. Undoing is done by the pi extension of the session; the change sets taken back are listed under therevertedkey of the package's data, the same in every browser. - Web extension (
pi.web,web-src/index.tsx→web/index.js): puts the pill and the list above the message box withui.setWidget(placementaboveEditor): it asks the host for the last change set when a conversation is shown, then followsmessage_endevents; the note of an undo is one line of the conversation (registerMessageRenderer); the diff ispi.ui.DiffEditor.
Undo
- Only while Ta is not working in the conversation, and the conversation is open in the Ta service (a conversation the page shows is).
- When a file changed again after the reply (by hand, by a later reply or by another program), it asks first; only then does it overwrite them, and the later changes are lost. Files already as they were before the reply are skipped.
- After undoing, a line "Took back the changes to N files" is added to the conversation. That message reaches the model: it tells Ta the files are back, and to read them again before changing them.
Limits
- Files written by the
editandwritetools, and, with another coding agent as the model (CodeBuddy Code, Claude Code, Codex; see ta-agents), those it writes with its own editing tools: ta-agents emitsTA_FILE_WRITE_EVENTonpi.eventsas soon as it knows which file a call changes (mostly before it runs), with the text before when the agent sends it (an ACP diff), which then counts; otherwise the file is read then. Files changed bybashand other commands are not listed, and not taken back. - Lines added and removed are counted as
git diff --statcounts them. Binary files count no lines and show no diff, but can be taken back. Files larger than 4 MB are counted, but their contents are not kept: they cannot be taken back. - Only in the Ta service (ta serve);
taalone (in a terminal) records nothing.