Python
fix(observability): the 👎 card says what it does before you send (T3-8)
Devika Verma149a5a1e6948
diff --git a/surfaces/gui/src/components/TurnFooter.test.tsx b/surfaces/gui/src/components/TurnFooter.test.tsxindex 3385797d..da811f62 100644--- a/surfaces/gui/src/components/TurnFooter.test.tsx+++ b/surfaces/gui/src/components/TurnFooter.test.tsx@@ -56,6 +56,30 @@ describe("TurnFooterLine", () => {await waitFor(() => expect((putTurnFeedback as any).mock.calls[1][2].rating).toBeNull());});+ it("the open 👎 card says reasons can be several and where the rating will go; 👎 again closes it unrated (T3-8)", () => {+ const up = { ...footer, feedback: { turn_id: "t1", session_id: "s1", rating: "up" as const, reasons: [], rated_at: 1, changed_at: null } };+ render(<TurnFooterLine sessionId="s1" footer={up} last defaultWhere={{ local: true, export: null, managed: false, with_note: false }} />);+ expect(screen.getByTestId("turn-footer-up").getAttribute("aria-pressed")).toBe("true");+ fireEvent.click(screen.getByTestId("turn-footer-down"));+ const card = screen.getByTestId("rating-card").textContent || "";+ expect(card).toContain("Pick any that apply.");+ expect(card).toContain("Will be saved on this machine.");+ expect(card).not.toContain("Saved on this machine.");+ // (d) 👎 is the one shown chosen while its card is open+ expect(screen.getByTestId("turn-footer-up").getAttribute("aria-pressed")).toBe("false");+ expect(screen.getByTestId("turn-footer-down").getAttribute("aria-pressed")).toBe("true");+ // (a) several reasons stay picked+ fireEvent.click(screen.getByTestId("rating-reason-wrong_answer"));+ fireEvent.click(screen.getByTestId("rating-reason-too_slow"));+ expect(screen.getByTestId("rating-reason-wrong_answer").getAttribute("aria-pressed")).toBe("true");+ expect(screen.getByTestId("rating-reason-too_slow").getAttribute("aria-pressed")).toBe("true");+ // (c) 👎 again closes the card without rating; the 👍 is back+ fireEvent.click(screen.getByTestId("turn-footer-down"));+ expect(screen.queryByTestId("rating-card")).toBeNull();+ expect(putTurnFeedback).not.toHaveBeenCalled();+ expect(screen.getByTestId("turn-footer-up").getAttribute("aria-pressed")).toBe("true");+ });+it("with recording off, says so and still offers a rating", () => {render(<TurnFooterLine sessionId="s1" footer={footer} recording={false} last />);expect(screen.getByTestId("turn-footer").textContent).toContain("Recording is off on this machine");diff --git a/surfaces/gui/src/components/TurnFooter.tsx b/surfaces/gui/src/components/TurnFooter.tsxindex ab42c80f..b4766a38 100644--- a/surfaces/gui/src/components/TurnFooter.tsx+++ b/surfaces/gui/src/components/TurnFooter.tsx@@ -96,10 +96,16 @@ export function TurnFooterLine({</>)}<span className="sep">·</span>- <button className={"thumb" + (rating === "up" ? " sel" : "")} aria-pressed={rating === "up"} data-testid="turn-footer-up"+ {/* T3-8: while the 👎 card is open, 👎 is the one shown chosen; 👎 again closes the card+ and leaves the rating as it was. */}+ <button className={"thumb" + (rating === "up" && !card ? " sel" : "")} aria-pressed={rating === "up" && !card} data-testid="turn-footer-up"title={t("p3.fb.up")} onClick={() => { setCard(false); void rate(rating === "up" ? null : "up"); }}>👍</button>- <button className={"thumb" + (rating === "down" ? " sel" : "")} aria-pressed={rating === "down"} data-testid="turn-footer-down"- title={t("p3.fb.down")} onClick={() => { if (rating === "down" && !card) { void rate(null); return; } setCard(true); }}>👎</button>+ <button className={"thumb" + (rating === "down" || card ? " sel" : "")} aria-pressed={rating === "down" || card} data-testid="turn-footer-down"+ title={t("p3.fb.down")} onClick={() => {+ if (card) setCard(false);+ else if (rating === "down") void rate(null);+ else setCard(true);+ }}>👎</button>{where && !card && <span className="text-faint ml-2" data-testid="turn-footer-where">{whereLine(where, t)}</span>}</div>{card && (@@ -123,8 +129,8 @@ export function TurnFooterLine({/** The machine's own answer says whether the note went too (`with_note`: a note was given* and "Your messages and the AI's answers" is on, TD3-11). */-export function whereLine(w: FeedbackWhere | null | undefined, t: (k: string, o?: any) => string): string {- const { key, withNote } = whereKey(w);+export function whereLine(w: FeedbackWhere | null | undefined, t: (k: string, o?: any) => string, future = false): string {+ const { key, withNote } = whereKey(w, future);return t(key, { by: w?.by || "" }) + (withNote ? " " + t("p3.fb.with_note") : "");}@@ -147,6 +153,8 @@ export function RatingCard({return (<div className="p3-ratecard" data-testid="rating-card"><b>{t("p3.fb.what_wrong")} <span className="text-faint font-normal">{t("p3.fb.optional")}</span></b>+ {/* T3-8 (a): reasons are zero or more of the five, so say so */}+ <div className="text-faint text-meta" data-testid="rating-pick-any">{t("p3.fb.pick_any")}</div><div className="flex gap-1.5 flex-wrap my-2">{REASONS.map((r) => (<button key={r} className={"p3-pill" + (reasons.includes(r) ? " on" : "")} aria-pressed={reasons.includes(r)}@@ -163,7 +171,7 @@ export function RatingCard({</button><button className="btn" data-testid="rating-skip" onClick={onSkip}>{t("p3.fb.skip")}</button><span className="text-faint ml-auto text-meta">- {failed ? t("p3.fb.failed") : whereLine(where, t)}+ {failed ? t("p3.fb.failed") : whereLine(where, t, true)}</span></div></div>diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex ba210ce3..dce4093d 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -4018,7 +4018,12 @@"where_langfuse": "Saved on this machine. Also sent to Langfuse (export is on).","where_otlp": "Saved on this machine. Also sent to your OpenTelemetry endpoint (export is on).","where_company": "Saved on this machine. Also sent to your company's Langfuse.",- "with_note": "With your note."+ "with_note": "With your note.",+ "pick_any": "Pick any that apply.",+ "will_local": "Will be saved on this machine.",+ "will_langfuse": "Will be saved on this machine, and sent to Langfuse (export is on).",+ "will_otlp": "Will be saved on this machine, and sent to your OpenTelemetry endpoint (export is on).",+ "will_company": "Will be saved on this machine, and sent to your company's Langfuse."},"doing": {"title": "How it's been doing · last 30 days, on this machine",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex 2d228c22..165622a0 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -3953,7 +3953,12 @@"where_langfuse": "已保存在这台机器上。也已发送到 Langfuse(导出已开启)。","where_otlp": "已保存在这台机器上。也已发送到你的 OpenTelemetry 端点(导出已开启)。","where_company": "已保存在这台机器上。也已发送到你公司的 Langfuse。",- "with_note": "包括你的备注。"+ "with_note": "包括你的备注。",+ "pick_any": "可多选。",+ "will_local": "将保存在这台机器上。",+ "will_langfuse": "将保存在这台机器上,并发送到 Langfuse(导出已开启)。",+ "will_otlp": "将保存在这台机器上,并发送到你的 OpenTelemetry 端点(导出已开启)。",+ "will_company": "将保存在这台机器上,并发送到你公司的 Langfuse。"},"doing": {"title": "表现如何 · 最近 30 天,在这台机器上",diff --git a/surfaces/gui/src/obs3.ts b/surfaces/gui/src/obs3.tsindex 46316c79..6c9f79a3 100644--- a/surfaces/gui/src/obs3.ts+++ b/surfaces/gui/src/obs3.ts@@ -189,10 +189,12 @@ export function turnForAnswer(footers: TurnFooter[], ts: number | undefined, ansexport const REASONS = ["wrong_answer", "too_slow", "did_unasked", "did_not_finish", "other"] as const;/** The rating card's last line: where the rating went (§8.3). */-export function whereKey(w: FeedbackWhere | null | undefined): { key: string; withNote: boolean } {- if (!w || !w.export) return { key: "p3.fb.where_local", withNote: false };- if (w.managed) return { key: "p3.fb.where_company", withNote: !!w.with_note };- return { key: w.export === "langfuse" ? "p3.fb.where_langfuse" : "p3.fb.where_otlp", withNote: !!w.with_note };+export function whereKey(w: FeedbackWhere | null | undefined, future = false): { key: string; withNote: boolean } {+ // T3-8: before Send or Skip nothing is saved yet, so the open card says where it *will* go.+ const pre = future ? "p3.fb.will_" : "p3.fb.where_";+ if (!w || !w.export) return { key: pre + "local", withNote: false };+ if (w.managed) return { key: pre + "company", withNote: !future && !!w.with_note };+ return { key: pre + (w.export === "langfuse" ? "langfuse" : "otlp"), withNote: !future && !!w.with_note };}// -- wake reasons (OB-17) ----------------------------------------------------------------------