Skip to content

Client: Coerce literal data-herb-set on seeded states to the held type - #2851

Open
pujitha24 wants to merge 1 commit into
marcoroth:mainfrom
pujitha24:auto/issue-2743
Open

pujitha24 wants to merge 1 commit into
marcoroth:mainfrom
pujitha24:auto/issue-2743

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation: a state declared with an expression default (kind seeded)
received a String from a literal data-herb-set (e.g. page=1), while
data-herb-increment wrote a Number. coerceState only converts for
boolean, integer and nil, so seeded kinds fell through to the raw text.
The state's type then depended on which action wrote it last, and the
Herb-State header could carry "page":"1" after "page":2.

Approach: in assignedValue, when the declared kind is seeded, read the
state's current value and coerce the literal to its type: a number for an
integer-looking literal when the state holds a number, a boolean for
true/false when it holds a boolean. Otherwise (string, null) the raw
text is kept as before.

Limitation: if the seeded state currently holds null, there is no type to
follow and the literal is still written as a String. The $value path is
unchanged.

Validation: in javascript/packages/client, npx vitest run test/actions.test.ts passes (44 tests). The new test fails without the
src change and passes with it. Full npx vitest run: 772 tests pass; one
test file fails to collect because the generated state-kinds module is
missing in this checkout, unrelated to this change (tsc reports the same
missing module).

Report: #2743
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5-5 (via Claude Code)

Fixes #2743

Motivation: a state declared with an expression default (kind `seeded`)
received a String from a literal `data-herb-set` (e.g. `page=1`), while
`data-herb-increment` wrote a Number. `coerceState` only converts for
boolean, integer and nil, so seeded kinds fell through to the raw text.
The state's type then depended on which action wrote it last, and the
`Herb-State` header could carry `"page":"1"` after `"page":2`.

Approach: in `assignedValue`, when the declared kind is `seeded`, read the
state's current value and coerce the literal to its type: a number for an
integer-looking literal when the state holds a number, a boolean for
`true`/`false` when it holds a boolean. Otherwise (string, null) the raw
text is kept as before.

Limitation: if the seeded state currently holds null, there is no type to
follow and the literal is still written as a String. The `$value` path is
unchanged.

Validation: in javascript/packages/client, `npx vitest run
test/actions.test.ts` passes (44 tests). The new test fails without the
src change and passes with it. Full `npx vitest run`: 772 tests pass; one
test file fails to collect because the generated `state-kinds` module is
missing in this checkout, unrelated to this change (`tsc` reports the same
missing module).

Report: marcoroth#2743
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5-5 (via Claude Code)
@github-actions github-actions Bot added typescript TypeScript source across the javascript/ packages client-runtime Browser runtime for the Herb slots. labels Oct 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-runtime Browser runtime for the Herb slots. typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client: a literal data-herb-set on a seeded state writes a String

1 participant