<feed xmlns='http://www.w3.org/2005/Atom'>
<title>dotemacs/tests/test-ai-conversations.el, branch main</title>
<subtitle>My Emacs configuration
</subtitle>
<id>https://git.cjennings.net/dotemacs/atom?h=main</id>
<link rel='self' href='https://git.cjennings.net/dotemacs/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/'/>
<updated>2026-05-16T22:39:56+00:00</updated>
<entry>
<title>feat(ai-conversations): autosave on a periodic timer</title>
<updated>2026-05-16T22:39:56+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-16T22:39:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/commit/?id=1fef9aed248aaf7586950475aa22849e413f1c04'/>
<id>urn:sha1:1fef9aed248aaf7586950475aa22849e413f1c04</id>
<content type='text'>
The existing autosave only fired after gptel-send returned, so a
conversation paused mid-thought wasn't on disk if Emacs crashed. I
added a buffer-local repeating timer that calls
cj/gptel--save-buffer-to-file every cj/gptel-autosave-interval seconds
(default 60) for as long as cj/gptel--autosave-active-p holds.
Toggle-off and kill-buffer-hook cancel it cleanly.

Tests cover start/stop idempotency, the active-p predicate, the
kill-buffer cleanup hook, and the toggle integration.
</content>
</entry>
<entry>
<title>feat(ai-conversations): add cj/gptel-autosave-toggle with [AS] mode-line indicator</title>
<updated>2026-05-16T06:42:30+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-16T06:42:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/commit/?id=a8c7e8bf822535470d1a4621030b0edd07aaccb4'/>
<id>urn:sha1:a8c7e8bf822535470d1a4621030b0edd07aaccb4</id>
<content type='text'>
`cj/gptel-autosave-enabled` flipped to t inside the save/load entry
points with no way back off short of editing the variable or
clearing the buffer, and no visible indicator that it was on.

Two pieces:

- `cj/gptel-autosave-toggle` flips the buffer-local state in the
  current GPTel buffer.  Bound to `C-; a A` via `cj/ai-keymap`
  (which-key: "toggle autosave").  When autosave is OFF and no
  filepath is configured yet, the command prompts to save the
  conversation first so a save target exists; otherwise it just
  flips the bit.
- `cj/gptel-autosave-mode-line-format` surfaces " [AS]" in the
  mode-line when autosave is on, blank when off.  Installed via a
  `gptel-mode-hook` so every GPTel buffer picks it up.  The install
  helper is idempotent.

6 new tests cover enable/disable paths, the no-filepath prompt path,
the not-a-gptel-buffer error path, the mode-line format evaluation,
and the install idempotence.
</content>
</entry>
<entry>
<title>test(ai-conversations): add 36 ERT tests covering helpers and entry points</title>
<updated>2026-05-16T06:34:03+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-16T06:34:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs/commit/?id=2a98feaf1285b495e7d6d1eed2abf02620188e29'/>
<id>urn:sha1:2a98feaf1285b495e7d6d1eed2abf02620188e29</id>
<content type='text'>
ai-conversations.el shipped without direct tests.  This file covers
every helper and interactive entry point across Normal / Boundary /
Error.

Helpers: `cj/gptel--slugify-topic` (ASCII, empty input, all-special,
unicode stripped, idempotent, trim, digits); `cj/gptel--timestamp-
from-filename` (normal decode, year-edge boundaries, malformed
inputs returning nil); `cj/gptel--existing-topics` and `cj/gptel--
latest-file-for-topic` (multi-topic / multi-timestamp temp dirs,
empty dir, missing dir, prefix-overlap isolation); `cj/gptel--
conversation-candidates` (newest-first and oldest-first sort order,
display-string shape, error on missing dir); `cj/gptel--save-buffer-
to-file` (visibility headers prepended, round-trip through `cj/
gptel--strip-visibility-headers`).

Autosave: post-response hook saves only when gptel-mode + enabled +
filepath are all set; autosave-after-send swallows write errors via
`message` instead of signaling; the install-once guard prevents
double-registration.

Interactive entry points: save/delete exercised via `cl-letf` stubs
on `completing-read` and `y-or-n-p`.

Per-test temp directories; no writes outside them.
</content>
</entry>
</feed>
