Commit Graph

58 Commits

Author SHA1 Message Date
root 60130b3d9b feat(canvas): build PSD export in the browser from canvas layers
Move PSD generation off the server. The image-generation API only
produces raster formats, so drop the PSD request path, the oov/psd
decoder, and the LayeredDocumentGenerator wiring. Layer separation now
returns clean background, foreground, and text_render_data artifacts
into a transparent frame.

Export that frame (or any image node) as PSD from the canvas context
menu: ag-psd assembles layers, rotation/flip, opacity, editable text,
and stroke effects from the current canvas state at download time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 11:01:46 +08:00
root 4ff246a294 feat(canvas): resolution/ratio composer settings and quality/count controls
Replace the ratio-baked size presets with a resolution tier (1K/2K/4K) plus
ratio selection and normalized dimensions, send imageQuality/imageCount to
the agent, and add the output_format field to GeneratorTaskInputArgs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:43:35 +08:00
root f0ae237da5 feat(server): wire quality/count params and layered document generator
Map imageQuality/imageCount and output_format across the HTTP and
WebSocket handlers, pass them into the design service calls, and register
the layered document generator in the service context.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:43:20 +08:00
root 41208e566c feat(piagent): support image quality and output_format in image client
Add quality and output_format to ImageRequestOptions, plumb them through
the JSON/multipart request bodies, generalize asset URL collection to
non-image formats, and add GenerateLayeredDocument for PSD output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:42:55 +08:00
root cb24ffd185 feat(application): PSD layer separation and image quality/count threading
Convert GPT Image 2 layered PSD output into canvas image/text nodes with a
local separation fallback (new layer_separation.go, oov/psd dependency),
default layer-separation/edit-elements output_format to psd, and thread
imageQuality/imageCount through project generation and job processing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:42:42 +08:00
root 00b70298f2 feat(design): thread image quality, count and layered output through domain
Add ImageQuality/ImageCount to AgentRequest, AgentChatRequest and Job,
add OutputFormat to GeneratorTaskInputArgs, and introduce the
LayeredDocument types and LayeredDocumentGenerator port for PSD output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:42:26 +08:00
root db41dac5e9 feat(server): add imageQuality/imageCount and output_format to API contract
Extend CreateProject/Generate/AgentChat request types with imageQuality
and imageCount, and add output_format to GeneratorTaskInputArgs for
layered (PSD) generation output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 20:42:11 +08:00
root a1503a1687 feat(canvas): frame-based layer separation UI
Render and manage the separated layers produced by the edit-elements
action as a manual-frame container with attached image and text
children.

- canvasNodeOps: frame container/child helpers, render ordering,
  auto-attach nodes to containing frames, and layer reordering
- CanvasWorkspace wires frame-aware selection, drag, resize, hide/lock,
  and layer reorder through the new ops
- CanvasPanels: expandable layer tree with rename/reorder
- designGateway.submitGeneratorTask + GeneratorTaskSubmitResponse and
  bbox/generator_name artifact metadata in the domain
- ArtboardPreview shows a working state for generating frame layers
- i18n: expandLayer / renameLayer / layerTitlePlaceholder; styles

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:27:00 +08:00
root 039d166972 feat(server): add layer-separation generator task
Introduce the `layer-separation` generator (edit-elements node action)
that splits a source image into a clean background layer, foreground
image artifacts with bounding boxes, and editable text render data.

- New layer_separation.go builds the separated result and artifacts
- SubmitGeneratorTask routes layer-separation and move-object via a
  switch; standalone task completion + polling support
- Extend artifact metadata with BBox and GeneratorName across the
  domain, API types, mapper, .api schema, and API.md
- edit-elements gets a transparent manual-frame placeholder holding the
  separated foreground images and text layers beside the original

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:26:43 +08:00
root 676e1c4c67 fix(canvas): start selection title rename on single click
Switch the editable selection title from onDoubleClick to onClick so
renaming a node/layer title begins with a single click.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:26:26 +08:00
root 299bac6c1a feat(piagent): fall back to concurrent single-image requests when count unsupported
Some image endpoints reject the `n` count parameter (Unknown parameter
tools[0].n / param: n). Detect that error and re-issue the batch as
concurrent count=1 requests, each with a suffixed idempotency key, then
assemble the URLs into a single GeneratedImage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:26:17 +08:00
root 568690e2f1 fix(server): widen letter-spacing normalization bounds to ±256
Negative and larger letter spacing values are legitimate for extracted
text layers; clamp only outside ±256 instead of rejecting anything
below 0 (or above 80 in the extractor).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:26:08 +08:00
root 906846a717 style(ui): widen image generator model button to 180px
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 09:05:55 +08:00
root 4f2825bb8e feat(ui): localize friendly agent errors and surface them as toasts
Thread a translate function through friendlyAgentErrorMessage/
friendlyProjectFailureMessage and move the hard-coded zh-CN error copy
into the i18n locale files (with a zh-CN fallback map). Generation
stream failures now report through a toast via showGenerationError in
addition to setError, so the removed inline .panel-error footer is
gone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 09:05:44 +08:00
root 3eae2beb12 feat(canvas): clone generator placeholders and place batch results as siblings
When an image-generator target requests multiple images, duplicate the
target placeholder into N generating clones and lay them out beside the
target. Incremental results after the first are appended as siblings
rather than merged into the target, and placeholder cleanup now clears
the target's generating clones on failure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 09:05:33 +08:00
root cc30ae4284 feat(piagent): batch-generate images in one call when generators share a prompt
When multiple image-generator tasks carry the same brief, request all
images from a single GPT Image call with Count=N instead of firing one
call per image. Adds directImageBatchCount/Prompt detection, batch
(incremental) generation paths, and folds the planned count into the
idempotency key. Disables the streaming plan probe for multi-image
requests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 09:05:18 +08:00
root 8a28a0bcea perf(canvas): slow generator task poll interval to 5s
Reduce polling pressure on the generator task status endpoint by raising
the client poll interval from 3s to 5s.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 02:20:33 +08:00
root a5a35648d7 fix(server): complete generator task when thread settles or project ready
Treat a generator task as completed when it produces artifacts, when a
task message reaches a terminal state, or when the project is ready —
even if the project is still exploring another concurrent thread. Adds
generatorTaskMessageCompleted to classify terminal task messages and
covers ready-without-messages and concurrent-thread cases with tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 02:20:23 +08:00
root 94718553c6 feat(ui): redesign image generator floating composer and settings panel
Compact the floating composer with an auto-resizing prompt editor and a
scrollable settings popover, add a titled settings panel, and show the
resolved image size in the settings summary. Add the imageCountLabel
string for the count section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:46:24 +08:00
root cbf4e21e2b feat(canvas): per-generator target size, placement and draft preservation
Persist each image-generator node's target resolution in metadata and
surface it in the selection frame and node preview. Place new generators
without overlapping existing ones, keep local draft generators when a
compressed snapshot omits them, and add a dedicated selection-frame
variant plus scale-aware preview styling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:46:16 +08:00
root 82683c40ea refactor(canvas): support multiple concurrent image generator streams
Track image-generator streams in a keyed Map/Set instead of a single ref
so several placeholders can generate at once without cancelling each
other. Generating state is derived from the number of open streams.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:46:07 +08:00
root 453de420fc fix(ui): show real contents in optimistic image messages and widen settings chip
Use the user-visible contents (without injected image-mode settings) for the
optimistic agent messages so the settings blob is not echoed in the thread.
Widen the composer settings chip to 150px so longer labels are not clipped.
Also picks up regenerated next-env.d.ts and tsbuildinfo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:10:17 +08:00
root 9a07f863ea fix(design): preserve existing canvas nodes when compressed snapshot omits them
SaveCanvas treated a nil Nodes/Connections slice from a compressed snapshot
as an empty canvas, wiping existing content. Distinguish nil (field omitted,
keep the project's current nodes/connections) from an explicit empty slice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:10:07 +08:00
root ffd8d78df7 feat(piagent): bypass planner for direct image generation modes
For image / pure-image / image-generator / image-action modes, skip the
task-planning round trip and hand the prompt straight to the image model,
deriving the requested image count from the composer settings. Also
normalize completed image-generator nodes back into regular image nodes
(clearing the image-generator layer role and defaulting Tone to "visual")
when merging generated results and when restoring finished nodes, so a
finished generator node is not re-appended as a duplicate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:09:59 +08:00
root a39e18950c refactor(auth): require bearer token only, drop legacy token header and cookie
Authenticate requests solely from the Authorization: Bearer header on the
server; stop accepting the legacy `token` header and `usertoken` cookie.
The frontend no longer sets auth cookies (only clears legacy ones), omits
credentials on all requests, and drops the redundant `token` header. Project
event SSE now streams over fetch so it can carry the Authorization header,
which EventSource cannot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 01:09:39 +08:00
root 263748af4a feat(api): add Lovart-style project and agent thread endpoints
Add canva/canda-compatible routes for lightweight project open/save and
agent thread history:
- POST /canva/project/queryProject, saveProject
- POST /canva/agent/queryAgentLastThread, agentThreadList
- GET /canda/chat-history, /canda/thread/status

Canvas save now accepts a compressed SHAKKERDATA:// snapshot payload,
preserves connections, and returns a SaveProject response; blank
successful image nodes are backfilled from generated artifacts. Frontend
designGateway adopts the new save/query flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 19:10:08 +08:00
root ada29cee12 refactor(agent): make emoji optional and sparse in agent replies
Loosen the creative agent guidance so emoji are used only as sparse
category markers rather than forced on every list item, and tighten the
frontend emoji section-break normalization to only split before short
labelled headings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:18:11 +08:00
root ba4db85241 fix(logic): ignore reference directives when checking for prompt text
Strip inline image tokens and reference directive URLs before deciding
whether a prompt carries real user text, so a reference-only prompt is
still treated as empty while text around references counts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:17:59 +08:00
root 68427ad91a feat(piagent): give image generator inline reference placement context
Derive an ordered map of each inline reference image to the surrounding
prompt text describing its role, and feed it into the decision, research,
task-plan, conversation and image-prompt builders. The image prompt now
carries this placement so reference roles are not swapped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:17:52 +08:00
root 9622b27de9 fix(piagent): upload local and private reference images as multipart
When URL input transport is configured, the remote image API cannot fetch
localhost or private-network reference URLs. Detect such hosts and fall back
to multipart file upload so those references still reach the model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:17:29 +08:00
root 13fdf464ae feat(netutil): add local and private host detection helper
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:17:20 +08:00
root 0eed208bbf feat(ui): add typewriter effect for streaming agent text
Add a useTypewriterText hook that reveals streamed content character by
character and reconciles when the target text changes. Apply it to
markdown content and agent step copy, with a blinking caret while
streaming.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 15:08:21 +08:00
root d7300ed0f6 feat(ui): make workspace layout responsive for narrow and mobile screens
Widen the assistant panel via a shared CSS variable, overlay it below
1180px, and add mobile breakpoints for the topbar, canvas controls,
toolbar, minimap, and bottom-sheet assistant panel. Use dvh units and
safe-area insets for mobile viewports.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 14:39:00 +08:00
root a339e09859 feat(agent): guide creative agent to use purposeful emoji in replies
Add prompt instructions for emoji-led list formatting in visible
responses, plan narration, and image summaries, with guardrails against
hyphen chaining and empty numbered choices. Tighten the planner's
userFacingResponse description.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 14:33:16 +08:00
root b842c34fca feat(ui): add scroll-to-latest button in assistant feed
Track the assistant feed scroll position and footer height, and show a
floating button to jump back to the newest message when scrolled up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 14:33:02 +08:00
root e9cfadfb90 refactor(ui): extract NotFoundPage into its own i18n-aware module
Move the inline 404 component and its styles out of App.tsx into a
dedicated NotFoundPage module, and localize its copy via i18n keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:16:30 +08:00
root c73e51e400 feat(i18n): add not-found page copy keys
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:16:20 +08:00
root 4e98a81aae feat(ui): path-based app-router routes with 404 and project auth preview
Resolve routes from pathname (and legacy hash), add a notFound route with
a dedicated 404 page, and show a blurred workspace preview for
unauthenticated project visits. Wire up Next.js app-router entry files and
listen for popstate so history navigation updates the route.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:07:13 +08:00
root 92343ef1f6 feat(ui): surface friendly agent and project failure messages
Add friendlyAgentErrors to map raw agent/image errors to user-facing
copy, and use it for timeline error bubbles and project failure banners.
Redirect home with a toast when a project returns 403/404 instead of
showing a generic error, and render the final agent response inline under
skill progress.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:07:05 +08:00
root d13a4c9a48 fix(agent): let stopped threads start a new task and scope thread state to the latest task
Replace the stored cancel func with a handle so a stale deferred cleanup
can't delete a newer task's cancellation, and clear a thread's cancelled
flag when it submits fresh work instead of refusing to restart. Thread
progress/finished state now derives from the latest user task in the
thread rather than the whole history. Adds coverage for continuing a
stopped thread and for sanitized generation-failure messages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:06:50 +08:00
root 7679854b5d feat(image): stream text-to-image generation with SSE and fallback
Send stream=true for text-to-image requests and consume the SSE
response, falling back to a non-streamed request when the stream errors
in a way that warrants it. Raises the scanner line limit to handle large
base64 image payloads.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:06:39 +08:00
root 7e05a8d47b feat(txt): add distill txt 2026-07-08 10:57:55 +08:00
root ad67fe1ebe feat(agent): clarify vague briefs before generating and harden prompts
Let the planner return a clarify/chat intent that asks 2-4 targeted
questions (imageCount 0) when essentials are missing, instead of forging
ahead. Tighten prompt guidance to preserve user wording and stated
reference-image roles, avoid inventing copy/specs, keep durable brand
constraints, and treat vague taste feedback as clarification. Also
fix the generation heartbeat goroutine to stop cleanly via defer, add
research-query fallbacks, and refresh image-only capability copy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:56:55 +08:00
root 1a1c0a6544 fix(image): add response-header timeout and idempotent retry
Give the image client a configurable ResponseHeaderTimeout (default 4m,
capped at the overall timeout) so a stalled upstream fails fast, and
retry such timeouts when an idempotency key is set so a slow-but-safe
request can recover instead of terminating. Raise the Next.js API proxy
maxDuration to 1200s to accommodate long generations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:56:42 +08:00
root 836de5b597 feat(research): hydrate web-search results with cleaned page content
Fetch and clean each search result's page body (bounded by size,
concurrency, and a configurable MaxPageContentRunes), store it on the
new ResearchResult.Content field, and surface those excerpts in agent
memory so the model reasons over real page text rather than snippets
alone. Promotes golang.org/x/net to a direct dependency for HTML
parsing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:56:31 +08:00
root 222e5a0219 refactor(ui): focus the product on image generation only
Drop the disabled video/3D model tabs from the composer and home model
picker, reword storyboard/campaign copy away from motion/video toward
static campaign frames, ease the home prompt editor font sizing, and
update the deterministic fallback message to describe image generation
and editing instead of "video not yet supported".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:56:14 +08:00
root d5c5470c3c feat(timeline): download generated images from a hover control
Render generated artifacts with a native <img> at their true aspect
ratio instead of a background-image fill, and add a hover/focus download
button that fetches the blob (falling back to a direct link) and saves
it with a sanitized, extension-aware filename.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:56:04 +08:00
root a549c7b14b refactor(i18n): extract inline dictionaries into locale JSON files
Move the large in-code zh-CN/en-US dictionaries out of i18n.tsx and
import them from locales/*.json, shrinking the module and making
translations easier to edit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 10:55:56 +08:00
root ef45606a24 feat(home): animated typewriter placeholder for the prompt composer
Cycle through localized example prompts with a typing/deleting animation
in the home composer placeholder, start the field empty instead of with
a default prompt, and style the home editor with larger prompt text.

Also rebrand the device-management copy from Lovart to Moteva.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 09:00:20 +08:00
root 3c5006e2f3 feat(composer): carry reference image names and submit on Enter
Propagate an optional imageName through the agent content pipeline
(frontend types → API → domain → prompt building) so reference images
render with their name instead of a bare "image" label.

Also switch PromptComposer to submit on plain Enter (Shift+Enter for
newline, IME-safe) and add a submitDisabled guard wired from the canvas
and home composers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 08:41:15 +08:00