Skip to content

Commit a23be1c

Browse files
committed
fix(workflow): preserve resume names and typed reads
1 parent 323fe50 commit a23be1c

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/workflow-cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ async function runWorkflowRun(args: string[], config: ServerConfig): Promise<voi
163163
const resolved = overrideResult.value;
164164
source = resolved.source;
165165
scriptHash = resolved.scriptHash;
166-
nameHint = "nameHint" in resolved ? resolved.nameHint : prior.name;
167-
priorScriptPath = file ?? prior.scriptPath;
166+
nameHint = file || name ? resolved.nameHint : prior.name;
167+
priorScriptPath = resolved.scriptPath;
168168
runSource = "resume";
169169
if (!Object.keys(workflowArgs).length && prior.argsJson && prior.argsJson !== "null") {
170170
try {

src/workflow-tools.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export function registerWorkflowTools(
116116
let runSource: "inline" | "named" | "resume" = "inline";
117117

118118
if (resumeFromRunId) {
119-
const prior = store.getRun(resumeFromRunId);
119+
const priorResult = store.getRunResult(resumeFromRunId);
120+
if (priorResult.isErr()) throw priorResult.error;
121+
const prior = priorResult.value;
120122
if (!prior) throw new WorkflowNotFoundError(resumeFromRunId);
121123
priorRunId = prior.id;
122124
const overridePath = scriptPath;
@@ -141,7 +143,7 @@ export function registerWorkflowTools(
141143
if (resolvedResult.isErr()) throw resolvedResult.error;
142144
source = resolvedResult.value.source;
143145
scriptHash = resolvedResult.value.scriptHash;
144-
nameHint = prior.name;
146+
nameHint = overridePath ? resolvedResult.value.nameHint : prior.name;
145147
}
146148
runSource = "resume";
147149
if (args === undefined && prior.argsJson && prior.argsJson !== "null") {
@@ -242,7 +244,9 @@ export function registerWorkflowTools(
242244
async ({ runId, sinceSeq, yieldTimeMs }) => {
243245
const store = createWorkflowStore(config);
244246
try {
245-
if (!store.getRun(runId)) throw new WorkflowNotFoundError(runId);
247+
const runResult = store.getRunResult(runId);
248+
if (runResult.isErr()) throw runResult.error;
249+
if (!runResult.value) throw new WorkflowNotFoundError(runId);
246250
const page = await yieldEvents(store, runId, sinceSeq ?? 0, yieldTimeMs ?? 0);
247251
return toolResult(page, "workflow_status");
248252
} catch (error) {

0 commit comments

Comments
 (0)