Guides
Follow the editor
Use follow mode to edit the code in your editor while Tiza shows it. Tiza reloads the code each time that you save the file. It keeps your annotations on their text.
Tiza is a terminal tool that draws annotations on code. To install it, see Install.
Start and stop
- Open the file with
--follow, for exampletiza src/main.rs --follow. In Tiza, you can also type:follow on. - Edit the file in your editor and save it. Tiza reloads the code about 120 ms after the last write.
- Read the state of follow mode in the status bar.
- Type
:follow offto stop.
| Status bar | Meaning |
|---|---|
⟳ following | Follow mode is on, and no reload occurred yet. |
⟳ following · last HH:MM:SSZ | Follow mode is on. This is the time of the last reload. |
⟳ following (file removed; waiting) | The file is not on disk, and Tiza waits for it. |
⟳ paused | Follow mode is on, and a code.patch is applied at this step. A save waits. See Moves. |
⟳ paused · changed | Follow mode is paused, and a save waits to load. |
⟳ paused (file removed) | Follow mode is paused, and the file is not on disk. |
| Command | What it does |
|---|---|
tiza FILE --follow | Opens the file with follow mode on. |
:follow on | Starts follow mode. |
:follow off | Stops follow mode. |
:follow | Shows the state: the number of reloads and the time of the last one. |
u | Undoes the last reload, or the last change. |
To use Tiza next to Zed, see Tiza from Zed.
What happens to annotations
Tiza keeps each annotation on the text that it points at. The rule is the same as for a paste.
- Lines that stay the same keep their annotations, in order. A note on the second
}stays on the second}. - In a line, a span stays on the same occurrence of its text.
- A line that you rewrite in place keeps its note and the spans whose text is still there.
- When you rewrite several adjacent lines together, the lines pair one to one. An example is a parameter that you rename on the signature and on the line that uses it.
- A block that you move keeps its annotations when their line is unique and moves 50 lines or fewer. A box, callout or spotlight on the block moves with it.
- This rule works line by line. Tiza drops a note on a moved line that is not unique, such as
}. - When you edit or move one edge line of a box, callout or spotlight, it keeps its height from the edge that stays. It does not grow toward the line that moved.
- A box, callout or spotlight grows when you insert lines between its two edges.
- A formatter that splits or joins a line, such as rustfmt, moves the span to the line that now has its text.
- Tiza drops an annotation when its text is gone. It never moves the annotation to another copy of the text.
- When two identical adjacent lines become one line, the annotations of both stay on the line that is left.
Undo a reload
uundoes the whole reload. It brings back the annotations that the reload dropped.- A reload that changes no annotation adds no undo step. Thus, after an undo in your editor, one
uin Tiza brings back the dropped annotations. - After
u, the message names what it undid, for exampleundone: reload #N,undone: note IDorundone: N annotations cleared. - When
ubrings back code that the file does not have now, follow mode turns off. See When follow mode turns off.
When follow mode turns off
These cases turn follow mode off. After each one, a save in the editor does not change the code on screen.
| Case | Message |
|---|---|
| You paste code. | follow off: the code is pasted, not FILE; :follow on reloads FILE |
| An undo or a redo brings back code that the file does not have now. | follow off: the code on screen is not FILE; :follow on reloads FILE |
You type :embed. | code frozen inside the .tiza; follow off: edits on disk no longer reach the screen (:link and :follow on to resume) |
You type :follow off. | follow off |
Follow mode also turns off in three more cases. The message gives the reason.
-
An agent sends another document with
scene put. -
The file watcher cannot start.
-
:linkor:refnames a file that Tiza cannot follow. -
Tiza keeps the pasted code. A save in the editor does not replace it.
-
A paste of the exact content of the file keeps follow mode on. With follow mode off, that paste keeps the code reference to the file.
-
When
ubrings back the code of the file, the message isfollow is off: :follow on reloads FILE. -
When the code on screen is not the code of the file, the document keeps it as embedded code. This occurs after a paste of other code, or after an undo or a redo to code that the file does not have now.
Turn follow mode on again
:follow onloads the file over the code on screen. This is one reload.uundoes it.- The document keeps the name of the file in
"follows": {"file": "main.rs"}. Thus:follow onand--followreload the file also after you quit and open the document again. :embed,:linkand a reload back to the file removefollows.- A document with embedded code and no
followshas no file to follow. Type:link PATHfirst.
Messages
The messages of follow mode are in Messages of follow mode.
Special cases
Moves
Only a code.patch move changes the text of the code. A cursor, select, wait, code.link or scroll move does not change the text. Thus a save at a step where no patch is applied loads at once, also when other moves are applied. The step keeps the file that its code.link shows, and step 0 shows the new code.
Follow mode is paused at a step where a code.patch is applied. A patch is applied when its at_step is that step or an earlier step. The patch can change any file of the document.
- The bar shows
⟳ paused. - A save in the editor does not load. It is a change that waits, and the bar shows
⟳ paused · changed. Only the newest save counts. - The first change of a pause gives one message:
step N loads the change to FILE. Step N is the last step before the first patch. The next saves of the same pause give no message, except when the file comes back after it was removed or could not be read. Then the message comes again. - While a change waits, the document keeps the code on screen as embedded code. With autosave on, if you quit, the document opens as you saw it. With autosave off, that code is not saved: see Quitting.
- At step N or an earlier step, Tiza loads the change at once. This is one reload.
uundoes it.
- The moves apply again on the new code. A move that does not match the new code is stale: Tiza skips it and tells you one time. In a
loop, this message comes one time for each change, not at each loop. - A jump to step N or earlier, such as
:goto 0orstep.goto, loads the change before the reply. - When you save the file back to the code on screen, no change waits. No new message comes, and the message about the change goes from the bar. When Tiza could not read the file before, the message is
FILE can be read again; following it. - When the file is removed during a pause, the bar shows
⟳ paused (file removed). When the file comes back with other code, that code is the change that waits. - When the file is not valid UTF-8, the message
cannot follow FILE: not valid UTF-8 (keeping the previous content)comes one time. That file is not a change. At step N, Tiza reads the file again. - In presentation mode, no message comes. When you leave presentation mode, the bar shows the state.
:follow offdrops a change that waits. The code on screen stays, as embedded code.:follow onfollows the file again: at a step where a patch is applied, the file is again a change that waits. The message isfollow off: the change to FILE is not loaded. When an agent turns follow mode off, the message about the change goes from the bar.- A save while you type a
:command, select text withvorV, have a panel open, or while a move types its code, waits until you finish.
A document opens at its saved step, or at step 1 when it has none. When a patch is applied at that step, --follow and :follow on start follow mode paused. The message is following FILE; step N loads a save. When the file has other code than the screen, that code is the change that waits.
Tiza follows only the main file. Tiza reads a file that a code.link shows when the document opens. A save of that file does not load.
Link another file
:link PATHor:ref PATHat step 0 to a file with other code loads the code of that file, as a reload does. The screen always shows what the saved document will show.- When the file has the same code as the screen, Tiza only references the file. There is no reload and no undo step.
- When follow mode is on, follow mode moves to the new file. A save of the old file does not reload anything.
umoves follow mode back. - Tiza refuses a file that a
code.linkshows already, because its annotations belong to that view. :linkwith no path changes nothing when the document references its file already.
An empty file
Some editors save a file with two writes. The first write is empty. When Tiza reads an empty file, it waits 120 ms more and reads the file again. A file that stays empty reloads as empty code. u brings the annotations back.
Agents and follow mode
Agents control follow mode through the socket methods follow.set and follow.status, and the MCP tool set_follow. follow.status gives enabled, path, reloads, reads, hash, last_reload, missing, paused, pending, resume_step and reason.
-
The reply of
follow.setcomes at once, for examplefollowing FILE. The file watcher starts on a thread of its own. -
A save while the watcher starts loads when the watcher runs.
-
pausedistrueat a step where acode.patchis applied. Thenresume_stepgives step N, where a change that waits loads.pendingistruewhen a change waits. -
statusgives the samepaused,pending,resume_step,readsandhashin itsfollowfield while follow mode is on. An MCP agent reads them with the toolstatus. -
reasontells why a save does not load now, or why follow mode is off.reasonis absent when no reason applies. -
hashis the sha256 of the file as Tiza last read it. To know that Tiza read your save, comparehashwith the sha256 of the file that you saved. When they are the same, Tiza read your save.reloads,pendingand the status bar tell what Tiza did with it. -
When you save the same bytes again,
hashdoes not change. Then wait untilreadsincreases.shasum -a 256 main.rs # or: sha256sum main.rs tiza api follow.status -
hashisnullwhen Tiza could not read the file, for example when the file is removed. A file that is not UTF-8 has a hash: Tiza read it, and the status bar shows the error. -
readscounts the reads of the file. It increases also when a save changes nothing, for example a save of the same bytes or of other line ends. When the watcher starts afterfollow.set, Tiza reads the file one more time. -
Saves that come close together can give one read. Wait until
readsis more than before, not for one read for each save. -
While the presenter types a
:command, selects text or has a panel open, or while a move types its code, a save waits. Tiza reads it when they finish. -
With follow mode off,
follow.statushas noreadsand nohash. The counts start again at eachfollow on. -
scene.getgivesfollows. Ascene.putthat sendsfollowssets the file that:follow onreloads. -
A
scene.putof the open document withoutfollowskeeps the file that the open document follows. -
While follow mode is paused, a
scene.putof the code on screen works, also when a change waits. Thusscene.getand thenscene.putof the same copy work. The code on screen does not change, and the change that waits still loads atresume_step. The other parts of the document, for example the annotations, change as you sent them. -
While a change waits, and while the followed file is missing or cannot be read, a
scene.putcannot changefollows: that is the file that follow reads next. Sendfollowsasscene.getgives it, or leave it out. The same file written another way, for example./main.rsor its absolute path, is the samefollows. -
When a
scene.put,scene.patchormove.deleteleaves nocode.patchapplied at the step on screen, the change that waits loads before the reply, as at a step change. When a change of the moves moves the resume step and the change still waits, the notice on the bar names the step where it loads now, if the notice is still there. -
While a change waits, a
scene.putwith other code fails, also with the code of the file on disk. The code on screen is not what the file holds now, and the pause stops new code at a step with acode.patch. The error gives the step where the file loads. To change the code, edit the file.
reason | When |
|---|---|
paused; loads at step 0 | Follow mode is on, and a code.patch is applied at the step on screen. |
the code is pasted, not FILE; :follow on reloads FILE | Follow mode is off after a paste. |
the code is the paste again, not FILE; :follow on reloads FILE | Follow mode is off, and an undo or a redo brought back a paste. |
the code on screen is not FILE; :follow on reloads FILE | Follow mode is off, and the file does not have the code on screen now. An undo or a redo brought back that code, or :follow off dropped a change that waited. |
cannot watch DIR: ERROR | Follow mode is off, because the file watcher could not start. |
- When the first patch is at step 2 or later, the first row ends with
loads at step M or earlier.Mis the step before the first patch. - When the file holds the code on screen again, follow mode is off and
reasonis absent.
How it works
Tiza watches the folder of the file, not only the file. Some editors, such as Zed, save to a temporary file and then rename it. Tiza waits about 120 ms after the last write, then reads the file. A line diff matches the old code with the new code. Each annotation goes to the line that matches its old line.