Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content): show when each opportunity was suggested, with sort and date filter (#1024)

Cihan3bbc0bfb656f
diff --git a/server/src/routes/content.js b/server/src/routes/content.js
index 5a9011d28..4478459af 100644
--- a/server/src/routes/content.js
+++ b/server/src/routes/content.js
@@ -270,12 +270,17 @@ router.get('/brand/:brandId', async (req, res) => {
prompt_id: promptId,
topic_id: topicId,
source,
+ created_from: createdFrom,
+ created_to: createdTo,
limit = 50,
offset = 0,
sort = 'score',
} = req.query;
const search = q ? String(q).replace(/[,()]/g, ' ') : null;
+ const isoOrNull = (v) => (v && Number.isFinite(Date.parse(String(v))) ? String(v) : null);
+ const fromBound = isoOrNull(createdFrom);
+ const toBound = isoOrNull(createdTo);
const { promptCluster, topicClusters } = await clusterScope(
brandId,
promptId ? String(promptId) : null,
@@ -302,6 +307,10 @@ router.get('/brand/:brandId', async (req, res) => {
filteredQuery = filteredQuery.eq('source', source);
}
+ // When it was suggested (CONTENT-002's date filter).
+ if (fromBound) filteredQuery = filteredQuery.gte('created_at', fromBound);
+ if (toBound) filteredQuery = filteredQuery.lte('created_at', toBound);
+
// A prompt matches its cluster's opportunities, own or merged, and any
// older opportunity written for the prompt itself.
if (promptId) {
@@ -335,9 +344,9 @@ router.get('/brand/:brandId', async (req, res) => {
dataQuery = dataQuery.order('opportunity_score', {
ascending: false,
});
- } else if (sort === 'newest') {
+ } else if (sort === 'newest' || sort === 'oldest') {
dataQuery = dataQuery.order('created_at', {
- ascending: false,
+ ascending: sort === 'oldest',
});
}
@@ -352,6 +361,8 @@ router.get('/brand/:brandId', async (req, res) => {
p_prompt_id: promptId ? String(promptId) : null,
p_topic_id: topicId ? String(topicId) : null,
p_source: source ? String(source) : null,
+ p_created_from: fromBound,
+ p_created_to: toBound,
});
const [{ data, error: dataError, count }, { data: aggregateData, error: aggregateError }] =
diff --git a/supabase/migrations/00127_opportunity_suggested_filter.sql b/supabase/migrations/00127_opportunity_suggested_filter.sql
new file mode 100644
index 000000000..b9f5f0766
--- /dev/null
+++ b/supabase/migrations/00127_opportunity_suggested_filter.sql
@@ -0,0 +1,103 @@
+-- The Content list's date filter (CONTENT-002): This month / Last 30 days /
+-- Custom bound the opportunities by when they were suggested (created_at),
+-- so the summary figures above the list take the same bounds. The list can
+-- now also sort oldest first, which an index on (brand_id, created_at)
+-- keeps cheap together with the newest-first sort.
+
+create index if not exists content_opportunities_brand_created_idx
+ on public.content_opportunities (brand_id, created_at desc);
+
+-- content_opportunity_aggregates (00126) with the date bounds.
+drop function if exists public.content_opportunity_aggregates(uuid, text, text, text, text, uuid, uuid, text);
+
+create or replace function public.content_opportunity_aggregates(
+ p_brand_id uuid,
+ p_status text default null,
+ p_impact text default null,
+ p_type text default null,
+ p_q text default null,
+ p_prompt_id uuid default null,
+ p_topic_id uuid default null,
+ p_source text default null,
+ p_created_from timestamptz default null,
+ p_created_to timestamptz default null
+)
+returns table (
+ avg_score numeric,
+ high_impact_count bigint,
+ sent_count bigint,
+ signal_count bigint
+)
+language sql
+stable
+security invoker
+set search_path = public
+as $$
+ select
+ coalesce(avg(co.opportunity_score), 0) as avg_score,
+ count(*) filter (
+ where co.impact = 'high'
+ ) as high_impact_count,
+ count(*) filter (
+ where co.status in ('sent', 'in_progress', 'done')
+ ) as sent_count,
+ (
+ select count(*)
+ from prompt_cluster_members m
+ join prompt_clusters pc on pc.id = m.cluster_id
+ where pc.brand_id = p_brand_id
+ ) + (
+ select count(*)
+ from prompt_cluster_queries q
+ join prompt_clusters pc on pc.id = q.cluster_id
+ where pc.brand_id = p_brand_id
+ ) as signal_count
+ from public.content_opportunities co
+ where co.brand_id = p_brand_id
+ and (
+ (p_status is null and co.status <> 'archived')
+ or co.status = p_status
+ )
+ and (p_impact is null or co.impact = p_impact)
+ and (p_type is null or co.type = p_type)
+ and (p_source is null or co.source = p_source)
+ and (p_created_from is null or co.created_at >= p_created_from)
+ and (p_created_to is null or co.created_at <= p_created_to)
+ and (
+ p_prompt_id is null
+ or co.prompt_id = p_prompt_id
+ or exists (
+ select 1
+ from prompt_cluster_members m
+ where m.prompt_id = p_prompt_id
+ and (m.cluster_id = co.cluster_id or m.cluster_id = any(co.related_cluster_ids))
+ )
+ )
+ and (
+ p_topic_id is null
+ or exists (
+ select 1
+ from prompt_clusters pc
+ where pc.topic_id = p_topic_id
+ and (pc.id = co.cluster_id or pc.id = any(co.related_cluster_ids))
+ )
+ )
+ and (
+ p_q is null
+ or co.title ilike '%' || p_q || '%'
+ or co.description ilike '%' || p_q || '%'
+ );
+$$;
+
+grant execute on function public.content_opportunity_aggregates(
+ uuid,
+ text,
+ text,
+ text,
+ text,
+ uuid,
+ uuid,
+ text,
+ timestamptz,
+ timestamptz
+) to authenticated;
diff --git a/supabase/schema.sql b/supabase/schema.sql
index a7360c3f2..01bf15e8a 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -14512,3 +14512,110 @@ grant execute on function public.content_opportunity_aggregates(
text
) to authenticated;
+-- ─────────────────────────────────────────────────────────────────────────
+-- migrations/00127_opportunity_suggested_filter.sql
+-- ─────────────────────────────────────────────────────────────────────────
+-- The Content list's date filter (CONTENT-002): This month / Last 30 days /
+-- Custom bound the opportunities by when they were suggested (created_at),
+-- so the summary figures above the list take the same bounds. The list can
+-- now also sort oldest first, which an index on (brand_id, created_at)
+-- keeps cheap together with the newest-first sort.
+
+create index if not exists content_opportunities_brand_created_idx
+ on public.content_opportunities (brand_id, created_at desc);
+
+-- content_opportunity_aggregates (00126) with the date bounds.
+drop function if exists public.content_opportunity_aggregates(uuid, text, text, text, text, uuid, uuid, text);
+
+create or replace function public.content_opportunity_aggregates(
+ p_brand_id uuid,
+ p_status text default null,
+ p_impact text default null,
+ p_type text default null,
+ p_q text default null,
+ p_prompt_id uuid default null,
+ p_topic_id uuid default null,
+ p_source text default null,
+ p_created_from timestamptz default null,
+ p_created_to timestamptz default null
+)
+returns table (
+ avg_score numeric,
+ high_impact_count bigint,
+ sent_count bigint,
+ signal_count bigint
+)
+language sql
+stable
+security invoker
+set search_path = public
+as $$
+ select
+ coalesce(avg(co.opportunity_score), 0) as avg_score,
+ count(*) filter (
+ where co.impact = 'high'
+ ) as high_impact_count,
+ count(*) filter (
+ where co.status in ('sent', 'in_progress', 'done')
+ ) as sent_count,
+ (
+ select count(*)
+ from prompt_cluster_members m
+ join prompt_clusters pc on pc.id = m.cluster_id
+ where pc.brand_id = p_brand_id
+ ) + (
+ select count(*)
+ from prompt_cluster_queries q
+ join prompt_clusters pc on pc.id = q.cluster_id
+ where pc.brand_id = p_brand_id
+ ) as signal_count
+ from public.content_opportunities co
+ where co.brand_id = p_brand_id
+ and (
+ (p_status is null and co.status <> 'archived')
+ or co.status = p_status
+ )
+ and (p_impact is null or co.impact = p_impact)
+ and (p_type is null or co.type = p_type)
+ and (p_source is null or co.source = p_source)
+ and (p_created_from is null or co.created_at >= p_created_from)
+ and (p_created_to is null or co.created_at <= p_created_to)
+ and (
+ p_prompt_id is null
+ or co.prompt_id = p_prompt_id
+ or exists (
+ select 1
+ from prompt_cluster_members m
+ where m.prompt_id = p_prompt_id
+ and (m.cluster_id = co.cluster_id or m.cluster_id = any(co.related_cluster_ids))
+ )
+ )
+ and (
+ p_topic_id is null
+ or exists (
+ select 1
+ from prompt_clusters pc
+ where pc.topic_id = p_topic_id
+ and (pc.id = co.cluster_id or pc.id = any(co.related_cluster_ids))
+ )
+ )
+ and (
+ p_q is null
+ or co.title ilike '%' || p_q || '%'
+ or co.description ilike '%' || p_q || '%'
+ );
+$$;
+
+grant execute on function public.content_opportunity_aggregates(
+ uuid,
+ text,
+ text,
+ text,
+ text,
+ uuid,
+ uuid,
+ text,
+ timestamptz,
+ timestamptz
+) to authenticated;
+
diff --git a/web/messages/en.json b/web/messages/en.json
index a05df1bda..0bf5947ac 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -1782,6 +1782,23 @@
"allTopics": "All Topics",
"allSources": "All Sources"
},
+ "suggestedRange": {
+ "label": "Suggested",
+ "all": "All time",
+ "month": "This month",
+ "last30": "Last 30 days",
+ "custom": "Custom",
+ "from": "From",
+ "to": "To"
+ },
+ "newSinceVisit": "New since your last visit",
+ "scope": {
+ "group": "{topic} · {count, plural, one {# prompt} other {# prompts}}",
+ "groupNoTopic": "{count, plural, one {# prompt} other {# prompts}}",
+ "single": "Single prompt",
+ "groupHint": "Built for a group of related prompts that one piece of content can answer",
+ "singleHint": "Built for one prompt"
+ },
"source": {
"label": "Source",
"system": "System",
@@ -1826,7 +1843,8 @@
"sort": {
"label": "Sort",
"score": "Highest score",
- "newest": "Newest"
+ "newest": "Newest",
+ "oldest": "Oldest"
},
"bulk": {
"selected": "{count} selected",
@@ -1842,6 +1860,7 @@
},
"table": {
"action": "Action",
+ "suggested": "Suggested",
"type": "Type",
"impact": "Impact",
"score": "Score",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
index 676448374..49b08147b 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
@@ -83,6 +83,7 @@ import { Sheet, SheetContent, SheetTitle } from '@/components/ui/sheet';
import { OpportunityDetail } from '@/components/content/opportunity-detail';
import { ContentUsageCard } from '@/components/content/content-usage-card';
import { hasContentQuota, onDemandMax, type ContentUsage } from '@/lib/content-usage';
+import { suggestedBounds, suggestedDate, type SuggestedRange } from '@/lib/suggested-date';
import {
NewOpportunitiesDialog,
type NewOpportunitiesInput,
@@ -108,8 +109,40 @@ const STATUS_VALUES = [
const IMPACT_VALUES = ['all', 'high', 'medium', 'low'] as const;
const TYPE_VALUES = ['all', 'owned', 'earned'] as const;
const SOURCE_VALUES = ['all', 'system', 'manual', 'prompt'] as const;
-const SORT_VALUES = ['score', 'newest'] as const;
-const URL_DEFAULTS = { status: 'all', impact: 'all', type: 'all', source: 'all', sort: 'score' };
+const SORT_VALUES = ['score', 'newest', 'oldest'] as const;
+const SUGGESTED_VALUES = ['all', 'month', 'last30', 'custom'] as const;
+const URL_DEFAULTS = {
+ status: 'all',
+ impact: 'all',
+ type: 'all',
+ source: 'all',
+ suggested: 'all',
+ from: '',
+ to: '',
+ sort: 'score',
+};
+
+/** When the list was last opened, per brand: rows suggested since get a dot. */
+const LAST_VISIT_KEY = 'aeo:content-last-visit:';
+
+/**
+ * The visit before this one, read once per brand per page load and cached,
+ * so running the effect twice (React's development mode does) doesn't read
+ * back the visit it just recorded.
+ */
+const visitBefore = new Map<string, number | null>();
+function previousVisit(brandId: string): number | null {
+ if (!visitBefore.has(brandId)) {
+ let previous: number | null = null;
+ try {
+ const key = LAST_VISIT_KEY + brandId;
+ previous = Number(localStorage.getItem(key)) || null;
+ localStorage.setItem(key, String(Date.now()));
+ } catch {}
+ visitBefore.set(brandId, previous);
+ }
+ return visitBefore.get(brandId) ?? null;
+}
/** Used when the month's usage couldn't be read; the server still caps it. */
const FALLBACK_REQUEST_MAX = 3;
@@ -121,7 +154,7 @@ const OPPORTUNITY_EXPORT_HEADERS = [
'score',
'status',
'related_prompt',
- 'created_at',
+ 'suggested_at',
];
// The export pages through the filtered list; the cap keeps a runaway brand
// from pinning the browser.
@@ -207,6 +240,57 @@ function KpiCard({
);
}
+/** When it was suggested, relative for a week, with the full date on hover. */
+function SuggestedCell({
+ createdAt,
+ locale,
+ isNew,
+ newLabel,
+}: {
+ createdAt: string;
+ locale: string;
+ isNew: boolean;
+ newLabel: string;
+}) {
+ const { label, full } = suggestedDate(createdAt, locale);
+ return (
+ <span className="inline-flex items-center gap-1.5" title={full}>
+ {isNew && (
+ <span
+ className="h-1.5 w-1.5 shrink-0 rounded-full bg-primary"
+ role="img"
+ aria-label={newLabel}
+ title={newLabel}
+ />
+ )}
+ {label}
+ </span>
+ );
+}
+
+/**
+ * What an opportunity was built for: a group of related prompts in a topic
+ * (cluster opportunities, #857) or a single prompt (the older generator).
+ */
+function OpportunityScope({ opp }: { opp: ContentOpportunity }) {
+ const t = useTranslations('content.scope');
+ const count = opp.sourceData?.prompts?.length ?? 0;
+ const group = !!opp.clusterId;
+ const label = group
+ ? opp.sourceData?.topicName
+ ? t('group', { topic: opp.sourceData.topicName, count })
+ : t('groupNoTopic', { count })
+ : t('single');
+ return (
+ <span
+ className="mr-1.5 font-medium text-foreground/70"
+ title={group ? t('groupHint') : t('singleHint')}
+ >
+ {label} ·
+ </span>
+ );
+}
+
const ALL_PROMPTS = '__all__';
interface PromptFilterItem {
@@ -235,6 +319,12 @@ export default function ContentPage() {
const [impactFilter, setImpactFilter] = useState<string>('all');
const [typeFilter, setTypeFilter] = useState<string>('all');
const [sourceFilter, setSourceFilter] = useState<string>('all');
+ // When it was suggested (CONTENT-002); custom takes YYYY-MM-DD bounds.
+ const [suggestedRange, setSuggestedRange] = useState<SuggestedRange>('all');
+ const [customFrom, setCustomFrom] = useState('');
+ const [customTo, setCustomTo] = useState('');
+ // The previous visit, read once per brand before this one is recorded.
+ const [lastVisit, setLastVisit] = useState<number | null>(null);
const [sortOrder, setSortOrder] = useState<string>('score');
// The prompt filter (#836) lives in the URL as ?prompt=<id> so a filtered
// view can be linked to. It is read after mount — useSearchParams would need
@@ -275,7 +365,7 @@ export default function ContentPage() {
// pager instead of the length of whatever page happens to be loaded.
const pager = usePagination(
total,
- `${statusFilter}|${impactFilter}|${typeFilter}|${sourceFilter}|${promptFilter}|${topicFilter}|${debouncedSearch}|${sortOrder}`,
+ `${statusFilter}|${impactFilter}|${typeFilter}|${sourceFilter}|${suggestedRange}|${customFrom}|${customTo}|${promptFilter}|${topicFilter}|${debouncedSearch}|${sortOrder}`,
);
// The list's filters and search, shared by the page load and the CSV export.
@@ -285,6 +375,9 @@ export default function ContentPage() {
if (impactFilter !== 'all') filters.impact = impactFilter;
if (typeFilter !== 'all') filters.type = typeFilter;
if (sourceFilter !== 'all') filters.source = sourceFilter;
+ const bounds = suggestedBounds(suggestedRange, { from: customFrom, to: customTo });
+ if (bounds.from) filters.createdFrom = bounds.from;
+ if (bounds.to) filters.createdTo = bounds.to;
if (promptFilter) filters.promptId = promptFilter;
if (topicFilter) filters.topicId = topicFilter;
if (debouncedSearch.trim()) filters.q = debouncedSearch.trim();
@@ -295,6 +388,9 @@ export default function ContentPage() {
impactFilter,
typeFilter,
sourceFilter,
+ suggestedRange,
+ customFrom,
+ customTo,
promptFilter,
topicFilter,
debouncedSearch,
@@ -371,6 +467,9 @@ export default function ContentPage() {
setImpactFilter(readUrlChoice('impact', IMPACT_VALUES, 'all'));
setTypeFilter(readUrlChoice('type', TYPE_VALUES, 'all'));
setSourceFilter(readUrlChoice('source', SOURCE_VALUES, 'all'));
+ setSuggestedRange(readUrlChoice('suggested', SUGGESTED_VALUES, 'all'));
+ setCustomFrom(params.get('from') ?? '');
+ setCustomTo(params.get('to') ?? '');
setSortOrder(readUrlChoice('sort', SORT_VALUES, 'score'));
setUrlRead(true);
}, []);
@@ -385,11 +484,31 @@ export default function ContentPage() {
impact: impactFilter,
type: typeFilter,
source: sourceFilter,
+ suggested: suggestedRange,
+ from: suggestedRange === 'custom' ? customFrom : '',
+ to: suggestedRange === 'custom' ? customTo : '',
sort: sortOrder,
},
URL_DEFAULTS,
);
- }, [urlRead, statusFilter, impactFilter, typeFilter, sourceFilter, sortOrder]);
+ }, [
+ urlRead,
+ statusFilter,
+ impactFilter,
+ typeFilter,
+ sourceFilter,
+ suggestedRange,
+ customFrom,
+ customTo,
+ sortOrder,
+ ]);
+
+ // Rows suggested since the previous visit get a dot; this visit is
+ // recorded for the next one. Storage failures only lose the dots.
+ useEffect(() => {
+ if (!activeBrandId) return;
+ setLastVisit(previousVisit(activeBrandId));
+ }, [activeBrandId]);
const selectOpportunity = useCallback((opportunityId: string | null) => {
setOpenOpportunityId(opportunityId);
@@ -569,7 +688,8 @@ export default function ContentPage() {
score: Math.round(o.opportunityScore),
status: o.status,
related_prompt: o.sourceData.promptText ?? (o.sourceData.prompts ?? []).join(' | '),
- created_at: o.createdAt,
+ // ISO 8601, whatever the UI language (CONTENT-002).
+ suggested_at: new Date(o.createdAt).toISOString(),
})),
OPPORTUNITY_EXPORT_HEADERS,
);
@@ -793,6 +913,7 @@ export default function ContentPage() {
impactFilter !== 'all' ||
typeFilter !== 'all' ||
sourceFilter !== 'all' ||
+ suggestedRange !== 'all' ||
promptFilter !== '' ||
topicFilter !== '' ||
search.trim() !== '';
@@ -802,6 +923,9 @@ export default function ContentPage() {
setImpactFilter('all');
setTypeFilter('all');
setSourceFilter('all');
+ setSuggestedRange('all');
+ setCustomFrom('');
+ setCustomTo('');
selectPrompt('');
setTopicFilter('');
setSearch('');
@@ -1066,6 +1190,47 @@ export default function ContentPage() {
))}
</SelectContent>
</Select>
+ <Select
+ value={suggestedRange}
+ onValueChange={(v) => v && setSuggestedRange(v as SuggestedRange)}
+ >
+ <SelectTrigger
+ className="h-8 w-[130px] text-xs"
+ aria-label={t('suggestedRange.label')}
+ >
+ <SelectValue>
+ {(value) => t(`suggestedRange.${value as SuggestedRange}`)}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ {SUGGESTED_VALUES.map((value) => (
+ <SelectItem key={value} value={value}>
+ {t(`suggestedRange.${value}`)}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ {suggestedRange === 'custom' && (
+ <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ <Input
+ type="date"
+ aria-label={t('suggestedRange.from')}
+ value={customFrom}
+ max={customTo || undefined}
+ onChange={(e) => setCustomFrom(e.target.value)}
+ className="h-8 w-[140px] text-xs"
+ />
+ –
+ <Input
+ type="date"
+ aria-label={t('suggestedRange.to')}
+ value={customTo}
+ min={customFrom || undefined}
+ onChange={(e) => setCustomTo(e.target.value)}
+ className="h-8 w-[140px] text-xs"
+ />
+ </span>
+ )}
<Select value={statusFilter} onValueChange={(v) => v && setStatusFilter(v)}>
<SelectTrigger className="h-8 w-[130px] text-xs">
<SelectValue>
@@ -1088,7 +1253,7 @@ export default function ContentPage() {
<Select value={sortOrder} onValueChange={(v) => v && setSortOrder(v)}>
<SelectTrigger className="h-8 w-[130px] text-xs" aria-label={t('sort.label')}>
<SelectValue>
- {(value) => t(`sort.${value as 'score' | 'newest'}`)}
+ {(value) => t(`sort.${value as 'score' | 'newest' | 'oldest'}`)}
</SelectValue>
</SelectTrigger>
<SelectContent>
@@ -1228,6 +1393,10 @@ export default function ContentPage() {
/>
</TableHead>
<TableHead className="pl-6 w-[40%]">{t('table.action')}</TableHead>
+ {/* Hidden on narrower screens, where the action column needs the room. */}
+ <TableHead className="hidden whitespace-nowrap xl:table-cell">
+ {t('table.suggested')}
+ </TableHead>
<TableHead className="text-center">{t('table.type')}</TableHead>
<TableHead className="text-center">{t('table.impact')}</TableHead>
<TableHead className="text-center">{t('table.score')}</TableHead>
@@ -1243,6 +1412,9 @@ export default function ContentPage() {
<Skeleton className="h-4 w-4/5" />
<Skeleton className="mt-1.5 h-3 w-3/5" />
</TableCell>
+ <TableCell className="hidden xl:table-cell">
+ <Skeleton className="h-3 w-12" />
+ </TableCell>
<TableCell className="text-center">
<Skeleton className="mx-auto h-5 w-14" />
</TableCell>
@@ -1300,13 +1472,20 @@ export default function ContentPage() {
)}
{opp.title}
</p>
- {opp.description && (
- <p className="text-xs text-muted-foreground line-clamp-1 mt-0.5">
- {opp.description}
- </p>
- )}
+ <p className="text-xs text-muted-foreground line-clamp-1 mt-0.5">
+ <OpportunityScope opp={opp} />
+ {opp.description}
+ </p>
</button>
</TableCell>
+ <TableCell className="hidden whitespace-nowrap text-xs text-muted-foreground xl:table-cell">
+ <SuggestedCell
+ createdAt={opp.createdAt}
+ locale={locale}
+ isNew={lastVisit !== null && Date.parse(opp.createdAt) > lastVisit}
+ newLabel={t('newSinceVisit')}
+ />
+ </TableCell>
<TableCell className="text-center">
<div className="flex flex-col items-center gap-1">
<Badge
diff --git a/web/src/components/content/opportunity-detail.tsx b/web/src/components/content/opportunity-detail.tsx
index 0b361338b..1af657b93 100644
--- a/web/src/components/content/opportunity-detail.tsx
+++ b/web/src/components/content/opportunity-detail.tsx
@@ -1,7 +1,7 @@
'use client';
import { useState, useEffect } from 'react';
-import { useTranslations } from 'next-intl';
+import { useLocale, useTranslations } from 'next-intl';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
@@ -50,6 +50,7 @@ import {
} from '@/components/content/opportunity-basket';
import { opportunityToMarkdown } from '@/lib/content/opportunity-markdown';
import { toast } from 'sonner';
+import { suggestedDate } from '@/lib/suggested-date';
export const IMPACT_COLORS: Record<string, string> = {
high: 'border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-400',
@@ -117,6 +118,7 @@ export function OpportunityDetail({
onChanged?: () => void;
}) {
const t = useTranslations('content');
+ const locale = useLocale();
const [opportunity, setOpportunity] = useState<ContentOpportunity | null>(null);
const [loading, setLoading] = useState(true);
@@ -328,9 +330,13 @@ export function OpportunityDetail({
<Badge variant="outline" className="text-xs tabular-nums">
Score: {Math.round(opportunity.opportunityScore)}
</Badge>
- <span className="text-xs text-muted-foreground ml-auto flex items-center gap-1.5">
+ {/* The UI's language, not the browser's: an English page showed "25 Eyl". */}
+ <span
+ className="text-xs text-muted-foreground ml-auto flex items-center gap-1.5"
+ title={suggestedDate(opportunity.createdAt, locale).full}
+ >
<Clock className="h-3.5 w-3.5" />
- {new Date(opportunity.createdAt).toLocaleDateString(undefined, {
+ {new Date(opportunity.createdAt).toLocaleDateString(locale, {
day: 'numeric',
month: 'short',
year: 'numeric',
diff --git a/web/src/lib/actions/content.ts b/web/src/lib/actions/content.ts
index d3ed704f2..71457566b 100644
--- a/web/src/lib/actions/content.ts
+++ b/web/src/lib/actions/content.ts
@@ -114,6 +114,9 @@ export async function getOpportunities(
promptId?: string;
topicId?: string;
source?: string;
+ /** Suggested on or after / before (ISO), CONTENT-002. */
+ createdFrom?: string;
+ createdTo?: string;
limit?: number;
offset?: number;
sort?: string;
@@ -138,6 +141,8 @@ export async function getOpportunities(
if (filters?.promptId) params.set('prompt_id', filters.promptId);
if (filters?.topicId) params.set('topic_id', filters.topicId);
if (filters?.source) params.set('source', filters.source);
+ if (filters?.createdFrom) params.set('created_from', filters.createdFrom);
+ if (filters?.createdTo) params.set('created_to', filters.createdTo);
if (filters?.limit) params.set('limit', String(filters.limit));
if (filters?.offset) params.set('offset', String(filters.offset));
if (filters?.sort) params.set('sort', filters.sort);
diff --git a/web/src/lib/suggested-date.test.ts b/web/src/lib/suggested-date.test.ts
new file mode 100644
index 000000000..1a491e491
--- /dev/null
+++ b/web/src/lib/suggested-date.test.ts
@@ -0,0 +1,52 @@
+/**
+ * suggested-date.test.ts (CONTENT-002)
+ *
+ * The Suggested column's date and the list's date filter bounds.
+ */
+
+import { describe, expect, test } from 'vitest';
+import { suggestedBounds, suggestedDate } from './suggested-date';
+
+const NOW = Date.parse('2026-10-13T12:00:00Z');
+const ago = (ms: number) => new Date(NOW - ms).toISOString();
+const H = 3_600_000;
+
+describe('suggestedDate', () => {
+ test('relative for the first week, in the UI language', () => {
+ expect(suggestedDate(ago(2 * H), 'en', NOW).label).toBe('2 hours ago');
+ expect(suggestedDate(ago(2 * 24 * H), 'en', NOW).label).toBe('2 days ago');
+ expect(suggestedDate(ago(5 * 60_000), 'en', NOW).label).toBe('5 minutes ago');
+ expect(suggestedDate(ago(2 * 24 * H), 'tr', NOW).label).toBe('2 gün önce');
+ });
+
+ test('a short date after a week, with the year only when it differs', () => {
+ expect(suggestedDate('2026-09-25T09:14:00Z', 'en', NOW).label).toBe('Sep 25');
+ expect(suggestedDate('2025-12-30T09:14:00Z', 'en', NOW).label).toBe('Dec 30, 2025');
+ });
+
+ test('the tooltip has the full date and time', () => {
+ expect(suggestedDate('2026-09-25T09:14:00Z', 'en', NOW).full).toMatch(/Sep 25, 2026/);
+ });
+});
+
+describe('suggestedBounds', () => {
+ const now = new Date(2026, 9, 13, 12);
+
+ test('this month starts on the 1st; last 30 days is a rolling window', () => {
+ expect(suggestedBounds('month', {}, now)).toEqual({
+ from: new Date(2026, 9, 1).toISOString(),
+ });
+ expect(suggestedBounds('last30', {}, now)).toEqual({
+ from: new Date(now.getTime() - 30 * 24 * H).toISOString(),
+ });
+ expect(suggestedBounds('all', {}, now)).toEqual({});
+ });
+
+ test('a custom range includes the whole last day and ignores empty inputs', () => {
+ expect(suggestedBounds('custom', { from: '2026-10-01', to: '2026-10-05' }, now)).toEqual({
+ from: new Date(2026, 9, 1).toISOString(),
+ to: new Date(new Date(2026, 9, 6).getTime() - 1).toISOString(),
+ });
+ expect(suggestedBounds('custom', { from: '' }, now)).toEqual({});
+ });
+});
diff --git a/web/src/lib/suggested-date.ts b/web/src/lib/suggested-date.ts
new file mode 100644
index 000000000..18486fb1d
--- /dev/null
+++ b/web/src/lib/suggested-date.ts
@@ -0,0 +1,70 @@
+/**
+ * How the Content list and the opportunity panel show when an opportunity
+ * was suggested (CONTENT-002): relative for the first week ("2 hours ago",
+ * "2 days ago"), then a short date ("Sep 25"), always in the UI's language,
+ * with the full date and time for the tooltip.
+ */
+
+const MINUTE = 60_000;
+const HOUR = 60 * MINUTE;
+const DAY = 24 * HOUR;
+
+/** Up to this age the date reads relative. */
+export const RELATIVE_FOR_MS = 7 * DAY;
+
+export function suggestedDate(
+ iso: string,
+ locale: string,
+ now: number = Date.now(),
+): { label: string; full: string } {
+ const at = new Date(iso);
+ const full = new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(
+ at,
+ );
+ const age = Math.max(0, now - at.getTime());
+ if (age < RELATIVE_FOR_MS) {
+ const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'always' });
+ const label =
+ age < HOUR
+ ? rtf.format(-Math.max(1, Math.round(age / MINUTE)), 'minute')
+ : age < DAY
+ ? rtf.format(-Math.round(age / HOUR), 'hour')
+ : rtf.format(-Math.round(age / DAY), 'day');
+ return { label, full };
+ }
+ const sameYear = at.getFullYear() === new Date(now).getFullYear();
+ const label = new Intl.DateTimeFormat(locale, {
+ month: 'short',
+ day: 'numeric',
+ ...(sameYear ? {} : { year: 'numeric' }),
+ }).format(at);
+ return { label, full };
+}
+
+export type SuggestedRange = 'all' | 'month' | 'last30' | 'custom';
+
+/**
+ * The created_at bounds a date filter preset stands for, as ISO strings;
+ * custom takes YYYY-MM-DD inputs and includes the whole "to" day.
+ */
+export function suggestedBounds(
+ range: SuggestedRange,
+ custom: { from?: string; to?: string } = {},
+ now: Date = new Date(),
+): { from?: string; to?: string } {
+ if (range === 'month') {
+ return { from: new Date(now.getFullYear(), now.getMonth(), 1).toISOString() };
+ }
+ if (range === 'last30') return { from: new Date(now.getTime() - 30 * DAY).toISOString() };
+ if (range === 'custom') {
+ const from = custom.from ? new Date(`${custom.from}T00:00:00`) : null;
+ const to = custom.to ? new Date(`${custom.to}T00:00:00`) : null;
+ return {
+ ...(from && !Number.isNaN(from.getTime()) ? { from: from.toISOString() } : {}),
+ ...(to && !Number.isNaN(to.getTime())
+ ? { to: new Date(to.getTime() + DAY - 1).toISOString() }
+ : {}),
+ };
+ }
+ return {};
+}