refactor(ai): extracted OpenAI compat logic into dedicated module
- Extracted OpenAI compatibility detection and resolution logic into dedicated `openai-completions-compat` module. - Refactored `detectCompat()` and `getCompat()` to delegate to new compat module functions with simplified conditional logic. - Fixed OAuth redirect URI validation to preserve exact configured values without trailing slash normalization. - Improved session deletion to return boolean status and display error messages in UI instead of silently failing. - Added `/session delete` command with Delete key support and confirmation dialogs for session management.
This commit is contained in:
@@ -3,17 +3,10 @@ import { getBundledModel } from "@oh-my-pi/pi-ai";
|
||||
import { runCommitAgentSession } from "../src/commit/agentic/agent";
|
||||
import * as toolsModule from "../src/commit/agentic/tools";
|
||||
import { Settings } from "../src/config/settings";
|
||||
import type { CreateAgentSessionResult } from "../src/sdk";
|
||||
import * as sdkModule from "../src/sdk";
|
||||
import type { PromptOptions } from "../src/session/agent-session";
|
||||
|
||||
vi.mock("../src/sdk", () => ({
|
||||
createAgentSession: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../src/commit/agentic/tools", () => ({
|
||||
createCommitTools: vi.fn(() => []),
|
||||
}));
|
||||
|
||||
describe("commit agent prompt attribution", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -29,10 +22,8 @@ describe("commit agent prompt attribution", () => {
|
||||
dispose: async () => {},
|
||||
};
|
||||
|
||||
(sdkModule.createAgentSession as unknown as { mockResolvedValue: (value: unknown) => void }).mockResolvedValue({
|
||||
session,
|
||||
});
|
||||
(toolsModule.createCommitTools as unknown as { mockReturnValue: (value: unknown) => void }).mockReturnValue([]);
|
||||
vi.spyOn(sdkModule, "createAgentSession").mockResolvedValue({ session } as unknown as CreateAgentSessionResult);
|
||||
vi.spyOn(toolsModule, "createCommitTools").mockReturnValue([]);
|
||||
|
||||
const model = getBundledModel("anthropic", "claude-sonnet-4-5");
|
||||
if (!model) {
|
||||
|
||||
Reference in New Issue
Block a user