Skip to content

fix(prompts): say a failed read failed, never "No prompts yet" - #1324

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/failed-reads-not-empty
Oct 22, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/failed-reads-not-empty

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

From the user's report, measured on prod (read-only, in the browser, on the Ansvisor brand):

  • Prompts → Tracked Prompts: switching Topics → Prompts showed "No prompts yet · Add prompt" for a brand with prompts. The console had Failed to load topics overview and Failed to load prompt data, both React i18n: wire the Agent page to next-intl #441, meaning the server action threw. One request took 8.6 s, the authenticated statement timeout.
    • loadData's catch left allPrompts empty with loading false, so a failed read rendered as an empty brand.
    • getPromptsPageData already degrades positions and volumes. getPromptVisibilitySummaries (the prompt_visibility_summaries GROUP BY over the window's answers) was not degraded, so one slow read blanked the whole table.
  • Mentions → Perception: 24h and 7d (3.1 s) load. 30d and 90d failed on every try at 8.6–8.7 s, showing "Couldn't load the perception figures. Try again in a moment." with no way to try again.

This PR (web only) makes a failed read say so, and lets the slow one degrade:

  • Prompts table. A failed read with nothing on screen now shows "Couldn't load your prompts." with Try again, as the Topics tab already does. It no longer shows "No prompts yet". A failed re-read keeps the rows already shown. The rule is promptsTableState() (prompts/table-state.ts, tested).
  • getPromptsPageData. When the visibility summaries fail or time out, the table still renders. Their columns read —, and a warning toast says the figures are temporarily unavailable, the same way positions and volumes behave. Only a failed prompt roster fails the page.
  • Perception. The error now has a Try again button that reads the same filters again, with the skeleton shown meanwhile.

Not in this PR: making those reads fast. Perception's 30/90 d needs mentions_perception not to unnest every answer's terms for the window and the one before it. That's your #1124 follow-up: a daily per-entity terms rollup, or a narrower read. prompt_visibility_summaries on large windows needs work too. Both will come as separate SQL PRs.

Related issue

None. Reported by the user.

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. Prompts → Tracked Prompts. Make the page data read fail, e.g. block the POST in DevTools (Network → Block request URL), or stop the database. The table should say "Couldn't load your prompts." with Try again, not "No prompts yet". Unblock and press Try again: the prompts load.
  2. With prompts already on screen, make a range change's read fail. The rows stay, and a toast says the read failed.
  3. Mentions → Perception, 30d. If the read fails, press Try again: it reads the same filters again.

Checked in light and dark, at 1024 px and wider.

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

yarn test: 282 files, 2,488 tests pass. In one full run an unrelated editor test timed out at 5 s under load and passes alone (63/63). yarn build passes with CI's placeholders.

🤖 Generated with Claude Code

On prod, switching Topics → Prompts made the page's read throw (one
request hit the 8 s statement timeout) and the table showed "No prompts
yet · Add prompt" for a brand with prompts. A failed read with nothing on
screen now says "Couldn't load your prompts." with Try again, and a failed
re-read keeps the rows shown (promptsTableState). The visibility
summaries degrade like positions and volumes: their columns read — with a
warning instead of failing the page. Mentions › Perception's load error
gets Try again too (30 and 90 days time out on prod).

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk This one comes from measuring the user's two speed reports on prod in the browser (read-only, Ansvisor brand). The numbers are in the description.

  • Web only. A failed read now says it failed and offers Try again, instead of "No prompts yet". The visibility summaries degrade like positions and volumes.
  • Next (SQL), and I'd like your timing on prod for them:
    1. Perception 30d/90d. mentions_perception unnests mentions_answer_terms for the window and the one before it, so 30d reads 60 days of per-answer term arrays. I'm planning your feat(mentions): show the Perception tab #1124 suggestion: a daily per-entity terms rollup filled beside refresh_mention_terms, with the raw path kept for topic/search filters. If you'd rather start with a narrower read (the previous window only for the brand's 15 terms), say so.
    2. Prompts page. On the Topics → Prompts switch, getTopicsOverview took 8.6 s once, and getPromptsPageData threw (React i18n: wire the Agent page to next-intl #441). Could you check Vercel's logs for which statement timed out there? prompt_visibility_summaries (00025) and the topics overview are my two suspects.

@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.

  • Prompts table: a failed read with nothing on screen now says so and offers Try again; a failed re-read keeps the rows already shown.
  • Visibility timeout: it degrades to "—" with a note instead of failing the page.
  • Perception tab: Try again reads the same filters again.

Tested on top of main together with #1326: web and server tests, tsc, lint and Prettier pass.

@gkhngyk
gkhngyk merged commit c66906f into ansvisor:main Oct 22, 2026
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