Repository navigation
feat(prompts): compare each tracked prompt across its locations in a Locations view (PROMPT-015, part 2) - #1656
Merged
gkhngyk merged 18 commits intoOct 28, 2026
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]>
…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]>
…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]>
… 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.
Nothing blocks the merge. No migration; it needs #1655's 00363 (it's stacked on it).
What I checked
- Own diff.
293a00b2..8cb4811d(#1655's head to this one):getPromptLocationMatrixand thegetPositionRowssplit inprompt.ts,prompt-location-matrix.ts,limiter.ts, the location column ids inprompt-table-columns.tsand the save schema,_location-matrix.tsx, the Columns panel's location columns, the page's layout switch,HEAT_SHADESmoved besideheatShade,en.jsonand the guide. The whole stack up to here merges on 8356ba3 with onlysupabase/schema.sqlconflicting (from #1655). - Reads and scoping. The matrix reads each location with the table's own reads (
prompt_visibility_summariesandprompt_position_summaries_json) through the caller's client, so another organization's brand reads nothing. The brand id is checked as a UUID, locations are filtered withisValidLocationand capped at 12, and the engines counted for Position come from the brand's own plan. - Load. The server runs at most 3 of a matrix read's database reads at once (
createLimiter, tested for order and the cap). The page sends one matrix read at a time, the hover/focus read-ahead included, and keeps each location's figures for a minute, so adding a location column reads only that location. Pausing, resuming, deleting or editing prompts clears that cache (reloadAfterChange). - Saved views. Location column ids are
loc:<metric>:<code>with an anchored, bounded pattern. The save takes at most 12 + 8 ids, the reader keeps at most 8 location columns and drops hidden ids that aren't in the order. The 8 KB check in 00363 still bounds the row. - Rendering. The shades use only the current page's values (
inView), so shading is linear in the cells shown. The averages, Gap and the three cards are linear in prompts × locations. - Speed. The only new pattern is the anchored location column id (
^loc:(…):([A-Za-z0-9~_-]{2,64})$), linear on any input. No regex or loop runs over prompt or answer text. - Tests and checks. The PR's tests pass (
limiter,prompt-location-matrix,_location-matrix,_columns-panel,prompt-table-columns,prompt.test.ts, and the insights heatmap tests after theHEAT_SHADESmove: 20 files, 136 tests). Webtscis clean. eslint and prettier are clean on the touched files.
Follow-ups
- The guide names the wrong roles for + Track.
docs/guides/prompts.mdx:60says + Track shows "for admins, managers and analysts". The page passesonEditPromptonly whencanManage(page.tsx:2142), so analysts don't get it. Say "for admins and managers". - A big brand's matrix costs up to 12 × the table's read.
prompt_visibility_summariesis read throughreadAllRpcRows, which re-runs the aggregate for every 1,000 prompts. So a brand with 3,000 prompts in 12 locations runs it 36 times, plus 12 position sums, when Locations opens. The 3-at-a-time cap keeps it from piling up. If it shows in the database's load, return the summaries as one jsonb value, as 00153 did for positions. - Until #1657 lands, + Track opens the prompt's edit dialog without the clicked location. #1657 replaces it with Track in more locations, so merge the two together.
Rollout
None beyond #1655's: 00363 must be applied first.
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 2 of 6: a Locations view that compares each tracked prompt across its locations.
Stacked on #1655. This PR's own change is its commits after part 1's.
HEAT_SHADESmoved besideheatShadeso both views share them.getPromptLocationMatrixreads each location with the table's own reads (visibility summaries and position sums). So a location's numbers equal the table filtered to that location. No migration.Speed and load (the pre-push review fixes are in 56c9c02 and ba50673):
web/src/lib/limiter.ts, tested);Where people see it: Prompts › Tracked Prompts › Locations.
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 web && npx vitest run src/lib/limiter.test.ts src/lib/prompt-location-matrix.test.tsBrowser check: local, 1024 px, light and dark (30-day range). The table scrolls inside its card and the page doesn't overflow.
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