Skip to content

feat(threads): archive threads idle for five days, and bring them back on activity - #8

Merged
zereight merged 2 commits into
mainfrom
feat/thread-auto-archive
Nov 12, 2026
Merged

zereight merged 2 commits into
mainfrom
feat/thread-auto-archive

Conversation

@zereight

Copy link
Copy Markdown
Owner

개요

봇 스레드가 5일 동안 아무 변화가 없으면 자동으로 보관됩니다. 새 메시지나 새 턴이 오면 다시 나오고, 사람이 보관을 해제하면 유휴 시계가 그 시점부터 다시 시작됩니다.

  • 매일 한 번( 시작 후 1분 뒤 첫 실행) 유휴 시간이 설정 일수 이상인 스레드를 보관합니다. 경계는 포함입니다. 유휴 시간은 updatedAt, lastThreadOrderAt, createdAt, restoredAt 중 가장 나중 값입니다.
  • 보관하지 않는 것: 고정, 읽지 않은 스레드, 슬루즈(영구 포함), 방/공유 채팅/봇 API/외부 스레드, 봇이 열고 아직 닫히지 않은 스레드, 바쁜 상태, 대기 중, 사람의 답변을 기다리는 스레드, 팀원을 기다리는 스레드, 진행 중인 직접 인계, 열린 사람 카드, 대기 중인 기다림, 루틴 실행 중, 루틴 결과를 받는 스레드, 메인 스레드.
  • 자동 보관은 archivedBy: "auto"를 남깁니다. 사람이 보관한 스레드는 라우팅에서 빠지고, 자동 보관된 스레드는 그대로 남습니다.
  • 새 메시지나 새 턴이 오면 자동 보관을 해제합니다. 복원 저장이 실패해도 메시지는 남고, 보관 플래그는 되돌리며, 다음 메시지가 다시 시도합니다.
  • 설정: threads.autoArchive( 기본 켜짐) 과 threads.autoArchiveDays( 기본 5, 1–3650). 꺼면 설정 화면은 다음 작업입니다.

이유

활성 상태로 방치된 스레드가 시간이 지나면서 누적됩니다. 사람이 직접 보관하지 않아도 쓰지 않는 스레드는 목록에서 빠지고, 다시 쓰면 돌아옵니다.

설정 화면에서 켜고 끄는 토글과 "자동 보관" 표시는 번역 16개가 필요해 이 PR에서 빼고 다음으로 미룩니다.

테스트 방법

pnpm typecheck
pnpm exec vitest run scripts/testing/file-size-ratchet.test.ts src/locales/vocabulary.test.ts server/independent-task-store.test.ts server/thread-auto-archive.test.ts server/config.test.ts server/thread-archive.test.ts server/mcp-bot-servers.test.ts server/mcp-result-budget.test.ts server/mcp-registry.test.ts server/postiz/service.test.ts

고립 피스처로만 확인했고, 사용 중인 앱이나 데이터는 건드리지 않았습니다.

Before

복원 저장이 실패하면 자동 복원이 메시지 자체를 뒤로 되돌렸습니다. server/independent-task-store.test.ts (vitest, 2026-11-13 00:51:15):

FAIL  server/independent-task-store.test.ts
Error: Couldn't save the thread change: OpenMausBot couldn't write bots.json
 ❯ RegistrySaveError server/registry-save.ts:23:11
 ❯ Store.patchTask server/store.ts
 ❯ restoreAutoArchived server/store.ts
 ❯ Store.appendMessage server/store.ts:1182
Caused by: Error: fixture disk full

Test Files  1 failed (1)
     Tests  1 failed | 30 skipped (31)

After

  • pnpm typecheck 통과.
  • 위 vitest 10개 파일 361개 테스트 전부 통과 (2026-11-13 01:13, 10.15s). 경계(정확히 5일, 5일 직전 1ms), 제외 14가지, 보유 상태 11가지, 스위프 동작, 설정 검증(0, 음수, 소수, 범위 초과 거부), 사람의 보관 해제 시 restoredAt 기록, 복원 저장 실패 시 메시지 유지를 다룹니다.
  • 저장 실패 테스트는 이제 메시지가 메모리와 재로드 후 모두 남고, 보관 플래그가 둘 다 유지되는지 확인합니다.

파일 크기 래칫 때문에 자동 보관 연결 코드를 server/index.ts, server/config.ts, server/store.ts, shared/wire.ts에서 분리했습니다(server/host/auto-archive.ts, server/thread-activity.ts, server/custom-mcp.ts, shared/thread-order.ts). 동작은 같습니다.

🤖 Generated with Claude Code

tao.exe and others added 2 commits November 13, 2026 00:53
…k on activity

A daily sweep hides bot threads nobody has touched for five days, skipping anything pinned, busy, unread, snoozed or still in use, and a new message or turn puts one back. A person unarchiving stamps restoredAt so the idle clock starts over, and a failed bookkeeping save never drops the message.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…files

The file-size ratchet caps server/index.ts, server/config.ts, server/store.ts and shared/wire.ts, and this feature pushed all four over. The held-thread check and sweep start now live in server/host, the thread clocks and restore in their own module, the config.json mcpServers reader in its own, and the thread ordering helpers in shared/thread-order.ts. Behaviour is unchanged.

Co-Authored-By: Claude Code <noreply@anthropic.com>
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