Repository navigation
feat(cli): thread rename, pin, and title search — headless 会话管理对齐(补齐 HTTP 面已有的能力) - #519
Merged
Merged
Conversation
The HTTP surface and Desktop chat list already support renaming, pinning, and title search for conversations (store/thread_metadata.go + httpapi/thread_metadata.go); the CLI — the documented first-class surface for headless and NDJSON workflows — had no access to any of them. Add 'cyberagent thread rename <id> <title>', 'cyberagent thread pin <id> [--pinned true|false]', and 'thread list --title-query/--pinned' with the same store semantics (no authority, not-found for deleted threads, monotonic versions). The text listing now shows pinned state per row. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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.
动机 / Motivation
继续对照 Claude Code 与 Codex CLI 的功能盘点:两者的主界面都支持重命名会话、置顶会话与按标题搜索(Claude Code 的 sessions 与 Codex 的 thread 管理)。Universal-Code 的存储层与 HTTP 面早已完整具备这三件事——
internal/store/thread_metadata.go的RenameThread/PinThread+internal/httpapi/thread_metadata.go的PUT /threads/{id}/name|pin,桌面聊天列表也在使用——但 CLI(文档明确的一等 headless/NDJSON 入口)一个都没有:thread子命令只有 create/list/show/send/compact/compactions/history/archive/restore/delete/export。对无人值守脚本来说,跑完一个 NDJSON 任务后无法给它起一个可识别的名字、无法置顶重点会话、也无法按标题找回历史任务,只能靠完整的 thread ID。本 PR 把这条不对称补齐。
变更 / Changes
cyberagent thread rename <thread-id> "new title":复用store.RenameThread(4096 字符上限、拒绝控制字符、trim;同值 no-op 幂等;已删除线程按标准 not-found),与 HTTP 面语义逐字对齐。cyberagent thread pin <thread-id> [--pinned true|false](默认 true):复用store.PinThread;--pinned为 String 旗标并严格校验true|false(Goflag.Bool不消费下一参数,--pinned false会把值当位置参数,因此与thread list --pinned一致采用 String)。cyberagent thread list --title-query <text> --pinned true|false:透传domain.ThreadFilter已有的TitleQuery/Pinned(ASCII 大小写不敏感字面子串、≤256 字符,其余 Unicode 精确比较);文本列表每行新增pinned=标记,--json走既有domain.Thread投影。docs/usage.md(中英)同步;docs/reviews/thread-cli-metadata/按仓库惯例记录 OCR delegate 复审(F1/F2 两条 P3 文档措辞问题,均已修复)与覆盖明细。不涉及 schema 迁移、不新增权限、不改 HTTP/Web 行为。
验证 / Verification
gofmt -l internal/app/无输出;go vet ./internal/app/无告警。go test ./internal/app/ -run TestThreadCLI -count=1通过(含两个新测试:rename/show 传播/大小写命中与未命中/空标题/控制字符/不存在线程;pin 默认值/双向过滤的 JSON 精确断言/unpin/非法值拒绝)。go test ./internal/app/中仅有的两个失败均与本 PR 无关且在干净 main 上同样复现:TestRunCommandExecuteIsConfirmedAuditedAndExactlyOnce依赖本机不可用的 approved executable;词表测试需要检出docs/openapi.json(稀疏检出产物,补齐后通过)。cmd/cyberagent端到端冒烟:rename 多词标题(含不带引号裸多词)、--pinned=false与--pinned false、--pinned maybe报错、纯空白--title-query不过滤、大小写混合查询命中、--pinned false过滤正确、每次实际变更 version 递增。差距说明 / Gap context
与 Claude Code / Codex 对照仍在的差距(供后续规划,本 PR 不涉及):聊天内"编辑历史消息并重发"(Esc-Esc / 点击编辑)、侧问通道(
/btw、/side)、语音听写、输出风格定制。上一次同类对比已通过 PR #518 补齐项目指令脚手架(/init对应物)。