From c93fcf98f820c532f92ead1fd845288cfa2c6efd Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 12 Apr 2026 08:27:49 +0000 Subject: [PATCH] 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. --- apps/server/src/ws.ts | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts index a1783dbd06..ccfb5b6246 100644 --- a/apps/server/src/ws.ts +++ b/apps/server/src/ws.ts @@ -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)