[Bug]: unsettled thread on a down machine blocks opening new threads until the machine serves again
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
Summary
When one machine is down (or not serving) and the user opens a project that the down machine was last working on, and the project's latest turn is unsettled, the app automatically opens the unsettled thread and the user is stuck with it: there is no way to settle it (the owning machine is unreachable) and no way to open a new thread or pick another machine to run in. Everything works again only after running npx t3 serve on the down machine, at which point the user can finally open a new thread.
Repro
- Machine A and machine B are both connected (e.g. via T3 Connect) and sharing projects.
- Machine A works on project P and leaves its latest turn unsettled (e.g. the machine is shut down mid-turn).
- From the client, open project P (or land on it).
- Observed: the app opens the unsettled thread owned by the down machine A. Starting a new thread does not work and the user cannot move past the unsettled state.
- Run
npx t3 serveon machine A. - Now the project works again and the user can open a new thread.
Expected
When the machine that owns the unsettled thread is unreachable, the app should not block on that thread. Instead it should either:
- automatically open the unsettled thread so the user can settle it, or
- let the user choose another machine (environment) to run in when the project is available on another one.
Notes from code exploration
- A thread's latest turn is unsettled while its session leaves "running" (
thread.unsettledevents;settledTurnStateForSessionStatusinapps/server/src/orchestration/projector.tssettles a still-running turn only once the session's status leaves running). isLatestTurnSettledinapps/web/src/session-logic.tstreats the latest turn as unsettled while the session is running or the turn has nocompletedAt.- Projects and threads are environment-scoped (
scopeProjectRef/scopeThreadRefinpackages/client-runtime), so an unsettled turn's session lives on the machine that was running it; while that machine is down, its session status cannot transition to settle the turn, which likely leaves the new-thread/draft flow stuck until the machine is reachable again.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/web/src/session-logic.ts and apps/server/src/orchestration/projector.ts, then inspect scopeProjectRef and scopeThreadRef in packages/client-runtime. Reproduce the two-machine scenario with an unsettled turn while the owning machine is offline. Done means the unavailable machine no longer blocks opening a new thread or choosing another available environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100