refactor(entities): require a template id for preset actions - #3
Merged
huyanxius merged 3 commits intoJul 28, 2026
Merged
Conversation
added 3 commits
July 28, 2026 15:25
The add-action input typed kind and actionTemplateId independently, so a caller could declare a preset action and leave out the template it was supposed to use. Nothing rejected that combination. Turn the input into a named discriminated union: the preset branch carries actionTemplateId, the custom branch carries none. Export AddActionInput from the entities facade so the shape is part of the public contract. The contradictory combination no longer type-checks.
…r one Two fields hold an uploaded image and both read like "the reference picture", which invites callers to reach for the wrong one. Say that sampleImageUrl constrains the visual style of every character in the project, and point at CreateCharacterInput.referenceImageUrl for the per-character image. Readers can tell the two layers apart without tracing call sites.
The previous assertion inlined the loose input shape, so loosening the union again would still satisfy it. Point the signature assertion at AddActionInput and add a case proving only the preset branch carries actionTemplateId. Reintroducing an optional template id now fails the contract suite.
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.
Picks up the two review points that
c7dec4cande5a13f9left open. Everything else those two commits covered is untouched here.Change Description
actionTemplateIdwas renamed but stayed optional, so{ name, kind: 'preset' }still passed while saying nothing about which template it used.Project.sampleImageUrlnow says it constrains the visual style of the whole project, and points atCreateCharacterInput.referenceImageUrlfor the per-character image. Both fields hold an uploaded picture and read alike.Implementation Approach
AddActionInputis a named discriminated union exported from the entities facade; the preset branch requiresactionTemplateId, the custom branch has no such field.ActionTemplate['id']rather than a bare string, so the link breaks at compile time if that id type changes.AddActionInput, with an added case covering the two branches.Testing
npm run typecheck— passnpm run lint— passnpm run format:check— passnpm test— 40 tests across 11 files pass, including the dependency-boundary suitenpm run build— passNo CI workflows exist in this repository, so these are the local equivalents.
Follow-ups
Not addressed here, raised for the record:
ActionTemplatelostfpsinc7dec4c, butAction.fpsstill needs a value. If the backend decides it, that is fine; if the frontend has to supply a frame rate when requesting generation, it now has no source.AddActionInput.Project.workflowIdkeeps the old name whileAction.sourceWorkflowRunIdwas corrected. Needs the backend to confirm whether it holds a workflow or a run.Wearablehas no scope field, so built-in wearables cannot be expressed the way built-in action templates now can.Related