Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

fix(chat): show check prompts without page overflow

Yuting Zhong180065ba395d
diff --git a/notfair/src/components/chat/messages.test.tsx b/notfair/src/components/chat/messages.test.tsx
index 6ea67534..7b00a6d1 100644
--- a/notfair/src/components/chat/messages.test.tsx
+++ b/notfair/src/components/chat/messages.test.tsx
@@ -1,9 +1,9 @@
// @vitest-environment jsdom
-import { fireEvent, render } from "@testing-library/react";
+import { fireEvent, render, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
-import { ToolGroup } from "./messages";
-import type { ToolEntry } from "./transcript-model";
+import { RenderItem, ToolGroup } from "./messages";
+import type { RenderedItem, ToolEntry } from "./transcript-model";
const runningTool: ToolEntry = {
toolCallId: "tool-1",
@@ -78,8 +78,51 @@ describe("ToolGroup", () => {
expect(label).toHaveTextContent("Edited file, read file, ran command");
expect(label.nextElementSibling).toBe(toggle);
expect(toggle).toHaveClass("opacity-0");
+ expect(summary).toHaveClass("relative");
expect(list).toHaveClass("max-h-64", "overflow-y-auto");
expect(list.querySelectorAll("[data-tool-row]")).toHaveLength(3);
+ for (const row of list.querySelectorAll("[data-tool-row]")) {
+ expect(row).toHaveClass("relative");
+ }
expect(list.querySelector("[data-tool-row] .ml-5")).toBeNull();
});
});
+
+describe("check prompt disclosure", () => {
+ it("lets the user expand the exact prompt that started a check", () => {
+ const prompt = [
+ "[TICK] Goal heartbeat #49 — 2026-07-21T20:00:00.000Z",
+ "",
+ "## Metric (measured by the platform just now)",
+ "- Lead-form failures: **2**",
+ ].join("\n");
+ const item: RenderedItem = {
+ kind: "user_message",
+ key: "tick-prompt",
+ body: prompt,
+ system: true,
+ };
+
+ const { container } = render(<RenderItem item={item} />);
+ const details = container.querySelector("details");
+
+ expect(details).not.toHaveAttribute("open");
+ const summary = container.querySelector("summary")!;
+ expect(summary).toHaveTextContent("View exact prompt");
+ expect(summary).toHaveClass("focus-visible:ring-2", "focus-visible:ring-ring");
+ const promptMessage = container.querySelector(
+ "[data-check-trigger-prompt]",
+ ) as HTMLElement;
+ expect(
+ within(promptMessage).getByRole("heading", {
+ level: 2,
+ name: "Metric (measured by the platform just now)",
+ }),
+ ).toBeInTheDocument();
+ expect(promptMessage.querySelector("strong")).toHaveTextContent("2");
+ expect(container).not.toHaveTextContent("Exact prompt sent to the agent");
+
+ fireEvent.click(container.querySelector("summary")!);
+ expect(details).toHaveAttribute("open");
+ });
+});
diff --git a/notfair/src/components/chat/messages.tsx b/notfair/src/components/chat/messages.tsx
index a5a897d7..52a69ada 100644
--- a/notfair/src/components/chat/messages.tsx
+++ b/notfair/src/components/chat/messages.tsx
@@ -43,12 +43,18 @@ export function RenderItem({
// not something the user typed — render a compact system line so the
// chat reads as "the agent got to work", not "who wrote this?".
if (item.system) {
- const label = item.body.startsWith("[TICK]")
- ? "Heartbeat tick — brief delivered to the agent"
+ const isCheckPrompt = item.body.startsWith("[TICK]");
+ const label = isCheckPrompt
+ ? "Check started — prompt delivered to the agent"
: item.body.startsWith("[INTAKE]")
? "Goal created — your ambition was handed to the agent"
: "Scheduled brief delivered to the agent";
- return <SystemLine label={label} />;
+ return (
+ <SystemLine
+ label={label}
+ prompt={isCheckPrompt ? item.body : undefined}
+ />
+ );
}
return <UserBubble body={item.body} />;
}
@@ -61,7 +67,41 @@ export function RenderItem({
return null;
}
-export function SystemLine({ label }: { label: string }) {
+export function SystemLine({
+ label,
+ prompt,
+}: {
+ label: string;
+ /** Verbatim platform prompt that initiated this check. */
+ prompt?: string;
+}) {
+ if (prompt) {
+ return (
+ <details className="group/check-prompt mx-auto w-full max-w-2xl">
+ <summary className="flex cursor-pointer list-none justify-center rounded-full ring-offset-background select-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
+ <span className="flex items-center gap-1.5 rounded-full bg-[hsl(var(--notfair-surface-2))] px-3.5 py-1 text-[11.5px] text-[hsl(var(--notfair-ink-4))]">
+ <span>{label}</span>
+ <span className="font-medium text-[hsl(var(--notfair-accent))]">
+ View exact prompt
+ </span>
+ <ChevronRight
+ className="size-3.5 transition-transform group-open/check-prompt:rotate-90"
+ aria-hidden
+ />
+ </span>
+ </summary>
+ <div className="mt-3 flex justify-end">
+ <div
+ data-check-trigger-prompt
+ className="max-h-96 max-w-[88%] overflow-y-auto rounded-[20px] rounded-br-md bg-[hsl(var(--notfair-surface-2))] px-4 py-3 text-foreground/95 shadow-sm"
+ >
+ <Markdown>{prompt}</Markdown>
+ </div>
+ </div>
+ </details>
+ );
+ }
+
return (
<div className="flex justify-center">
<span className="rounded-full bg-[hsl(var(--notfair-surface-2))] px-3.5 py-1 text-[11.5px] text-[hsl(var(--notfair-ink-4))]">
@@ -128,7 +168,7 @@ export function ToolGroup({
>
<summary
className={cn(
- "group/summary flex min-h-8 cursor-pointer list-none select-none items-center gap-2 py-0.5 text-[15px] leading-6",
+ "group/summary relative flex min-h-8 cursor-pointer list-none select-none items-center gap-2 py-0.5 text-[15px] leading-6",
"text-[hsl(var(--notfair-ink-3))] focus-visible:outline-none [&::-webkit-details-marker]:hidden",
)}
>
@@ -195,7 +235,7 @@ function ToolRow({
<div
data-tool-row
data-tool-status={statusLabel.toLowerCase()}
- className="flex min-h-7 items-center gap-2 py-0.5"
+ className="relative flex min-h-7 items-center gap-2 py-0.5"
title={entry.label ?? rowLabel}
>
<span className="flex size-4 shrink-0 items-center justify-center">