---
digest: >
  v0.39.4 is a patch release of one pull request by Alan Nascimento, his first here. On
  Claude Code, two ordinary situations made the Stop hook drop a real reply: a prompt typed
  while a turn was still running, whose prompt hook fires at queue time under the running
  turn's id, and a journey entered in plain words, whose Builder load switches the
  conversation mid-turn. Both replies are now logged beside their prompts, and
  `nothing_waiting` in `hooks.log` means what it says again. No schema change, no
  migration, and no model or prompt change.
---

# v0.39.4 — The Reply Finds Its Prompt

**Date:** 2026-11-03

## Highlights

- **A prompt typed while a turn runs keeps its reply**
  ([PR #51](https://github.com/mirror-mind-ai/mirror/pull/51), by @alannascimento1;
  [CR196](../project/refinement/rs010-cv22-oracle-and-port-hygiene/cr196-a-prompt-typed-while-a-turn-runs-loses-its-reply-on-claude-code.md)).
  Claude Code fires the prompt hook when such a prompt enters its queue, with the running
  turn's id; the prompt later runs under an id no hook sent, and its Stop found nothing
  waiting. The prompt is now recorded as queued during the running turn, the running turn's
  reply stays with its own question, and the Stop of the turn the queued prompt ran as
  claims it. Never for a command turn, and never a prompt an ordinary one has since
  followed.
- **Entering a journey in plain words keeps the turn together**
  ([CR166](../project/refinement/rs010-cv22-oracle-and-port-hygiene/cr166-a-plain-language-journey-switch-strands-its-turn.md)).
  "I want to enter journey X" logs the prompt in one conversation; the model's `build load`
  closes it and binds the journey's; the Stop paired in the new, empty one. A hook prompt
  still owed its reply now moves with the switch. A prompt logged by hand stays where it
  was, so `mm-new` and the logger CLI behave as before. Pi gets this half too: its prompts
  carry turn ids.
- **`nothing_waiting` means a lost reply again.** On one host, 20 of 22 such lines in a
  week were these two cases; `runtime diagnose`'s `hook_failures_recorded` was mostly
  counting them.
- No schema change (`queued_in_turn` is one more optional key in the `metadata` JSON
  column `turn_id` already lives in), no migration, and no model or prompt change.

## Where We Started

Alan Nascimento opened PR #51 on 2026-10-30 with the session transcript that shows the
mechanism, Claude Code's own `queue-operation` record between the prompt hook and the
Stop, and a week of `hooks.log` counted by cause. The journey-switch half had been in the
backlog as CR166 since 2026-10-24, unassigned; the queued-prompt half no record described.
The review, through four lenses, had nothing to amend: the reply rule gains one branch
between "by turn id" and "by position", each new path bounded by an explicit guard, and
ten tests of which five fail without the change.

## What Changed

All in `ts/src/conversation/logger.ts`. `promptMetadata` records a second prompt under a
turn still owed its reply as `queued_in_turn`. `handleStopHook`, for a turn id with no
prompt of its own, claims the oldest unclaimed queued prompt that no ordinary prompt has
followed, and logs the reply as paired by `queued_prompt`. `switchConversation` moves the
old conversation's last row to the new one when it is a hook prompt with no reply after
it. The reply rule's docblock names the new branch.

## Conscious Exclusions

Both named by the author and recorded in CR166 and CR196:

- In the queued case the running turn's reply is still written after the queued prompt,
  because the prompt hook fires at queue time: the rows pair by `turn_id`, but a reader
  ordering by `created_at` sees `Q1, Q2, A1, A2`. Rewriting `created_at` would make it lie
  about when the prompt was typed.
- The waiting prompt moves after the old conversation's close-time extraction, which
  therefore still saw it. Moving it earlier would mean starting the new conversation
  before closing the old.
- The two `nothing_waiting` lines in the week that match neither pattern.

## Upgrading

```bash
mirror runtime update
```

## Next Horizon

Moacir Moda's PR #27; CR190, CR192, and CR195 in RS010's backlog. CV24 continues on its
branch.
