From a577024792c2a0d65195c9b1196378913aa56976 Mon Sep 17 00:00:00 2001 From: ayoubdiourin7 Date: Tue, 1 Dec 2026 22:01:18 +0100 Subject: [PATCH] Add feedback tool previews to the run's Actions panel --- services/hackbot-ui/components/RunDetail.tsx | 48 ++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/services/hackbot-ui/components/RunDetail.tsx b/services/hackbot-ui/components/RunDetail.tsx index f8b613beea4..65f87e305b6 100644 --- a/services/hackbot-ui/components/RunDetail.tsx +++ b/services/hackbot-ui/components/RunDetail.tsx @@ -19,29 +19,41 @@ import { StatusBadge } from "./StatusBadge"; import { parseTestPlan, TestPlanView } from "./TestPlanView"; // What a proposed action would write, rendered under its row so the reviewer -// approves the actual text and not just an action type. A comment carries its -// body in params.text; a Phabricator submission carries the title and summary of -// the revision it would open for the patch (previewed by PatchView), and an -// update carries them only when it rewords the existing revision's. +// approves the actual text and not just an action type. Each entry lists the +// params whose text is shown. A Phabricator update carries a title and summary +// only when it rewords the existing revision's; the patch itself is previewed +// by PatchView. +const ACTION_PREVIEWS: Record = { + "bugzilla.add_comment": { + label: "Comment preview", + fields: ["text"], + }, + "phabricator.submit_patch": { + label: "Revision preview", + fields: ["title", "summary"], + }, + "phabricator.update_patch": { + label: "Revision preview", + fields: ["title", "summary"], + }, + "feedback.report_problem": { + label: "Feedback preview", + fields: ["title", "message"], + }, +}; + function actionPreview( action: RunAction ): { label: string; text: string } | null { + const preview = ACTION_PREVIEWS[action.type]; + if (!preview) return null; const text = (v: unknown): string => typeof v === "string" && v.trim() ? v : ""; - if (action.type === "bugzilla.add_comment") { - const body = text(action.params?.text); - return body ? { label: "Comment preview", text: body } : null; - } - if ( - action.type === "phabricator.submit_patch" || - action.type === "phabricator.update_patch" - ) { - const body = [text(action.params?.title), text(action.params?.summary)] - .filter(Boolean) - .join("\n\n"); - return body ? { label: "Revision preview", text: body } : null; - } - return null; + const body = preview.fields + .map((field) => text(action.params?.[field])) + .filter(Boolean) + .join("\n\n"); + return body ? { label: preview.label, text: body } : null; } const POLL_MS = 4000;