Skip to content

refactor(entities): require a template id for preset actions - #3

Merged
huyanxius merged 3 commits into
feat/58-frontend-skeletonfrom
refactor/59-add-action-input
Jul 28, 2026
Merged

refactor(entities): require a template id for preset actions#3
huyanxius merged 3 commits into
feat/58-frontend-skeletonfrom
refactor/59-add-action-input

Conversation

@huyanxius

Copy link
Copy Markdown
Owner

Picks up the two review points that c7dec4c and e5a13f9 left open. Everything else those two commits covered is untouched here.

Change Description

  • Declaring a preset action without naming its template no longer type-checks. actionTemplateId was renamed but stayed optional, so { name, kind: 'preset' } still passed while saying nothing about which template it used.
  • Project.sampleImageUrl now says it constrains the visual style of the whole project, and points at CreateCharacterInput.referenceImageUrl for the per-character image. Both fields hold an uploaded picture and read alike.

Implementation Approach

  • AddActionInput is a named discriminated union exported from the entities facade; the preset branch requires actionTemplateId, the custom branch has no such field.
  • The id is typed as ActionTemplate['id'] rather than a bare string, so the link breaks at compile time if that id type changes.
  • The existing signature assertion inlined the loose shape, which would have accepted a re-loosened union; it now points at AddActionInput, with an added case covering the two branches.

Testing

  • npm run typecheck — pass
  • npm run lint — pass
  • npm run format:check — pass
  • npm test — 40 tests across 11 files pass, including the dependency-boundary suite
  • npm run build — pass

No CI workflows exist in this repository, so these are the local equivalents.

Follow-ups

Not addressed here, raised for the record:

  • ActionTemplate lost fps in c7dec4c, but Action.fps still 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.
  • Where a custom action's prompt comes from is still open; left as a TODO next to AddActionInput.
  • Project.workflowId keeps the old name while Action.sourceWorkflowRunId was corrected. Needs the backend to confirm whether it holds a workflow or a run.
  • Wearable has no scope field, so built-in wearables cannot be expressed the way built-in action templates now can.

Related

huyan 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.
@huyanxius
huyanxius merged commit 111221a into feat/58-frontend-skeleton Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant