Skip to content

Share thread state idle TTL across client atoms#3163

Merged
juliusmarminge merged 1 commit into
mainfrom
t3code/ae7c29d0-a1e5-4a61-b4ed-90a83f850645
Jun 19, 2026
Merged

Share thread state idle TTL across client atoms#3163
juliusmarminge merged 1 commit into
mainfrom
t3code/ae7c29d0-a1e5-4a61-b4ed-90a83f850645

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Extracted the thread idle retention window into a shared THREAD_STATE_IDLE_TTL_MS constant.
  • Applied the shared TTL to thread state atoms and all thread detail-derived atoms for consistent retention behavior.
  • Added a regression test covering thread state atom idle TTL and family caching behavior.

Testing

  • vp check
  • vp run typecheck
  • vp run lint
  • vp test packages/client-runtime/src/state/threads-atoms.test.ts

Note

Low Risk
Client-side atom caching/retention only; behavior change is bounded TTL alignment and slightly longer retention for primary thread state atoms.

Overview
Introduces THREAD_STATE_IDLE_TTL_MS (5 minutes) in threadRetention.ts so stream-backed thread state and all thread-detail-derived atoms use the same idle retention window—aimed at keeping thread data alive across brief subscriber gaps (e.g. mobile back navigation) without retaining every opened thread indefinitely.

createEnvironmentThreadStateAtoms now pipes Atom.setIdleTTL and a debug label onto each per-thread state atom; detail atoms in threadDetail.ts switch from a local constant to the shared one. A small test asserts the TTL value and Atom.family identity per environment/thread pair.

Reviewed by Cursor Bugbot for commit c5fe456. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Share idle TTL constant across thread state client atoms

  • Extracts a shared THREAD_STATE_IDLE_TTL_MS constant (5 minutes) into a new threadRetention.ts module, replacing the local copy in threadDetail.ts.
  • Updates createEnvironmentThreadStateAtoms in threads.ts to apply Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS) and a descriptive label to each atom in the family — previously these atoms had no idle TTL or label.
  • Adds tests in threads-atoms.test.ts verifying the idle TTL value and atom family memoization behavior.

Macroscope summarized c5fe456.

- Extract the thread retention TTL into a shared constant
- Apply the same idle retention to thread state and detail atoms
- Add coverage for atom family caching and TTL behavior
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cad1ea0c-eb69-4031-9749-8298d9403502

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/ae7c29d0-a1e5-4a61-b4ed-90a83f850645

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 19, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR consolidates a shared constant for thread state idle TTL and applies it consistently across client atoms. The behavioral change (adding idle TTL to thread state atoms) is intentional, documented, and tested—low-risk state management alignment.

You can customize Macroscope's approvability policy. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint 27e228668e373d1941548dc669856ecf3fd6261f fa880122b8876ecaafbb21281d21e292d7b09484
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 27e228668e373d1941548dc669856ecf3fd6261f
App version: 0.1.0
Git commit: 4b7b08e5ecc101f940c220c08cae29c47d2d85b8
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: fa880122b8876ecaafbb21281d21e292d7b09484
App version: 0.1.0
Git commit: 8ef95c479ae1c01cbd33365fe792b762398ffd5d
Update Details Update Permalink
DetailsBranch: pr-3163
Runtime version: 27e228668e373d1941548dc669856ecf3fd6261f
Git commit: 4b7b08e5ecc101f940c220c08cae29c47d2d85b8
Update Permalink
DetailsBranch: pr-3163
Runtime version: fa880122b8876ecaafbb21281d21e292d7b09484
Git commit: 4b7b08e5ecc101f940c220c08cae29c47d2d85b8
Update QR

@juliusmarminge juliusmarminge merged commit cdaba7f into main Jun 19, 2026
15 checks passed
@juliusmarminge juliusmarminge deleted the t3code/ae7c29d0-a1e5-4a61-b4ed-90a83f850645 branch June 19, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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