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.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
fix(action-center): read a task's Where for its page up to the length the drawer keeps (#1594)
Gökhan Geyik2f924cee2575
diff --git a/server/src/lib/action-center/task-send.js b/server/src/lib/action-center/task-send.jsindex e686421e5..345a8f46b 100644--- a/server/src/lib/action-center/task-send.js+++ b/server/src/lib/action-center/task-send.js@@ -70,14 +70,20 @@ export async function loadTask(taskId) {return { task, action };}+/** The most of a Where or URL read for a page: the drawer keeps them to this. */+const WHERE_CHARS = 500;+/*** The brand's page a task's Where names, as a URL: "acme.example/pricing ·* lost on ChatGPT" gives https://acme.example/pricing, and a bare path is on* the brand's first domain. Null when Where names no page of the brand's.+ * Only its first WHERE_CHARS are read, so a long one is read in bounded time.*/export function ownPageOf(where, brandDomains) {const isOwn = ownDomainMatcher(brandDomains);- for (const token of text(where).split(/[\s·,;()]+/)) {+ for (const token of text(where)+ .slice(0, WHERE_CHARS)+ .split(/[\s·,;()]+/)) {const cleaned = token.replace(/^["'“”]+|["'“”.]+$/g, '');if (!cleaned) continue;if (cleaned.startsWith('/') && cleaned.length > 1 && brandDomains[0]) {diff --git a/server/src/lib/action-center/task-send.test.js b/server/src/lib/action-center/task-send.test.jsindex 429155e2f..34a2f7bd1 100644--- a/server/src/lib/action-center/task-send.test.js+++ b/server/src/lib/action-center/task-send.test.js@@ -126,6 +126,18 @@ describe('ownPageOf', () => {);expect(ownPageOf('g2.com/categories/ai-rank-tracking', ['acme.example'])).toBeNull();});++ it('reads a long Where in bounded time, up to the length the drawer keeps', () => {+ ownPageOf('acme.example/pricing', ['acme.example']);+ const started = Date.now();+ expect(ownPageOf(`${'.'.repeat(100_000)}x`, ['acme.example'])).toBeNull();+ expect(ownPageOf(`"${'“'.repeat(100_000)}`, ['acme.example'])).toBeNull();+ expect(Date.now() - started).toBeLessThan(200);+ // What the drawer keeps is read as before.+ expect(ownPageOf(`${'a '.repeat(240)}acme.example/pricing`, ['acme.example'])).toBe(+ 'https://acme.example/pricing',+ );+ });});describe('opportunityFromTask', () => {