Every Code chat now gets its own git worktree
Two chats on the same project can no longer step on each other's changes. Each one works on its own branch, and you decide what to keep.
The problem
Point two Code chats at the same folder and both of them edit the same files. The changes tangle together, you can't tell which chat did what, and undoing one chat's work means untangling it by hand.
What changed
Since September 18–19, every new Code chat starts on its own real git worktree and branch. It's created when you send the first message, not when you pick the folder, so browsing around doesn't leave stray worktrees behind. The branch is named from your first message, so when several are running you can still tell them apart.
This works in the desktop app's Code mode and in the nia terminal command.
Keeping or dropping the work
When a chat's work is good, merge it into your project. If the merge hits a conflict, Nia stops cleanly and leaves your project exactly as it was, so a bad merge never leaves you half-way through one. When it isn't good, discard it: the worktree is deleted and your original code was never touched.
Going back to your previous code is just deleting a folder. There's nothing to undo.
In the terminal these are the /merge and /discard commands. In the desktop app they're in the chat's options menu, and worktree chats show a small branch badge in the sidebar.
One fix along the way
The nia --resume command used to keep whatever directory you happened to launch it from instead of going back to the chat's own folder. It now returns to the chat's real directory, falls back to the main project if the worktree has since been merged or discarded, and warns you if neither exists anymore.