Merge origin/master (v0.5.81) into gitea/new_feature
Resolve conflicts: - streamingHandler.js: merge buildStreamErrorBytes onAbortTerminal + local shouldPersistRequestDetail & streamStatusForContent - capabilities.js: preserve server-injected user-asserted caps and models.dev catalog lookup; wire CommandCode /alpha/generate caps inside resolve() - commandcode.js (services/usage): adopt upstream whoami + billing credits/subscriptions with 5h/weekly rate windows and plan caps - openai-to-commandcode.js: merge toNativeImageBlock (data-URI & http(s) support) and assistant reasoning_content preservation - commandcode-to-openai.js: adopt upstream mid-stream error throw for clean retry and abortion - tests: sync commandcode test suite and exclude .next from vitest config
This commit is contained in:
@@ -139,25 +139,23 @@ describe("commandcode-to-openai — finish", () => {
|
||||
});
|
||||
|
||||
describe("commandcode-to-openai — error event", () => {
|
||||
it("emits an OpenAI-shaped error chunk instead of fake success content", () => {
|
||||
const { chunks } = feed([
|
||||
{ type: "error", error: { type: "server_error", message: "Boom" } },
|
||||
]);
|
||||
expect(chunks[0].error).toEqual({ message: "Boom", type: "server_error" });
|
||||
expect(chunks[0].choices[0].delta.content).toBeUndefined();
|
||||
expect(chunks[1].choices[0].finish_reason).toBe("stop");
|
||||
expect(JSON.stringify(chunks)).not.toContain("[CommandCode error:");
|
||||
it("throws rather than emitting fake success content with stop chunks", () => {
|
||||
expect(() =>
|
||||
feed([
|
||||
{ type: "error", error: { type: "server_error", message: "Boom" } },
|
||||
]),
|
||||
).toThrow(/\[CommandCode error:.*Boom/);
|
||||
});
|
||||
|
||||
it("keeps the stream terminal so clients do not hang waiting for more", () => {
|
||||
const { chunks } = feed([
|
||||
{ type: "start" },
|
||||
{
|
||||
type: "error",
|
||||
error: { type: "server_error", message: "Network connection lost." },
|
||||
},
|
||||
]);
|
||||
expect(chunks[0].error.message).toBe("Network connection lost.");
|
||||
expect(chunks[1].choices[0].finish_reason).toBe("stop");
|
||||
it("throws on mid-stream error so stream handler can retry or abort cleanly", () => {
|
||||
expect(() =>
|
||||
feed([
|
||||
{ type: "start" },
|
||||
{
|
||||
type: "error",
|
||||
error: { type: "server_error", message: "Network connection lost." },
|
||||
},
|
||||
]),
|
||||
).toThrow(/\[CommandCode error:.*Network connection lost/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user