Files
openbot/scripts/opencode-service-failure-e2e.ts
T
Aleksander DygońandClaude Opus 5.5 bda18dd974 Name OpenCode 2.1 service failures and the provider of each provider error (#2872)
* Name OpenCode 2.1 service failures and the provider of each provider error

OpenCode 2.1.3 sends "Internal error: Internal service failure" for each
failure that has no ACP error. OpenBot matched only the older "OpenCode
service failure" text, so a failed turn showed the generic text. A failed
turn now shows the OpenCode service-failure message.

A provider error with no chat (start failed, restart failed, stderr
diagnostic) went to a toast with no provider name. The message now names
the provider. The provider row and the analytics cause keep the original
error.

Refs #2850

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Name the provider in the toast title, not in the error text

The backend put "{provider} reported an error:" in front of each provider
error. The renderer reads the kind of an error from the start of its text
(401, network, JSON or stack output), so the prefix showed raw technical
text and stopped the sign-in refresh. It also named the provider twice in
OpenBot's own messages, such as the disk check.

Remove the prefix. The toast of an error with no agent now takes the
provider from the event code `<provider>_<kind>` and shows "{provider}
error" as its title. The message does not change.

Refs #2850

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 10:36:39 +02:00

46 lines
2.2 KiB
TypeScript

// Runs a turn on the real OpenCode driver against a fake `opencode acp` that fails the prompt as
// OpenCode 2.1.3 does: `-32603` "Internal error: Internal service failure" (#2850). Checks that the
// failed turn reads as OpenCode's service failure, with its fix, not the generic text.
// `bun run test:opencode-service-failure`. Writes .openbot-build/opencode-service-failure-e2e/report.json.
import assert from "node:assert/strict";
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { sourceText } from "@openbot/i18n/source";
import type { AgentClient } from "../src/backend/agent-client";
import type { AgentCliInfo } from "../src/backend/cli";
import { NO_PROVIDER_CREDENTIALS, requireProviderDriver } from "../src/backend/provider-drivers";
import { installFakeAgent, runTurn, startThread, stopClients } from "./provider-fakes/host";
const OUT = resolve(import.meta.dirname, "../.openbot-build/opencode-service-failure-e2e");
interface Report {
passed: boolean;
turn?: { error: string };
}
const root = await mkdtemp(join(tmpdir(), "openbot-opencode-service-failure-e2e-"));
const report: Report = { passed: false };
const clients: AgentClient[] = [];
try {
const workspace = join(root, "workspace");
await mkdir(workspace);
const executable = join(root, "opencode", "bin", "opencode");
await installFakeAgent(executable, "opencode-service-failure");
const cli: AgentCliInfo = { executable, version: "2.1.3", source: "managed" };
const client = requireProviderDriver("opencode").createClient(cli, 10_000, NO_PROVIDER_CREDENTIALS);
clients.push(client);
client.start();
const { error } = await runTurn(client, await startThread(client, { cwd: workspace }));
assert.equal(error, sourceText("error.provider.opencodeServiceFailure"), "A failed turn names OpenCode's service.");
report.turn = { error };
report.passed = true;
} finally {
await stopClients(clients);
await mkdir(OUT, { recursive: true });
await writeFile(join(OUT, "report.json"), `${JSON.stringify(report, null, 2)}\n`);
await rm(root, { recursive: true, force: true });
}
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);