Skip to content

journal log: preflight the transcriber toolchain at record-start, not after recording - #88

Merged
ericmann merged 1 commit into
mainfrom
agent/issue-82
Jul 1, 2026
Merged

ericmann merged 1 commit into
mainfrom
agent/issue-82

Conversation

@claude

@claude claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Agent-Generated PR

Closes #82
Agent Used: Claude Code
Complexity: medium


Summary

journal log's mic-toggle/hotkey flow preflighted ffmpeg before recording but only discovered a missing whisper.cpp binary or model file after the recording finished (inside Transcribe()), wasting the recording. This adds a transcriber preflight to the record-start path, mirroring the existing ffmpeg preflight.

Implementation Notes

  • Added internal/log.CheckAvailable(modelDir, model string) error, which performs the same two checks WhisperCPP.Transcribe does (model file os.Stat, binary findWhisperBin lookup) but without running transcription. Transcribe itself is untouched to avoid any risk to the existing transcription path.
  • Added an injectable checkTranscriberAvailable var in cmd/log.go, mirroring the existing checkFfmpegAvailable pattern, so tests never depend on a real whisper.cpp install/model.
  • Wired it into runLogStartRecording right after the ffmpeg check and before the recorder is spawned / lockfile is written.
  • On failure it returns the same actionable error (run \journal models pull` / whisper.cpp install hint) and additionally sends a desktop notification (✕ journal log failed`) — the ffmpeg preflight's existing behavior (terminal-only, no notification) is left unchanged, per the issue's acceptance criteria.
  • The direct journal log <audio.wav> path is untouched — it already surfaces transcription errors inline.

Changes

  • internal/log/transcribe.go: add CheckAvailable.
  • cmd/log.go: add checkTranscriberAvailable var, call it in runLogStartRecording.
  • internal/log/transcribe_test.go: table test for CheckAvailable covering present / missing-binary / missing-model.
  • cmd/log_test.go: add stubTranscriberAvailable helper, wire it into existing start/toggle tests, and add new tests covering the fail-fast behavior (no spawn, no lockfile, notification sent) and the pass-through (available) case.

Testing

Automated:

  • Unit tests added/updated
  • Integration tests added/updated
  • All existing tests pass

Manual testing performed:

  • Ran make fmt vet, go build ./..., and go test -p 1 ./... locally — all green.
  • golangci-lint isn't available in this environment; CI will run it on the PR.

Review Checklist

Correctness

  • Code actually solves the issue
  • Acceptance criteria are met
  • Edge cases handled

Code Quality

  • Follows existing codebase patterns
  • Follows project coding standards
  • Naming conventions consistent
  • No unnecessary complexity
  • Comments where needed (but code is self-documenting)

Security

  • Input validation present
  • No exposed secrets or credentials
  • Data properly sanitized/escaped
  • Authentication/authorization checks where needed

Performance

  • No obvious N+1 queries
  • Reasonable algorithmic complexity
  • Caching used where appropriate
  • No blocking operations in request lifecycle

Tests

  • Tests actually test behavior (not just coverage)
  • Edge cases covered
  • Failure modes tested

Reviewer Notes

Out of scope per the issue: bundling whisper.cpp or auto-pulling models — not touched.

journal log's mic-toggle flow already preflights ffmpeg before recording,
but a missing whisper.cpp binary or model file was only discovered inside
Transcribe(), after the recording had already finished — spending a
recording just to lose it to a toolchain error.

Add internal/log.CheckAvailable (binary + model file, no transcription)
and wire an injectable checkTranscriberAvailable check into
runLogStartRecording alongside checkFfmpegAvailable. On failure, the
recorder is never spawned, no lockfile is written, and the same actionable
error (`journal models pull` / whisper.cpp install hint) is surfaced via
terminal output and a desktop notification.

Closes #82
@claude claude Bot added the agent-generated PR was created by an AI agent label Jul 1, 2026
@ericmann
ericmann merged commit 90bd720 into main Jul 1, 2026
2 checks passed
@ericmann
ericmann deleted the agent/issue-82 branch July 1, 2026 21:34
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Retro: no durable lesson (merged clean / one-off).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-generated PR was created by an AI agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

journal log: preflight the transcriber toolchain at record-start, not after recording

1 participant