120 Commits

Author SHA1 Message Date
b76f1f3593 fix(security): pin the OpenCode CORS proxy to opencode.ai upstreams
A request path like /api/opencode/go/https://evil.com/steal made
joinUpstream's `new URL(relative, base)` discard `base` entirely
(WHATWG URL semantics for an absolute URL segment), so the proxy would
forward the request's authorization/x-api-key/x-goog-api-key headers
to an attacker-chosen host instead of opencode.ai. This runs live in
production via scripts/shotluma-worker.ts on app.shotluma.com.

Reject any resolved upstream whose origin does not match the intended
opencode.ai origin, and add regression tests covering absolute,
protocol-relative, and plain adversarial path segments plus a
worker-level test asserting no outbound fetch happens for the crafted
path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-20 16:09:51 +03:00
Danny Ward
d501dbffdb
fix: anchor corner resize to the opposite edge (#25)
* fix: anchor corner resize to the opposite edge

* fix: pin the bottom edge when resizing from top handles

The opposite-edge anchor only adjusted x and width, so nw and ne left the
top edge fixed instead of the bottom. Measure the element's rendered height
during the drag (text rewraps, mockups keep an aspect ratio) and move y by
the height change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Mahmoud <mahmoud.ali-khan@gmx.net>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 23:37:31 +02:00
mahmoud
b561446870
fix(deps): clear the dependency audit gate (#26)
The overrides pinned exact versions that later advisories flagged. Raise
each to its lowest patched release and cover the packages shadcn, wrangler,
and the AI SDK pin transitively. `braces` has no patched release upstream
and only reaches the project through the shadcn CLI, so the audit script
ignores that one advisory until one ships.

Vitest moves to 4.1.12 for GHSA-82fw-gwwq-j7x9.
2026-10-19 23:37:06 +02:00
Enderson Vizcaino
952cd42c0b
fix(ai): send x-opencode-session on every OpenCode request (#23)
* fix(ai): send x-opencode-session on every OpenCode request

OpenCode Go and Zen require a stable per-conversation session id in the
x-opencode-session header so the gateway can route traffic and reuse prompt
caches (https://opencode.ai/docs/go/#where-can-i-use-it). Without it the
gateway answers "Request is missing x-opencode-session and cannot be routed
efficiently" and the run fails.

- build one module-scope session id per browser session and pass it through
  headers to all four OpenCode dialects (responses, chat, messages, google),
  which also covers the vision describer
- forward the header through the hosted Cloudflare Worker proxy, whose
  allowlist previously stripped it; the Vite dev proxy already forwarded it

* fix(ai): keep the OpenCode session id stable across reloads

The module-scope session id was regenerated on every full page load, so
reloads dropped the stable identity the OpenCode gateway needs for routing
and prompt caching.

Read the id from sessionStorage, generate one when none is stored, and
persist it; a fresh tab still gets its own id, which keeps sharding traffic
across clients. Storage that is unavailable or throws falls back to a
per-page-load id instead of failing the request.
2026-10-19 23:16:55 +02:00
realZachi
fd92c2ac88 Add GPT-6 Astra to AI provider catalogs 2026-09-04 21:17:00 +02:00
realZachi
a30a12fe6c fix(ai): make headline word highlights a scarce device
The prompts asked for a highlight in "most headlines" and called a
flat single-color headline generic, so every generated screen ended up
with its closing words pilled or underlined - period included.

Cap word highlights at two screens per set (hero plus one earned
claim), point emphasis at type contrast first, and tell the model to
pick the word that carries the claim instead of the trailing one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019hVAeQ62iAy7ZX675CmmaF
2026-08-26 13:05:06 +02:00
realZachi
542f55704b feat(ai): protect live generations from project switches and page exits
A running AI generation used to survive a project switch invisibly: the
run band unmounted without aborting, and because the slide/upload refs
are shared, the remaining tool calls wrote their screens into the newly
opened project (which then even adopted the generated app name). Leaving
the page killed a run without any warning or later explanation.

- useAiWorkflow now owns the run lifecycle: the modal registers a cancel
  handle, controller writes are gated on the registered run, and
  handleProjectReplaced unconditionally cancels before refs swap.
- Project switch, creation, and duplication during a run first ask via
  the new AiRunCancelDialog; deletion is disabled until the run ends.
- beforeunload warns while (and only while) a run is active.
- Saves during a run mark the project with interruptedGeneration; the
  marker is cleared by a save after the run ends and otherwise consumed
  on the next load with a one-time toast explaining the unfinished
  screens.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fjKLZWb1cqRDEW86V7HJm
2026-08-26 11:55:30 +02:00
realZachi
761ea418d1 feat(ai): default HTML screens on and restyle its experimental badge
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fjKLZWb1cqRDEW86V7HJm
2026-08-26 11:45:27 +02:00
realZachi
56e87b9d39 feat(ai): ask the coding AI for hero benefit, differentiator, and pains
The generator's story arc reserves slide 1 for the single strongest
benefit and slide 2 for the differentiator, and its copywriting rules
lean on pains the app removes. The copy-prompt now requests exactly
those, orders features by importance, widens the word budget to fit,
and forbids invented claims or ratings alongside invented features.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JUx2FJ86zfq7hEimRxM5W2
2026-08-26 11:39:48 +02:00
realZachi
976564a0b6 feat(ai): adopt the entered app name as the project title
A generate run now renames the project to the app name typed in the AI modal,
deduplicated against the other projects the same way new projects are ("Aurora"
-> "Aurora 2"). The rename only happens while the title is still one the app
assigned itself - the seed project, an untitled one, or "New Project 3" - so a
title the user typed is never overwritten. Edit runs carry no app name and
leave the title alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fjKLZWb1cqRDEW86V7HJm
2026-08-26 11:31:06 +02:00
realZachi
100b708d93 feat(ai): derive art direction from the app's own visual style
Drop the "bold" mission framing and the saturated-background bias so the
generated set adapts the palette, mood, and shape language of the uploaded
screenshots instead of imposing one. Prefer cohesion over forced archetype
variety across screens.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fjKLZWb1cqRDEW86V7HJm
2026-08-26 11:28:09 +02:00
realZachi
3a90b0431c Sample rendered colors for share preview backdrop 2026-08-20 20:33:49 +02:00
realZachi
005b83218f Extract perspective mapping and size real screenshot planes 2026-08-20 20:21:52 +02:00
realZachi
0848e78cdb chore: bump version to 0.5.0 v0.5.0 2026-08-20 19:50:00 +02:00
mahmoud
bc1fb094a4
feat(share): project share links with short URLs and OG previews (#21)
* feat(share): add project share links with short URLs and OG previews

Projects can be shared as links from the project menu. The share payload is
the whole project as deflate-raw compressed JSON with every image inlined,
capped at export resolution and re-encoded as WebP when smaller.

Short /s/<id> links store the payload opaquely in Cloudflare KV (90-day TTL,
10 MB cap) through a share API running as the script of the existing
shotluma-app Worker; /s/<id> also serves per-share Open Graph tags with a
client-rendered 1200x630 unfurl image composed from the live artboards.
When the share API is unreachable the link degrades to a self-contained
#share= fragment that carries the payload itself.

Opening a link imports an independent local copy, so the recipient can edit
or delete without affecting the sender. Share payloads are treated as
untrusted input: decoding re-sanitizes AI screen markup and rich text, drops
malformed records and unsafe image schemes, and caps decompressed size. The
import consumes the URL exactly once and is cached module-wide because React
StrictMode double-invokes the hydration effect in development.

* fix(share): harden share flow after review

- Add request timeouts to all share API calls so a stalled Worker degrades
  to the inline fallback instead of hanging the dialog or the import.
- Strip the static og:/twitter: tags from index.html before injecting
  per-share tags; crawlers honor the first tag they see. Propagate a failed
  asset fetch instead of serving its body as a 200 page.
- Reject oversized uploads from the content-length header before buffering,
  add x-content-type-options: nosniff to stored-bytes responses, and add an
  optional per-IP rate-limit binding for share writes.
- Settle the one-shot shared import after it is applied so a re-run of the
  hydration effect cannot re-apply the imported project, and surface a toast
  when hydration fails after the share fragment was already consumed.
- Track clipboard failures separately in the share dialog, keep the link
  visible, and offer a selectable fallback field.
- Give dropped project-name words a visible ellipsis in the OG preview.
- Document the #s= fragment as a consumed compatibility format.
2026-08-20 19:37:22 +02:00
mahmoud
5bccd8338b
feat(ai): add OpenCode Zen and Go providers (#18)
* feat(ai): add OpenCode Zen and Go providers

Add OpenCode as a key-based provider with shared Zen/Go credentials, a same-origin CORS proxy, runtime model catalogs, and a vision-model fallback that describes screenshots for text-only coding models.

* fix(ai): keep OpenCode Zen/Go path prefixes when proxying

Absolute /v1/... suffixes were resolved against the OpenCode origin and dropped /zen and /zen/go. Join relative to those prefixes in the worker and Vite rewrites.


* chore(deps): bump nanoid override to 3.3.18

Clear GHSA-2v37-7h3g-55p8 so bun audit can pass. The previous 3.3.17 pin is now reported as vulnerable.

* fix(ai): surface run status events and cache image descriptions across steps

OpenCode text-only models describe screenshots with a vision model before
generating. The modal dropped 'status' run events, so the band showed
'Starting up …' for the whole describe phase, and each tool-loop step
re-described every image from scratch because the description cache lived
only one prepare call.


* refactor(ai): enhance OpenCode model handling and proxy functionality

* fix: allow images to be used in devices

* fix(ai): defer vision fallback, harden image cache keys, and remount model browser per provider

Address CodeRabbit review on #18:
- resolve the OpenCode vision describer only once a prepared step contains
  an image, so text-only models run image-free requests without a fallback
- relay tool preview images whenever the vision fallback is active, not
  only for chat-dialect models
- hash full binary payloads for image description cache keys so distinct
  same-length images are described separately
- build the unavailable-transport error from the selected provider
- remount AiCatalogModelBrowser per provider so catalogs never leak
  between OpenRouter and OpenCode gateways
- bound the OpenCode catalog fetch with a 10s timeout and guard the
  catalog-revision state update after unmount
- correct the worker key-handling doc and the vision-default comment
2026-08-20 01:10:05 +02:00
realZachi
e09f076af8 fix: allow images to be used in devices 2026-08-19 22:01:14 +02:00
mahmoud
94cfcac978
feat(persistence): store images as disk-backed blobs and load workspaces lazily (#20)
* feat(persistence): store images as disk-backed blobs and load workspaces lazily

Project documents no longer embed images as base64 data URLs. Image bytes
now live as Blobs in a content-addressed IndexedDB asset store (SHA-256
ids), documents persist blob-asset: references, and the app renders
object URLs — so image data stays out of the JS heap and identical
images deduplicate across projects. Legacy documents migrate
transparently on load and persist references on the next save.

Startup no longer deserializes every project via getAll(): a cursor walk
builds the project list one document at a time and only the active
project is fully retained, so tab memory peaks at one project instead of
the sum of all of them.

Uploads store their file Blob directly (with a data URL fallback when
Blob storage is unavailable), AI attachments register blob assets while
keeping data URL provider payloads, and overlay reference images are
converted back to base64 on demand. Deleting a project sweeps blobs no
surviving project references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: address review findings on run guarding and cache retention

- Mark the AI generate run active before awaiting attachment preparation
  so a second click cannot start a parallel run, the close guard applies
  during preparation, cancellation is honored before the run starts, and
  preparation failures surface in the error view.
- Drop the data-URL-to-asset-id memo map; it pinned full base64 strings
  in the heap for the tab lifetime, contradicting the goal of this
  change. Re-hashing the rare inline data URL on save is cheaper.
- Guard openDatabase's failure path against a late error clearing a
  newer cached database promise after a retry.
- Document the deliberate session-lifetime asset retention (unsaved
  state and undo history) and the cross-tab sweep limitation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-19 04:48:08 +02:00
realZachi
7e27020069 feat(ui): drop the decorative-graphics toggle and badge the HTML screens switch v0.4.0 2026-08-19 02:44:14 +02:00
mahmoud
709a6b7a9a
feat(ai): experimental HTML screen mode and Grok 4.6 (#19)
* feat(ai): add experimental HTML screen mode and Grok 4.6

Let the model author whole screens as sanitized HTML instead of element tools, and surface Grok 4.6 as the default xAI model.

* chore: bump version to 0.4.0

* test(ai): cover new controller surface in slide-tools mock

* fix(ai): harden HTML screen mode after review

Strip non-fragment url() from SVG presentation attributes, collapse
root-selector chains that @scope cannot match, defer a new screen's first
preview until its slideId exists, and only count successfully created
HTML screens.

* fix(app): use shared button for project creation and quiet test warnings

* chore(deps): update @ai-sdk/xai for grok-4.6

* fix(ai): treat CSS comments as selector separators in scope rewrite
2026-08-19 02:40:26 +02:00
realZachi
f2627f794a feat(ai): update Google Gemini model to 3.7 and adjust related tests 2026-08-19 01:45:11 +02:00
mahmoud
ca6b2e556b
feat(ai): reduce screenshot generation token usage (#17) 2026-08-11 22:52:10 +02:00
realZachi
4ff3397b46 ci: add GitHub Pages SEO landing for shotluma.com backlinks
Ship a lightweight indexable project page with canonical pointing at the marketing site and deploy it via Actions.
2026-08-10 17:47:42 +02:00
realZachi
5723f9f0d0 chore: bump version to 0.3.1 v0.3.1 2026-08-09 02:26:14 +02:00
mahmoud
4feeab6b4b
feat(ai): add ChatGPT Codex bridge (#15)
* feat(ai): add ChatGPT Codex bridge

* fix(ai): harden Codex bridge lifecycle
2026-08-09 01:49:57 +02:00
mahmoud
c7782a9949
ci: isolate Cloudflare credentials from build (#14) 2026-08-08 21:49:25 +02:00
mahmoud
13490f1ace
ci: deploy editor to Cloudflare after main pushes (#13)
Run bun run deploy once quality gates pass so merges to main publish
app.shotluma.com without a manual release step.
2026-08-08 21:47:09 +02:00
mahmoud
82d3684654
feat: polish empty canvas and AI modal header (#12)
* feat(editor): redesign empty canvas with phone preview

Lead with AI generation and a lightweight phone skeleton so the empty stage feels product-shaped instead of a generic add prompt.

* feat(ai): simplify generate modal header copy

Drop the icon chrome for a clearer title-and-subtitle header, with supporting styles for the close control and copy-prompt action.
2026-08-08 21:29:38 +02:00
realZachi
47c0e2b2fc chore: bump version to 0.3.0 v0.3.0 2026-08-08 20:26:40 +02:00
realZachi
90245dc83f chore: update shadcn dependency to version 4.16.2 and enhance AiRunBand component
Updated the shadcn package in both package.json and bun.lock files to version 4.16.2. Modified the AiRunBand component to include a new CSS class for improved styling, ensuring the latest activity is visually distinct. Added a test to verify the presence of the new class in the rendered output.
2026-08-08 20:09:07 +02:00
realZachi
df11c24c56 feat(ai): integrate normalizeAiCopy and normalizeAiHighlights for text processing
Added normalization functions to improve text handling in the AI tools. The `normalizeAiCopy` function processes text to ensure proper line breaks, while `normalizeAiHighlights` standardizes highlight formatting. Updated relevant components to utilize these functions, enhancing the consistency and readability of text elements in the application. Removed unnecessary tool call count state from the AiGenerateModal and AiRunBand components to streamline the UI.
2026-08-08 20:06:33 +02:00
realZachi
af7fd65d62 feat(ai): implement narration smoothing for assistant prose
Added a new feature to release assistant prose and reasoning one word at a time, enhancing the smoothness of the output stream. Introduced a constant for word delay and a function to apply the smoothing transformation during AI model execution. This change aims to improve the readability of the output by preventing abrupt jumps in the text display.
2026-08-08 20:02:50 +02:00
realZachi
b33d7ade2f fix(export): keep uploaded images in WebKit exports
html-to-image snapshots an artboard by inlining it into one SVG data URL and
rasterising that through an <img>. WebKit stops resolving the images nested in
such a snapshot once the embedded payload passes a few hundred kilobytes: text,
shapes and backgrounds still paint, but every uploaded screenshot and device
frame in that artboard comes out empty. A raw camera-resolution upload is several
megabytes once base64-encoded, so one mockup is enough to cross the ceiling.

Each source is now re-encoded at the size it actually occupies in the exported
PNG, which keeps a snapshot one or two orders of magnitude smaller without
giving up resolution the export could have used. The sizing arithmetic lives in
export-image-sizing.ts, the canvas work in export-image-payload.ts, and the
substituted sources are restored after the run.

Also primes each artboard with one unencoded toCanvas pass, because WebKit
otherwise rasterises the first capture before its nested images are ready.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 19:48:45 +02:00
realZachi
7ac3492499 fix(ai): show Gemini thoughts, stop the run band jumping, name the latest action
Three problems with the run band, one of them a real provider bug.

Gemini showed "Starting up …" for an entire run. Reasoning visibility is a
separate switch from reasoning effort, and the providers are asymmetric: OpenAI's
Responses API defaults reasoningSummary to 'detailed' once an effort is set,
while @ai-sdk/google reads includeThoughts only from providerOptions.google with
no fallback from the portable reasoning value. We never sent it, so Gemini
thought, billed those tokens, and returned no summaries. Because prompt.ts also
forbids turn-by-turn narration, reasoning is the only live prose during a run —
without it the band had nothing to show. A test now asserts includeThoughts
reaches Google's actual request body, alongside the effort it must not override.

The band resized on almost every delta because the prose box had a min-height and
no upper bound. Its height is now fixed at four lines, bottom-anchored, so older
text scrolls out of view upward instead of moving the whole band. Measured
constant at 196px across one short line, one wrapping line, three lines, and six
overflowing lines.

"18 actions" reported only that something happened. The footer now names the
latest tool detail ("18 Preview checked"), which for a model that streams no
reasoning is the only live signal there is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 19:45:32 +02:00
realZachi
0c28ead7d8 feat(ai): replace run dialog with a floating run band
The run phase reused the generate dialog shrunk to 320x320, which forced four
streams into two scroll areas: tool calls got the loudest surface for the least
informative lines, reasoning was sliced to a 160-character window and pasted
next to the spinner, and assistant prose piled up as one block whose sentences
collided ("...Noah set.Art direction is set:").

The run now renders as a band over the canvas. Assistant prose and reasoning
share one area at reading size, accumulated per sentence by run-narration so no
scroll area appears and two steps never merge into one line. Tool calls are
reduced to their latest human-readable detail. A screen rail shows the plan the
model declares via the new declare_plan tool, reconciled against the screens
actually built so a drifting run cannot make the rail claim it finished early.

The band is also the result and error surface, so no run hands control back to
the centered dialog.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 19:29:13 +02:00
realZachi
ef84986709 feat(ai): add OpenRouter support and enhance AI provider catalog
- Integrated OpenRouter as a new AI provider, allowing direct calls to its API.
- Updated the AI provider catalog to include OpenRouter models and reasoning efforts.
- Implemented dynamic model resolution for OpenRouter, enabling runtime fetching of available models.
- Enhanced UI components to support OpenRouter selection and browsing of models.
- Updated tests to validate the new OpenRouter functionality and ensure compatibility with existing providers.
2026-08-08 18:07:30 +02:00
realZachi
2aa3418b6b chore: update nanoid to version 3.3.17 and enhance AI prompt instructions
- Updated the nanoid dependency in both package.json and bun.lock files.
- Expanded AI prompt instructions to include detailed copywriting guidelines and story arc structure for slide presentations.
- Added tests for new AI prompt features related to copywriting and story arc.
2026-08-08 17:28:47 +02:00
realZachi
724e6c9efe chore: bump version to 0.2.0 v0.2.0 2026-08-08 16:51:06 +02:00
realZachi
a7d6a4e13a docs: enhance AI generation documentation and prompt batching instructions
- Added a section on prompt caching and cost optimization, detailing provider-specific cache routing for Anthropic, OpenAI, and Google Gemini.
- Updated the AI generation invariants to emphasize the importance of batching tool calls to reduce input token costs.
- Clarified the usage of the `inspect_slide` tool, indicating it is rarely needed due to existing mutation results.
- Improved instructions in the prompt to encourage batching of tool calls and final passes for efficiency.
- Introduced a new file for per-provider cache routing in `src/ai/prompt-caching.ts`.
2026-08-08 16:41:27 +02:00
realZachi
24c8837b98 feat: add support for spanning mockups across screens
- Introduced a new `spansScreens` property for device elements, allowing mockups to continue seamlessly onto adjacent screens.
- Implemented a `SpanGhostItem` component to visually represent the continuation of spanning mockups in the editor.
- Updated relevant components and tests to support and validate the new spanning functionality.
- Enhanced the UI with a toggle button for enabling/disabling the spanning feature.
2026-08-08 15:16:38 +02:00
realZachi
830f3a6279 docs: update README with badge links for website and editor 2026-08-04 01:23:54 +02:00
realZachi
220c21e5ff docs: link website and update repository URLs 2026-08-04 00:14:53 +02:00
realZachi
77382a978d build: deploy editor separately on Cloudflare 2026-08-04 00:02:54 +02:00
realZachi
8eac294ef0 refactor(ai): update button styles and class names in AiGenerateModal
- Changed button class names to include 'export-button' for better clarity.
- Removed unnecessary styles from base.css and theme.css, optimizing button appearance.
- Added new styles for the .ai-modal-generate class to enhance button visuals and interactions.
2026-08-04 00:01:36 +02:00
realZachi
bdfbfaa515 feat(ai): update default AI provider and model selection
- Changed the default AI provider from Google to Moonshot and updated the model from Gemini 3.6 Flash to Kimi K3.
- Adjusted related tests and UI components to reflect the new default settings.
- Enhanced the AI provider controls to display the updated model and reasoning effort correctly.
2026-08-04 00:01:36 +02:00
realZachi
1f16d13845 chore(deps): patch audited transitive packages 2026-08-04 00:01:36 +02:00
realZachi
7275bdcd62 docs: clarify public browser key handling 2026-08-04 00:01:36 +02:00
realZachi
ff03ae35e3 feat(ai): improve API key management dialog 2026-08-04 00:00:46 +02:00
realZachi
38afa83d43 fix(ai): harden browser provider key handling 2026-08-04 00:00:46 +02:00
realZachi
3aa9a53362 feat: enhance AI provider key management and UI
- Updated the AI generation process to allow API keys to be entered directly in the browser and stored in localStorage, with optional fallback to `.env.local` for local development.
- Improved the user interface to manage API keys, including a new dialog for entering keys and updated messaging to clarify key requirements.
- Refactored components to utilize the new key management system, ensuring a seamless experience for users when configuring AI providers.
- Enhanced documentation to reflect changes in key handling and security practices.
2026-08-04 00:00:45 +02:00