agent: Set WAL mode and busy_timeout on threads database
Richard Feldman
created
The threads SQLite database was opened without setting journal_mode or
busy_timeout. Without WAL mode, readers block writers and vice versa.
Without busy_timeout, SQLite returns SQLITE_BUSY immediately instead of
retrying when it encounters a lock.
This caused a flood of "database is locked" errors in the logs, especially
when save_thread and list_threads (triggered by reload) overlapped, or
when multiple Zed windows shared the same threads.db file.
Set journal_mode=WAL so readers and writers can proceed concurrently, and
busy_timeout=1000 so SQLite retries for up to one second before giving up.