Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(plugins): daily review line on marketplace cards (#1748)

TioitWangcaf6e7ee38ea
diff --git a/apps/desktop/electron/main/ipc/market-ipc.ts b/apps/desktop/electron/main/ipc/market-ipc.ts
index 3508e23d1..c74734565 100644
--- a/apps/desktop/electron/main/ipc/market-ipc.ts
+++ b/apps/desktop/electron/main/ipc/market-ipc.ts
@@ -113,6 +113,12 @@ export function registerMarketIpc({
return host.call("market.reviewSummaries", { pluginIds });
});
+ handle(IPC.invoke.marketReviewTickers, async (payload?: { pluginIds?: unknown }) => {
+ if (!host) throw new Error("host unavailable");
+ const pluginIds = Array.isArray(payload?.pluginIds) ? payload.pluginIds : [];
+ return host.call("market.reviewTickers", { pluginIds });
+ });
+
handle(IPC.invoke.marketReviews, async (payload?: Partial<PluginReviewQuery>) => {
if (!host) throw new Error("host unavailable");
return host.call("market.reviews", { ...(payload ?? {}) });
diff --git a/apps/desktop/src/features/plugins/MarketplacePanel.tsx b/apps/desktop/src/features/plugins/MarketplacePanel.tsx
index 8134024fd..38657dae8 100644
--- a/apps/desktop/src/features/plugins/MarketplacePanel.tsx
+++ b/apps/desktop/src/features/plugins/MarketplacePanel.tsx
@@ -1,6 +1,7 @@
import { Button, cx } from "../../components/ui";
import { IconCheck, IconSearch, IconShield } from "../../components/icons";
import { PermissionChips, RatingChip } from "./presentation";
+import { ReviewTicker } from "./ReviewTicker";
import {
formatDate,
monogram,
@@ -26,6 +27,7 @@ export function MarketplacePanel({
busyId,
queueInstall,
reviewSummaries,
+ reviewTickers,
}: PluginsPageModel) {
return (
<div
@@ -151,10 +153,16 @@ export function MarketplacePanel({
</span>
</>
) : null}
- <RatingChip
- summary={reviewSummaries[item.id]}
- locale={locale}
- />
+ <span className="plugins-dot" aria-hidden>
+ ·
+ </span>
+ <span>
+ {installed
+ ? t("plugins.installedVersion", { version: installed.version })
+ : t("plugins.updatedOn", {
+ date: formatDate(item.updatedAt, locale),
+ })}
+ </span>
</span>
</span>
</span>
@@ -162,13 +170,12 @@ export function MarketplacePanel({
<PermissionChips permissions={item.permissionSummary} />
</button>
<div className="plugins-card-foot">
- <span className="plugins-card-state">
- {installed
- ? t("plugins.installedVersion", { version: installed.version })
- : t("plugins.updatedOn", {
- date: formatDate(item.updatedAt, locale),
- })}
- </span>
+ <RatingChip
+ summary={reviewSummaries[item.id]}
+ locale={locale}
+ showDot={false}
+ />
+ <ReviewTicker ticker={reviewTickers[item.id]} />
{installed && !upgradable ? (
<span className="plugins-installed-mark">
<IconCheck size={13} />
diff --git a/apps/desktop/src/features/plugins/ReviewTicker.tsx b/apps/desktop/src/features/plugins/ReviewTicker.tsx
new file mode 100644
index 000000000..28e36ef13
--- /dev/null
+++ b/apps/desktop/src/features/plugins/ReviewTicker.tsx
@@ -0,0 +1,60 @@
+import { useEffect, useState } from "react";
+import type { PluginReviewTicker } from "@pi-desktop/shared";
+
+/** How long one review line stays on screen before the next one fades in. */
+const ADVANCE_MS = 6000;
+
+/**
+ * The one-line review a marketplace card carries.
+ *
+ * The center selects and orders the rows; this only plays them. The line is
+ * supplementary — the description is what the card is for — so it is one
+ * clamped line, it pauses while the pointer or focus is on it, and a reader who
+ * asked for reduced motion sees the first row only.
+ */
+export function ReviewTicker({ ticker }: { ticker?: PluginReviewTicker }) {
+ const rows = ticker?.rows ?? [];
+ const [index, setIndex] = useState(0);
+ const [paused, setPaused] = useState(false);
+ const [reducedMotion, setReducedMotion] = useState(false);
+
+ useEffect(() => {
+ setIndex(0);
+ }, [ticker?.pluginId]);
+
+ useEffect(() => {
+ if (typeof window.matchMedia !== "function") return;
+ const query = window.matchMedia("(prefers-reduced-motion: reduce)");
+ const sync = () => setReducedMotion(query.matches);
+ sync();
+ query.addEventListener("change", sync);
+ return () => query.removeEventListener("change", sync);
+ }, []);
+
+ useEffect(() => {
+ if (paused || reducedMotion || rows.length <= 1) return;
+ const handle = window.setInterval(() => {
+ setIndex((current) => (current + 1) % rows.length);
+ }, ADVANCE_MS);
+ return () => window.clearInterval(handle);
+ }, [paused, reducedMotion, rows.length]);
+
+ if (rows.length === 0) return null;
+ const row = rows[index] ?? rows[0];
+
+ return (
+ <span
+ className="plugins-card-review"
+ title={row.body}
+ aria-live="off"
+ onMouseEnter={() => setPaused(true)}
+ onMouseLeave={() => setPaused(false)}
+ onFocus={() => setPaused(true)}
+ onBlur={() => setPaused(false)}
+ >
+ <span key={row.id} className="plugins-card-review-text">
+ {row.body}
+ </span>
+ </span>
+ );
+}
diff --git a/apps/desktop/src/features/plugins/presentation.tsx b/apps/desktop/src/features/plugins/presentation.tsx
index 7a455dcdd..6ac96732d 100644
--- a/apps/desktop/src/features/plugins/presentation.tsx
+++ b/apps/desktop/src/features/plugins/presentation.tsx
@@ -211,9 +211,12 @@ export function AgentExtensionDetails({ status }: { status: PluginAgentExtension
export function RatingChip({
summary,
locale,
+ showDot = true,
}: {
summary: PluginReviewSummary | undefined;
locale: string;
+ /** The card footer separates rating from review text with its own rule. */
+ showDot?: boolean;
}) {
const { t } = useTranslation();
const avg = summary ? formatRatingAvg(summary.ratingAvg, locale) : null;
@@ -227,9 +230,11 @@ export function RatingChip({
count: summary.ratingCount,
})}
>
- <span className="plugins-dot" aria-hidden>
- ·
- </span>
+ {showDot ? (
+ <span className="plugins-dot" aria-hidden>
+ ·
+ </span>
+ ) : null}
<IconStar size={11} style={{ fill: "currentColor" }} aria-hidden="true" />
<span className="plugins-rating-text">
{t("plugins.reviews.ratingChip", { avg, count: summary.ratingCount })}
diff --git a/apps/desktop/src/features/plugins/usePluginsPage.ts b/apps/desktop/src/features/plugins/usePluginsPage.ts
index 1282b6379..af3dfe938 100644
--- a/apps/desktop/src/features/plugins/usePluginsPage.ts
+++ b/apps/desktop/src/features/plugins/usePluginsPage.ts
@@ -8,6 +8,7 @@ import type {
MarketPluginSummary,
PluginPermissionReview,
PluginReviewSummary,
+ PluginReviewTicker,
PluginServiceStatus,
PluginSummary,
ProjectRecord,
@@ -97,6 +98,15 @@ export function usePluginsPage() {
const [reviewSummaries, setReviewSummaries] = useState<
Record<string, PluginReviewSummary>
>({});
+ /**
+ * The center's selected review line per plugin, batched with the summaries.
+ * Kept separate because it is optional decoration: a center that predates
+ * the ticker route must leave the cards intact, not put them in an error
+ * state.
+ */
+ const [reviewTickers, setReviewTickers] = useState<
+ Record<string, PluginReviewTicker>
+ >({});
const [reviewsStatus, setReviewsStatus] = useState<
"idle" | "loading" | "ready" | "unavailable"
>("idle");
@@ -333,6 +343,43 @@ export function usePluginsPage() {
};
}, [plugins, market]);
+ /**
+ * The review line is decoration, so it has its own read and its own failure
+ * mode. A center without the ticker route (or a transient failure) leaves the
+ * map empty and the cards render exactly as they did before this feature.
+ */
+ useEffect(() => {
+ const ids = [
+ ...new Set([...plugins.map((plugin) => plugin.id), ...market.map((item) => item.id)]),
+ ];
+ if (!ids.length) {
+ setReviewTickers({});
+ return;
+ }
+ let cancelled = false;
+ const handle = window.setTimeout(() => {
+ void (async () => {
+ try {
+ const tickers = await api.marketReviewTickers(ids);
+ if (cancelled) return;
+ const next: Record<string, PluginReviewTicker> = {};
+ for (const id of ids) {
+ const ticker = tickers[id];
+ if (ticker && ticker.rows.length > 0) next[id] = ticker;
+ }
+ setReviewTickers(next);
+ } catch {
+ if (cancelled) return;
+ setReviewTickers({});
+ }
+ })();
+ }, 200);
+ return () => {
+ cancelled = true;
+ window.clearTimeout(handle);
+ };
+ }, [plugins, market]);
+
const servicesByPlugin = useMemo(() => {
const map = new Map<string, PluginServiceStatus[]>();
for (const status of services) {
@@ -753,6 +800,7 @@ export function usePluginsPage() {
settingsPlugin,
setSettingsPlugin,
reviewSummaries,
+ reviewTickers,
reviewsStatus,
reviewsId,
openReviews,
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index 79ed9b38f..a23632a11 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -75,6 +75,7 @@ import type {
PluginReviewPage,
PluginReviewQuery,
PluginReviewSummary,
+ PluginReviewTicker,
ProjectRecord,
ProjectGroupRecord,
ProjectMemory,
@@ -1507,6 +1508,16 @@ export const api = {
/** One page of public reviews, its summary, and the trusted review URL. */
marketReviews: (query: PluginReviewQuery) =>
invoke<PluginReviewPage>(IPC.invoke.marketReviews, query),
+ /**
+ * The center's selected review line for plugin ids, keyed by id. Anonymous
+ * read through the host, stable for a UTC day. An older center rejects; the
+ * card then simply has no review line.
+ */
+ marketReviewTickers: (pluginIds: string[]) =>
+ invoke<{ tickers: Record<string, PluginReviewTicker> }>(
+ IPC.invoke.marketReviewTickers,
+ { pluginIds },
+ ).then((result) => result.tickers),
/** Import a pi CLI extension file or directory as a development plugin (spec 16 §3). */
importPiExtension: () =>
invoke<
diff --git a/apps/desktop/src/styles/plugins.css b/apps/desktop/src/styles/plugins.css
index fce04f75d..2d0b64a4a 100644
--- a/apps/desktop/src/styles/plugins.css
+++ b/apps/desktop/src/styles/plugins.css
@@ -1,5 +1,5 @@
-/*
- Plugins page — alerts, search and segmented filters, plugin rows and cards,
+/*
+ Plugins page 鈥?alerts, search and segmented filters, plugin rows and cards,
the detail sheet (permissions, versions, readme), and install/permission
modals.
*/
@@ -11,8 +11,8 @@
page renders correctly in both themes.
The page draws no dividers (D296). In-flow structure is carried by three
- tonal layers — the page, soft tiles mixed from the text colour, and the
- raised pill of an active control — plus spacing. Hairlines, inset rings and
+ tonal layers 鈥?the page, soft tiles mixed from the text colour, and the
+ raised pill of an active control 鈥?plus spacing. Hairlines, inset rings and
border-top/bottom rules are reserved for floating layers (menus, the detail
sheet, dialogs, tooltips), where an edge is an elevation cue rather than a
partition. */
@@ -1102,39 +1102,97 @@
}
.plugins-card-meta {
- display: flex;
- align-items: center;
- gap: 5px;
- flex-wrap: wrap;
+ display: block;
+ overflow: hidden;
color: var(--ds-text-muted);
font-size: var(--text-xs-plus);
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.plugins-card-author {
+ display: inline-block;
+ max-width: 14ch;
overflow: hidden;
text-overflow: ellipsis;
+ vertical-align: bottom;
white-space: nowrap;
- max-width: 14ch;
}
-/* Two clamped lines keep every card the same height without a min-height hack. */
+/* The description is the card's body: four quiet lines, never a teaser. */
.plugins-card-desc {
display: -webkit-box;
-webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- line-clamp: 2;
+ -webkit-line-clamp: 4;
+ line-clamp: 4;
overflow: hidden;
color: var(--ds-text-secondary);
- font-size: var(--text-sm-plus);
- line-height: var(--leading-body);
+ font-size: var(--text-md-plus);
+ line-height: var(--leading-prose);
}
.plugins-card-foot {
display: flex;
align-items: center;
- justify-content: space-between;
- gap: 10px;
- padding: 2px 14px 12px;
+ gap: 8px;
+ padding: 8px 14px 12px;
+ background: color-mix(in oklab, var(--ds-text-primary) 3%, transparent);
+}
+
+/* The rating and the install action are fixed-size; the review line takes the
+ space that is left, so neither can be squeezed by a long quote. */
+.plugins-card-foot .plugins-rating {
+ flex: 0 0 auto;
+}
+
+.plugins-card-foot .btn,
+.plugins-card-foot .plugins-installed-mark {
+ flex: 0 0 auto;
+ margin-left: auto;
+}
+
+.plugins-card-review {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ flex: 1 1 auto;
+ min-width: 0;
+ overflow: hidden;
+ color: var(--ds-text-muted);
+ font-size: var(--text-xs-plus);
+ line-height: var(--leading-body);
+}
+
+.plugins-card-review::before {
+ content: "";
+ flex: 0 0 1px;
+ height: 9px;
+ background: var(--ds-border-subtle);
+}
+
+.plugins-card-review-text {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ animation: plugins-review-fade var(--motion-duration-slow) var(--motion-ease-out);
+}
+
+@keyframes plugins-review-fade {
+ from {
+ opacity: 0;
+ transform: translateY(3px);
+ }
+ to {
+ opacity: 1;
+ transform: none;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .plugins-card-review-text {
+ animation: none;
+ }
}
.plugins-card-state {
@@ -1467,7 +1525,7 @@
justify-content: center;
}
-/* The composer stays inert — reviews are written on the centre — and its one
+/* The composer stays inert 鈥?reviews are written on the centre 鈥?and its one
action is a real link there. */
.plugins-reviews-composer {
display: flex;
@@ -2176,8 +2234,8 @@
padding: 14px 18px 18px;
}
-/* Manual install and update: one dialog follows the host's reports — the phase
- it is in, the mirror being tried, the bytes that arrived — and ends either on
+/* Manual install and update: one dialog follows the host's reports 鈥?the phase
+ it is in, the mirror being tried, the bytes that arrived 鈥?and ends either on
its own success or as a failure report naming the mirrors that were tried. */
.plugins-install-modal {
width: min(560px, 100%);
@@ -2343,3 +2401,4 @@
transition: none;
}
}
+
diff --git a/apps/desktop/test/plugins-page-style.test.mjs b/apps/desktop/test/plugins-page-style.test.mjs
index 40a0525f5..311352e55 100644
--- a/apps/desktop/test/plugins-page-style.test.mjs
+++ b/apps/desktop/test/plugins-page-style.test.mjs
@@ -113,7 +113,7 @@ test("extensions page draws no in-flow dividers", async () => {
assert.doesNotMatch(pluginsCss, /\.plugins-menu-sep\s*\{[^}]*background/);
assert.match(pluginsCss, /\.plugins-sheet-cta\s*\{[^}]*border-radius/);
assert.doesNotMatch(pluginsCss, /\.plugins-sheet-section\s*\{[^}]*border/);
- assert.match(pluginsCss, /\.plugins-card-foot\s*\{[^}]*padding:\s*2px 14px 12px/);
+ assert.match(pluginsCss, /\.plugins-card-foot\s*\{[^}]*padding:\s*8px 14px 12px/);
assert.doesNotMatch(pluginsCss, /\.plugins-card-foot\s*\{[^}]*border/);
assert.match(pluginsCss, /\.plugins-empty\s*\{[^}]*background:\s*var\(--plugins-tile\)/);
assert.doesNotMatch(pluginsCss, /\.plugins-market-settings/);
diff --git a/crates/host-core/src/plugins/reviews.rs b/crates/host-core/src/plugins/reviews.rs
index af1567a9c..5a5b1fb53 100644
--- a/crates/host-core/src/plugins/reviews.rs
+++ b/crates/host-core/src/plugins/reviews.rs
@@ -30,6 +30,10 @@ pub(crate) const MAX_REVIEW_RESPONSE_BYTES: usize = 1024 * 1024;
/// The number of plugin ids one summaries request may carry.
pub(crate) const MAX_SUMMARY_IDS: usize = 100;
+/// How many rows one ticker may carry. The center returns at most this many;
+/// a larger answer is a contract violation, not a longer carousel.
+pub(crate) const MAX_TICKER_ROWS: usize = 10;
+
/// Bodies a public read may carry; the write contract bounds them at 2000
/// unicode codepoints.
const MAX_REVIEW_BODY_CHARS: usize = 2000;
@@ -98,6 +102,30 @@ pub struct PluginReviewPage {
pub review_url: String,
}
+/// One row of a marketplace card's review ticker.
+///
+/// The center selects and orders these; the host only validates the shape. The
+/// row is deliberately smaller than a full review: the card shows one line, so
+/// the body is bounded and the private fields are not part of the contract.
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PluginReviewTickerRow {
+ pub id: String,
+ pub author_name: String,
+ pub rating_half_stars: u8,
+ pub body: String,
+ pub helpful_count: u64,
+ pub created_at: String,
+}
+
+/// The selected ticker rows for one plugin, best first.
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PluginReviewTicker {
+ pub plugin_id: String,
+ pub rows: Vec<PluginReviewTickerRow>,
+}
+
/// Which reviews one read asks for.
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct PluginReviewQuery {
@@ -225,6 +253,11 @@ pub(crate) fn summaries_url(origin: &str, ids: &[String]) -> String {
)
}
+/// Tickers URL for one batch of ids on the trusted origin.
+pub(crate) fn tickers_url(origin: &str, ids: &[String]) -> String {
+ format!("{origin}/api/v1/review-tickers?pluginIds={}", ids.join(","))
+}
+
/// Reviews URL for one query on the trusted origin.
pub(crate) fn reviews_url(origin: &str, query: &PluginReviewQuery) -> String {
let mut url = format!(
@@ -277,6 +310,38 @@ pub(crate) fn fetch_review_summaries(
Ok(summaries)
}
+/// Read the selected ticker rows for the given ids, batched and deduplicated.
+///
+/// Ids the center does not know are left out; ids the center answers for but
+/// nobody asked about are dropped. A failed batch fails the whole read, for the
+/// same reason as summaries: a partial map would look like "this plugin has no
+/// review line", which is a different claim.
+pub(crate) fn fetch_review_tickers(
+ origin: &str,
+ ids: &[String],
+) -> Result<BTreeMap<String, PluginReviewTicker>> {
+ let requested: BTreeSet<&str> = ids.iter().map(String::as_str).collect();
+ let mut tickers = BTreeMap::new();
+ for chunk in summary_id_chunks(ids) {
+ let url = tickers_url(origin, &chunk);
+ let (status, payload) = get_json(&url)?;
+ if status != 200 {
+ return Err(center_refusal(&url, status, &payload));
+ }
+ let wire: TickersWire = serde_json::from_slice(&payload).map_err(|error| {
+ anyhow!("PLUGIN_MARKET_INVALID: the plugin center's review ticker answer is not readable: {error}")
+ })?;
+ for (id, ticker) in wire.tickers {
+ if !requested.contains(id.as_str()) {
+ continue;
+ }
+ validate_ticker(&ticker, &id)?;
+ tickers.insert(id, ticker);
+ }
+ }
+ Ok(tickers)
+}
+
/// Read one page of public reviews plus its summary and webpage URL.
pub(crate) fn fetch_reviews(origin: &str, query: &PluginReviewQuery) -> Result<PluginReviewPage> {
let url = reviews_url(origin, query);
@@ -319,6 +384,12 @@ struct ReviewsWire {
summary: PluginReviewSummary,
}
+#[derive(Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct TickersWire {
+ tickers: BTreeMap<String, PluginReviewTicker>,
+}
+
/// Validate one summary against the public contract.
///
/// The counters are one partition of the same visible rows: the five floor
@@ -423,6 +494,52 @@ fn validate_review_date(review_id: &str, field: &str, value: &str) -> Result<()>
Ok(())
}
+/// Validate one plugin's ticker against the public contract.
+///
+/// The rows are the center's selection, so the host checks bounds and identity,
+/// not order: an ordering rule belongs to the center, and duplicating it here
+/// would let two implementations disagree about what a card shows.
+fn validate_ticker(ticker: &PluginReviewTicker, expected_plugin_id: &str) -> Result<()> {
+ if ticker.plugin_id != expected_plugin_id {
+ bail!(
+ "PLUGIN_MARKET_INVALID: review ticker for {expected_plugin_id} names {}",
+ ticker.plugin_id
+ );
+ }
+ if ticker.rows.len() > MAX_TICKER_ROWS {
+ bail!("PLUGIN_MARKET_INVALID: review ticker for {expected_plugin_id} carries more than {MAX_TICKER_ROWS} rows");
+ }
+ let mut seen = BTreeSet::new();
+ for row in &ticker.rows {
+ if row.id.trim().is_empty() {
+ bail!("PLUGIN_MARKET_INVALID: review ticker for {expected_plugin_id} carried a row without an id");
+ }
+ if !seen.insert(row.id.as_str()) {
+ bail!(
+ "PLUGIN_MARKET_INVALID: review ticker for {expected_plugin_id} repeated review {}",
+ row.id
+ );
+ }
+ if !(8..=10).contains(&row.rating_half_stars) {
+ bail!(
+ "PLUGIN_MARKET_INVALID: ticker review {} is below the four-star gate",
+ row.id
+ );
+ }
+ if row.body.trim().is_empty() || row.body.chars().count() > MAX_REVIEW_BODY_CHARS {
+ bail!(
+ "PLUGIN_MARKET_INVALID: ticker review {} has a body outside the public bounds",
+ row.id
+ );
+ }
+ if row.author_name.chars().count() > MAX_AUTHOR_NAME_CHARS {
+ bail!("PLUGIN_MARKET_INVALID: ticker review {} has an author name outside the public bounds", row.id);
+ }
+ validate_review_date(&row.id, "createdAt", &row.created_at)?;
+ }
+ Ok(())
+}
+
fn validate_cursor(cursor: Option<&str>) -> Result<()> {
if let Some(cursor) = cursor {
if cursor.len() > 4096 || cursor.chars().any(char::is_control) {
@@ -562,6 +679,68 @@ mod tests {
assert_eq!(REVIEW_TIMEOUT_SECONDS, 5);
assert_eq!(MAX_REVIEW_RESPONSE_BYTES, 1024 * 1024);
assert_eq!(MAX_SUMMARY_IDS, 100);
+ assert_eq!(MAX_TICKER_ROWS, 10);
+ }
+
+ #[test]
+ fn a_ticker_row_is_the_public_contract() {
+ let row = PluginReviewTickerRow {
+ id: "rev_1".into(),
+ author_name: "linzhou27".into(),
+ rating_half_stars: 10,
+ body: "装上之后基本没再开过系统文件管理器。".into(),
+ helpful_count: 60,
+ created_at: "2026-10-16T08:00:00Z".into(),
+ };
+ let ticker = PluginReviewTicker {
+ plugin_id: "pi.file-manager".into(),
+ rows: vec![row.clone()],
+ };
+ assert!(validate_ticker(&ticker, "pi.file-manager").is_ok());
+
+ // Identity is checked: a ticker filed under another plugin is a
+ // contract violation, not a row to render on the wrong card.
+ assert!(validate_ticker(&ticker, "pi.other").is_err());
+
+ // The gate and the row bounds are the center's, and the host refuses to
+ // render an answer that breaks them.
+ let mut below_gate = ticker.clone();
+ below_gate.rows[0].rating_half_stars = 7;
+ assert!(validate_ticker(&below_gate, "pi.file-manager").is_err());
+
+ let mut too_many = ticker.clone();
+ too_many.rows = (0..=MAX_TICKER_ROWS)
+ .map(|index| PluginReviewTickerRow {
+ id: format!("rev_{index}"),
+ ..row.clone()
+ })
+ .collect();
+ assert!(validate_ticker(&too_many, "pi.file-manager").is_err());
+
+ let mut duplicate = ticker.clone();
+ duplicate.rows.push(row.clone());
+ assert!(validate_ticker(&duplicate, "pi.file-manager").is_err());
+
+ let mut empty_body = ticker.clone();
+ empty_body.rows[0].body = " ".into();
+ assert!(validate_ticker(&empty_body, "pi.file-manager").is_err());
+
+ let mut bad_date = ticker.clone();
+ bad_date.rows[0].created_at = "yesterday".into();
+ assert!(validate_ticker(&bad_date, "pi.file-manager").is_err());
+
+ let mut empty_id = ticker.clone();
+ empty_id.rows[0].id = " ".into();
+ assert!(validate_ticker(&empty_id, "pi.file-manager").is_err());
+ }
+
+ #[test]
+ fn ticker_url_names_the_ticker_route() {
+ let ids = vec!["a.b".to_string(), "c-d".to_string()];
+ assert_eq!(
+ tickers_url("https://plugins.aiuo.net", &ids),
+ "https://plugins.aiuo.net/api/v1/review-tickers?pluginIds=a.b,c-d"
+ );
}
#[test]
diff --git a/crates/host-core/src/rpc/mod.rs b/crates/host-core/src/rpc/mod.rs
index 790e318d0..4f86af66b 100644
--- a/crates/host-core/src/rpc/mod.rs
+++ b/crates/host-core/src/rpc/mod.rs
@@ -5254,7 +5254,7 @@ async fn handle_request(
.map_err(|message| rpc_err(1002, message, "INVALID_PARAMS"))?;
Ok(json!({ "ok": true }))
}
- "market.reviewSummaries" | "market.reviews" => {
+ "market.reviewSummaries" | "market.reviewTickers" | "market.reviews" => {
plugin_reviews_rpc::handle(&state, method, params).await
}
"market.refresh" => {
diff --git a/crates/host-core/src/rpc/plugin_reviews_rpc.rs b/crates/host-core/src/rpc/plugin_reviews_rpc.rs
index 8a2d97a7b..6212d02a0 100644
--- a/crates/host-core/src/rpc/plugin_reviews_rpc.rs
+++ b/crates/host-core/src/rpc/plugin_reviews_rpc.rs
@@ -13,7 +13,8 @@ use tokio::sync::Mutex;
use super::{plugin_err, rpc_err, JsonRpcError};
use crate::plugins::reviews::{
- fetch_review_summaries, fetch_reviews, PluginReviewQuery, ReviewSentiment, ReviewSort,
+ fetch_review_summaries, fetch_review_tickers, fetch_reviews, PluginReviewQuery,
+ ReviewSentiment, ReviewSort,
};
use crate::state::AppState;
@@ -31,6 +32,7 @@ pub(super) async fn handle(
) -> Result<Value, JsonRpcError> {
match method {
"market.reviewSummaries" => review_summaries(state, params).await,
+ "market.reviewTickers" => review_tickers(state, params).await,
"market.reviews" => reviews(state, params).await,
_ => Err(rpc_err(
-32601,
@@ -61,6 +63,27 @@ async fn review_summaries(
Ok(json!({ "summaries": summaries }))
}
+/// Selected review ticker rows for the given plugin ids.
+///
+/// Same batching and origin rules as the summaries read. The center decides the
+/// selection and the order, and it keeps them stable for a UTC day; the host
+/// does not re-rank, so the card shows what the marketplace chose.
+async fn review_tickers(
+ state: &Arc<Mutex<AppState>>,
+ params: Value,
+) -> Result<Value, JsonRpcError> {
+ let ids = parse_ids(&params)?;
+ if ids.is_empty() {
+ return Ok(json!({ "tickers": {} }));
+ }
+ let origin = review_origin(state).await?;
+ let tickers = tokio::task::spawn_blocking(move || fetch_review_tickers(&origin, &ids))
+ .await
+ .map_err(worker_error)?
+ .map_err(plugin_err)?;
+ Ok(json!({ "tickers": tickers }))
+}
+
/// One page of public reviews, with the summary and the trusted webpage URL.
async fn reviews(state: &Arc<Mutex<AppState>>, params: Value) -> Result<Value, JsonRpcError> {
let query = parse_query(&params)?;
diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts
index 9fbe4f3f4..422414371 100644
--- a/packages/shared/src/protocol.ts
+++ b/packages/shared/src/protocol.ts
@@ -390,6 +390,7 @@ export const IPC = {
marketApplyUpdates: "pi-desktop/market/applyUpdates",
marketCancelInstall: "pi-desktop/market/cancelInstall",
marketReviewSummaries: "pi-desktop/market/reviewSummaries",
+ marketReviewTickers: "pi-desktop/market/reviewTickers",
marketReviews: "pi-desktop/market/reviews",
commandPaletteSearch: "pi-desktop/commandPalette/search",
commandPaletteExecute: "pi-desktop/commandPalette/execute",
diff --git a/packages/shared/src/types/marketplace.ts b/packages/shared/src/types/marketplace.ts
index 06c9c9b22..87f8f8ef2 100644
--- a/packages/shared/src/types/marketplace.ts
+++ b/packages/shared/src/types/marketplace.ts
@@ -120,3 +120,24 @@ export type PluginReviewQuery = {
sentiment?: "all" | "positive" | "neutral" | "negative";
sort?: "newest" | "helpful";
};
+
+/**
+ * One row of a marketplace card's review ticker.
+ *
+ * The center selects these; the client never re-ranks them. The body is a
+ * single quiet line on the card, not a full review surface.
+ */
+export type PluginReviewTickerRow = {
+ id: string;
+ authorName: string;
+ ratingHalfStars: number;
+ body: string;
+ helpfulCount: number;
+ createdAt: string;
+};
+
+/** The selected rows for one plugin, best first, at most ten. */
+export type PluginReviewTicker = {
+ pluginId: string;
+ rows: PluginReviewTickerRow[];
+};