Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/33856-flow-runs-completed-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@object-ui/console': patch
---

fix(console): a screen run finished from the Flow Runs test panel no longer reads as paused

Clause-②: no
Metadata-protocol: none

On the developer Flow Runs page, a screen flow's test run that the runner drove to completion left the Test Run panel showing the trigger's paused answer: "Waiting for input", "This run is paused at screen …" and a "Continue run" button. Continuing reopened the old screen, and submitting it answered 404 `RUN_NOT_FOUND`, because the server no longer holds a suspended run. When the runner completes the run, the panel now reads the run back (`automation.getRun`) and shows it as the result, with its final status and duration, and offers no "Continue run". A run the tester dismisses while it is still paused keeps its "Continue run", as before.
44 changes: 41 additions & 3 deletions ui/apps/console/src/pages/developer/FlowRunsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import userEvent from '@testing-library/user-event';
// Hoisted so the vi.mock factories below can close over them, and so the
// adapter is a STABLE singleton (a fresh object per render loops the page's
// fetch effects).
const { execute, ADAPTER, authFetch } = vi.hoisted(() => {
const { execute, getRun, ADAPTER, authFetch } = vi.hoisted(() => {
const flow = {
name: 'reassign_wizard',
label: 'Reassign',
Expand All @@ -38,11 +38,22 @@ const { execute, ADAPTER, authFetch } = vi.hoisted(() => {
fields: [{ name: 'new_assignee', label: 'New Assignee', type: 'text', required: true }],
},
}));
// The run row as the server records it once the resume finished it.
const getRun = vi.fn(async () => ({
id: 'run_1',
flowName: 'reassign_wizard',
status: 'completed',
trigger: { type: 'manual' },
steps: [],
startedAt: '2026-11-15T00:00:00.000Z',
completedAt: '2026-11-15T00:00:01.000Z',
durationMs: 1000,
}));
const ADAPTER = {
getClient: () => ({
// The served list item IS the flow definition (objectui#12829).
meta: { getItems: async (type: string) => (type === 'flow' ? [flow] : []) },
automation: { execute, listRuns: async () => ({ runs: [] }) },
automation: { execute, getRun, listRuns: async () => ({ runs: [] }) },
}),
};
const authFetch = vi.fn(async () =>
Expand All @@ -51,7 +62,7 @@ const { execute, ADAPTER, authFetch } = vi.hoisted(() => {
headers: { 'Content-Type': 'application/json' },
}),
);
return { execute, ADAPTER, authFetch };
return { execute, getRun, ADAPTER, authFetch };
});

vi.mock('@object-ui/app-shell', async (importOriginal) => {
Expand All @@ -76,6 +87,7 @@ import { FlowRunsPage } from './FlowRunsPage';

beforeEach(() => {
execute.mockClear();
getRun.mockClear();
authFetch.mockClear();
});
afterEach(cleanup);
Expand Down Expand Up @@ -146,3 +158,29 @@ describe('Flow Runs — screen flows are completable from the Test Run panel', (
expect(reopened.queryByText('reassign_wizard')).not.toBeInTheDocument();
});
});

describe('Flow Runs — a screen run completed from the Test Run panel stops reading as paused', () => {
it('shows the completed run and drops "Waiting for input" and "Continue run"', async () => {
const user = userEvent.setup();
render(<FlowRunsPage />);

await screen.findByRole('button', { name: /Run Flow/i });
await user.click(screen.getByRole('button', { name: /Run Flow/i }));
await screen.findByRole('dialog');
// The pause is what the panel reads before the run is finished.
expect(screen.getByText('Waiting for input')).toBeInTheDocument();

const textboxes = screen.getAllByRole('textbox');
await user.type(textboxes[textboxes.length - 1], 'ada@example.com');
await user.click(screen.getByRole('button', { name: 'Submit' }));
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());

// The panel re-reads the run the runner finished and shows it as the result.
await waitFor(() => expect(getRun).toHaveBeenCalledWith('reassign_wizard', 'run_1'));
expect(await screen.findByText('Result')).toBeInTheDocument();
expect(screen.getByText(/"status": "completed"/)).toBeInTheDocument();
expect(screen.queryByText('Waiting for input')).not.toBeInTheDocument();
expect(screen.queryByText(/This run is paused at screen/)).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: /Continue run/i })).not.toBeInTheDocument();
});
});
32 changes: 30 additions & 2 deletions ui/apps/console/src/pages/developer/FlowRunsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* from here too.
*/

import { useEffect, useMemo, useState, useCallback } from 'react';
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
import { useDisplayLocale, useObjectTranslation } from '@object-ui/i18n';
import { ConsolePageHeader, useAdapter, useMetadata, FlowRunner, type ScreenFlowState, DeveloperNamespaceGate } from '@object-ui/app-shell';
import { createAuthenticatedFetch } from '@object-ui/auth';
Expand Down Expand Up @@ -367,8 +367,12 @@ function FlowTestRunner({
// The paused screen a test run stopped at — driven to completion by
// <FlowRunner>, exactly as a `type: 'flow'` action would.
const [screenFlow, setScreenFlow] = useState<ScreenFlowState | null>(null);
// Bumped by every new run and flow switch: a completed run's re-read that
// lands after either belongs to a panel the tester has already left.
const runGeneration = useRef(0);

useEffect(() => {
runGeneration.current += 1;
setValues({});
setResult(null);
setError(null);
Expand All @@ -382,6 +386,7 @@ function FlowTestRunner({
setError({ unavailable: 'automation.execute' });
return;
}
runGeneration.current += 1;
setRunning(true);
setError(null);
setResult(null);
Expand Down Expand Up @@ -410,6 +415,29 @@ function FlowTestRunner({
}
};

// The runner drove the paused run to completion. The trigger answer in
// `result` still describes the pause, and its screen no longer exists on the
// server, so it is replaced by the run as the server now records it: the
// panel reads the run's final status and offers no "Continue run".
const handleComplete = async () => {
const runId = screenFlow?.runId ?? result?.runId;
const generation = runGeneration.current;
setScreenFlow(null);
setResult(null);
onExecuted?.();
if (!runId) return;
if (!client?.automation?.getRun) {
setError({ unavailable: 'automation.getRun' });
return;
}
try {
const res: any = await client.automation.getRun(flow.name, runId);
if (generation === runGeneration.current) setResult(res?.run ?? res);
} catch (e: any) {
if (generation === runGeneration.current) setError({ message: e?.message ?? String(e) });
}
};

return (
<Card>
<CardHeader className="pb-3">
Expand Down Expand Up @@ -527,7 +555,7 @@ function FlowTestRunner({
dataSource={adapter}
objects={objects}
onClose={() => { setScreenFlow(null); onExecuted?.(); }}
onComplete={() => { setScreenFlow(null); onExecuted?.(); }}
onComplete={handleComplete}
/>
</Card>
);
Expand Down
Loading