Skip to content

fix(prompts): Generate by topic adds prompts to the topic by its id - #2479

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/topic-prompts-topic-id
Nov 17, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/topic-prompts-topic-id

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Follow-up to #2473 (Generate by topic on Prompt Suggestions), from the review note there.

Problem

Add selected sent each prompt's topic by name only, although the review list already holds the topic's id. If a topic was renamed between Generate and Add selected, the prompts could land under another topic that now has the old name, or importPrompts would create a new topic with the old name.

Fix

  • _topic-prompts.tsx: each row now carries topicId along with the topic's name. The name is used alone only when there is no id.
  • importPrompts (lib/actions/prompt.ts): already took topicId, but passed it straight to import_prompts without checking it. It now uses an id only when the id is one of this brand's topics. The brand's topics are read by brand_id with the person's own client, so the id belongs to the same brand and organization. The row is then filed under the topic's current name, so category matches the renamed topic. Any other id is treated as no id, and the row goes by its name as before. That covers another brand's topic, another organization's topic, and a topic deleted since. Chat's add_prompts (addTopicPrompts) already checked its topic and works the same as before.
  • The file is still 'use server' and still exports only async functions. There is no migration and no new dependency.

Tests

  • _topic-prompts.test.tsx: rows carry each topic's id (the rename case), and a topic with no id sends its name and no topicId.
  • prompt-wait-on-add.test.ts:
    • A renamed topic is filed by its id under its current name, and no topic is created from the old name, even when another topic has taken that name.
    • Another brand's topic id is ignored, and the row goes by name.
    • A row with no id goes by name: the brand's topic with that name if there is one, otherwise a new topic.
    • Both new server tests fail without the fix.
  • Also run: tsc, the Prompts page tests, src/lib/actions/prompt*, src/lib/chat, src/lib/mcp, src/components/chat, src/lib/help, src/i18n, use-server-exports, subscription-guard(-coverage). git merge-tree against current main: clean.

Generated by Claude Code

Add selected sent only the topic's name, so a topic renamed between
generating and adding could put the prompts under another topic of that
name, or make a new one. It now sends the topic's id too (the name alone
only when there is none). importPrompts takes an id only when it is one
of this brand's topics, and files the row under that topic's current
name; any other id counts as none and the row goes by its name, as
before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@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: topicId is honored only for this brand's topics, under their current name, otherwise the row falls back to the name.

@gkhngyk
gkhngyk merged commit 09e99a6 into ansvisor:main Nov 17, 2026
13 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.

3 participants