omi-twitter-app: extract_tweet_content slices the original text with offsets from the stripped copy — leading whitespace prepends the trigger's tail to the tweet ($25 bounty proposed)
Symptom
plugins/omi-twitter-app/tweet_detector.py → TweetDetector.extract_tweet_content() returns the wrong slice of the transcript whenever the text has leading whitespace: every leading whitespace character moves the cut one character back into the trigger phrase, so the tail of the trigger is prepended to the tweet.
" Tweet now hello" -> "ow hello" (expected "hello")
"\n\nTweet this AI is cool end tweet" -> "is AI is cool" (expected "AI is cool")
" Tweet now shipping the voice poster today" -> "w shipping the voice poster today"
The webhook feeds the detector " ".join(segment_texts) (main_simple.py:694-703), so an empty first segment, or a segment whose text starts with a space (common in streamed transcripts), triggers it on the very first "Tweet now". The shifted slice is stored as the session's accumulated_text (main_simple.py:708-713), joined with the next two segments and sent to ai_extract_tweet_from_segments() (:734); when that OpenAI call fails, the clean_tweet_content() fallback of the same text (tweet_detector.py:219-222) is what gets posted.
Evidence
plugins/omi-twitter-app/tweet_detector.py:48-68 (current main): the trigger is located in a normalized copy, but the offsets are applied to the original string:
normalized = cls.normalize_text(text) # text.lower().strip()
...
for trigger in cls.TRIGGER_PHRASES:
idx = normalized.find(trigger) # offset into the STRIPPED copy
...
start_index = trigger_index + len(matched_trigger)
content = text[start_index:].strip() # applied to the ORIGINAL text
normalize_text() strips leading whitespace, so every leading space/newline shifts the slice left by one character.
Hermetic reproduction (stubs openai and dotenv, loads the real module):
$ PYTHONUTF8=1 python3 plugins/omi-twitter-app/test_tweet_offsets.py # against current main
FAIL test_leading_spaces_do_not_shift_the_slice: ' Tweet now hello' -> 'ow hello', expected 'hello'
FAIL test_leading_newlines_with_end_phrase: '\n\nTweet this AI is cool end tweet' -> 'is AI is cool', expected 'AI is cool'
FAIL test_webhook_join_with_empty_first_segment: ' Tweet now shipping the voice poster today' -> 'w shipping the voice poster today', expected 'shipping the voice poster today'
FAIL test_mixed_case_trigger_keeps_content_case: ' TWEET NOW Big News from OMI' -> 'NOW Big News from OMI', expected 'Big News from OMI'
PASS test_no_leading_whitespace_control
PASS test_trailing_whitespace_is_trimmed
PASS test_no_trigger_returns_none
Fix
Match the trigger case-insensitively on the original text (re.search(re.escape(trigger), text, re.IGNORECASE)) so the match offsets index the same string that is sliced; content casing is preserved as before. Plus a hermetic regression test for the cases above (with no-whitespace, trailing-whitespace and no-trigger controls), registered in .github/checks-manifest.yaml. The test lives in test_tweet_offsets.py so it does not collide with the broader suite PR #14209 proposes in test_tweet_detector.py (which does not cover this case). PR incoming.
Bounty
Per the Contribution guide ("No bounties available? … suggest your own"), proposing a US$25 bounty for this fix + regression test. cc @josancamon19 @kodjima33
Investigated and fixed with Claude Code on behalf of @Suyann; every command above was actually run.