Repository navigation
feat(tracking): track prompts in cities, asked by the engines that can answer from one (PROMPT-015, part 4) - #1658
Merged
Conversation
…columns, and share them with the brand (PROMPT-015, part 1) PROMPT-015a. A Columns panel beside the table's search: - show or hide every column but Prompt, and reorder them by dragging or with the arrows; - saved per person and brand (00363 prompt_table_views, RLS); - an admin or manager can share their columns with everyone on the brand, who see them until they change their own; - Reset goes back to the brand's view, or the default. Nobody who never opens Columns sees a change: the default is today's columns in today's order. The table builds its header and cells by column id, unchanged inside. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Locations view (PROMPT-015, part 2) PROMPT-015b. A Table | Locations switch above Tracked Prompts: - Locations shows each prompt in each location the brand tracks, side by side: Visibility, Position, Mentions or Citations; an average row; a Gap column (best minus worst location); and three cards: the weakest and strongest location and the prompt that differs most between them. - Cells use Brand Visibility's Topics vs competitors shades (HEAT_SHADES, moved beside heatShade). A cell opens the prompt's Positions panel on that location; a location the prompt isn't tracked in offers + Track (its Edit dialog for now). - The Columns panel can add "<metric> · <location>" columns to the table. - getPromptLocationMatrix reads each location with the table's own reads (visibility summaries, position sums), side by side, so a location's numbers equal the table filtered to it. No migration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… brand (PROMPT-015, part 1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…PT-015, part 2) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aving, with more countries (PROMPT-015, part 3) PROMPT-015c. Track in more locations, from the Locations view's + Add location or a cell's + Track: - pick countries or US states (LocationPicker), and the prompts to ask there: the one clicked, the selected, a topic, or all shown; - Plan usage shows used → after of the plan's prompt locations before anything is saved, with the same arithmetic the save enforces (planBulkLocationChange, bulkUpdatePromptLocations); - past the limit the dialog says what the choice needs and what is left, with the plan's way out (Starter: upgrade or a custom plan; Growth: a custom plan; Enterprise: raise the limit), and Save stays off. Prompts can be tracked in about 50 countries (TRACKING_COUNTRIES), not 18; a brand's own region keeps the shorter list that volumes and audits read. PromptLimitActions moves to its own file (a page can't export it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n answer from one (PROMPT-015, part 4)
PROMPT-015d. A city is the location code `<country>~<CITY>` (`TR~ISTANBUL`),
51 major cities in both lists (server/src/lib/cities.js,
web/src/config/cities.ts; same ids):
- Google AI Overview and AI Mode ask from the city: the provider gets the
city's Google canonical name as `location` beside the country.
- The API models (OpenAI, Claude) get `user_location` with the city and its
region.
- ChatGPT, Perplexity, Copilot, Gemini and Grok can't target a city through
the provider, so locationsForScraper skips city codes for them: no second
country-wide run, no double cost. A prompt tracked only in cities runs
nothing on them.
- A city counts one location on the plan, like a country (decision 6), on
every plan.
Web: the location picker lists cities ("City · Turkey") with a note on which
engines ask there; the Locations view marks a city column "AI Mode · AIO ·
APIs"; Track in more locations turns a city off, and says why, when none of
the chosen prompts runs one of those engines.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ROMPT-015, part 4) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…OMPT-015, part 2) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ound of reads (PROMPT-015, part 2) The user's bar: data within 1–2 s of a choice. Measured locally (dev, hosted dev DB) the matrix read took 1.4–1.8 s. - getPromptLocationMatrix starts every read at once: the plan's engines no longer wait in front of the locations' reads. - A matrix read stays a minute in the browser (loadLocationMatrix), so going Table ↔ Locations, or back to a location column, reads nothing again; switching the metric was already in the browser. - The Locations button reads ahead on hover or focus, so the view opens on data already there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d-locations # Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
…their own view with the brand (PROMPT-015, part 1) Someone looking at the brand's shared view without one of their own changed it with every click: a member got "Only admins and managers can share" errors, and a manager hiding one column changed it for everyone. Changes now update the brand's view only after an admin or manager shared their own, which sharing now also saves as theirs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…able (PROMPT-015, part 1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ations-view # Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/prompts/_columns-panel.test.tsx # web/src/app/[locale]/(dashboard)/dashboard/prompts/_columns-panel.tsx
… and each location once a minute (PROMPT-015, part 2) Up to twelve locations ran two heavy aggregates each, all at once, on every open, every read-ahead on hover and every new location column. The server now runs at most three of them at a time, the page sends one read at a time, read-ahead included, and each location's figures are kept for a minute on their own, so a new location column reads only its location. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed, resumed, deleted or edited (PROMPT-015, part 2) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d-locations # Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
…o longer shown, not to every prompt (PROMPT-015, part 3) Track in more locations opened from a Locations view cell fell back to every prompt shown when the cell's prompt had left the rows. It now targets none, says to choose the prompts, and keeps the save button off until a scope is picked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y-tracking # Conflicts: # web/messages/en.json # web/src/app/[locale]/(dashboard)/dashboard/prompts/_add-locations-dialog.tsx
…ntry-wide under its name (PROMPT-015, part 4) An unknown city code read as its country: Google's engines ran without a location and the API models without a city, and both answers were saved with the city's code. The worker now skips such a code for every engine and logs it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o, and ask Google from its cities as Turkiye (PROMPT-015, part 4) The location lists, labels and docs say Türkiye. The picker finds it, and its cities, typed as Turkey or Turkiye. The cities' Google location names spell the country Turkiye, from one constant, to be confirmed with a real request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iye name (PROMPT-015, part 4) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e same on the web and the API (PROMPT-015, part 4) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a promise (PROMPT-015, part 2) Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 of 12 tasks
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…le-columns # Conflicts: # supabase/schema.sql
# Conflicts: # supabase/schema.sql
Collaborator
Author
|
Merged main forward (8356ba3) through the stack; no new conflicts on this branch. Typecheck and lint pass on the chain tip. |
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups
Reviewed this PR's own change (part 3's head 518770c → 773461a).
What I checked
- City codes end to end.
TR~ISTANBULparses the same way on both sides (server/src/lib/locations.js,web/src/lib/region.ts), andcities.test.jskeeps the two city lists and the city-capable engines in step. Google AI Mode and AI Overview get the city's Google name aslocationbesidecountry; no other engine ever getslocation(tested incloro-scraper.test.js). The API models getuser_locationwith the city and its region. - Cost. A city never causes a second, country-wide run: the engines that can't ask from a city drop the code (
locationsForScraper), and the Google collapse keeps cities apart from states. A city code no list names runs on no engine and is logged, instead of running untargeted under the city's name. The progress total (totalTasks) counts the same tasks the run submits, and a job whose prompts end up with no tasks still settles (plannedTasks <= 0stamps). - Plan limits. No new write path. Cities go through the existing
updatePromptLocations/bulkUpdatePromptLocationsserver actions, which re-read the prompts' current locations, check the org's usage against the plan on the server, and reject codesisValidLocationdoesn't know (so an unknown city can't be saved from the app). A city counts as one location, as the PR says. - Dialog. "None of these prompts runs an engine that answers from a city" disables the save; the partial case says the city still counts on the plan for the prompts that won't ask it.
- Search. "Turkey", "Turkiye" and "Ist" find Türkiye and İstanbul;
withoutMarksis a fixed, linear pass over short labels. - Tests on this tree: server
cities,locations,cloro-scraper,workers/*(97 passed); webregion,_add-locations-dialog,_columns-panel,_location-matrix(37 passed). At the top of the stack: webtscclean, eslint and prettier clean on every touched file, full server suite passes apart from the known timing-sensitive tests under load (content-people, content-agent, page-content, audit). - Merge on current main: only
supabase/schema.sqlconflicts, and that comes from part 3's 00363.
Before merging
- The web goes out on merge, the API doesn't. Today's API reads
TR~ISTANBULas no location at all, so a city added before the API deploy would run every engine untargeted and save those answers under the city's code. Deploy the API with this part first, or at the same time.
Follow-ups
GOOGLE_TURKIYE: confirm the spelling with one real AI Mode request, as the PR asks.- The per-prompt location picker on the brand's prompts page (and the suggestion card) lets anyone add a city to a prompt with no city engine. It shows only the general city note, and the city still counts on the plan. The bulk dialog blocks or warns here; the picker could do the same when none of the prompt's
platforms/modelsanswers from a city. - Docs: the list has 51 cities, the guide says "about 50" (part 5 changes it to "50 major cities").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PROMPT-015, part 4 of 6: track prompts in cities, asked only by the engines that can answer from one.
Stacked on #1657. This PR's own change is its commits after part 3's.
A city is a new location code,
<country>~<CITY>(e.g.TR~ISTANBUL). The same 51 major cities are listed inserver/src/lib/cities.jsandweb/src/config/cities.ts, with the same ids.location, beside the country.user_locationwith the city and its region.Pre-push review fixes:
Turkiye, from one constant (GOOGLE_TURKIYEincities.js). Could you confirm with one real Google AI Mode request forIstanbul,Istanbul,Turkiye? If Google wants another spelling, only that line changes.Where people see it: the location picker lists cities ("City · Türkiye") with a note on which engines ask there, and a Locations view city column is marked "AI Mode · AIO · APIs".
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/cities.test.js src/lib/locations.test.jscd web && npx vitest run src/lib/region.test.tsBrowser check: local, 1024 px. The search finds Türkiye and its cities by "turkey".
Related issue
PROMPT-015 (location matrix and custom columns), spec and mockup in Drive › Prompt. No GitHub issue.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Full checks at the top of the stack (part 6, 29f649d):
npm test: 248 files, 3,364 tests passed;vitest(453 files, 4,403 tests) and build: all pass;schema.sqlmatchesbuild-schema.sh.A pre-push review found 9 issues; all are fixed in this stack (the
fix(...)commits). Migrations 00363 and 00364 are applied on the dev database.Follow-ups, not in this stack:
writeUrlParamsfor the layout switch (keeps the hash);removePromptTableViewshould say when nothing was removed;en.json;processTrackingJobtest for country skips.🤖 Generated with Claude Code