fix: thread/unarchive 不再预 resume(已归档 thread 直接调 thread/unarchive)

This commit is contained in:
host committed 2026-10-28 08:33:04 +08:00
1 parent 5c9beb8a6d
commit f186c60e4e
2 files changed
+20 -3

No files matched your search

+4 -1
View File
@@ -2694,8 +2694,11 @@ def main():
print(json.dumps({"error": str(e)}, ensure_ascii=False))
raise SystemExit(1)
elif args.cmd == "thread-unarchive":
# 与 archive 一致:不 resume,直接调 thread/unarchive。
# 已归档 thread 先 resume 会失败(thread/resume 报错 →
# CLI 退出 1 → 服务端回 502),而 unarchive 本身只认
# threadId,不需要先恢复会话。
try:
srv.resume_thread(args.thread_id)
resp = srv.request("thread/unarchive",
{"threadId": args.thread_id},
timeout=60)
+16 -2
View File
@@ -151,7 +151,7 @@ class ThreadCliTest(unittest.TestCase):
calls = self._calls_before_close(fake)
self.assertEqual(calls, [("archive", "th-1")])
def test_unarchive_resume_first(self):
def test_unarchive_no_resume(self):
fake = FakeServer()
code, out, _ = self._run(
fake, ["thread-unarchive", "--thread-id", "th-1"])
@@ -159,7 +159,21 @@ class ThreadCliTest(unittest.TestCase):
self.assertEqual(json.loads(out), {"thread": {"id": "th-1"}})
calls = self._calls_before_close(fake)
self.assertEqual(calls, [
("resume", "th-1"),
("request", "thread/unarchive", {"threadId": "th-1"}),
])
def test_unarchive_resume_failure_does_not_block(self):
# 回归:已归档 thread 的 resume 会失败;unarchive 不再调
# resume,所以 resume 失败也不应挡住 unarchive(此前
# resume 抛错 → CLI 退出 1 → 服务端回 502)。
fake = FakeServer()
fake.resume_error = True
code, out, _ = self._run(
fake, ["thread-unarchive", "--thread-id", "th-1"])
self.assertEqual(code, 0)
self.assertEqual(json.loads(out), {"thread": {"id": "th-1"}})
calls = self._calls_before_close(fake)
self.assertEqual(calls, [
("request", "thread/unarchive", {"threadId": "th-1"}),
])