Show lowercase profile names in posted comments

This commit is contained in:
Danny Kim
2026-10-20 01:53:32 +09:00
parent 41a9c6258a
commit 13efaccb17
3 changed files with 27 additions and 13 deletions
+8 -8
View File
@@ -147,7 +147,7 @@ test("posts a successful issue result and removes runtime credentials", async ()
const [request] = requests;
expect(request?.url).toStrictEqual(`${context.apiUrl}/repos/owner/repo/issues/7/comments`);
expect(requestBody(request?.init)).toStrictEqual({
body: "done\n\n> Profile: `CODEX` · `gpt-test`",
body: "done\n\n> Profile: `codex` · `gpt-test`",
});
expect(request?.init?.headers).toStrictEqual({
Authorization: "token reviewer-secret",
@@ -178,11 +178,11 @@ test("retries a rejected inline review without anchors", async () => {
);
expect(bodies[0]).toMatchObject({
comments: [{ body: "Finding\n\n> Profile: `CODEX` · `gpt-test`" }],
comments: [{ body: "Finding\n\n> Profile: `codex` · `gpt-test`" }],
});
expect(bodies[1]).toMatchObject({
comments: [],
body: "✅ Approved\nReady\n\n> Profile: `CODEX` · `gpt-test`",
body: "✅ Approved\nReady\n\n> Profile: `codex` · `gpt-test`",
});
assert(await missing(result.runtimeDir));
});
@@ -205,9 +205,9 @@ test("reports each tried profile and keeps the action failed", async () => {
expect(bodies).toStrictEqual([
{
body:
"AI bot failed.\n\n> Tried: `CODEX` · `gpt-test` (sign-in failed), " +
"`CLAUDE` · `claude-test` (usage exhausted), " +
"`OPENCODE` · `openrouter/test` (failed)",
"AI bot failed.\n\n> Tried: `codex` · `gpt-test` (sign-in failed), " +
"`claude` · `claude-test` (usage exhausted), " +
"`opencode` · `openrouter/test` (failed)",
},
]);
assert(!JSON.stringify(bodies).includes("reviewer-secret"));
@@ -235,7 +235,7 @@ test("drops failure entries that are not known labels", async () => {
expect(bodies).toStrictEqual([
{
body: "AI bot failed.\n\n> Tried: `CLAUDE` · `claude-test` (sign-in failed)",
body: "AI bot failed.\n\n> Tried: `claude` · `claude-test` (sign-in failed)",
},
]);
});
@@ -315,7 +315,7 @@ test("reports an attributed failure when a pull request review is missing", asyn
expect(bodies).toStrictEqual([
{
body: "AI bot failed.\n\n> Tried: `CODEX` · `gpt-test` (failed)",
body: "AI bot failed.\n\n> Tried: `codex` · `gpt-test` (failed)",
},
]);
assert(await missing(result.runtimeDir));
+3 -3
View File
@@ -12,7 +12,7 @@ import {
test("formats profile attribution as a Markdown quote", () => {
expect(profileFooter({ type: "OPENCODE", model: "openrouter/qwen/qwen3.8-27b" })).toBe(
"> Profile: `OPENCODE` · `openrouter/qwen/qwen3.8-27b`",
"> Profile: `opencode` · `openrouter/qwen/qwen3.8-27b`",
);
});
@@ -105,8 +105,8 @@ test("falls through after a sign-in failure and records each try", async () => {
{ type: "CLAUDE", model: "claude-sonnet-5", reason: "USAGE_EXHAUSTED" },
]);
expect(failureFooter(failures)).toStrictEqual(
"> Tried: `CODEX` · `gpt-5.6-terra` (sign-in failed), " +
"`CLAUDE` · `claude-sonnet-5` (usage exhausted)",
"> Tried: `codex` · `gpt-5.6-terra` (sign-in failed), " +
"`claude` · `claude-sonnet-5` (usage exhausted)",
);
});
+16 -2
View File
@@ -8,8 +8,20 @@ export interface BotProfile extends ProfileIdentity {
token?: string;
}
// The lowercase name a profile type reads as in posted comments.
function profileName(type: ProfileIdentity["type"]): string {
switch (type) {
case "CLAUDE":
return "claude";
case "CODEX":
return "codex";
case "OPENCODE":
return "opencode";
}
}
export function profileFooter(profile: ProfileIdentity): string {
return `> Profile: \`${profile.type}\` · \`${profile.model}\``;
return `> Profile: \`${profileName(profile.type)}\` · \`${profile.model}\``;
}
export function withProfile(body: string, profile: ProfileIdentity): string {
@@ -66,7 +78,9 @@ export function failureFooter(failures: ProfileFailure[]): string {
return "> Profile: none";
}
return `> Tried: ${failures
.map(({ type, model, reason }) => `\`${type}\` · \`${model}\` (${toMessage(reason)})`)
.map(
({ type, model, reason }) => `\`${profileName(type)}\` · \`${model}\` (${toMessage(reason)})`,
)
.join(", ")}`;
}