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
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)

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