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.
Unified · Split
| @@ -161,33 +161,20 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) => · 160 unmodified lines | |||
| 161 | readonly tone: "error"; | 161 | readonly tone: "error"; |
| 162 | } | 162 | } |
| 163 | ), | 163 | ), |
| 164 | ) => | 164 | ) => { |
| 165 | orchestrationEngine.dispatch({ | 165 | const { threadId, ...rest } = input; |
| 166 | return orchestrationEngine.dispatch({ | ||
| 166 | type: "thread.activity.append", | 167 | type: "thread.activity.append", |
| 167 | commandId: serverCommandId("setup-script-activity"), | 168 | commandId: serverCommandId("setup-script-activity"), |
| 168 | threadId: input.threadId, | 169 | threadId, |
| 169 | activity: | 170 | activity: { |
| 170 | input.kind === "setup-script.failed" | 171 | id: EventId.make(crypto.randomUUID()), |
| 171 | ? { | 172 | ...rest, |
| 172 | id: EventId.make(crypto.randomUUID()), | 173 | turnId: null, |
| 173 | tone: input.tone, | 174 | }, |
| 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 | }, | ||
| 189 | createdAt: input.createdAt, | 175 | createdAt: input.createdAt, |
| 190 | }); | 176 | }); |
| 177 | }; | ||
| 191 | 178 | ||
| 192 | const toDispatchCommandError = (cause: unknown, fallbackMessage: string) => | 179 | const toDispatchCommandError = (cause: unknown, fallbackMessage: string) => |
| 193 | Schema.is(OrchestrationDispatchCommandError)(cause) | 180 | Schema.is(OrchestrationDispatchCommandError)(cause) |