Skip to content

Harden project thread resource lifecycle - #335

Merged
TraderSamwise merged 1 commit into
masterfrom
chore/core-sidecar-next-60
Jul 6, 2026
Merged

Harden project thread resource lifecycle#335
TraderSamwise merged 1 commit into
masterfrom
chore/core-sidecar-next-60

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • move project Threads onto the shared project resource lifecycle store
  • add request ownership for project observability, tasks, and threads so stale remount/endpoint responses cannot overwrite current data
  • preserve cached thread snapshots across transient refresh failures and update the north-star progress doc

Verification

  • yarn --cwd app typecheck
  • yarn --cwd app test stores/project.test.ts
  • yarn --cwd app lint (existing warnings in plans/[sessionId].tsx and cli-auth.tsx)
  • yarn --cwd app test
  • git diff --check
  • yarn typecheck
  • yarn lint
  • yarn build
  • yarn vitest

Summary by CodeRabbit

  • New Features

    • Project threads now use the same persistent loading and refresh behavior as other project data, so the thread list can stay visible while updates are in progress.
  • Bug Fixes

    • Improved thread refresh handling to avoid showing outdated results from older requests.
    • Added clearer thread states for loading, empty, and error scenarios, including a message when a refresh fails but previously loaded threads are still available.
    • Project data recovery now clears stale error states more reliably across refreshes.

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 6, 2026 9:17am

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 300e7ee3-2429-4714-a431-7fa6afea1c15

📥 Commits

Reviewing files that changed from the base of the PR and between 4303871 and 17e24e8.

📒 Files selected for processing (5)
  • app/app/(main)/(tabs)/(threads)/threads.tsx
  • app/app/(main)/(tabs)/project/index.tsx
  • app/stores/project.test.ts
  • app/stores/project.ts
  • docs/core-sidecar-north-star.md

📝 Walkthrough

Walkthrough

This PR introduces a Jotai-backed resource model for project threads (projectThreadsResourceFamily, refresh lifecycle atoms), migrates ThreadsScreen and project index refresh flows to request-key-gated success/failure handling, expands request-scope keying logic, adds corresponding tests, and updates north-star documentation.

Changes

Project threads resource and refresh migration

Layer / File(s) Summary
Threads resource types and request-key contract
app/stores/project.ts
Adds ProjectThreadsValue, ApplyProjectThreadsSuccessInput, updates ApplyProjectResourceFailureInput to include requestKey, and adds request-scope/sequence helpers with an updated projectResourceRequestKey signature.
Threads resource atoms and request-key gating
app/stores/project.ts
Adds projectThreadsResourceFamily/projectThreadsFamily and threads refresh atoms (begin/apply success/failure/clear/settle); updates observability and tasks apply atoms to ignore stale responses via pendingRequestKey matching.
Project index refresh key wiring
app/app/(main)/(tabs)/project/index.tsx
refreshProject/refreshTasks compute requestKey via the new projectResourceRequestKey signature (no explicit seq) and pass it to apply success/failure atoms.
ThreadsScreen migration to threads resource
app/app/(main)/(tabs)/(threads)/threads.tsx
Replaces local state with threadsResource, rebuilds refresh via request scope/generation tracking, and updates rendering for pending/stale/error states including a stale-refresh-failure card.
Project store test coverage for threads lifecycle
app/stores/project.test.ts
Adds thread factories/seeding helpers and tests for stale-on-failure, recovery, endpoint-disappearance clearing, unique request keys, and marker-ownership/staleness across resources.
North star doc updates for threads resource
docs/core-sidecar-north-star.md
Adds project Threads to the resource-lifecycle preservation contract and adjusts the remaining-migration bullet ordering.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ThreadsScreen
  participant beginProjectThreadsRefreshAtom
  participant API
  participant applyProjectThreadsSuccessAtom
  participant projectThreadsResourceFamily

  ThreadsScreen->>beginProjectThreadsRefreshAtom: begin refresh with requestKey
  ThreadsScreen->>API: fetch threads
  API-->>ThreadsScreen: response
  ThreadsScreen->>applyProjectThreadsSuccessAtom: apply success with requestKey
  applyProjectThreadsSuccessAtom->>projectThreadsResourceFamily: update value if requestKey matches pendingRequestKey
  projectThreadsResourceFamily-->>ThreadsScreen: render visibleThreads/visibleError
Loading

Possibly related PRs

  • TraderSamwise/aimux#251: Both PRs change ThreadsScreen's refresh/fetch logic and the computation of visibleThreads/visibleError in the same component.
  • TraderSamwise/aimux#328: Both PRs modify ThreadsScreen's refresh flow, with the retrieved PR changing the refresh nonce trigger that this PR's refactored resource lifecycle now drives.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: strengthening the project thread resource lifecycle.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/core-sidecar-next-60

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

app/app/(main)/(tabs)/(threads)/threads.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

app/app/(main)/(tabs)/project/index.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

app/stores/project.test.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 1 others

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

@TraderSamwise
TraderSamwise merged commit cacc73c into master Jul 6, 2026
3 checks passed
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