forked from pingdotgg/t3code
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(codex): map plan_delta to canonical turn.proposed.delta #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
apps/server/src/provider/Layers/codexEventMapping.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /** | ||
| * Unit tests for codexEventMapping — calls mapToRuntimeEvents directly | ||
| * without the full adapter/stream infrastructure. | ||
| */ | ||
| import { describe, it, expect } from "bun:test"; | ||
| import { mapToRuntimeEvents } from "./codexEventMapping.ts"; | ||
| import { | ||
| EventId, | ||
| type ProviderEvent, | ||
| ProviderItemId, | ||
| ThreadId, | ||
| TurnId, | ||
| } from "@t3tools/contracts"; | ||
|
|
||
| const threadId = ThreadId.makeUnsafe("thread-1"); | ||
|
|
||
| function makeEvent(overrides: Partial<ProviderEvent>): ProviderEvent { | ||
| return { | ||
| id: EventId.makeUnsafe("evt-1"), | ||
| kind: "notification", | ||
| provider: "codex", | ||
| createdAt: new Date().toISOString(), | ||
| threadId, | ||
| ...overrides, | ||
| } as ProviderEvent; | ||
| } | ||
|
|
||
| describe("codexEventMapping — codex/event/plan_delta", () => { | ||
| it("maps plan_delta with msg.delta to turn.proposed.delta", () => { | ||
| const events = mapToRuntimeEvents( | ||
| makeEvent({ | ||
| method: "codex/event/plan_delta", | ||
| turnId: TurnId.makeUnsafe("turn-1"), | ||
| payload: { | ||
| msg: { | ||
| turn_id: "turn-1", | ||
| delta: "- Step 1: read the file", | ||
| }, | ||
| }, | ||
| }), | ||
| threadId, | ||
| ); | ||
|
|
||
| expect(events).toHaveLength(1); | ||
| expect(events[0]!.type).toBe("turn.proposed.delta"); | ||
| if (events[0]!.type === "turn.proposed.delta") { | ||
| expect(events[0]!.payload.delta).toBe("- Step 1: read the file"); | ||
| } | ||
| }); | ||
|
|
||
| it("maps plan_delta with msg.text fallback", () => { | ||
| const events = mapToRuntimeEvents( | ||
| makeEvent({ | ||
| method: "codex/event/plan_delta", | ||
| payload: { | ||
| msg: { | ||
| text: "plan text via text field", | ||
| }, | ||
| }, | ||
| }), | ||
| threadId, | ||
| ); | ||
|
|
||
| expect(events).toHaveLength(1); | ||
| if (events[0]!.type === "turn.proposed.delta") { | ||
| expect(events[0]!.payload.delta).toBe("plan text via text field"); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| it("maps plan_delta with msg.content.text fallback", () => { | ||
| const events = mapToRuntimeEvents( | ||
| makeEvent({ | ||
| method: "codex/event/plan_delta", | ||
| payload: { | ||
| msg: { | ||
| content: { text: "nested content text" }, | ||
| }, | ||
| }, | ||
| }), | ||
| threadId, | ||
| ); | ||
|
|
||
| expect(events).toHaveLength(1); | ||
| if (events[0]!.type === "turn.proposed.delta") { | ||
| expect(events[0]!.payload.delta).toBe("nested content text"); | ||
| } | ||
| }); | ||
|
|
||
| it("returns empty for plan_delta with no extractable delta", () => { | ||
| const events = mapToRuntimeEvents( | ||
| makeEvent({ | ||
| method: "codex/event/plan_delta", | ||
| payload: { | ||
| msg: {}, | ||
| }, | ||
| }), | ||
| threadId, | ||
| ); | ||
|
|
||
| expect(events).toHaveLength(0); | ||
| }); | ||
|
|
||
| it("returns empty for plan_delta with empty delta string", () => { | ||
| const events = mapToRuntimeEvents( | ||
| makeEvent({ | ||
| method: "codex/event/plan_delta", | ||
| payload: { | ||
| msg: { delta: "" }, | ||
| }, | ||
| }), | ||
| threadId, | ||
| ); | ||
|
|
||
| expect(events).toHaveLength(0); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 New test file imports from
bun:testinstead of@effect/vitest, violating AGENTS.md and project conventionsThe new test file
codexEventMapping.test.tsimportsdescribe,it, andexpectfrombun:test, while every other test file inapps/server/src/uses@effect/vitest(see e.g.apps/server/src/provider/Layers/CodexAdapter.test.ts:15,apps/server/src/provider/Layers/ProviderHealth.test.ts:2, and all ~18 other test files in the server). AGENTS.md explicitly states: "NEVER runbun test. Always usebun run test(runs Vitest)." The server's test script is"test": "vitest run"(apps/server/package.json). Whenvitest runprocesses this file, tests registered viabun:test'sdescribe/itwon't integrate with Vitest's runner — they'll either fail to import or silently not execute, meaning these tests provide no verification.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.