Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

ui improvements

Pedro Ladeiraa15f4c5f2579
diff --git a/apps/web/lib/ai/review-reward-tooltip-schema.ts b/apps/web/lib/ai/review-reward-tooltip-schema.ts
index 616201c573..480dece0f0 100644
--- a/apps/web/lib/ai/review-reward-tooltip-schema.ts
+++ b/apps/web/lib/ai/review-reward-tooltip-schema.ts
@@ -43,7 +43,9 @@ const tooltipSuggestionSchema = z.object({
.string()
.min(1)
.max(200)
- .describe("One short sentence explaining the contradiction."),
+ .describe(
+ "One short sentence for a non-technical user. Quote the tooltip phrase and the conflicting condition wording. Never use raw operator IDs.",
+ ),
suggested: tooltipSuggestionPatchSchema.describe(
"Operator and/or value to write back. Never change entity or attribute.",
),
diff --git a/apps/web/lib/ai/review-reward-tooltip.ts b/apps/web/lib/ai/review-reward-tooltip.ts
index 49ab8fd56e..d5caf3622d 100644
--- a/apps/web/lib/ai/review-reward-tooltip.ts
+++ b/apps/web/lib/ai/review-reward-tooltip.ts
@@ -67,14 +67,14 @@ export async function reviewRewardTooltipConsistency(
const { event, modifiers } = parsedInput.data;
const { output } = await generateText({
- model: anthropic("claude-sonnet-4-6"),
+ model: anthropic("claude-haiku-4-5"),
output: Output.object({
schema: reviewRewardTooltipOutputSchema,
}),
system: buildSystemPrompt(event),
prompt: buildUserPrompt({ tooltip, modifiers }),
temperature: 0,
- maxOutputTokens: 1500,
+ maxOutputTokens: 600,
});
const parsedOutput = reviewRewardTooltipOutputSchema.safeParse(output);
@@ -108,11 +108,17 @@ Rules:
- A suggestion may change operator and/or value only.
- If you are not sure, return an empty suggestions array. Never guess.
- confidence is 0–1. Use below 0.5 when the reading is ambiguous or only loosely implied.
-- reason must be one short sentence.
+- reason must be one short sentence a program manager can understand.
+- Use the human operator labels (e.g. "is greater than"), never raw IDs like greater_than or field paths like sale.amount.
+- Wrap the tooltip phrase and the conflicting condition wording in double quotes.
+- Do not explain inclusive/exclusive in parentheses. Say what a partner would expect vs what the condition does.
+
+Good reason: "Minimum $20 deposit" implies $20 qualifies, but "is greater than" excludes it.
+Bad reason: Tooltip says "min $20" (at least $20, inclusive) but the condition uses greater_than 20 (excludes $20).
Examples of contradictions:
-- Tooltip says "minimum $20" / "at least $20" but the condition is greater_than 20 (excludes $20).
-- Tooltip says "more than $20" / "over $20" but the condition is greater_than_or_equal 20.
+- Tooltip says "minimum $20" / "at least $20" but the condition is "is greater than" $20 (excludes $20).
+- Tooltip says "more than $20" / "over $20" but the condition is "is greater than or equal to" $20.
Not contradictions:
- Tooltip is shorter than the config or omits extra filters (country, product, metadata).
@@ -153,5 +159,7 @@ ${tooltip}
"""
Conditions:
-${serialized}`;
+${serialized}
+
+Write the reason for a non-technical user. Use the operator labels in parentheses, not the raw operator keys.`;
}
diff --git a/apps/web/ui/partners/rewards/suggested-fix-popover.tsx b/apps/web/ui/partners/rewards/suggested-fix-popover.tsx
index 1d1d2d6750..3e5d4abe51 100644
--- a/apps/web/ui/partners/rewards/suggested-fix-popover.tsx
+++ b/apps/web/ui/partners/rewards/suggested-fix-popover.tsx
@@ -124,7 +124,7 @@ export function SuggestedFixBadge({
setActiveIndex(thisIndex);
}
}}
- className="inline-flex items-center gap-1 rounded bg-[#FFFBEB] px-1.5 text-left text-sm font-semibold text-[#973C00] transition-colors"
+ className="inline-flex items-center gap-1 rounded bg-[#FFFBEB] px-1.5 text-left align-middle text-sm font-semibold leading-[inherit] text-[#973C00] transition-colors"
>
<Sparkle3 variant="fill" className="size-3 shrink-0 text-[#E17100]" />
{text}
@@ -206,37 +206,35 @@ function SuggestedFixContent({
</div>
<div className="flex flex-col gap-3 p-3">
- <div className="rounded-lg bg-neutral-50 px-2.5 py-2">
- <div className="flex items-start gap-2">
- <div className="flex size-6 shrink-0 items-center justify-center rounded-md bg-white">
- <InvoiceDollar className="size-3.5 text-neutral-800" />
- </div>
- <p className="min-w-0 text-sm font-medium leading-relaxed text-neutral-800">
- If <PreviewChip>{entityLabel}</PreviewChip>{" "}
- <PreviewChip>{attributeLabel}</PreviewChip>{" "}
- <PreviewChip
- changed={suggestionTouchesField({
- field: "operator",
- current,
- suggested: suggestion.suggested,
- })}
- >
- {operatorLabel}
- </PreviewChip>{" "}
- <PreviewChip
- changed={suggestionTouchesField({
- field: "value",
- current,
- suggested: suggestion.suggested,
- })}
- >
- {valueLabel}
- </PreviewChip>
- </p>
+ <div className="flex min-h-16 w-full items-start gap-2 rounded-[10px] border border-neutral-200 bg-white p-2.5 shadow-[0px_2px_4px_0px_#00000008]">
+ <div className="flex size-6 shrink-0 items-center justify-center rounded-md bg-neutral-50">
+ <InvoiceDollar className="size-3.5 text-neutral-800" />
</div>
+ <p className="min-w-0 text-sm font-medium leading-relaxed text-neutral-800">
+ If <PreviewChip>{entityLabel}</PreviewChip>{" "}
+ <PreviewChip>{attributeLabel}</PreviewChip>{" "}
+ <PreviewChip
+ changed={suggestionTouchesField({
+ field: "operator",
+ current,
+ suggested: suggestion.suggested,
+ })}
+ >
+ {operatorLabel}
+ </PreviewChip>{" "}
+ <PreviewChip
+ changed={suggestionTouchesField({
+ field: "value",
+ current,
+ suggested: suggestion.suggested,
+ })}
+ >
+ {valueLabel}
+ </PreviewChip>
+ </p>
</div>
- <p className="text-sm text-neutral-600">{suggestion.reason}</p>
+ <SuggestedFixReason reason={suggestion.reason} />
</div>
<div
@@ -275,6 +273,37 @@ function SuggestedFixContent({
);
}
+function SuggestedFixReason({ reason }: { reason: string }) {
+ const nodes: ReactNode[] = [];
+ const quoteRe = /"([^"]+)"|“([^”]+)”/g;
+ let lastIndex = 0;
+ let match: RegExpExecArray | null;
+ let key = 0;
+
+ while ((match = quoteRe.exec(reason)) !== null) {
+ if (match.index > lastIndex) {
+ nodes.push(reason.slice(lastIndex, match.index));
+ }
+
+ nodes.push(
+ <span key={key++} className="font-semibold">
+ {match[0]}
+ </span>,
+ );
+ lastIndex = match.index + match[0].length;
+ }
+
+ if (lastIndex < reason.length) {
+ nodes.push(reason.slice(lastIndex));
+ }
+
+ return (
+ <p className="text-sm font-normal leading-[1.4] tracking-[-0.02em] text-neutral-800">
+ {nodes}
+ </p>
+ );
+}
+
function PreviewChip({
children,
changed,
diff --git a/apps/web/ui/partners/rewards/use-reward-tooltip-consistency.ts b/apps/web/ui/partners/rewards/use-reward-tooltip-consistency.ts
index 1e4920b6be..fffe0f61dd 100644
--- a/apps/web/ui/partners/rewards/use-reward-tooltip-consistency.ts
+++ b/apps/web/ui/partners/rewards/use-reward-tooltip-consistency.ts
@@ -25,7 +25,7 @@ import {
useState,
} from "react";
-const DEBOUNCE_MS = 600;
+const DEBOUNCE_MS = 200;
const reviewCache = new Map<string, TooltipSuggestion[]>();
type RewardTooltipConsistencyValue = {