feat: Remove Tag workflow action to complement Add Tag

Removes a tag (by name, matching the tag's full path value) from the
matched assets via DELETE /tags/:id/assets. The tag is looked up
without creating it — removing a tag that doesn't exist is a no-op
rather than an error, so add/remove pairs are safe in the same
workflow.

Registered in the node palette, action node, run-detail view, and
action config (same tag-name field as Add Tag).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jonvdveenandClaude Fable 5 committed 2026-07-02 22:54:43 -06:00
1 parent f0d8a88c27
commit 95ede2efd7
5 files changed
+29 -4

No files matched your search

+19
View File
@@ -180,6 +180,25 @@ export async function executeAction(
}
}
case "remove_tag": {
if (!config.tagName) throw new Error("Tag name is required");
try {
// Look up the tag by value (full path for nested tags) without creating it —
// removing a tag that doesn't exist is a no-op, not an error.
const result = await db.execute(
sql`SELECT id FROM "tag" WHERE "userId" = ${user.id} AND "value" = ${config.tagName} LIMIT 1`
);
const tagId = result.rows?.[0]?.id as string | undefined;
if (!tagId) {
return { action: "remove_tag", assetsProcessed: 0 };
}
await immichFetch(`/tags/${tagId}/assets`, "DELETE", { ids: assetIds }, user);
return { action: "remove_tag", assetsProcessed: assetIds.length };
} catch (e: any) {
return { action: "remove_tag", assetsProcessed: 0, error: e.message };
}
}
default:
return { action: subType, assetsProcessed: 0, error: `Unknown action: ${subType}` };
}