Summary #
The Owner starts a free Chat on a Repo, and talks with an agent about its code. It is the first real agent. Ticket: .scratch/v1-core-loop/issues/05-free-chat.md.
daemon/src/
+├── chats.ts # pilot_chats, startChat / writeChat / followChat / removeChat
+├── roles.ts # free Chat: its prompt, tools read + bash (no push, no pull request)
+├── store.ts # Pilot's writes retry instead of blocking Pi Durable's write lock
├── harness-host.ts # + Chats in Pilot's words; prompt sections AGENTS.md, GLOSSARY.md
└── server.ts # + each command gets the connection that sent it
app/
+├── chat.tsx # the Chat Sheet: follows the open Chat, New Chat, Remove Chat
└── pages.tsx # Repo page: New Chat, the Repo's Chats
ui/
+└── chat.tsx # ChatPanel: virtualized, stays at its end while an answer streams, tool rows
- A message sent while the agent works is a Pi Durable steer. The Chat shows "Waits for the agent's next step" until the agent reads it, and the agent is never stopped.
- Protocol:
startChat,writeChat,followChat,removeChat;chatsChanged,chatStreamed;chatsin the snapshot;createdinreplied. - Free Chats run on one model (
chatModel) until model picking (ticket 14), which now also lets the Owner pick the model of a new free Chat. - Fix found while checking by hand: Pilot's synchronous SQLite writes blocked the event loop while Pi Durable held the write lock across awaits, so two Chats started at once failed with "database is locked".
store.tsnow retries with the event loop free.
Evidence #
- Before: no Chats. Two Chats started at once:
Pilot's Daemon failed: database is locked. After:just testpasses: 29 Daemon tests, 21 App tests, 15 gallery tests.just checkandjust lintare clean.
daemon/test/chats.test.ts (real Pi Durable, jj and bash; scripted model)
✔ the Owner starts a free Chat on a Repo and gets the agent's answer as it streams
prompt has AGENTS.md + glossary; tools are exactly [bash, read]
✔ the agent runs its tools in Pilot's clone of the Repo, and the Chat shows their output
✔ a message sent while the agent works reaches it after its current step, and does not stop it
✔ a Chat goes on after a Daemon restart
✔ the Owner removes one Chat: its agent stops, and the Repo's other Chats stay
✔ two Chats that start at the same time both start (failed before store.ts)
app/test/Chat.test.tsx (scripted Daemon): start, stream, queued message, refusal, reconnect, remove
- Checked by hand in a macOS window against the scratch Daemon: New Chat on octocat/Hello-World, the Repo page lists it, the Sheet shows "No model could answer: Pilot is not signed in to Claude or OpenAI yet." (sign-in is ticket 06), and Remove Chat with its Dialog.
Merge Danger #
Door: two-way
New pilot_chats table and Pi Durable conversations in pilot.sqlite. Rolling back leaves them unused.
Blast Radius: Daemon
- Every Pilot write now goes through
store.ts(Repos too). - The free Chat has
bashin the Repo's clone, so an agent could still change the clone. Only its prompt stops it, by the Owner's choice. - Until ticket 06, every real Chat ends with the sign-in line.