Skip to content

feat: add trim and fallback_on_empty options to PostProcessConfig#270

Open
KaiStarkk wants to merge 1 commit intopeteonrails:mainfrom
KaiStarkk:feat/post-process-trim-fallback
Open

feat: add trim and fallback_on_empty options to PostProcessConfig#270
KaiStarkk wants to merge 1 commit intopeteonrails:mainfrom
KaiStarkk:feat/post-process-trim-fallback

Conversation

@KaiStarkk
Copy link

Summary

Adds two new boolean fields to PostProcessConfig that give post-process scripts finer control over output handling:

  • trim (default: true) — When set to false, only trailing newlines (shell artifacts) are stripped from command output, preserving all other whitespace. This is needed when a post-process script intentionally adds trailing spaces, e.g. appending a space after sentence-ending punctuation for smoother dictation flow.

  • fallback_on_empty (default: true) — When set to false, empty command output is returned as an empty string instead of falling back to the original transcription text. This is needed when a post-process script intentionally outputs nothing to suppress unwanted transcriptions, e.g. filtering out [BLANK_AUDIO] markers.

Why this is needed

The current post-processing pipeline unconditionally calls .trim() on command output, which strips trailing spaces that some scripts add intentionally. It also unconditionally falls back to the original text when output is empty, which defeats scripts designed to suppress certain transcriptions.

These two behaviors are reasonable defaults, but they need to be configurable for legitimate use cases.

Backward compatibility

Both fields default to true, which preserves the existing behavior exactly. No configuration changes are required for existing users.

Config example

[output.post_process]
command = "my-dictation-formatter"
trim = false              # preserve trailing spaces from formatter
fallback_on_empty = false # allow formatter to suppress output

Tests

4 new tests added covering the new fields. All 16 post_process tests pass.

Files changed

  • src/config.rs — Add trim and fallback_on_empty fields to PostProcessConfig with serde defaults and documentation comments; add config file comments
  • src/daemon.rs — Populate new fields when constructing PostProcessConfig from profile overrides
  • src/output/post_process.rs — Implement conditional trim and fallback logic in PostProcessor; add 4 tests

Add two new boolean fields to PostProcessConfig that give post-process
scripts control over whitespace handling and empty-output behavior:

- trim (default: true): when false, only trailing newlines are stripped
  from command output, preserving intentional whitespace like trailing
  spaces after punctuation for dictation flow.

- fallback_on_empty (default: true): when false, empty command output is
  returned as-is instead of falling back to the original transcription.
  This allows scripts to intentionally suppress output (e.g. filtering
  [BLANK_AUDIO] markers).

Both fields default to true for full backward compatibility. Adds 4 new
tests covering the new behavior; all 16 post_process tests pass.
@KaiStarkk KaiStarkk requested a review from peteonrails as a code owner March 19, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant