History

Address Codex review feedback

Julius Marminge committed 7 months ago

Commit fa4a29f1 parent 3a38f065 files · +75 −8Browse files

Showing the changes to packages/effect-codex-app-server (2 of 5 files). Show all

Unified · Split

2 files
  1. packages/effect-codex-app-server/src/client.test.ts +30 −0
  2. packages/effect-codex-app-server/src/client.ts +7 −5
packages/effect-codex-app-server/src/client.test.ts+30−0
@@ -121,4 +121,34 @@ it.layer(NodeServices.layer)("effect-codex-app-server client", (it) => { · 120 unmodified lines
121 ]);121 ]);
122 }),122 }),
123 );123 );
124
125 it.effect("initializes a command-backed app-server client", () =>
126 Effect.gen(function* () {
127 const path = yield* Path.Path;
128 const scope = yield* Scope.make();
129 const clientLayer = CodexClient.layerCommand({
130 command: "bun",
131 args: ["run", yield* mockPeerPath],
132 cwd: path.join(import.meta.dirname, ".."),
133 });
134 const context = yield* Layer.buildWithScope(clientLayer, scope);
135
136 const initialized = yield* Effect.gen(function* () {
137 const client = yield* CodexClient.CodexAppServerClient;
138 return yield* client.request("initialize", {
139 clientInfo: {
140 name: "effect-codex-app-server-test",
141 title: "Effect Codex App Server Test",
142 version: "0.0.0",
143 },
144 capabilities: {
145 experimentalApi: true,
146 optOutNotificationMethods: null,
147 },
148 });
149 }).pipe(Effect.provide(context), Effect.ensuring(Scope.close(scope, Exit.void)));
150
151 assert.equal(initialized.userAgent, "mock-codex-app-server");
152 }),
153 );
124});154});
packages/effect-codex-app-server/src/client.ts+7−5
@@ -281,7 +281,7 @@ export const layerCommand = ( · 280 unmodified lines
281 ...(options.env ? { env: { ...process.env, ...options.env } } : {}),281 ...(options.env ? { env: { ...process.env, ...options.env } } : {}),
282 shell: process.platform === "win32",282 shell: process.platform === "win32",
283 });283 });
284 const handle = yield* spawner.spawn(command).pipe(284 return yield* spawner.spawn(command).pipe(
285 Effect.mapError(285 Effect.mapError(
286 (cause) =>286 (cause) =>
287 new CodexError.CodexAppServerSpawnError({287 new CodexError.CodexAppServerSpawnError({
@@ -290,9 +290,11 @@ export const layerCommand = ( · 2 unmodified lines
290 }),290 }),
291 ),291 ),
292 );292 );
293 const client = yield* make(makeChildStdio(handle), options, makeTerminationError(handle));
294 return { client, handle };
295 }),293 }),
296 ({ handle }) => handle.kill().pipe(Effect.orDie),294 (handle) => handle.kill().pipe(Effect.orDie),
297 ).pipe(Effect.map(({ client }) => client)),295 ).pipe(
296 Effect.flatMap((handle) =>
297 make(makeChildStdio(handle), options, makeTerminationError(handle)),
298 ),
299 ),
298 );300 );