Skip to content

fix(localapi): reject over-limit inline audio instead of silently truncating - #429

Closed
postoso wants to merge 1 commit into
altic-dev:mainfrom
postoso:fix/localapi-inline-audio-duration
Closed

postoso wants to merge 1 commit into
altic-dev:mainfrom
postoso:fix/localapi-inline-audio-duration

Conversation

@postoso

@postoso postoso commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

LocalAPI has a 300-second audio limit, but inline audio decoded through LocalAPIAudioDecoder.samples(fromAudioData:suggestedExtension:) could be silently truncated to the first 300 seconds because the shared decoder capped framesToRead with min(file.length, maxFrames).

This changes the shared decode path to reject over-limit audio with the same LocalAPIAudioDecoder duration-limit error instead of truncating. Under-limit inline audio still decodes normally.

The PR also centralizes the duration-limit error in durationLimitExceededError(), so file-path and inline/body uploads return the same error domain, code, and message.

Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • 📝 Documentation update

Related Issue or Discussion

Tracking discussion: #429.

Testing

  • Tested on Intel Mac
  • Tested on Apple Silicon Mac
  • Tested on macOS 15.7.7
  • Ran linter locally: swiftlint --strict --config .swiftlint.yml Sources Tests/FluidDictationIntegrationTests/LocalAPIAudioDecoderTests.swift
  • Ran formatter locally: swiftformat --config .swiftformat Sources
  • Built locally: xcodebuild build-for-testing -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS,arch=arm64' CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

Added LocalAPIAudioDecoderTests coverage:

  • testInlineAudioOverLimitThrowsInsteadOfTruncating
  • testInlineAudioUnderLimitDecodesNormally
  • testFilePathDecodeRejectsOverLimitAudio

The tests build synthetic silent WAV fixtures/data, so they do not require downloading or running a speech model.

Notes

This is API behavior only. It does not change UI, settings, onboarding, overlay, menu bar, or visual behavior.

Full hosted test execution was not run locally because the installed FluidVoice app was open; the hosted test runner can hang in that state. build-for-testing compiled the app and test target, and CI should run the full hosted suite after the branch update.

Screenshots / Video

  • No UI/visual changes; screenshots/video are not applicable.

@postoso
postoso force-pushed the fix/localapi-inline-audio-duration branch from aa70e19 to 08d01c4 Compare July 6, 2026 10:41
@postoso
postoso force-pushed the fix/localapi-inline-audio-duration branch from 08d01c4 to 1e0ca39 Compare August 14, 2026 02:08
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Greptile Summary

The PR changes the shared LocalAPI audio decoder to reject audio longer than 300 seconds rather than decoding only the first 300 seconds.

  • Centralizes the duration-limit error so file and inline request paths return consistent error details.
  • Adds synthetic WAV tests for over-limit inline audio, under-limit decoding, and file-path validation.
  • Registers the new tests with the integration-test target.

Confidence Score: 5/5

The PR appears safe to merge, with the intended duration-limit behavior consistently applied across LocalAPI audio input paths.

The changed decoder rejects over-limit audio before allocation and decoding, preserves normal under-limit decoding, and has no callers outside the intended LocalAPI scope.

Reviews (1): Last reviewed commit: "fix(localapi): reject over-limit inline ..." | Re-trigger Greptile

@postoso

postoso commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as superseded. Main no longer truncates audio at 300 seconds or enforces that limit.
ChunkReader reads the file in 20-minute chunks and the caller continues until EOF, so the
behaviour this PR fixed is gone and the rejection it added no longer matches main.

The tests here are tied to the removed duration limit, so there is nothing to rebase.

@postoso postoso closed this Sep 1, 2026
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