Skip to content

fix(server): automatically settle empty inactive threads - #15783

Open
Adamulek123 wants to merge 2 commits into
pingdotgg:mainfrom
Adamulek123:fix/v2-zero-activity-settlement-focused
Open

Adamulek123 wants to merge 2 commits into
pingdotgg:mainfrom
Adamulek123:fix/v2-zero-activity-settlement-focused

Conversation

@Adamulek123

@Adamulek123 Adamulek123 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An empty thread never reaches automatic inactivity settlement because its activity timestamps are all null. Such threads stay active indefinitely even when they are older than the configured inactivity window.

Change

Use creation time when the thread has no activity timestamp. The existing inactivity window, pin checks, explicit settlement overrides, disabled configuration, and live-work guards still apply. The persisted settlement timestamp also uses creation time so clients keep stable sorting.

Scope and approval

Replaces only the empty-thread settlement part of #15310. This applies the existing inactivity window to threads with no activity; prior maintainer issue triage or approval is not claimed.

Verification

Integrated main 83b982a85c at ba32e284ae. The two full affected suites passed 94 tests; server package typecheck, targeted lint and formatting passed. The only merge conflict was a test-layer rename, and the original five-file scope is preserved.

Validation on the captured main base efecd3cf8b:

  • Focused tests cover old, recent, exact-window, pinned, and configuration-disabled empty threads.
  • A runtime regression reads the empty thread from SQLite's settlement candidates, applies the decision through thread.auto-settle, and verifies creation time in both the persisted projection and shell snapshot, with no messages or runs.
  • All 22 ThreadSettlementService.test.ts cases and the new runtime regression passed. Server typecheck, scoped lint, and formatting passed.

Implemented with GPT-6.1 Sol through Codex on Windows, using Effect/Vitest and SQLite.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 4, 2026
@Adamulek123
Adamulek123 marked this pull request as ready for review October 4, 2026 22:23
@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 9467444

Macroscope's review found this PR approvable — This is a focused server bug fix that applies the existing inactivity policy to empty threads using their creation time, while preserving current guards and configuration behavior. Targeted unit and runtime tests verify the settlement decision and persisted shell/projection state.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5320dfe5-2cd5-4f4f-81e5-c627450a5a73
📥 Commits

Reviewing files that changed from the base of the PR and between efecd3c and 9467444.

📒 Files selected for processing (5)
  • apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
  • apps/server/src/orchestration-v2/ThreadSettlementService.ts
  • apps/server/src/orchestration-v2/runtimeLayer.test.ts
  • docs/internals/overview.md
  • docs/user/thread-sidebar.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Empty threads now use their creation time as the activity timestamp for automatic settlement. Tests cover threshold conditions and verify that the timestamp persists in the thread projection and shell snapshot. Documentation describes this behavior.

Changes

Empty-thread settlement

Layer / File(s) Summary
Creation-time fallback and threshold behavior
apps/server/src/orchestration-v2/ThreadSettlementService.ts, apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
When an empty thread has no message or run timestamps, settlement uses its creation time. Tests cover disabled, elapsed, unelapsed, and exact-threshold cases, plus pinned threads.
Lifecycle persistence and documentation
apps/server/src/orchestration-v2/runtimeLayer.test.ts, docs/internals/overview.md, docs/user/thread-sidebar.md
A lifecycle test checks that the creation-time settlement timestamp is retained in the thread projection and shell snapshot. Documentation describes the fallback.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 94674

Empty threads now settle automatically based on their creation time, and the docs describe this. No merge-blocking risk was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 94674

The change affects 2 systems.

Changed systems: apps/server, docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 3 changed files map to changed impact.
  • observed — docs (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/orchestration-v2/ThreadSettlementService.test.ts: Replaces the prior empty-thread expectation with an assertion that, when autoSettleAfterDays is null, the result equals the thread’s creation time.
  • observed — Modified behavior in apps/server/src/orchestration-v2/ThreadSettlementService.test.ts: Adds expectations for empty threads with a two-day inactivity threshold: a thread created three days earlier resolves to its creation time, while threads created one day or exactly two days earlier, a disabled threshold, and a pinned thread resolve to null.
  • observed — Modified behavior in apps/server/src/orchestration-v2/ThreadSettlementService.ts: activityAtMs now falls back to thread.createdAt when no user-message or run timestamp exists. Terminal pull-request settlement returns that timestamp directly, and the inactivity path no longer returns null solely because those activity timestamps are absent; it still returns null when auto-settlement by age is disabled.
  • observed — Modified behavior in apps/server/src/orchestration-v2/runtimeLayer.test.ts: Adds the ThreadSettlementService import for lifecycle tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: automatically settling empty threads that exceed the inactivity window.
Description check ✅ Passed The description covers the problem, change, scope, and verification in detail. It also clearly states that prior maintainer approval is not claimed, but it does not explain why this focused fix qualif…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant