Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(app): show threads from unreachable environments as offline #8935

ClosedGigioxx(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8935/headopened View on GitHub

Problem

When a T3 Connect or other remote environment goes offline (power loss on the remote machine, a dead tunnel), its cached threads keep showing live states like Working or Monitoring indefinitely, with no local hint that nothing on them can progress. Reported in #8924, closed as a duplicate of #4852 (stale Working threads when their environment is offline).

Change

The shared client runtime derives an environmentUnavailable flag on each thread shell from the environment's presented connection phase (reconnecting or error while this device is online). Point reads and list reads both carry it.

  • Web and mobile thread lists read live and actionable states (Working, Monitoring, Pending Approval, Awaiting Input, Plan Ready) from unreachable environments as a gray Offline. Historical facts stay: Failed stays Failed, Completed stays Completed, quiet rows stay quiet. On web, Offline rows recede like resting rows.
  • Thread order is unchanged. Reconnecting restores live states in place.
  • Offline browsing on this device and first connection attempts are unaffected, so cached rows do not flicker at startup or while the client itself is offline.

Threads are marked rather than hidden: settle and stop are server-owned and already fail with a toast naming the disconnected environment, and Settings → Connections → Remove clears a permanently dead environment. The user guide gets a short section on this.

Scope and approval

Bug fix for the stale-state problem triaged by a maintainer when closing #8924 as a duplicate of #4852: https://github.com/pingdotgg/t3code/issues/8924#issuecomment-5501854594. An earlier version also moved unavailable rows below reachable ones; that ordering change was dropped after maintainer review (https://github.com/pingdotgg/t3code/pull/8935#issuecomment-5921664668), so this PR now only adds the Offline status.

Verification

  • Established the problem with two live environments, killing the remote one mid-turn: on main the remote row kept claiming Monitoring for over a minute after the environment died.
  • Rebased onto main at 0cf482b in this session and removed the ordering change (environmentUnavailableRank, the sort tier in web and mobile, and its tests). Main retired the legacy mobile grouped list (#13183), so the Offline mapping now lives only in the v2 list resolver.
  • vp test run packages/client-runtime/src/state/entities.test.ts apps/web/src/components/Sidebar.logic.test.ts apps/mobile/src/features/threads/threadListV2.test.ts: 3 files, 270 tests passed. Coverage: connection phases that do and do not mark a shell (first attempt, backoff, retry, device offline, reconnected), list reads carrying the mark, and web/mobile status mapping (live states become Offline, Failed and quiet rows stay).
  • tsc --noEmit for client-runtime, web, and mobile: all three exit 0.
  • vp lint on changed files: no new findings (an existing unused cn import and ref warnings in Sidebar.logic.ts are on main). vp fmt --check: clean.
  • Real client run on the rebased head (e16a2b3), web dev server plus a second local environment paired through Settings → Connections. Started a turn on the remote thread, killed the remote server, and waited 20s: the row reads Offline and keeps its position in the list. Reconnect was verified on the earlier head (last column of the older table below); not re-checked on this head.

Current behavior on main while the environment has been dead for over a minute; the row still claims live work:

Main: dead environment still shows a live Monitoring state

This head, before and after the remote environment goes down:

Remote environment onlineRemote environment offline
Online: remote thread shows its live stateOffline: remote thread reads Offline in the same position
Earlier head (old ordering, offline rows sank below local threads)
Both environments onlineRemote environment offline (old ordering)Reconnected
OnlineOfflineReconnected

Made with Claude Fable 5 through the Claude Code harness in T3 Code. Rebase and scope reduction by Claude Opus 5.5 via Claude Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 69260ce1-2d06-447b-9f17-663a6cb871cf

      📥 Commits

      Reviewing files that changed from the base of the PR and between 4e8e64fc065a4a72535eee5fe60b689f5b48d35c and 1deee04f4ee03887cef80b553d382cda72bf36cb.

      📒 Files selected for processing (15)
      • apps/mobile/src/features/threads/thread-list-v2-items.tsx
      • apps/mobile/src/features/threads/threadListV2.test.ts
      • apps/mobile/src/features/threads/threadListV2.ts
      • apps/mobile/src/features/threads/threadPresentation.ts
      • apps/mobile/src/state/threads.ts
      • apps/web/src/components/Sidebar.logic.test.ts
      • apps/web/src/components/Sidebar.logic.ts
      • apps/web/src/components/Sidebar.tsx
      • apps/web/src/lib/threadSort.ts
      • apps/web/src/state/threads.ts
      • docs/user/thread-sidebar.md
      • packages/client-runtime/src/state/entities.test.ts
      • packages/client-runtime/src/state/models.ts
      • packages/client-runtime/src/state/threadShell.ts
      • packages/client-runtime/src/state/threadSort.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The change propagates environment connection failures into cached thread shells. Mobile and web thread lists display active remote threads as Offline, sort them below reachable threads, preserve historical statuses, and document related cleanup behavior.

      Changes

      Offline thread state

      Layer / File(s)Summary
      Connection state propagation
      packages/client-runtime/src/state/models.ts, packages/client-runtime/src/state/threadShell.ts, packages/client-runtime/src/state/threadSort.ts, packages/client-runtime/src/state/entities.test.ts
      Connection phases derive environmentUnavailable for cached thread shells. The flag flows through shell scoping and tests cover reconnect, retry, offline, and reconnect transitions.
      Mobile offline status and ordering
      apps/mobile/src/features/threads/*, apps/mobile/src/state/threads.ts
      Mobile status resolution maps unavailable approval, input, and working threads to Offline. Offline presentation uses muted styling, and sorting places unavailable threads after reachable threads.
      Web sidebar offline status and ordering
      apps/web/src/components/Sidebar.logic.ts, apps/web/src/components/Sidebar.tsx, apps/web/src/components/Sidebar.logic.test.ts, apps/web/src/state/threads.ts, apps/web/src/lib/threadSort.ts
      The sidebar adds offline status resolution, pills, dimmed rows, and sorting. Failed, completed, and ready states remain unchanged.
      Offline thread behavior documentation
      docs/user/thread-sidebar.md
      Documentation describes offline display, unavailable-environment actions, and clearing threads through connection settings.

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

      Suggested reviewers: juliusmarminge, t3dotgg, shivamhwp

      Merge Risk: ⚪ Minimal · up to 1deee

      The PR changes how threads from unreachable environments are labeled and sorted, with no actionable merge-blocking risk remaining beyond normal checks and review.

      🚥 Pre-merge checks | ✅ 3 | ❌ 2

      ❌ Failed checks (2 warnings)

      Check nameStatusExplanationResolution
      Linked Issues check⚠️ WarningThe PR satisfies the offline labeling and sorting objective in #8924. It does not implement local settle or dismiss actions, and it does not disable remote-dependent actions with a clear explanation a…Implement local cleanup for cached threads, including settle or dismiss behavior that does not contact the unavailable environment. Disable remote-dependent actions such as Stop and show a clear explanation, or update the linked issue and P…
      Docstring Coverage⚠️ WarningDocstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 14 files. (1 skipped:…Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Out of Scope Changes check✅ PassedThe runtime flag, status presentation, sorting, state wiring, tests, documentation, and shared helper changes all support the offline-thread behavior described in #8924. No unrelated code changes are …
      Title check✅ PassedThe title clearly and concisely describes the main change: showing threads from unreachable environments as offline.
      Description check✅ PassedThe description includes all required sections, explains the problem and solution, documents scope and approval, and provides detailed verification results with UI evidence. However, it states that or…
      Full details: Linked Issues check

      Explanation

      The PR satisfies the offline labeling and sorting objective in #8924. It does not implement local settle or dismiss actions, and it does not disable remote-dependent actions with a clear explanation as requested by the issue.

      Resolution

      Implement local cleanup for cached threads, including settle or dismiss behavior that does not contact the unavailable environment. Disable remote-dependent actions such as Stop and show a clear explanation, or update the linked issue and PR scope if these requirements are intentionally deferred.

      Full details: Docstring Coverage

      Explanation

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

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Comment `@coderabbitai help` to get the list of available commands.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at e16a2b3

      Macroscope's review found this PR approvable — The PR makes a focused, tested correction to stale thread-status presentation across web and mobile while preserving cached threads, historical states, actions, and ordering. Its shared-runtime wiring is additive and does not introduce schema, deployment, security, or workflow changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Note

      This comment is posted by Julius' dot

      The Offline status addresses the stale live state in #8924, but this also moves all unavailable environment rows below reachable rows, including quiet threads that retain their historical status. The linked triage establishes the stale state, not that ordering choice. Under the problem and scope requirement, please explain why changing the existing static order is needed for this fix and link maintainer approval for that behavior, or retain the existing order. Leaving this open for that scope decision.

    5. [claude-opus-5-5] Responding on behalf of Guille


      @juliusmarminge Dropped the ordering change in e16a2b3134 (also rebased onto current main). environmentUnavailableRank, the sort tier in the web sidebar and mobile list, and its tests are gone, so rows keep the existing static order. The PR now only adds the Offline status for live states from unreachable environments. The "Remote environment offline" screenshot in the description still shows the old ordering and is marked as such until it is refreshed.

    6. juliusmarminge added labelsmacroscope-review

    7. Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.

      The patch conflicts with the rewrite in apps/mobile/src/features/threads/thread-list-v2-items.tsx, apps/mobile/src/features/threads/threadListV2.ts, apps/web/src/components/Sidebar.logic.ts and 3 other files. Even where the conflict is small enough to rebase, we are asking for fresh PRs against the new base so we can review and verify the behavior in V2.

      Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.

    8. juliusmarminge closed this

Sign in to join this conversation.