Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(clients): delegated tasks stay under a parent left out as older settled #37310

ClosedOnkarj012(GitHub profile, opens in a new tab)wants to merge 0 commits intomain fromrefs/pull/37310/headopened View on GitHub

Problem

A task that a linked environment runs for one of your threads is hidden under that thread only while the client has the parent loaded. Shell snapshots leave out all but the 25 newest settled threads. Once the parent settles behind 25 newer ones, it drops out of the snapshot, and the task shows up as a top-level thread in the web/desktop sidebar and the mobile home list. Users then see days-old delegated tasks in their main list and have to clean them up by hand.

The server can't keep the parent in the snapshot, because delegatedFrom points at a thread on another environment.

Change

delegatedUnderParentAtom now treats a missing parent as present when that environment's snapshot left out older settled threads (olderSettled.counts has a non-zero count). Expanding the Settled shelf loads the parent, and the task then shows under it as before.

Nothing else changes. A parent that is loaded and archived, a parent on a disabled environment, and a parent missing from a snapshot that left nothing out still list the task on its own.

One case to know about: if the parent is deleted while its environment still leaves out older threads, the task stays hidden from the sidebar. It can still be found through the command palette, which doesn't use this check.

Scope

A small fix for an obvious bug. A user hit it, and two independent code reviews traced it to this check. There's no issue for it.

Verification

  • Added a row to the existing threadShell.test.ts case for linked-environment tasks. The parent's snapshot leaves the parent out and reports an older settled count, and the task must stay out of navigationThreadShells. It failed on main (expected [ 'remote-environment-v2/remote-task' ] to deeply equal []) and passes with the fix. The case's existing assertions for an empty, archived, and disabled-environment parent still pass.
  • vp run check:changed passes: format, lint, knip, typecheck (7 packages), and tests.
  • Not done: a manual check across two linked environments in a real client.

Made with Claude Opus 5.5 in Claude Code, run through T3 Code. Codex (gpt-6.1-sol) and Grok 4.7 did the read-only bug hunt.

🤖 Generated with Claude Code

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

    2. @@ -681,9 +681,11 @@
      681681 for (const environmentId of environmentIds) {
      682682 for (const thread of get(environmentThreadsAtom(environmentId))) {
      683683 const parent = thread.delegatedFrom;
      684+ if (parent === undefined || !environmentIds.has(parent.environmentId)) continue;
      685+ const parentShell = get(environmentThreadIndexAtom(parent.environmentId)).get(
      686+ parent.threadId,
      687+ );
      684688 if (
      685- parent !== undefined &&
      686- environmentIds.has(parent.environmentId) &&
      687- // An archived parent leaves navigation; its task there stays listed on its own.
      688- get(environmentThreadIndexAtom(parent.environmentId)).get(parent.threadId)?.archivedAt ===
      689- null
      689+ parentShell === undefined
      690+ ? // A snapshot that leaves out older settled threads may be leaving out the parent.
      691+ (get(input.snapshotAtom(parent.environmentId))?.olderSettled?.counts ?? []).some(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium state/threadShell.ts:691

      An archived delegated task disappears from navigationThreadShellsAtom when its parent is removed from snapshot.threads and olderSettled.counts contains any positive count; the task is then treated as still belonging under the parent instead of being listed independently. The aggregate count cannot distinguish an omitted settled parent from an archived one, so preserve the archived-parent distinction rather than using unrelated counts to classify every missing parent.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @packages/client-runtime/src/state/threadShell.ts around line 691:
      
      An archived delegated task disappears from `navigationThreadShellsAtom` when its parent is removed from `snapshot.threads` and `olderSettled.counts` contains any positive count; the task is then treated as still belonging under the parent instead of being listed independently. The aggregate count cannot distinguish an omitted settled parent from an archived one, so preserve the archived-parent distinction rather than using unrelated counts to classify every missing parent.
    3. Approvability

      Verdict: Would Approve

      Macroscope's review found this PR approvable — This changes delegated-task grouping when a parent is omitted from a partial snapshot, without modifying stored tasks. The reported Medium navigation-visibility finding remains subject to the separate correctness gate.

      Needs human approval because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Closing: #34870 already keeps a linked-environment task's parent in trimmed snapshots on the server, which fixes this at the source. The Macroscope finding is right too. An archived parent leaves the snapshot the same way, so this change would hide its task.

    5. Thanks for this. Before a bug fix is taken further, the bug is reproduced on current main, and here it did not appear.

      We ran your steps on main at c5e6b24ff5 in the web client with two fresh environments linked to each other. An agent on the first environment delegated a real task to the second, and it finished there. We then settled the parent and 26 newer threads on the first environment, so the parent was the oldest of 27 settled threads, and reloaded without opening the Settled shelf. The delegated task did not appear as its own thread in the sidebar. It stayed out of the list, just as it did while the parent was active.

      The reason is on the server. Since #34870, a thread that delegated a task to a linked environment is always kept in that environment's trimmed thread list, even when it is past the 25-newest settled cut. We checked the list the client actually received: it left out a newer settled thread that fell past the cut and counted it as older settled, but it kept the parent, so the client always had it. Because of that, the fallback this pull request adds is never needed in this case. As your description and the review comment note, it would also hide tasks whose parent was really deleted or archived whenever older settled threads exist.

      If you saw a task listed on its own in practice, the server or client may have been older than #34870, or the parent may not have been a delegate_task parent. A screenshot or the server version would help us look again.

      Closing this pull request. If it still happens for you, please open an issue with the exact steps, what you see, and the version and platform you are on; a fix is picked up from there.

Sign in to join this conversation.