Skip to content

feat(opencode): add trigger words for inline image attachments#21586

Open
divitkashyap wants to merge 4 commits intoanomalyco:devfrom
divitkashyap:feat/inline-image-trigger-words
Open

feat(opencode): add trigger words for inline image attachments#21586
divitkashyap wants to merge 4 commits intoanomalyco:devfrom
divitkashyap:feat/inline-image-trigger-words

Conversation

@divitkashyap
Copy link
Copy Markdown

@divitkashyap divitkashyap commented Apr 8, 2026

Issue for this PR

Closes #21514

Type of change

  • New feature

What does this PR do?

Skills like vision-analysis auto-activate based on trigger words in the message text (like "screenshot", "describe", "analyze"). However, inline images sent to the LLM only include the file part without surrounding text context, so these skills never activate.

This PR adds trigger word extraction from the filename before sending inline image parts:

  • Screenshot 2026-04-08 at 2.54.51 pm.png → prepends [screenshot]
  • clipboard-2026-05.png → prepends [clipboard]
  • photo.jpg → prepends [photo]
  • Other images → prepends [image]

The change is in packages/opencode/src/session/message-v2.ts - when sending a media file part to the LLM, we now first extract a trigger word from the filename and prepend it as a text part.

How did you verify your code works?

The code compiles successfully. The fix follows the existing pattern in the file where stripMedia already adds text for images. Manual testing would involve sending an inline screenshot and verifying the vision-analysis skill activates.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The message.role type only allows 'user' or 'assistant', so checking
for 'system' role was redundant. Removed the conditional to show all
non-system messages in fork dialog.
When sending inline images to the LLM, extract trigger words from the
filename to help skills like vision-analysis auto-activate.

For filenames containing "screenshot", "clipboard", or "photo", prepend
the matching trigger word as a text part before the file part.
Fallback to "image" for other image types.

Fixes anomalyco#21514
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 8, 2026
@divitkashyap
Copy link
Copy Markdown
Author

I've updated the PR description to follow the template. Could you please re-check if it now meets the requirements? The description now includes: Issue for this PR, Type of change, What does this PR do, How did you verify, and Checklist sections.

The feature adds trigger text before inline image file parts to help
skills auto-activate. Updated test expectations accordingly.
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

[FEATURE]: Inline image attachments don't include trigger text for skill auto-activation

1 participant