From 1a0587fdabb1774d3ee94354154111d8922fcc4a Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 13:50:51 +0000
Subject: [PATCH 1/7] fix(website): a refused workflow run is shown where the
reader is looking
When Cloud turned a request down, the output panel fell through to the example:
a picture of a successful run, beside a form that had just been refused. The
phase carries only the error, so the three branches that read an observation
could not fire, `busy` was false and nothing claimed the panel.
The refusal now stands up in the panel, in the vocabulary the model half's
panel already words and offers a way out of. Two refusals are left alone
there: a session that expired and a form gone out of date are said in the
page's own words, and standing them up under a sentence about something else
would be worse than leaving them where they are.
That also connects a way out that was already built and never reachable: the
panel draws Add credits from `reason === 'noCredits'`, which this page never
produced, so a reader out of credits was shown the sentence and a Run button
that would be refused again.
Two findings this turned up are left for their own changes: the run-failed case
says "Review your inputs" under the form and "Keep your inputs unchanged" in
the panel, which is one event giving opposite advice; and `workflow_not_found`
is constructed nowhere, so its sentence is dead.
---
.../workshop/WorkflowResults.test.ts | 56 ++++++++++++++++++-
.../components/workshop/WorkflowResults.vue | 8 +++
.../src/lib/workshop/workflow-refusal.test.ts | 53 ++++++++++++++++++
.../src/lib/workshop/workflow-refusal.ts | 40 +++++++++++++
4 files changed, 156 insertions(+), 1 deletion(-)
create mode 100644 apps/website/src/lib/workshop/workflow-refusal.test.ts
create mode 100644 apps/website/src/lib/workshop/workflow-refusal.ts
diff --git a/apps/website/src/components/workshop/WorkflowResults.test.ts b/apps/website/src/components/workshop/WorkflowResults.test.ts
index 2b4ac46876a..cfd388284dc 100644
--- a/apps/website/src/components/workshop/WorkflowResults.test.ts
+++ b/apps/website/src/components/workshop/WorkflowResults.test.ts
@@ -3,7 +3,10 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/vue'
import { assert, describe, expect, it, onTestFinished, vi } from 'vitest'
import { defineComponent, h, shallowRef } from 'vue'
-import { createWorkflowApi } from '../../config/workshop-workflow-api'
+import {
+ createWorkflowApi,
+ WorkshopWorkflowError
+} from '../../config/workshop-workflow-api'
import { workflowDetailsBySlug } from '../../config/workshop-workflow-content'
import { createWorkflowController } from '../../config/workshop-workflow-controller'
import type { WorkflowState } from '../../config/workshop-workflow-state'
@@ -196,3 +199,54 @@ describe('WorkflowResults', () => {
expect(f.state.value.phase).toBe('settled')
})
})
+
+// A request Cloud turns down used to leave the panel showing the example: a
+// picture of a successful run, beside a form that had just been refused.
+describe('a refused request', () => {
+ function mountRefused(code: string) {
+ const model = workflowDetailsBySlug.get('workflows/remove-background')
+ assert(model)
+ render(WorkflowResults, {
+ props: {
+ model,
+ state: {
+ phase: 'failed',
+ error: new WorkshopWorkflowError(
+ code as ConstructorParameters[0]
+ )
+ } satisfies WorkflowState,
+ exampleIndex: 0,
+ busy: false,
+ statusLabel: '',
+ canStart: true,
+ refreshOutput: async () => undefined
+ }
+ })
+ }
+
+ it('stands the refusal up in the output panel instead of the example', () => {
+ mountRefused('insufficient_credits')
+
+ // Shown and also announced, so the sentence is on the page more than once.
+ expect(
+ screen.getAllByText('Not enough credits. Add credits to continue.').length
+ ).toBeGreaterThan(0)
+ expect(screen.queryByText('An example from this template.')).toBeNull()
+ })
+
+ // The panel already knows how to send a reader to buy credits; it was never
+ // being told that was the refusal.
+ it('offers the way out the refusal has', () => {
+ mountRefused('insufficient_credits')
+
+ expect(screen.getByRole('button', { name: /credits/i })).toBeTruthy()
+ })
+
+ // A session that expired and a form gone out of date are said in the page's
+ // own words elsewhere, so the panel is left alone for those.
+ it('leaves the panel alone for a refusal it has no words for', () => {
+ mountRefused('not_authenticated')
+
+ expect(screen.getByText('An example from this template.')).toBeTruthy()
+ })
+})
diff --git a/apps/website/src/components/workshop/WorkflowResults.vue b/apps/website/src/components/workshop/WorkflowResults.vue
index fbf29dae9fe..a7abd596c06 100644
--- a/apps/website/src/components/workshop/WorkflowResults.vue
+++ b/apps/website/src/components/workshop/WorkflowResults.vue
@@ -9,6 +9,7 @@ import { useWorkshopDelivery } from '../../composables/useWorkshopDelivery'
import type { WorkflowState } from '../../config/workshop-workflow-state'
import { workflowOutputs } from '../../config/workshop-workflow-response'
import { outputLabels } from '../../lib/workshop/output-labels'
+import { workflowRunFailure } from '../../lib/workshop/workflow-refusal'
import { t } from '../../i18n/translations'
import { captureWorkshopEvent } from '../../scripts/posthog'
import type { WorkshopRunAnalytics } from '../../scripts/workshop-analytics'
@@ -66,6 +67,13 @@ const outputState = computed(() => {
if (result?.run.state === 'cancelled') return { status: 'idle' }
if (result?.run.state === 'failed')
return { status: 'failed', reason: 'provider', fieldErrors: {} }
+ // A request Cloud turned down used to fall through to the example, so the
+ // panel showed what the workflow makes while the run had just been refused.
+ if (state.phase === 'failed') {
+ const reason = workflowRunFailure(state.error)
+ if (reason)
+ return { status: 'failed', reason, fieldErrors: state.error.fieldErrors }
+ }
if (busy) return runningState.value
if (state.phase === 'settled') return { status: 'idle' }
return exampleState.value
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
new file mode 100644
index 00000000000..5cd959765e2
--- /dev/null
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from 'vitest'
+
+import type { RunFailure } from '../../config/workshop-run'
+import type { WorkflowErrorCode } from '../../config/workshop-workflow-response'
+import { failureLabelKey } from './failure-label'
+import { workflowRunFailure } from './workflow-refusal'
+
+// Every code the API can report and the refusal the panel stands up for it.
+// The table is the specification: a code nobody decided about reads as
+// undefined here rather than as a wrong sentence on the page.
+const REFUSALS: readonly [
+ WorkflowErrorCode | 'network' | 'response' | 'persistence',
+ RunFailure | undefined
+][] = [
+ ['invalid_request', 'validation'],
+ ['invalid_input', 'validation'],
+ ['payload_too_large', 'validation'],
+ ['unsupported_media_type', 'validation'],
+ ['access_denied', 'policy'],
+ ['insufficient_credits', 'noCredits'],
+ ['rate_limited', 'rateLimit'],
+ ['media_unavailable', 'unavailable'],
+ ['execution_failed', 'provider'],
+ ['delivery_failed', 'network'],
+ ['submission_unknown', 'network'],
+ ['network', 'network'],
+ ['response', 'response'],
+ ['persistence', 'client'],
+ ['run_not_found', 'client'],
+ ['not_authenticated', undefined],
+ ['workflow_not_found', undefined],
+ ['definition_changed', undefined],
+ ['definition_incompatible', undefined]
+]
+
+describe('workflowRunFailure', () => {
+ it.for(REFUSALS)('stands %s up as %s', ([code, refusal]) => {
+ expect(workflowRunFailure({ code })).toBe(refusal)
+ })
+
+ // A code this page has not met yet is not given a sentence about something
+ // else; the page keeps saying what it says today.
+ it('claims nothing about a code it does not know', () => {
+ expect(
+ workflowRunFailure({ code: 'teapot' as WorkflowErrorCode })
+ ).toBeUndefined()
+ })
+
+ it('only ever names a refusal the panel has words for', () => {
+ for (const [, refusal] of REFUSALS)
+ if (refusal) expect(failureLabelKey[refusal]).toBeTruthy()
+ })
+})
diff --git a/apps/website/src/lib/workshop/workflow-refusal.ts b/apps/website/src/lib/workshop/workflow-refusal.ts
new file mode 100644
index 00000000000..eca34cb8240
--- /dev/null
+++ b/apps/website/src/lib/workshop/workflow-refusal.ts
@@ -0,0 +1,40 @@
+import type { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
+import type { RunFailure } from '../../config/workshop-run'
+
+/**
+ * Which refusal the output panel should stand up, in the vocabulary the model
+ * half's panel already words and offers a way out of.
+ *
+ * `undefined` where the shared vocabulary has no word for what happened: a
+ * session that expired and a form that went out of date are both things the
+ * workflow page says in its own words, and standing them up under a sentence
+ * about something else would be worse than leaving them where they are.
+ */
+export function workflowRunFailure(
+ error: Pick
+): RunFailure | undefined {
+ return REFUSALS[error.code]
+}
+
+const REFUSALS: Record = {
+ invalid_request: 'validation',
+ invalid_input: 'validation',
+ payload_too_large: 'validation',
+ unsupported_media_type: 'validation',
+ access_denied: 'policy',
+ insufficient_credits: 'noCredits',
+ rate_limited: 'rateLimit',
+ media_unavailable: 'unavailable',
+ execution_failed: 'provider',
+ delivery_failed: 'network',
+ submission_unknown: 'network',
+ network: 'network',
+ response: 'response',
+ persistence: 'client',
+ run_not_found: 'client',
+ // Said in the page's own words instead, because the panel has none for them.
+ not_authenticated: undefined,
+ workflow_not_found: undefined,
+ definition_changed: undefined,
+ definition_incompatible: undefined
+}
From 576cbd84d8a54017cf3592f036fc60a757b7f9b6 Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 13:57:47 +0000
Subject: [PATCH 2/7] fix(website): one sentence per refusal, and a way out
that reaches something
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Standing the refusal up in the panel left three things wrong, all of them
visible to a reader.
The sentence was said twice. The panel says the refusals it has words for, and
the paragraph beside the form went on saying them too — sometimes the same
words twice, sometimes two that disagree. That paragraph is now for what only
this page can say.
What is wrong with an input no longer goes to the panel at all. A rejection the
panel cannot pin to a field is worded there as a model refusing inputs, which
is not what happened, and a field's own trouble belongs beside the field. Those
four codes stay with the form.
Add credits reached nothing. The panel draws that button from the refusal and
emits it; this page bound retry and the delivery handlers and not that one, so
the reader out of credits was handed a button that did nothing when pressed.
---
.../workshop/WorkflowPlayground.vue | 19 +++++++++++++++++--
.../components/workshop/WorkflowResults.vue | 2 ++
.../src/lib/workshop/workflow-refusal.test.ts | 8 ++++----
.../src/lib/workshop/workflow-refusal.ts | 15 +++++++++------
4 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/apps/website/src/components/workshop/WorkflowPlayground.vue b/apps/website/src/components/workshop/WorkflowPlayground.vue
index 6e8c2c0f99b..18aa5065d4a 100644
--- a/apps/website/src/components/workshop/WorkflowPlayground.vue
+++ b/apps/website/src/components/workshop/WorkflowPlayground.vue
@@ -17,6 +17,7 @@ import {
workflowErrorKey,
workflowStatusKey
} from '../../config/workshop-workflow-presentation'
+import { workflowRunFailure } from '../../lib/workshop/workflow-refusal'
import { useTablist } from '../../composables/useTablist'
import { useWorkflowFormDraft } from '../../composables/useWorkflowFormDraft'
import { useWorkflowRun } from '../../composables/useWorkflowRun'
@@ -125,6 +126,16 @@ const error = computed(() =>
: undefined
)
const fieldErrors = computed(() => error.value?.fieldErrors ?? {})
+// The output panel stands up the refusals it has words for, so saying those
+// again beside the form hands the reader the same thing twice — and twice in
+// different words wherever the two vocabularies disagree. What is left here is
+// what only this page can say.
+const refusalSaidHere = computed(() => {
+ if (!error.value) return undefined
+ const inThePanel =
+ state.value.phase === 'failed' && workflowRunFailure(error.value)
+ return inThePanel ? undefined : t(workflowErrorKey(error.value))
+})
const statusLabel = computed(() => {
if (cancelRequested.value && busy.value)
return t('workshop.workflow.cancelling')
@@ -251,8 +262,12 @@ function start() {
>
{{ t('workshop.workflow.paused') }}
-
- {{ t(workflowErrorKey(error)) }}
+
+ {{ refusalSaidHere }}
= {
- invalid_request: 'validation',
- invalid_input: 'validation',
- payload_too_large: 'validation',
- unsupported_media_type: 'validation',
access_denied: 'policy',
insufficient_credits: 'noCredits',
rate_limited: 'rateLimit',
@@ -32,9 +28,16 @@ const REFUSALS: Record = {
response: 'response',
persistence: 'client',
run_not_found: 'client',
- // Said in the page's own words instead, because the panel has none for them.
+ // Said in the page's own words instead. A session that expired and a form
+ // gone out of date the panel has no word for at all; what is wrong with an
+ // input belongs beside the input, and the panel's own words for a rejection
+ // it cannot pin to a field are about a model rather than a workflow.
not_authenticated: undefined,
workflow_not_found: undefined,
definition_changed: undefined,
- definition_incompatible: undefined
+ definition_incompatible: undefined,
+ invalid_request: undefined,
+ invalid_input: undefined,
+ payload_too_large: undefined,
+ unsupported_media_type: undefined
}
From 0f96a80da9bd70b80b279840faa6cf51beca13d0 Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 14:31:21 +0000
Subject: [PATCH 3/7] fix(website): a shared word is not a shared meaning
Writing every refusal out side by side showed five of the eleven saying the
wrong thing. A workspace Cloud denied was read out as a provider's content
policy blocking the prompt. An input upload that never arrived became a model
being temporarily unavailable. Outputs that could not be fetched after a run
finished became a connection that dropped mid-run, with its warning that the run
may still be billed. A run that is not in this account became the page failing
to complete a request. Browser storage the page could not write lost the one
sentence that names its fix.
So a code reaches the panel only where the sentence the panel already has is
about the same event: not enough credits and too many runs, which are the same
sentence in both; a response that arrived and could not be read; a connection
that went while a run may be alive; and a run the provider failed, where the
panel says more of it than this page does.
For everything else the page's own accurate sentence stays beside the form, and
the panel shows nothing. That still fixes what was wrong to begin with, which
was never the words: it was a picture of a successful run sitting beside a form
that had just been refused.
---
.../workshop/WorkflowResults.test.ts | 12 +++---
.../components/workshop/WorkflowResults.vue | 8 +++-
.../src/lib/workshop/workflow-refusal.test.ts | 40 ++++++++++-------
.../src/lib/workshop/workflow-refusal.ts | 43 ++++++++-----------
4 files changed, 56 insertions(+), 47 deletions(-)
diff --git a/apps/website/src/components/workshop/WorkflowResults.test.ts b/apps/website/src/components/workshop/WorkflowResults.test.ts
index cfd388284dc..9fdceedbeae 100644
--- a/apps/website/src/components/workshop/WorkflowResults.test.ts
+++ b/apps/website/src/components/workshop/WorkflowResults.test.ts
@@ -242,11 +242,13 @@ describe('a refused request', () => {
expect(screen.getByRole('button', { name: /credits/i })).toBeTruthy()
})
- // A session that expired and a form gone out of date are said in the page's
- // own words elsewhere, so the panel is left alone for those.
- it('leaves the panel alone for a refusal it has no words for', () => {
- mountRefused('not_authenticated')
+ // A refusal the panel has no sentence for is said beside the form instead.
+ // The panel then shows nothing — not the example, which is a picture of a run
+ // that worked.
+ it('shows nothing rather than the example for a refusal it cannot word', () => {
+ mountRefused('access_denied')
- expect(screen.getByText('An example from this template.')).toBeTruthy()
+ expect(screen.queryByText('An example from this template.')).toBeNull()
+ expect(screen.getByText('Your output will appear here.')).toBeTruthy()
})
})
diff --git a/apps/website/src/components/workshop/WorkflowResults.vue b/apps/website/src/components/workshop/WorkflowResults.vue
index 7ea83e43554..a2086e08c2c 100644
--- a/apps/website/src/components/workshop/WorkflowResults.vue
+++ b/apps/website/src/components/workshop/WorkflowResults.vue
@@ -70,10 +70,14 @@ const outputState = computed(() => {
return { status: 'failed', reason: 'provider', fieldErrors: {} }
// A request Cloud turned down used to fall through to the example, so the
// panel showed what the workflow makes while the run had just been refused.
+ // Where the panel has the words for it, it says so; where it does not, the
+ // page says it beside the form and the panel shows nothing, because nothing
+ // was made.
if (state.phase === 'failed') {
const reason = workflowRunFailure(state.error)
- if (reason)
- return { status: 'failed', reason, fieldErrors: state.error.fieldErrors }
+ return reason
+ ? { status: 'failed', reason, fieldErrors: state.error.fieldErrors }
+ : { status: 'idle' }
}
if (busy) return runningState.value
if (state.phase === 'settled') return { status: 'idle' }
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
index 06136137d2e..1fa5de072c9 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.test.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -5,32 +5,42 @@ import type { WorkflowErrorCode } from '../../config/workshop-workflow-response'
import { failureLabelKey } from './failure-label'
import { workflowRunFailure } from './workflow-refusal'
-// Every code the API can report and the refusal the panel stands up for it.
-// The table is the specification: a code nobody decided about reads as
-// undefined here rather than as a wrong sentence on the page.
+// Every code the API can report and the refusal the panel stands up for it. The
+// table is the specification: a code whose event the panel has no sentence for
+// reads as undefined here, rather than as a sentence about something else.
const REFUSALS: readonly [
WorkflowErrorCode | 'network' | 'response' | 'persistence',
RunFailure | undefined
][] = [
- ['invalid_request', undefined],
- ['invalid_input', undefined],
- ['payload_too_large', undefined],
- ['unsupported_media_type', undefined],
- ['access_denied', 'policy'],
['insufficient_credits', 'noCredits'],
['rate_limited', 'rateLimit'],
- ['media_unavailable', 'unavailable'],
- ['execution_failed', 'provider'],
- ['delivery_failed', 'network'],
- ['submission_unknown', 'network'],
['network', 'network'],
['response', 'response'],
- ['persistence', 'client'],
- ['run_not_found', 'client'],
+ ['execution_failed', 'provider'],
+ // What is wrong with an input belongs beside the input, and the panel's own
+ // words for a rejection it cannot pin to a field are about a model.
+ ['invalid_request', undefined],
+ ['invalid_input', undefined],
+ ['payload_too_large', undefined],
+ ['unsupported_media_type', undefined],
+ // A session that expired and a form gone out of date the panel has no word
+ // for at all.
['not_authenticated', undefined],
['workflow_not_found', undefined],
['definition_changed', undefined],
- ['definition_incompatible', undefined]
+ ['definition_incompatible', undefined],
+ // Codes the panel has a word for, about a different event: a workspace Cloud
+ // denied is not a provider's content policy; an input upload that never
+ // arrived is not a model being down; outputs that could not be fetched after
+ // a run finished is not a connection that dropped mid-run; browser storage
+ // the page could not write names its own fix, which the panel's sentence
+ // does not.
+ ['access_denied', undefined],
+ ['media_unavailable', undefined],
+ ['delivery_failed', undefined],
+ ['submission_unknown', undefined],
+ ['persistence', undefined],
+ ['run_not_found', undefined]
]
describe('workflowRunFailure', () => {
diff --git a/apps/website/src/lib/workshop/workflow-refusal.ts b/apps/website/src/lib/workshop/workflow-refusal.ts
index 34d51c0d433..2ef560e95bb 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.ts
@@ -2,13 +2,16 @@ import type { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
import type { RunFailure } from '../../config/workshop-run'
/**
- * Which refusal the output panel should stand up, in the vocabulary the model
- * half's panel already words and offers a way out of.
+ * Which refusal the output panel should stand up, where the panel's own words
+ * are about the same event as this page's.
*
- * `undefined` where the shared vocabulary has no word for what happened: a
- * session that expired and a form that went out of date are both things the
- * workflow page says in its own words, and standing them up under a sentence
- * about something else would be worse than leaving them where they are.
+ * The two halves of the Hub refuse things in different vocabularies, and a
+ * shared word is not a shared meaning: Cloud denying a workspace is not a
+ * provider's content policy, and an input upload that never arrived is not a
+ * model being down. So a code reaches the panel only where the sentence the
+ * panel already has says what actually happened; everywhere else the page's
+ * own accurate sentence stays beside the form, and the panel shows nothing
+ * rather than either the wrong words or a picture of a run that succeeded.
*/
export function workflowRunFailure(
error: Pick
@@ -17,27 +20,17 @@ export function workflowRunFailure(
}
const REFUSALS: Record = {
- access_denied: 'policy',
+ // The same sentence in both, and the only way out of it — Add credits, or
+ // the reader's own workspace — is the panel's to offer.
insufficient_credits: 'noCredits',
+ // The same sentence in both.
rate_limited: 'rateLimit',
- media_unavailable: 'unavailable',
- execution_failed: 'provider',
- delivery_failed: 'network',
- submission_unknown: 'network',
+ // Both about a connection that went while a run may be alive and billed.
network: 'network',
+ // A response that arrived and could not be read, which is what this page
+ // otherwise reports only as a run it could not check.
response: 'response',
- persistence: 'client',
- run_not_found: 'client',
- // Said in the page's own words instead. A session that expired and a form
- // gone out of date the panel has no word for at all; what is wrong with an
- // input belongs beside the input, and the panel's own words for a rejection
- // it cannot pin to a field are about a model rather than a workflow.
- not_authenticated: undefined,
- workflow_not_found: undefined,
- definition_changed: undefined,
- definition_incompatible: undefined,
- invalid_request: undefined,
- invalid_input: undefined,
- payload_too_large: undefined,
- unsupported_media_type: undefined
+ // One event, and the panel says more of it: the credits that may have gone
+ // without a result, and the request ID to quote.
+ execution_failed: 'provider'
}
From 8f4e4d0c041a6cb3274fa2173250f75b4ce6a4cf Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 16:06:35 +0000
Subject: [PATCH 4/7] fix(website): one reader, one account of a refused run
The decision about which half of the page says a refusal now lives in the
library beside the mapping it depends on, so the page and the panel cannot
disagree about who is speaking. Splitting the panel's state into what Cloud
reported and what it turned down keeps each readable on its own.
The credits test now presses the button and watches for the request, so a
binding that reaches nothing fails it.
---
.../workshop/WorkflowPlayground.vue | 18 +++---
.../workshop/WorkflowResults.test.ts | 19 ++++---
.../components/workshop/WorkflowResults.vue | 57 ++++++++++++-------
.../src/lib/workshop/workflow-refusal.test.ts | 24 +++++++-
.../src/lib/workshop/workflow-refusal.ts | 12 ++++
5 files changed, 89 insertions(+), 41 deletions(-)
diff --git a/apps/website/src/components/workshop/WorkflowPlayground.vue b/apps/website/src/components/workshop/WorkflowPlayground.vue
index 18aa5065d4a..d6ca5ed5f61 100644
--- a/apps/website/src/components/workshop/WorkflowPlayground.vue
+++ b/apps/website/src/components/workshop/WorkflowPlayground.vue
@@ -17,7 +17,7 @@ import {
workflowErrorKey,
workflowStatusKey
} from '../../config/workshop-workflow-presentation'
-import { workflowRunFailure } from '../../lib/workshop/workflow-refusal'
+import { panelSaysRefusal } from '../../lib/workshop/workflow-refusal'
import { useTablist } from '../../composables/useTablist'
import { useWorkflowFormDraft } from '../../composables/useWorkflowFormDraft'
import { useWorkflowRun } from '../../composables/useWorkflowRun'
@@ -126,16 +126,12 @@ const error = computed(() =>
: undefined
)
const fieldErrors = computed(() => error.value?.fieldErrors ?? {})
-// The output panel stands up the refusals it has words for, so saying those
-// again beside the form hands the reader the same thing twice — and twice in
-// different words wherever the two vocabularies disagree. What is left here is
-// what only this page can say.
-const refusalSaidHere = computed(() => {
- if (!error.value) return undefined
- const inThePanel =
- state.value.phase === 'failed' && workflowRunFailure(error.value)
- return inThePanel ? undefined : t(workflowErrorKey(error.value))
-})
+// What is left for this page to say is what the panel does not carry.
+const refusalSaidHere = computed(() =>
+ error.value && !panelSaysRefusal(state.value)
+ ? t(workflowErrorKey(error.value))
+ : undefined
+)
const statusLabel = computed(() => {
if (cancelRequested.value && busy.value)
return t('workshop.workflow.cancelling')
diff --git a/apps/website/src/components/workshop/WorkflowResults.test.ts b/apps/website/src/components/workshop/WorkflowResults.test.ts
index 9fdceedbeae..46877c0b4ae 100644
--- a/apps/website/src/components/workshop/WorkflowResults.test.ts
+++ b/apps/website/src/components/workshop/WorkflowResults.test.ts
@@ -7,6 +7,7 @@ import {
createWorkflowApi,
WorkshopWorkflowError
} from '../../config/workshop-workflow-api'
+import { subscribeToWorkshopBuyCredits } from '../../config/workshop-buy-credits'
import { workflowDetailsBySlug } from '../../config/workshop-workflow-content'
import { createWorkflowController } from '../../config/workshop-workflow-controller'
import type { WorkflowState } from '../../config/workshop-workflow-state'
@@ -203,7 +204,7 @@ describe('WorkflowResults', () => {
// A request Cloud turns down used to leave the panel showing the example: a
// picture of a successful run, beside a form that had just been refused.
describe('a refused request', () => {
- function mountRefused(code: string) {
+ function mountRefused(code: WorkshopWorkflowError['code']) {
const model = workflowDetailsBySlug.get('workflows/remove-background')
assert(model)
render(WorkflowResults, {
@@ -211,9 +212,7 @@ describe('a refused request', () => {
model,
state: {
phase: 'failed',
- error: new WorkshopWorkflowError(
- code as ConstructorParameters[0]
- )
+ error: new WorkshopWorkflowError(code)
} satisfies WorkflowState,
exampleIndex: 0,
busy: false,
@@ -235,11 +234,17 @@ describe('a refused request', () => {
})
// The panel already knows how to send a reader to buy credits; it was never
- // being told that was the refusal.
- it('offers the way out the refusal has', () => {
+ // being told that was the refusal. A button that reaches nothing is not a way
+ // out, so press it and watch for the request the page answers.
+ it('offers the way out the refusal has', async () => {
+ const asked = vi.fn()
+ onTestFinished(subscribeToWorkshopBuyCredits(asked))
mountRefused('insufficient_credits')
- expect(screen.getByRole('button', { name: /credits/i })).toBeTruthy()
+ await userEvent
+ .setup()
+ .click(screen.getByRole('button', { name: /credits/i }))
+ expect(asked).toHaveBeenCalledOnce()
})
// A refusal the panel has no sentence for is said beside the form instead.
diff --git a/apps/website/src/components/workshop/WorkflowResults.vue b/apps/website/src/components/workshop/WorkflowResults.vue
index a2086e08c2c..d33df9159ae 100644
--- a/apps/website/src/components/workshop/WorkflowResults.vue
+++ b/apps/website/src/components/workshop/WorkflowResults.vue
@@ -55,30 +55,43 @@ const runningState = computed(() => ({
const outputs = computed(() =>
observation.value ? workflowOutputs(observation.value) : []
)
-const outputState = computed(() => {
+// What Cloud last said about a run it accepted. Undefined while it has said
+// nothing the panel can draw yet, including a finished run whose outputs have
+// not arrived.
+const observedState = computed(() => {
const result = observation.value
- if (result?.run.state === 'succeeded' && outputs.value[0]) {
- return {
- status: 'succeeded',
- output: outputs.value[0],
- nsfw: false,
- completedAt: Date.parse(result.run.completedAt ?? result.run.updatedAt)
- }
- }
- if (result?.run.state === 'cancelled') return { status: 'idle' }
- if (result?.run.state === 'failed')
+ if (!result) return undefined
+ const output = outputs.value[0]
+ if (result.run.state === 'succeeded')
+ return output
+ ? {
+ status: 'succeeded',
+ output,
+ nsfw: false,
+ completedAt: Date.parse(
+ result.run.completedAt ?? result.run.updatedAt
+ )
+ }
+ : undefined
+ if (result.run.state === 'cancelled') return { status: 'idle' }
+ if (result.run.state === 'failed')
return { status: 'failed', reason: 'provider', fieldErrors: {} }
- // A request Cloud turned down used to fall through to the example, so the
- // panel showed what the workflow makes while the run had just been refused.
- // Where the panel has the words for it, it says so; where it does not, the
- // page says it beside the form and the panel shows nothing, because nothing
- // was made.
- if (state.phase === 'failed') {
- const reason = workflowRunFailure(state.error)
- return reason
- ? { status: 'failed', reason, fieldErrors: state.error.fieldErrors }
- : { status: 'idle' }
- }
+ return undefined
+})
+// A request Cloud turned down used to fall through to the example, so the panel
+// showed what the workflow makes while the run had just been refused. Where the
+// panel has the words for it, it says so; where it does not, the page says it
+// beside the form and the panel shows nothing, because nothing was made.
+const refusedState = computed(() => {
+ if (state.phase !== 'failed') return undefined
+ const reason = workflowRunFailure(state.error)
+ return reason
+ ? { status: 'failed', reason, fieldErrors: state.error.fieldErrors }
+ : { status: 'idle' }
+})
+const outputState = computed(() => {
+ if (observedState.value) return observedState.value
+ if (refusedState.value) return refusedState.value
if (busy) return runningState.value
if (state.phase === 'settled') return { status: 'idle' }
return exampleState.value
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
index 1fa5de072c9..14941bb9da2 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.test.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -1,9 +1,10 @@
import { describe, expect, it } from 'vitest'
+import { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
import type { RunFailure } from '../../config/workshop-run'
import type { WorkflowErrorCode } from '../../config/workshop-workflow-response'
import { failureLabelKey } from './failure-label'
-import { workflowRunFailure } from './workflow-refusal'
+import { panelSaysRefusal, workflowRunFailure } from './workflow-refusal'
// Every code the API can report and the refusal the panel stands up for it. The
// table is the specification: a code whose event the panel has no sentence for
@@ -61,3 +62,24 @@ describe('workflowRunFailure', () => {
if (refusal) expect(failureLabelKey[refusal]).toBeTruthy()
})
})
+
+// Whether the page keeps quiet beside the form follows from the same table: it
+// speaks exactly where the panel does not, so the reader is never handed the
+// same refusal twice, nor two different accounts of it.
+describe('panelSaysRefusal', () => {
+ it.for(REFUSALS)('leaves %s to the panel only as %s', ([code, refusal]) => {
+ expect(
+ panelSaysRefusal({
+ phase: 'failed',
+ error: new WorkshopWorkflowError(code)
+ })
+ ).toBe(refusal !== undefined)
+ })
+
+ it.for([{ phase: 'idle' }, { phase: 'preparing' }] as const)(
+ 'says nothing about a $phase page',
+ (state) => {
+ expect(panelSaysRefusal(state)).toBe(false)
+ }
+ )
+})
diff --git a/apps/website/src/lib/workshop/workflow-refusal.ts b/apps/website/src/lib/workshop/workflow-refusal.ts
index 2ef560e95bb..9cb6afeefdf 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.ts
@@ -1,5 +1,6 @@
import type { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
import type { RunFailure } from '../../config/workshop-run'
+import type { WorkflowState } from '../../config/workshop-workflow-state'
/**
* Which refusal the output panel should stand up, where the panel's own words
@@ -34,3 +35,14 @@ const REFUSALS: Record = {
// without a result, and the request ID to quote.
execution_failed: 'provider'
}
+
+/**
+ * Whether the output panel is the one saying this refusal. The page then keeps
+ * quiet beside the form rather than handing the reader the same thing twice —
+ * and twice in different words wherever the two vocabularies disagree.
+ */
+export function panelSaysRefusal(state: WorkflowState): boolean {
+ return (
+ state.phase === 'failed' && workflowRunFailure(state.error) !== undefined
+ )
+}
From 39d925a108aedfc6818c28a69f0c7364f33c22f0 Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 16:11:20 +0000
Subject: [PATCH 5/7] fix(website): a code the page has never met is absent,
not inherited
Looking the code up in a plain object answered 'toString' with a method of
Object.prototype, so an unknown code arrived as a refusal and displaced the
accurate sentence. A Map has no such names to lend.
---
.../src/lib/workshop/workflow-refusal.test.ts | 16 ++++++++++------
.../src/lib/workshop/workflow-refusal.ts | 19 +++++++++++--------
2 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
index 14941bb9da2..8543cf357d9 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.test.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -50,12 +50,16 @@ describe('workflowRunFailure', () => {
})
// A code this page has not met yet is not given a sentence about something
- // else; the page keeps saying what it says today.
- it('claims nothing about a code it does not know', () => {
- expect(
- workflowRunFailure({ code: 'teapot' as WorkflowErrorCode })
- ).toBeUndefined()
- })
+ // else; the page keeps saying what it says today. 'toString' is here because
+ // a plain object would have answered it with a method of its prototype.
+ it.for(['teapot', 'toString', 'constructor'] as const)(
+ 'claims nothing about %s, a code it does not know',
+ (code) => {
+ expect(
+ workflowRunFailure({ code: code as WorkflowErrorCode })
+ ).toBeUndefined()
+ }
+ )
it('only ever names a refusal the panel has words for', () => {
for (const [, refusal] of REFUSALS)
diff --git a/apps/website/src/lib/workshop/workflow-refusal.ts b/apps/website/src/lib/workshop/workflow-refusal.ts
index 9cb6afeefdf..7ab9322308b 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.ts
@@ -17,24 +17,27 @@ import type { WorkflowState } from '../../config/workshop-workflow-state'
export function workflowRunFailure(
error: Pick
): RunFailure | undefined {
- return REFUSALS[error.code]
+ return REFUSALS.get(error.code)
}
-const REFUSALS: Record = {
+// A Map, not an object: a code the page has never met must read as absent, and
+// an object would hand back whatever Object.prototype happens to call by that
+// name — 'toString' would arrive as a refusal.
+const REFUSALS = new Map([
// The same sentence in both, and the only way out of it — Add credits, or
// the reader's own workspace — is the panel's to offer.
- insufficient_credits: 'noCredits',
+ ['insufficient_credits', 'noCredits'],
// The same sentence in both.
- rate_limited: 'rateLimit',
+ ['rate_limited', 'rateLimit'],
// Both about a connection that went while a run may be alive and billed.
- network: 'network',
+ ['network', 'network'],
// A response that arrived and could not be read, which is what this page
// otherwise reports only as a run it could not check.
- response: 'response',
+ ['response', 'response'],
// One event, and the panel says more of it: the credits that may have gone
// without a result, and the request ID to quote.
- execution_failed: 'provider'
-}
+ ['execution_failed', 'provider']
+])
/**
* Whether the output panel is the one saying this refusal. The page then keeps
From 2d95263c54262928f271c44b3c669e2f222da277 Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 17:46:53 +0000
Subject: [PATCH 6/7] fix(website): a run Cloud reports failed is said once, by
the panel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The suppression only looked at a request Cloud turned down. A run it accepted
and then reported failed took the other path: the panel stood it up as a
provider failure while the page added a sentence of its own beside the form —
in different words, telling the reader to change the inputs the panel had just
told them to leave alone. That contradiction is the thing this branch set out
to remove, and it was still live on the commonest failure of all.
---
.../src/lib/workshop/workflow-refusal.test.ts | 48 ++++++++++++++++++-
.../src/lib/workshop/workflow-refusal.ts | 9 +++-
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
index 8543cf357d9..d7db7fcea50 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.test.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -2,7 +2,11 @@ import { describe, expect, it } from 'vitest'
import { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
import type { RunFailure } from '../../config/workshop-run'
-import type { WorkflowErrorCode } from '../../config/workshop-workflow-response'
+import type {
+ WorkflowErrorCode,
+ WorkflowRunSummary
+} from '../../config/workshop-workflow-response'
+import type { WorkflowState } from '../../config/workshop-workflow-state'
import { failureLabelKey } from './failure-label'
import { panelSaysRefusal, workflowRunFailure } from './workflow-refusal'
@@ -86,4 +90,46 @@ describe('panelSaysRefusal', () => {
expect(panelSaysRefusal(state)).toBe(false)
}
)
+
+ // A run Cloud accepted and then reported failed is the panel's to say, and it
+ // says it as a provider failure. The page used to add a second sentence of its
+ // own here — in different words, telling the reader to change the inputs the
+ // panel had just told them to leave alone.
+ it.for([
+ { reported: 'failed', panel: true },
+ { reported: 'succeeded', panel: false },
+ { reported: 'cancelled', panel: false }
+ ] as const)(
+ 'leaves a run reported $reported to the panel: $panel',
+ ({ reported, panel }) => {
+ expect(panelSaysRefusal(observed(reported))).toBe(panel)
+ }
+ )
})
+
+function observed(state: WorkflowRunSummary['state']): WorkflowState {
+ const stamp = new Date(0).toISOString()
+ return {
+ phase: 'settled',
+ record: {
+ version: 2,
+ cancelRequested: false,
+ stage: 'run',
+ runId: 'run',
+ workflowId: 'workflow',
+ definitionVersion: '1'
+ },
+ observation: {
+ run: {
+ id: 'run',
+ workflowId: 'workflow',
+ definitionVersion: '1',
+ state,
+ outputState: 'ready',
+ createdAt: stamp,
+ updatedAt: stamp
+ },
+ outputs: []
+ }
+ }
+}
diff --git a/apps/website/src/lib/workshop/workflow-refusal.ts b/apps/website/src/lib/workshop/workflow-refusal.ts
index 7ab9322308b..5b15da63590 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.ts
@@ -40,11 +40,18 @@ const REFUSALS = new Map([
])
/**
- * Whether the output panel is the one saying this refusal. The page then keeps
+ * Whether the output panel is the one saying this failure. The page then keeps
* quiet beside the form rather than handing the reader the same thing twice —
* and twice in different words wherever the two vocabularies disagree.
+ *
+ * A run Cloud reports as failed is always the panel's: it stands that up as a
+ * provider failure regardless of what the page made of the request. Only a
+ * request Cloud turned down depends on whether the panel has words for the
+ * code.
*/
export function panelSaysRefusal(state: WorkflowState): boolean {
+ if ('observation' in state && state.observation?.run.state === 'failed')
+ return true
return (
state.phase === 'failed' && workflowRunFailure(state.error) !== undefined
)
From fa0eaa59f943220784a60887e5d16685b3e56034 Mon Sep 17 00:00:00 2001
From: Mariana Martinho
Date: Sat, 26 Sep 2026 18:45:50 +0000
Subject: [PATCH 7/7] test(website): a failed run outranks the error that
dropped the connection
---
.../src/lib/workshop/workflow-refusal.test.ts | 59 ++++++++++++-------
1 file changed, 39 insertions(+), 20 deletions(-)
diff --git a/apps/website/src/lib/workshop/workflow-refusal.test.ts b/apps/website/src/lib/workshop/workflow-refusal.test.ts
index d7db7fcea50..387216d44b8 100644
--- a/apps/website/src/lib/workshop/workflow-refusal.test.ts
+++ b/apps/website/src/lib/workshop/workflow-refusal.test.ts
@@ -4,9 +4,11 @@ import { WorkshopWorkflowError } from '../../config/workshop-workflow-api'
import type { RunFailure } from '../../config/workshop-run'
import type {
WorkflowErrorCode,
+ WorkflowRun,
WorkflowRunSummary
} from '../../config/workshop-workflow-response'
import type { WorkflowState } from '../../config/workshop-workflow-state'
+import type { SavedWorkflow } from '../../config/workshop-workflow-storage'
import { failureLabelKey } from './failure-label'
import { panelSaysRefusal, workflowRunFailure } from './workflow-refusal'
@@ -105,31 +107,48 @@ describe('panelSaysRefusal', () => {
expect(panelSaysRefusal(observed(reported))).toBe(panel)
}
)
+
+ // A dropped connection is the one state that carries both: what Cloud last
+ // said about the run, and the error that dropped it. The run wins. Reading the
+ // error first would hand this back to the page, which has a second sentence
+ // ready for a code the panel cannot name.
+ it('leaves a failed run to the panel when the connection dropped on a code it has no words for', () => {
+ expect(
+ panelSaysRefusal({
+ phase: 'interrupted',
+ record: RECORD,
+ observation: run('failed'),
+ error: new WorkshopWorkflowError('media_unavailable')
+ })
+ ).toBe(true)
+ })
})
-function observed(state: WorkflowRunSummary['state']): WorkflowState {
+const RECORD: SavedWorkflow = {
+ version: 2,
+ cancelRequested: false,
+ stage: 'run',
+ runId: 'run',
+ workflowId: 'workflow',
+ definitionVersion: '1'
+}
+
+function run(state: WorkflowRunSummary['state']): WorkflowRun {
const stamp = new Date(0).toISOString()
return {
- phase: 'settled',
- record: {
- version: 2,
- cancelRequested: false,
- stage: 'run',
- runId: 'run',
+ run: {
+ id: 'run',
workflowId: 'workflow',
- definitionVersion: '1'
+ definitionVersion: '1',
+ state,
+ outputState: 'ready',
+ createdAt: stamp,
+ updatedAt: stamp
},
- observation: {
- run: {
- id: 'run',
- workflowId: 'workflow',
- definitionVersion: '1',
- state,
- outputState: 'ready',
- createdAt: stamp,
- updatedAt: stamp
- },
- outputs: []
- }
+ outputs: []
}
}
+
+function observed(state: WorkflowRunSummary['state']): WorkflowState {
+ return { phase: 'settled', record: RECORD, observation: run(state) }
+}