Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): bound the workflows list sent to clients #49057 (GitHub #49050)

Mergedjuliusmarmingemerged 6 commits intomain fromrefs/pull/49050/headmerged by juliusmarminge View on GitHub

Showing 12 changed files with 124 additions and 28 deletions (loading 9).

x
0 of 12 viewed, 12 left
15 additions and 4 deletionsapps/mobile/src/features/workflows/WorkflowRunRouteScreen.tsxModified
View file
@@ -10,6 +10,7 @@
type WorkflowBeat,
type WorkflowQuestionChoice,
type WorkflowRunNode,
+ withWorkflowRun,
} from "@t3tools/client-runtime/workflows";
import { EnvironmentId, type WorkflowQuestion } from "@t3tools/contracts";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
@@ -299,7 +300,8 @@
</Card>
const ended = run.endedAt !== null;
- const resultLines = workflowResultLines(run.result);
+ // A list sends a large result cut short; the run itself has all of it.
+ const resultLines = workflowResultLines(detail.data?.run.result ?? run.result);
// A result worth showing says more than the last answer it may only repeat.
const lastAnswer = beats.findLast((beat) => beat.kind === "ask" && beat.status === "completed");
const answered = lastAnswer === undefined ? null : workflowAnswer(lastAnswer.result);
@@ -412,7 +414,16 @@
export function WorkflowRunRouteScreen({ route }: StaticScreenProps<WorkflowRunParams>) {
const environmentId = EnvironmentId.make(route.params.environmentId);
const live = useEnvironmentQuery(serverEnvironment.workflowsLive({ environmentId, input: {} }));
- const snapshot = live.data;
+ const { runId } = route.params;
+ // A run the list leaves out is read on its own: the list holds only the newest runs.
+ const lookUp = live.data !== null && !live.data.runs.some((run) => run.runId === runId);
+ const unlisted = useEnvironmentQuery(
+ lookUp ? serverEnvironment.workflowRun({ environmentId, input: { runId } }) : null,