Skip to content

feat(generation): integrate animation generation API and directional sprite records - #218

Merged
nighca merged 8 commits into
1024XEngineer:mainfrom
KurodaKayn:feat/animation-generation-integration
Aug 14, 2026
Merged

feat(generation): integrate animation generation API and directional sprite records#218
nighca merged 8 commits into
1024XEngineer:mainfrom
KurodaKayn:feat/animation-generation-integration

Conversation

@KurodaKayn

Copy link
Copy Markdown
Collaborator

Change Description

  • Replaces mock animation generation logic with production API endpoints and React Query mutations.
  • Integrates directional asset helpers (directional-asset.ts) and core sprite record models (core-sprite-record.ts).
  • Updates CreateAnimationTrigger and header generation dropdown to handle real-time task status tracking and session store updates.

Implementation Approach

  • Created animation-generation.api.ts and animation-generation.mutation.ts for API interactions.
  • Added directional-asset.ts to compute available target directions based on project/asset perspective rules.
  • Extended editor session store to sync active generation runs with workspace state.
  • Updated i18n locales (zh-CN and en-US) for animation trigger controls and task dropdown options.

Related Issue

Closes #217

Testing

  • PUBLIC_CORE_API_BASE_URL=http://localhost/api/v1 pnpm test --run - 73 test files passed (305 tests)

Checklist

  • The PR is focused and does not include unrelated changes.
  • Asset names, formats, dimensions, and metadata follow project conventions.
  • Licensing and attribution information is included or unchanged as appropriate.
  • Documentation or examples were updated when needed.

…sprite records

Replace mock animation generation logic with production API endpoints and React Query mutations to support real animation workflows in the asset editor.

Introduce directional asset helper utilities, core sprite record data structures, and UI components including directional animation triggers and task status tracking.

Enable end-to-end animation generation trigger, progress monitoring, and session store synchronization with complete test coverage.
@KurodaKayn KurodaKayn added type:feature A new capability or improvement to existing behavior. area:asset-editor Asset editor UI & canvas. area:generation Asset generation flows, pipelines, post-generation. labels Aug 14, 2026
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
holonic-asset Ready Ready Preview Aug 14, 2026 5:58am

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.80000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...eatures/asset-editor/state/editor-session-store.ts 96.77% 2 Missing ⚠️
...rontend/src/model/generation/run/generation.api.ts 97.91% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

fennoai[bot]

This comment was marked as outdated.

…nd runtime texture loading

Add unit test coverage for animated sprite canvas rendering components and texture loading error handling.

Introduce SpriteSheetFrameRenderer test suite and expand SpriteSheetFrameTextureCache and AnimatedSpriteCanvasRuntime tests to verify frame cropping, missing texture skipping, and deduplication.

Improve test reliability and ensure robust sprite canvas rendering state under missing or asynchronous frame texture loads.
@KurodaKayn

Copy link
Copy Markdown
Collaborator Author

@nighca
感觉要是做确认之类的操作这个branch今天就合并不了了
这个分支暂时就先不去做用户操作record的事情了,就直接无脑读到完成的任务加一个新的一条record
record后面单独弄好了

External animation refreshes were recorded as local edits.

Skip no-op refreshes, pause tracking, and rebase temporal snapshots onto the incoming server baseline.

Undo now preserves generated animations while reverting local edits.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: animation generation API integration

Solid migration off the mock path. The three-way animation merge, the perspective-scoped direction picker, and the texture-cache gate that stops PixiJS building textures from unloaded sources are all well-handled, and the new tests cover the interesting branches.

The findings below cluster around what happens when the Core API does not behave: a failed asset fetch, a failed run, or metadata that never made it to localStorage. Inline comments carry the detail.

Main themes

  1. Fallback to mock records doesn't actually work. loadCoreSpriteAssetWorkspace has no error handling, and unwrapApiResponse (frontend/src/model/fetchers.ts:63-83) throws on any non-2xx. So (await loadCoreSpriteAssetWorkspace(input)) ?? getMockAssetRecord(input) in record.api.ts:6-7 only falls back for non-numeric ids and non-sprite types — a 404 or 500 rejects the whole record query instead.

  2. Unbounded reconciliation retries. In generation-runs.query.ts, handledRunIds is set only in the terminal branches while reconcilingRunIds is always cleared in finally. The catch path and any non-terminal detail.status therefore retry every poll tick (GENERATION_POLL_INTERVAL_MS = 1_000) with no cap or backoff. refreshSettledAssets passes throwOnError: true, so a persistently unreadable record keeps the loop alive indefinitely.

  3. Animation runs depend on localStorage to stay visible. generationKindToAssetKind resolves generate_animation only via requestedKind, which comes solely from the metadata written by rememberGenerationRunMetadata. If that write failed or the run started in another browser/tab, toGenerationRun returns undefined and the run disappears from the queue and is never reconciled — so the finished animation only appears after a manual reload. Other kinds degrade via name: request?.name ?? \New ${kind}``; animations have no equivalent.

Smaller items

  • pruneGenerationRequests (generation.api.ts:83) has no production caller left — the PR removed the one in listRuns and added an assetId parameter nothing passes. Per .agents/principle.md ("remove orphans your change creates"), it and its four tests look removable. Note this also leaves forgetGenerationRunMetadata as the only cleanup, and it runs only when the editor is mounted and observes a completed/cancelled detail — metadata for failed runs, or runs that settle with the tab closed, stays in localStorage indefinitely.
  • generationPrompt is now unused in frontend/src (replaced by creativeBrief) but remains in en-US/generation.json:46 and zh-CN/generation.json:46.
  • syncEditorSessionExternalRecord merges only animations; prompt, prototype, and nodePositions from the incoming record are dropped. Since the inspector's edit_character_prototype runs trigger a record refetch on completion, the canvas keeps showing the stale prototype. Worth either widening the merge or renaming to reflect the animation-only scope.

Verified clean: i18n keys are complete in both en-US and zh-CN (all directions.*, frameCount, fps, sourceDuration, secondsShort, animationSummary, queueingAnimation, creativeBrief, plus the editor.json status keys), interpolation placeholders match their call sites, no dangerouslySetInnerHTML on the path that renders backend detail.error, no secrets in the diff, and no dangling references to the removed GenerateAnimationResult / GeneratedCharacterAnimation / mock-animation-generation / sprite.animation.generated.

Not verified: I could not run the test suite — pnpm install fails in this sandbox (the pinned pnpm needs a newer Node than the available v20). All findings are from static analysis and reading the surrounding code, not execution.

Comment thread frontend/src/model/asset/record/core-sprite-record.ts
Comment thread frontend/src/model/generation/run/generation-runs.query.ts
Comment thread frontend/src/model/generation/run/generation.api.ts
Comment thread frontend/src/model/generation/run/generation.api.ts Outdated
Comment thread frontend/src/features/asset-editor/state/editor-session-store.ts
Comment thread frontend/src/model/asset/record/core-sprite-record.ts
Comment thread frontend/src/features/generation/create-animation-trigger.tsx
Settled runs could poll indefinitely when detail or record refresh requests kept failing.

Track at most three reconciliation attempts and finalize completed runs before refreshing dependent caches.

Generation queues now stop retrying stale runs while later server lists can rediscover active work.
Animation runs disappeared when localStorage metadata was unavailable, and the unused pruning helper no longer had a production caller.

Resolve missing animation kinds from Core assets, fall back to a visible character placeholder, and remove obsolete pruning coverage.

Generation queues now retain cross-tab or storage-failure runs for reconciliation.
Clearing a number input left the previous request value in state while the field appeared empty.

Allow numeric draft fields to become undefined and keep the submit control disabled until validation succeeds.

Animation generation settings now stay synchronized with their visible form values.
The animation form now uses the creative brief label and no longer reads the legacy generation prompt key.

Remove the orphaned key from the English and Chinese generation locale files.

Both locales now match the current animation generation UI contract.

@nighca nighca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先 merge,review 提到的问题可以看下


export const recordApi: AssetRecordApi = {
get: getMockAssetRecord,
get: async (input) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个怪怪的,get record 跟 loadCoreSpriteAssetWorkspace 语义上并不相关,record 和 core-sprite-asset-workspace 是一个东西吗?

return record.mode === "character" || record.mode === "object";
}

function mergeExternalAnimations(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 看上去很多复杂度是前端跟服务端(generation 逻辑)同时都会去修改 asset 内部数据引入的

如果 generation 自己不去写(甚至也不读)project/asset 数据,只提供生成能力和对生成任务状态的管理,只由前端的 editor(通过消费生成任务的状态和结果)去做 asset 数据的修改,那样可能整体会更简单些;当然这个是大的调整了,是不是确实要调整可以再看

@nighca
nighca merged commit 138e50b into 1024XEngineer:main Aug 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:asset-editor Asset editor UI & canvas. area:generation Asset generation flows, pipelines, post-generation. type:feature A new capability or improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Integrate animation generation API and directional sprite records

2 participants