Skip to content

export/import prompts, agents and mcp servers#3

Merged
DimitriGilbert merged 6 commits into
mainfrom
export/prompt_mcp_agents
Jun 14, 2025
Merged

export/import prompts, agents and mcp servers#3
DimitriGilbert merged 6 commits into
mainfrom
export/prompt_mcp_agents

Conversation

@DimitriGilbert

Copy link
Copy Markdown
Owner

No description provided.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

…obably not have made the error myself or not...
@cursor

cursor Bot commented Jun 14, 2025

Copy link
Copy Markdown

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_fe93b685-c5ca-4eeb-9371-60a7c804ac68).

@DimitriGilbert

Copy link
Copy Markdown
Owner Author

bugbot run

cursor[bot]

This comment was marked as outdated.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Data Import Deletion Fails for Unidentified Records

During data import, the deletion logic for prompt templates, agents, and tasks incorrectly generates a new random ID using nanoid() for any existing records that lack an ID. These newly generated random IDs are then used in the deletion query, causing the deletion to silently fail for records without IDs, as the random IDs do not match any existing database entries.

src/services/persistence.service.ts#L613-L637

}
if (options.importPromptTemplates) {
// Clear ONLY the exact templates that will be imported (type is "prompt" or undefined)
// This preserves custom-typed templates that are not being imported
const allTemplates = await db.promptTemplates.toArray();
const templatesToDelete = allTemplates.filter(t => !(t as any).type || (t as any).type === "prompt");
const idsToDelete = templatesToDelete.map(t => t.id || nanoid()); // Generate ID if missing
if (idsToDelete.length > 0) {
await db.promptTemplates.where("id").anyOf(idsToDelete).delete();
}
}
if (options.importAgents) {
// Clear ONLY the exact agents and their linked tasks that will be imported
// This preserves orphaned tasks and non-exported agents
if (data.agents) {
const agentsToImport = data.agents.filter((a: any) => a.type === "agent");
const agentIds = agentsToImport.map((a: any) => a.id || nanoid()); // Generate ID if missing
const tasksToImport = data.agents.filter((a: any) => a.type === "task");
const taskIds = tasksToImport.map((t: any) => t.id || nanoid()); // Generate ID if missing
const idsToDelete = [...agentIds, ...taskIds];
if (idsToDelete.length > 0) {
await db.promptTemplates.where("id").anyOf(idsToDelete).delete();
}
}
}

Fix in Cursor


Bug: Import Fails to Clear Existing Records

When importing agents and tasks (stored as prompt templates), the pre-import clear logic generates new random IDs with nanoid() for items in the import data that lack an id. These generated IDs do not match existing database records, causing the db.promptTemplates.where("id").anyOf(idsToDelete).delete() operation to silently fail to clear existing agents and tasks without IDs.

src/services/persistence.service.ts#L628-L632

const agentsToImport = data.agents.filter((a: any) => a.type === "agent");
const agentIds = agentsToImport.map((a: any) => a.id || nanoid()); // Generate ID if missing
const tasksToImport = data.agents.filter((a: any) => a.type === "task");
const taskIds = tasksToImport.map((t: any) => t.id || nanoid()); // Generate ID if missing
const idsToDelete = [...agentIds, ...taskIds];

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@DimitriGilbert

Copy link
Copy Markdown
Owner Author

I do not want to delete all existing stuff withoud ID, if any they probably come from user messing around with the indexeDB.
all in all, it is a good catch but i do not think it is relevant in this case.

@DimitriGilbert DimitriGilbert merged commit e5a78f2 into main Jun 14, 2025
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.

1 participant