Skip to content

Commit c10d06a

Browse files
fix: harness null adapter cast and file-read approval method mapping
- Make adapterHarness nullable in OrchestrationIntegrationHarness interface to surface null-pointer errors at compile time when realCodex is enabled - Update PendingApprovalRequest.method ternary to correctly map file-read requests to 'item/fileRead/requestApproval' instead of falling through to 'item/fileChange/requestApproval' - Add 'item/fileRead/requestApproval' to PendingApprovalRequest.method type Co-authored-by: Julius Marminge <[email protected]>
1 parent 7d5b896 commit c10d06a

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

apps/server/integration/OrchestrationEngineHarness.integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export interface OrchestrationIntegrationHarness {
152152
readonly rootDir: string;
153153
readonly workspaceDir: string;
154154
readonly dbPath: string;
155-
readonly adapterHarness: TestProviderAdapterHarness;
155+
readonly adapterHarness: TestProviderAdapterHarness | null;
156156
readonly engine: OrchestrationEngineShape;
157157
readonly snapshotQuery: ProjectionSnapshotQuery["Service"];
158158
readonly providerService: ProviderService["Service"];
@@ -435,7 +435,7 @@ export const makeOrchestrationIntegrationHarness = (
435435
rootDir,
436436
workspaceDir,
437437
dbPath,
438-
adapterHarness: adapterHarness as TestProviderAdapterHarness,
438+
adapterHarness,
439439
engine,
440440
snapshotQuery,
441441
providerService,

apps/server/integration/orchestrationEngine.integration.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ it.live("runs a single turn end-to-end and persists checkpoint state in sqlite +
180180
],
181181
};
182182

183-
yield* harness.adapterHarness.queueTurnResponseForNextSession(turnResponse);
183+
yield* harness.adapterHarness!.queueTurnResponseForNextSession(turnResponse);
184184
yield* startTurn({
185185
harness,
186186
commandId: "cmd-turn-start-single",
@@ -314,7 +314,7 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
314314
Effect.gen(function* () {
315315
yield* seedProjectAndThread(harness);
316316

317-
yield* harness.adapterHarness.queueTurnResponseForNextSession({
317+
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
318318
events: [
319319
{
320320
type: "turn.started",
@@ -373,7 +373,7 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
373373
(entry) => entry.checkpoints.length === 1 && entry.session?.threadId === "thread-1",
374374
);
375375

376-
yield* harness.adapterHarness.queueTurnResponse(THREAD_ID, {
376+
yield* harness.adapterHarness!.queueTurnResponse(THREAD_ID, {
377377
events: [
378378
{
379379
type: "turn.started",
@@ -473,7 +473,7 @@ it.live("tracks approval requests and resolves pending approvals on user respons
473473
Effect.gen(function* () {
474474
yield* seedProjectAndThread(harness);
475475

476-
yield* harness.adapterHarness.queueTurnResponseForNextSession({
476+
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
477477
events: [
478478
{
479479
type: "turn.started",
@@ -538,7 +538,7 @@ it.live("tracks approval requests and resolves pending approvals on user respons
538538
assert.equal(resolvedRow.decision, "accept");
539539

540540
const approvalResponses = yield* waitForSync(
541-
() => harness.adapterHarness.getApprovalResponses(THREAD_ID),
541+
() => harness.adapterHarness!.getApprovalResponses(THREAD_ID),
542542
(responses) => responses.length === 1,
543543
"provider approval response",
544544
);
@@ -554,7 +554,7 @@ it.live("records failed turn runtime state and checkpoint status as error", () =
554554
Effect.gen(function* () {
555555
yield* seedProjectAndThread(harness);
556556

557-
yield* harness.adapterHarness.queueTurnResponseForNextSession({
557+
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
558558
events: [
559559
{
560560
type: "turn.started",
@@ -633,7 +633,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
633633
Effect.gen(function* () {
634634
yield* seedProjectAndThread(harness);
635635

636-
yield* harness.adapterHarness.queueTurnResponseForNextSession({
636+
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
637637
events: [
638638
{
639639
type: "turn.started",
@@ -691,7 +691,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
691691
(entry) => entry.session?.threadId === "thread-1" && entry.checkpoints.length === 1,
692692
);
693693

694-
yield* harness.adapterHarness.queueTurnResponse(THREAD_ID, {
694+
yield* harness.adapterHarness!.queueTurnResponse(THREAD_ID, {
695695
events: [
696696
{
697697
type: "turn.started",
@@ -796,7 +796,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
796796
gitRefExists(harness.workspaceDir, checkpointRefForThreadTurn(THREAD_ID, 2)),
797797
false,
798798
);
799-
assert.deepEqual(harness.adapterHarness.getRollbackCalls(THREAD_ID), [1]);
799+
assert.deepEqual(harness.adapterHarness!.getRollbackCalls(THREAD_ID), [1]);
800800

801801
const checkpointRows = yield* harness.checkpointRepository.listByThreadId({
802802
threadId: THREAD_ID,

apps/server/src/codexAppServerManager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ interface PendingRequest {
3434
interface PendingApprovalRequest {
3535
requestId: ApprovalRequestId;
3636
jsonRpcId: string | number;
37-
method: "item/commandExecution/requestApproval" | "item/fileChange/requestApproval";
37+
method:
38+
| "item/commandExecution/requestApproval"
39+
| "item/fileChange/requestApproval"
40+
| "item/fileRead/requestApproval";
3841
requestKind: ProviderRequestKind;
3942
threadId: ThreadId;
4043
turnId?: TurnId;
@@ -1064,7 +1067,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
10641067
method:
10651068
requestKind === "command"
10661069
? "item/commandExecution/requestApproval"
1067-
: "item/fileChange/requestApproval",
1070+
: requestKind === "file-read"
1071+
? "item/fileRead/requestApproval"
1072+
: "item/fileChange/requestApproval",
10681073
requestKind,
10691074
threadId: context.session.threadId,
10701075
...(route.turnId ? { turnId: route.turnId } : {}),

0 commit comments

Comments
 (0)