Skip to content

feat(prompts): say when a new prompt's first results come in the Table view, as the Locations view does - #1717

Merged
gkhngyk merged 63 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompts-table-pending
Oct 29, 2026
Merged

gkhngyk merged 63 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompts-table-pending

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

PROMPT-015 follow-up: the Table view says when a new prompt's first results come, as the Locations view does (#1660).

A prompt with no answers in the window showed a dash in every answer column, even right after it was added. The row now says why once, in the first answer column shown (usually Visibility). It uses the same LocationPending cell as the Locations view:

  • Within 24h (with a clock): the prompt is active, was added in the last two days and has no answers yet. The tooltip says: "This prompt's first results come with the next daily run, within 24 hours." That's a new en.json key, prompts.locations.promptPendingTip.
  • Paused: a paused prompt, but only when the Status column is hidden. When Status shows, it already says Paused, so the cell keeps the dash.
  • With a location picked in the filter, the cell shows that location's own reason ("Tracked in … from the next daily run", No engine here), as in the Locations view.
  • A dash, as before:
    • an older prompt with no runs in the range;
    • a range that ended before today;
    • a location the prompt isn't tracked in;
    • no answer column shown.

The other answer columns keep the dash, so each row says it only once. pendingColumn() in prompt-table-columns.ts picks the column, from ANSWER_COLUMNS. It has unit tests.

This PR's own commits:

  • c220ec3: the change.
  • 1a80a87: an older prompt with no runs in the range shows a dash, not Within 24h.
  • f2f01b5: Within 24h shows only for a prompt added in the last two days.

The branch was cut from #1660's tip. Because #1655–#1660 were squash-merged, the commit list also shows their commits. Files changed shows only this PR's 7 files. There's no migration.

Where people see it: Prompts › Tracked Prompts, Table view, on a newly added prompt's row.

Related issue

PROMPT-015 follow-up (Drive spec). No GitHub issue.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open Prompts › Tracked Prompts, Table view. Add a prompt with Add prompt, or add one from Prompt Suggestions.
    • Before its first run, its Visibility cell says Within 24h. Hover it, or tab to it, to see the tooltip.
    • Mentions, Citations and the other answer columns show a dash.
  2. Hide Visibility in the Columns panel. The text moves to the next answer column shown.
  3. Hide the Status column and pause the prompt: the cell says Paused. Show Status again: a dash.
  4. Pick a location in the location filter:
    • one the prompt is tracked in: that location's reason shows;
    • one it isn't tracked in: a dash.
  5. A prompt added more than two days ago with no runs in the range, or a custom range that ended yesterday: a dash.
  6. cd web && npx vitest run src/lib/prompt-table-columns.test.ts "src/app/[locale]/(dashboard)/dashboard/prompts/_location-matrix.test.tsx"

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

What was run:

  • Main (ce9a3dc) is merged in, with no conflicts.
  • On the earlier merge with cfd8a35: yarn lint and yarn typecheck pass. No change on main since then touches the Prompts page or prompt-table-columns.ts.
  • On this tip:
    • prettier --check and eslint pass on the changed files. The full yarn format:check wasn't run, so its box is unchecked.
    • The two test files above pass (33 tests).
    • The embed-hint guard test (the profiles → organizations follow-up to 62eb7b7) passes.
  • Not run in this round: the full web suite, the build, and a browser check. Other heavy checks were running on the same machine.

🤖 Generated with Claude Code

cihan-gyk and others added 30 commits October 28, 2026 03:46
…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]>
…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]>
…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
…from, read daily from the provider (PROMPT-015, part 5)

PROMPT-015e. The tracking provider supports a different set of countries
per engine, and asking an engine in a country it doesn't support fails;
its GET /v1/countries?model= is the only source of truth (its docs publish
no list). So:
- The daily run reads every engine's list before tracking
  (refreshCloroCountries) into cloro_countries (00364). A list that can't be
  read keeps the last one; an empty or malformed answer never empties it.
  No provider key (self-hosted, local): nothing read, nothing restricted.
- The tracking run skips an engine in a country it doesn't support
  (supportedLocations), and logs how many pairs it skipped: no failed task,
  no spent credit.
- The location picker offers the countries the engines answer from, named
  by the runtime's own region names, with "not on <engine>" where one
  doesn't; cities only where Google's engines answer. Before the first read
  it keeps its own list. Any country code is now valid on save.

Real lists need the provider key: gkhngyk was asked on ansvisor#1625 to paste them,
to check the first read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the plan's locations are used up (PROMPT-015, part 6)

A location just added to a prompt showed a bare dash until the next daily
run. Its cells now say when its answers come or why they won't:

- "Within 24h": tracked there, asked by the next daily run;
- "Paused": the prompt is paused;
- "No engine here": none of the prompt's engines answers from that
  country (or city), from the engines' country lists (00364).

A custom range that ended before today keeps the plain dash. Once the
plan's prompt locations are used up, + Track reads "Limit reached" and
still opens the dialog with the plan's way out. The dialog's toast says
the first results come within 24 hours.

useTrackingCountries moves into its own module so the matrix can share
it with the location picker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
…ro-countries

# Conflicts:
#	server/src/workers/tracking-worker.js
#	supabase/schema.sql
#	web/src/components/dashboard/location-picker.tsx
#	web/src/lib/region.test.ts
…try lists (PROMPT-015, part 5)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cihan-gyk and others added 23 commits October 28, 2026 05:29
…e view, as the Locations view does

A prompt with no answers in the range showed a dash in every figure
column until its first run. Its row now says it once, in the first
answer column shown (Visibility, Mentions, Citations, Positions, Runs or
Last run, in the person's column order):

- "Within 24h": the next daily run asks it;
- "Paused": the prompt is paused, only when the Status column is hidden,
  since Status already says so.

The reason shows in a tooltip on hover and keyboard focus, and reaches
screen readers as the label's description, as in the Locations view
(LocationPending, now usable without a location). With a location
picked, a prompt tracked there says it for that location ("No engine
here" included); one not tracked there keeps the dash. A custom range
that ended before today keeps the plain dash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…no runs in the range

"Within 24h" showed in every tracked location without answers in the
range, so an older prompt whose runs were missing or failed in it read as
a new one. A location now says it only while its first answers can still
come from the next daily run:

- the prompt was added within the last 48 hours; or
- it has answers in another location in the range, so this one was most
  likely just added.

Otherwise the cell keeps the plain dash ("No answers here in this
period"). "Paused" and "No engine here" are unchanged, whatever the
prompt's age. Applies to the Locations view and the Table view's
location columns; the guide says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…table-pending

# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/prompts/_location-matrix.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
…le-columns

# Conflicts:
#	supabase/schema.sql
…ro-countries

# Conflicts:
#	server/src/lib/catalog/__fixtures__/fake-db.js
…d in the last two days

A row with no answers in the range said "Within 24h" whatever the
prompt's age, so an older prompt whose runs were missing or failed in the
range read as a new one. The row now says it only while the prompt's
first answers can still come from the next daily run (awaitsFirstAnswers):
it was added within the last 48 hours or, with a location picked, it has
answers in another location column shown. Otherwise its first figure
column keeps the plain dash, as the others do.

"Paused" (Status column hidden) and "No engine here" (a location picked)
are unchanged, whatever the prompt's age. The guide now says which ways
of adding a prompt start its analysis right away (Add prompt, Bulk
import) and which wait for the next daily run (Prompt Suggestions).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 0eaa855.

Approve preview

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Reviewed 68d7dd1. It merged main at ce9a3dc, so its own diff is origin/main...68d7dd11: 7 files. No migration, no server or data code. There is no new query: the row reuses the visibility and location-matrix reads already on the page.

What I checked

  • pendingColumn(). It returns null in four cases:

    • the row has answers;
    • the location picked isn't one the prompt is tracked in;
    • the prompt is paused and the Status column already says so;
    • no answer column is shown.

    Otherwise it returns the first answer column in the person's own column order, so a reordered or hidden Visibility moves the text to the next one. The unit tests cover each case.

  • LocationPending without a location. parsed is null, so the "no engine here" branch can't fire for the whole-prompt cell. Pending uses the new promptPendingTip, and paused keeps pausedTip. With a location picked, the cell passes that location and reads exactly as the Locations view does.

  • Region-consistent inputs. vis is read with the region filter applied, so hasAnswers and the cell describe the same location. awaiting still counts answers from other locations (a location just added), as before.

  • Dash cases. An older prompt with no runs in the range, and a range that ended before today, both give a dash (reachesToday, awaitsFirstAnswers). The new _location-matrix tests cover them.

  • The tests catch it. With main's _location-matrix.tsx under the PR's tests, the 5 new Table-view cases fail. With the PR's file, _location-matrix.test.tsx and prompt-table-columns.test.ts pass (33). The rest of the Prompts folder passes too (121 tests in 13 files; the _columns-panel and page.test timeouts under machine load pass when run alone).

  • Docs. The prompts.mdx paragraph matches the behaviour. "Starts analyzing right away when it can" matches the analyze-new call on add and bulk import.

  • tsc is clean, and eslint and prettier are clean on the touched files. It merges cleanly on ce9a3dc and alongside #1719 and #1741, which also touch en.json.

@gkhngyk
gkhngyk merged commit 086a12f into ansvisor:main Oct 29, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants