feat(import): opt-in cloud vision screenshot import (BYO OpenRouter key) - #45
Merged
Conversation
Add aiParseWorkoutsFromImages to openrouter.ts — builds a multimodal user message (text + image_url parts) and reuses the shared fetch/parse pipeline. Default vision model: meta-llama/llama-3.2-11b-vision-instruct:free (free, vision-capable on OpenRouter). aiVisionModel added to AppSettings, DEFAULT_SETTINGS, and Settings UI. ImportPage shows opt-in 'Read with AI' button when images are staged and an API key is configured; Tesseract remains the default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in "Read with AI" path: an imported workout screenshot is sent to a vision LLM via the user's own OpenRouter key, returning a structured workout (image→structured) — for messy/handwritten screenshots the on-device path can't crack. Tesseract stays the free, on-device default. Web-only.
How
aiParseWorkoutsFromImages()reuses the existingaiParseWorkoutsprompt + catalog mapping via a shared helper (text path byte-identical). Multimodalimage_urlcontent, temp 0, json_object, ≥1 image required, cap 8 (surfaced via toast).aiVisionModelsetting (defaultmeta-llama/llama-3.2-11b-vision-instruct:free— text default isn't vision-capable), wired through persistence likeaiModel.Privacy/security
Strictly opt-in; HTTPS + Bearer key; no key/image logged or persisted; nothing leaves the device unless the user clicks.
Verification
356 tests (mocked fetch/FileReader, no network): request shape, mapping, every error branch, image-count guard + cap, button gating. Code review: "Ready to merge: Yes."
Spec:
docs/superpowers/specs/2026-06-23-cloud-vision-import-design.md