Plainchant Dev Diary: Somewhere Safer for the Words

September 25, 2026

Github Repo

This stretch of work was almost invisible from the outside, and it may be the most important so far. Plainchant keeps every script in the browser itself, on your own machine, with no account and no server. That promise is only as good as the place the scripts are kept.

First, a Small Convenience

Before the big job, autocomplete arrived. As you type a character's name or a scene's location, suggestions appear in the row of buttons above the editor, taken from the names and places already in your script. Tab takes the first one. Enter never does, because Enter should always mean "new line" and nothing else.

The Problem With the Old Storage

Scripts had been saved in the browser's simplest storage, which has two problems. It holds only about five megabytes for the whole app, and the way it was used meant the entire library was rewritten on every save. One script is small, but a writer's collection is not, and every keystroke's save was getting a little heavier.

The fix was to move everything into the browser's proper database, IndexedDB, which can hold far more and can save one script at a time. This was planned carefully and written up as a specification before a single line changed, because the move is not a simple swap.

The Unload Race

The old storage saved instantly. The database saves "soon": the browser promises to finish the write, but not before your code moves on. That is fine, until someone closes the tab mid-sentence and the browser shuts the page down before the database has finished.

So Plainchant now keeps a small emergency copy of the script you are working on, written instantly every time it saves. If the database write never lands, the next time you open the app the emergency copy is compared with what the database holds, and the newer words win.

Two open tabs also now tell each other when a script changes, so one tab does not quietly overwrite the other's work.

A Testing Surprise

The automated tests run in a headless browser with a trick that makes time pass faster than real time. It turned out that the database never finishes anything under that trick: time raced past its replies, and not a single write ever completed. The tests now run in real time instead. They take about fifty seconds, which is a fair price for testing the real thing.

No Legacy Baggage

The first version of the move carefully copied old scripts across and kept the old storage as a fallback. But nobody is writing real work in Plainchant yet, so all of that was removed. There is one way to store scripts now, and it is the good one. That makes the code simpler and leaves fewer places for words to go missing.

Around the same time, development moved from Windows to Arch Linux, and the test runner moved with it.

Where the Project Stands

Scripts now live in a real database, with an instant emergency copy, and tabs that keep each other informed. It has been confirmed on Arch Linux in Firefox, and the full suite passes on the development machine.

Next: Paper

A screenplay that cannot be printed is not finished. The next job is turning Plainchant's preview into real screenplay pages: the right margins, the right page breaks, and a PDF that anyone in the industry would recognise.