Skip to content

Commit c93fcf9

Browse files
committed
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.
1 parent 58f45db commit c93fcf9

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

apps/server/src/ws.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,20 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) =>
161161
readonly tone: "error";
162162
}
163163
),
164-
) =>
165-
orchestrationEngine.dispatch({
164+
) => {
165+
const { threadId, ...rest } = input;
166+
return orchestrationEngine.dispatch({
166167
type: "thread.activity.append",
167168
commandId: serverCommandId("setup-script-activity"),
168-
threadId: input.threadId,
169-
activity:
170-
input.kind === "setup-script.failed"
171-
? {
172-
id: EventId.make(crypto.randomUUID()),
173-
tone: input.tone,
174-
kind: input.kind,
175-
summary: input.summary,
176-
payload: input.payload,
177-
turnId: null,
178-
createdAt: input.createdAt,
179-
}
180-
: {
181-
id: EventId.make(crypto.randomUUID()),
182-
tone: input.tone,
183-
kind: input.kind,
184-
summary: input.summary,
185-
payload: input.payload,
186-
turnId: null,
187-
createdAt: input.createdAt,
188-
},
169+
threadId,
170+
activity: {
171+
id: EventId.make(crypto.randomUUID()),
172+
...rest,
173+
turnId: null,
174+
},
189175
createdAt: input.createdAt,
190176
});
177+
};
191178

192179
const toDispatchCommandError = (cause: unknown, fallbackMessage: string) =>
193180
Schema.is(OrchestrationDispatchCommandError)(cause)

0 commit comments

Comments
 (0)