Remove redundant ternary in appendSetupScriptActivity
The ternary branches produced structurally identical activity objects. Use destructuring + spread to build the activity once, preserving discriminated-union type safety without duplicating the object literal.
This commit is contained in:
1 file changed
+10
-23
+10
-23
@@ -161,33 +161,20 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) =>
|
||||
readonly tone: "error";
|
||||
}
|
||||
),
|
||||
) =>
|
||||
orchestrationEngine.dispatch({
|
||||
) => {
|
||||
const { threadId, ...rest } = input;
|
||||
return orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId: serverCommandId("setup-script-activity"),
|
||||
threadId: input.threadId,
|
||||
activity:
|
||||
input.kind === "setup-script.failed"
|
||||
? {
|
||||
id: EventId.make(crypto.randomUUID()),
|
||||
tone: input.tone,
|
||||
kind: input.kind,
|
||||
summary: input.summary,
|
||||
payload: input.payload,
|
||||
turnId: null,
|
||||
createdAt: input.createdAt,
|
||||
}
|
||||
: {
|
||||
id: EventId.make(crypto.randomUUID()),
|
||||
tone: input.tone,
|
||||
kind: input.kind,
|
||||
summary: input.summary,
|
||||
payload: input.payload,
|
||||
turnId: null,
|
||||
createdAt: input.createdAt,
|
||||
},
|
||||
threadId,
|
||||
activity: {
|
||||
id: EventId.make(crypto.randomUUID()),
|
||||
...rest,
|
||||
turnId: null,
|
||||
},
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
};
|
||||
|
||||
const toDispatchCommandError = (cause: unknown, fallbackMessage: string) =>
|
||||
Schema.is(OrchestrationDispatchCommandError)(cause)
|
||||
|
||||
Reference in new issue
Block a user