Repository navigation
feat(prompts): stop tracking prompts in a location - #1731
Merged
gkhngyk merged 4 commits intoOct 29, 2026
Merged
Conversation
The locations dialog gets Add | Remove. Remove offers the locations the prompts shown track (with how many track each), the same scopes, and a preview of the tracked locations it removes and the plan locations it frees; a prompt left with no location keeps it and is counted. The preview and the save run planBulkLocationChange, as adding does. Openers: a column "..." menu in the Locations view (Stop tracking in <location>), a hover/focus x on each tracked cell (Stop tracking here, one prompt), and a Locations > Add / Remove menu in the bulk bar. The new openers go through the read-only guard. Past results stay: the RPC only rewrites prompts.regions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Locations view: + Track and + Add location open the upgrade dialog on a read-only workspace, like the column menu, the cell's x and the bulk bar. - The cell's x is clickable only while it shows (no unseen taps on touch screens) and is left off a prompt's last location. - The Remove chips count the prompts chosen, keep a pick when the prompts change, and tell screen readers what the number counts. - The dialog's save resets its button even when the write is refused. - bulkUpdatePromptLocations checks location codes only when adding, so a code no list names any more can still be stopped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
… list per prompt A removal's codes aren't checked against the known locations, so the list can be long; planBulkLocationChange now keeps them in a set.
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good with 9fd9e85: I made one small change on top.
What I changed
planBulkLocationChangechecked each prompt's locations against the list to remove by scanning that list. Since this PR, a removal's codes are no longer checked against the known locations (rightly, so that a dropped city can still be taken off). That means the list can be as long as a request body allows. With 60,000 codes and 2,000 prompts, one save took about 5 s of server time. The codes to remove are now kept in a set, and the same case takes a few milliseconds. A test pins it: it fails on the PR's head at about 5,300 ms and passes with the change.
What I checked
- Plan arithmetic. Preview and save both run
planBulkLocationChange, and the server re-readsregionsandis_activeinstead of trusting the client. "Removes X" is the sum of the changes' negative deltas, paused prompts included. "Frees Y" is-change.delta, which only counts active prompts. That matchesorg_prompt_location_usage, where paused prompts don't count. A prompt that would be left with no location is skipped and counted (blocked), andapply_prompt_locationsstill refuses an empty list. Removing never reaches the limit check (plan.delta <= 0), and the dialog'soveris off in Remove mode, so an organization that is over its limit after a downgrade can still remove locations. - Organization scoping. No change to the read or the write. Prompts are read with the user's client (RLS) and written through
apply_prompt_locations, which issecurity invoker, so a prompt id from another organization reads as nothing and is never written. Removal never charges a plan, so it doesn't matter which organization's plan the batch is measured against. - Validation. Only additions are checked with
isValidLocation. A removal can only take codes out of a prompt's own list, so an unknown code just changes nothing. - Read-only workspace.
bulkUpdatePromptLocationsstill starts withassertWritable(). All six openers go throughguard(including + Track and + Add location, which weren't gated before). The dialog'sfinallyclears the spinner when the action rejects.subscription-guard-coverage.test.tspasses on this branch merged with #1730 and main. - Past results. Nothing deletes
prompt_results. The worker readsregionsagain at the start of each job, so "Past results stay; tracking stops from the next run" is accurate. - The cell's × is only shown when the prompt has another location, and it can't be clicked while it's hidden (
pointer-events-noneuntil hover or focus). - No migration. No PostgREST embeds, server actions or routes are added.
- Tests on the branch: the prompts folder,
actions/prompt,prompt-locations,tracking-countries,components/dashboardand the subscription guard tests pass (180 tests; 168 on the merge with #1730).tscpasses, and prettier and eslint pass on the touched files.
Follow-ups
- The chips and the matrix use the stored codes as they are, while the server upper-cases the codes it is sent. A prompt whose stored code isn't upper-case (from an older write path) would show a chip that removes nothing. Comparing case-insensitively in
planBulkLocationChangewould cover it. - The column menu's Stop tracking in acts on the selected prompts when any are selected, not on all the prompts shown. The docs say so ("or the selected ones"), but the PR description doesn't.
- The ones the PR lists: the usage bar doesn't show the share a removal frees, and
trackedLocationsduplicatesmatrixLocations.
3 tasks done
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
Tracked Prompts could add locations to many prompts at once (#1657), but nothing stopped tracking a prompt in a location. This adds the way back, with the same scopes and the same plan arithmetic.
aria-label"Germany, tracked by 2 prompts");blockedcount already enforces;apply_prompt_locations(00074) only rewritesregions, no trigger deletes results, and the tracking worker re-reads the prompts at the start of each job. A job already running finishes its list.planBulkLocationChange; the save isbulkUpdatePromptLocations(ids, 'remove', locs).guard, so a read-only or demo workspace gets the plan dialog. That now includes the Locations view's existing + Track and + Add location, which weren't gated. The dialog's save always clears its spinner.bulkUpdatePromptLocationschecks location codes only when adding, so a code that's no longer valid (a city dropped from the list) can still be removed.docs/guides/prompts.mdxgets a "Removing locations" section; the "No engine here" note links to it.Follow-ups (not here): the dialog's usage bar doesn't yet show the share a removal frees (the number line does), and
trackedLocationsrepeatsmatrixLocationswith counts; they could share a helper.Related issue
None (PROMPT-015 follow-up, reported in the product).
Type of change
feat— New featureHow to test
Checklist
yarn lint(0 errors),yarn typecheckandyarn buildpass.yarn test555/557 files; the Content Editor page and before-publish tests timed out under load (known). After the review fixes:tsc --noEmit, eslint, prettier, and the prompts folder +actions/prompttests (14 files, 138 tests) pass.🤖 Generated with Claude Code