A desktop coding agent with free access to frontier models.
TypeScript
fix: keep a placement in both slots
Samrat Talukdarabd163cd13ce
diff --git a/apps/desktop/electron/placements-desktop.test.mjs b/apps/desktop/electron/placements-desktop.test.mjsindex 42d0154d..62c2e56a 100644--- a/apps/desktop/electron/placements-desktop.test.mjs+++ b/apps/desktop/electron/placements-desktop.test.mjs@@ -131,6 +131,29 @@ test("shared: caps, snooze and expiry", async () => {assert.equal(e.claim("home_banner"), null, "ended");});+test("shared: one id in both slots: both entries kept, the count shared by id", async () => {+ const both = [placement({ id: "plc_both", slot: "home_banner", max_per_day: 2 }), placement({ id: "plc_both", slot: "turn_footer", title: "Turn copy", max_per_day: 2 })];+ assert.equal(parseAnswer(answer(both)).placements.length, 2);+ const { d } = desktop({ routes: () => ({ status: 200, data: answer(both) }) });+ assert.equal((await d.placement({ slot: "home_banner" })).slot, "home_banner");+ const turn = await d.placement({ slot: "turn_footer", sessionId: "ses_1" });+ assert.equal(turn.slot, "turn_footer");+ assert.equal(turn.title, "Turn copy");+ assert.equal(d.service.state().shown.plc_both.count, 2);+ assert.equal(await d.placement({ slot: "turn_footer", sessionId: "ses_2" }), null, "shared max_per_day");+ assert.deepEqual(await d.action({ id: "plc_both", action: "dismiss" }), { ok: true });+ assert.equal(d.service.current("turn_footer"), null);+});++test("shared: events go to /client/placements/events?client=desktop", async () => {+ const paths = [];+ const { d } = desktop({ routes: (p) => { paths.push(p); return p.startsWith("/client/placements/events") ? { status: 204 } : { status: 200, data: answer() }; } });+ const p = await d.placement({ slot: "home_banner" });+ await d.action({ id: p.id, action: "impression" });+ assert.equal(await d.service.flush(), 1);+ assert.equal(paths.at(-1), "/client/placements/events?client=desktop");+});+test("shared: the file is the CLI's (PARITY.sha256)", () => {const dir = path.join(here, "placements");const rows = fs.readFileSync(path.join(dir, "PARITY.sha256"), "utf8").split("\n").filter((line) => line && !line.startsWith("#"));diff --git a/apps/desktop/electron/placements/PARITY.sha256 b/apps/desktop/electron/placements/PARITY.sha256index 5c3744c2..410208b9 100644--- a/apps/desktop/electron/placements/PARITY.sha256+++ b/apps/desktop/electron/placements/PARITY.sha256@@ -1,3 +1,3 @@# Sponsored placements: the same file in omnirush-cli (assets/extensions/omnirush/placements/)# and omnirush-gui (apps/desktop/electron/placements/). A change to one must be ported to the other and this list updated in both.-b7b8f275d2c6c4bd14942723056b0b30a2423ffce1808d5cc2a07ba4829bb317 placements.mjs+fc2c3cabdde4c1460481324807abd058575540bad2a2c95e1fe883018687f543 placements.mjsdiff --git a/apps/desktop/electron/placements/placements.mjs b/apps/desktop/electron/placements/placements.mjsindex 7ef6cb88..74a361c1 100644--- a/apps/desktop/electron/placements/placements.mjs+++ b/apps/desktop/electron/placements/placements.mjs@@ -140,8 +140,11 @@ export function parseAnswer(body) {if (enabled && Array.isArray(body.placements)) {for (const raw of body.placements.slice(0, 50)) {const placement = parsePlacement(raw);- if (!placement || seen.has(placement.id)) continue;- seen.add(placement.id);+ if (!placement) continue;+ // One id may run in both slots (one entry per slot); per-day count, dismiss and click stay keyed by id.+ const key = `${placement.slot}\n${placement.id}`;+ if (seen.has(key)) continue;+ seen.add(key);placements.push(placement);}}@@ -353,7 +356,8 @@ export function createPlacements({const save = () => (allowed ? writeState(stateFile, state) : false);const answer = () => cachedAnswer(state, now());- const known = (id) => answer()?.placements.find((p) => p.id === id) ?? null;+ /** The placement with `id` (in `slot` when given: one id may have an entry per slot). */+ const known = (id, slot = null) => answer()?.placements.find((p) => p.id === id && (!slot || p.slot === slot)) ?? null;const schedule = () => {if (stopped || !started) return;@@ -452,7 +456,7 @@ export function createPlacements({if (!allowed || !SLOTS.includes(slot)) return null;const at = now();if (slot === "home_banner" && runClaims.has(slot)) {- const kept = known(runClaims.get(slot));+ const kept = known(runClaims.get(slot), slot);return kept && eligibleKept(kept, at) ? placementView(kept) : null;}if (slot === "turn_footer") {@@ -476,7 +480,7 @@ export function createPlacements({/** The placement this run claimed for `slot` (not counted again), or null. */current(slot) {const id = runClaims.get(slot);- const placement = id ? known(id) : null;+ const placement = id ? known(id, slot) : null;return placement && eligibleKept(placement, now()) ? placementView(placement) : null;},/** It was drawn on screen. */@@ -533,7 +537,7 @@ export function createPlacements({const batch = state.events.slice(0, MAX_EVENT_BATCH);let result = null;try {- result = await request(EVENTS_PATH, { method: "POST", body: { events: batch }, timeoutMs });+ result = await request(`${EVENTS_PATH}?client=${client === "desktop" ? "desktop" : "cli"}`, { method: "POST", body: { events: batch }, timeoutMs });} catch {result = null;}