标签改造:词表所有权、多标签筛选、标签管理接口 - #112
Merged
Merged
Conversation
- sr_user_tag gains source ("auto" | "mine") and last_used_at; sr_user_bookmark_tag
gains source ("user" | "ai"). Migration backfills last_used_at from live links.
- Vocabulary (listUserTags) now filters display=true and orders mine-first by
recency; the AI picker (pickTagsForBookmark) keeps "mine" ahead and caps at 3.
- Prompt lists "my tags" before fallback tags.
- AI attachments write source=ai without touching last_used_at; user attachments
write source=user and bump last_used_at. updateUserTagsDisplay no longer revives
hidden tags on the AI path, so a deleted word stays deleted.
- New routes: /v1/tag/promote, /v1/tag/demote, /v1/tag/delete (the web already
called delete; it was a 404). /v1/tag/update and the new routes accept tag_uuid
for local-first clients. /v1/tag/list?within=a,b returns candidate tags with counts.
- /v1/bookmark/list accepts topic_ids=a,b (intersection via metadata.tags containment)
and filter=untagged; list rows now carry tags[] with added_by.
- add_tag / add_tags accept bookmark_uid.
- deleteBookmarkTag is a soft delete, matching the PowerSync path. Orphaned auto
tags are hidden; "mine" tags stay at zero links.
- Sync batch: created tags are "mine"; added links are "user" and bump recency;
auto-hide only applies to auto tags and is scoped by user_id.
- Regenerated router and DI (the DI file also picks up ContentOrchestrator, which
was missing from the generated file). CI test step runs vitest once instead of watch.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QiL9KgdsseJDNAhSqwnCG
DGuang21
approved these changes
Sep 7, 2026
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.
标签改造的公开后端部分。设计文档由 Luca 另发(HTML),这里只写改了什么和怎么测。
合并顺序
这个 PR 先合,私有仓
unnoo/slax_reader_backend的 PR 把 submodule 指向这里的提交。改了什么
sr_user_tag加source(auto/mine)和last_used_at;sr_user_bookmark_tag加source(user/ai)。迁移用最后一条未软删的关联回填last_used_at。getUserTags只返回display = true,SQL 里按我的标签优先、最近使用倒序。pickTagsForBookmark(src/utils/tags.ts):只认词表里的词,我的标签在前,截 3 个。prompt 拆成“我的标签 / 备选标签”两段。AI 贴的关联写source = 'ai',不动last_used_at;AI 路径改成纯查询,不再有任何造词的口子。source = 'user'并刷新last_used_at。文章里删标签改成软删(和 PowerSync 一致),孤儿自动标签隐藏,我的标签零篇也留着。POST /v1/tag/promote、/v1/tag/demote、/v1/tag/delete(前端早就在调 delete,之前是 404)。/v1/tag/update和新路由都收tag_uuid,给 local-first 用户用。GET /v1/tag/list?within=a,b返回交集里的候选词带篇数。GET /v1/bookmark/list收topic_ids=a,b(按metadata.tags的 jsonb 包含做交集,旧topic_id仍认)和filter=untagged;列表项带tags[](含added_by)。add_tag/add_tags收bookmark_uid。createBookmarkTag的update: {}清不掉is_deleted;createUserTags缺skipDuplicates;updateUserTagDisplay写死 true;add_tags在关联全部已存在时报 500;标签页旧查询漏deleted_at IS NULL和orderBy。gen:di重新生成后补上了ContentOrchestrator的注册,原生成物是旧的。怎么测
本地:
pnpm test -- run(14 条),pnpm lint。完整的仓库函数测试在私有仓的 PR 里(含真 Postgres 集成测试)。beta 部署后用 curl:
再存一篇新文章等 AI 打完标签:
sr_user_bookmark_tag.source = 'ai',对应sr_user_tag.last_used_at没变。没做的
metadata->'tags'没有 GIN 索引,单用户量级靠user_id前缀索引够用,慢了再加。pnpm test仍是 watch 模式,会挂住;改成pnpm test -- run的一行改动因为 token 没有 workflow 权限没推上来。system_tag列 2025-07 被主动删过一次,这次加的是词表所有权,AI 仍不能造词。当年删的原因请知道的同学在评论里说一下。🤖 Generated with Claude Code
https://claude.ai/code/session_011QiL9KgdsseJDNAhSqwnCG