Extract atomic_write_lines so history.jsonl, session JSONL saves, and WebUI transcript rewrites share unique temp files, optional fsync, and BaseException cleanup. Closes #5290
Extract atomic_write_lines so history.jsonl, session JSONL saves, and WebUI transcript rewrites share unique temp files, optional fsync, and BaseException cleanup. Closes #5290