History

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.

Cursor Agent committed 7 months ago

Commit c93fcf91 parent 58f45db1 file · +10 −23Browse files

Unified · Split

apps/server/src/ws.ts+10−23
@@ -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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t