GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(client): an opened idle subagent reads its family once · scuttletoby/t3code@2b59d9f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/client-runtime/src/state
    • threadFamilies.test.ts
    • threadFamilies.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/client-runtime/src/state/threadFamilies.test.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/state/threadFamilies.test.ts
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,26 @@ describe("createThreadFamilyAtoms", () => {
235235
expect(threadFamilyRead(registry.get(family))).toBe("settled");
236236
expect(mergedIds()).toEqual(["parent", "idle-child"]);
237237

238-
// A child that woke after the shell left out its idle parent reads its family unmounted.
238+
// Children that woke after the shell left out their idle parent arrive as deltas, and
239+
// read their family unmounted, once for the root.
239240
release();
240241
const woken = row("woken", "woken", child.id, parent.id);
241-
registry.set(shellState, AsyncResult.success(shellAt(3, [parent, woken])));
242+
const sibling = row("woken-sibling", "woken-sibling", child.id, parent.id);
243+
registry.set(shellState, AsyncResult.success(shellAt(2, [parent, woken, sibling])));
242244
yield* Queue.offer(
243245
replies,
244-
Effect.succeed({ snapshotSequence: 6, threads: [parent, child, woken] }),
246+
Effect.succeed({ snapshotSequence: 6, threads: [parent, child, woken, sibling] }),
245247
);
246-
yield* settle;
247-
expect(mergedIds()).toEqual(["parent", "woken", "idle-child"]);
248+
const wokenFamily = families.familyAtom(TARGET.environmentId, woken.id);
249+
yield* AtomRegistry.getResult(registry, wokenFamily, { suspendOnWaiting: true }).pipe(
250+
Effect.tap(() => Effect.yieldNow),
251+
);
252+
expect(mergedIds()).toEqual(["parent", "woken", "woken-sibling", "idle-child"]);
248253

249-
// That read is settled, but a caller waiting on its own mount sees it only once mounted.
250-
const mountedRead = families.mountedReadAtom(TARGET.environmentId, parent.id);
251-
expect(threadFamilyRead(registry.get(family))).toBe("settled");
254+
// Opening the woken child mounts that same read. It answers only once it is mounted.
255+
const mountedRead = families.mountedReadAtom(TARGET.environmentId, woken.id);
252256
expect(registry.get(mountedRead)).toBe("pending");
253-
families.mount(registry, TARGET.environmentId, parent.id);
257+
families.mount(registry, TARGET.environmentId, woken.id);
254258
expect(registry.get(mountedRead)).toBe("settled");
255259
}),
256260
),
Collapse file

‎packages/client-runtime/src/state/threadFamilies.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/state/threadFamilies.ts
+14-10Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,25 @@ export function threadFamilyRowsMissingFromShell(input: {
6666
}
6767

6868
/**
69-
* Roots of subagents and side chats whose parent row the shell left out. A shell sent with
70-
* `omitIdleSubagentParents` drops idle chains, so a child that wakes later arrives without them.
69+
* Subagents and side chats whose parent row the shell left out, one per root. A shell sent with
70+
* `omitIdleSubagentParents` drops idle chains, so a child that wakes or is opened later arrives
71+
* without them. The family is read by the child, the read an open thread's mount already made.
7172
*/
72-
function rootsWithMissingParents(
73+
function threadsWithMissingParents(
7374
threads: ReadonlyArray<OrchestrationV2ThreadShell>,
7475
): ReadonlyArray<ThreadId> {
7576
const present = new Set<ThreadId>(threads.map((thread) => thread.id));
76-
const roots = new Set<ThreadId>();
77-
for (const { lineage } of threads) {
77+
const byRoot = new Map<ThreadId, ThreadId>();
78+
for (const { id, lineage } of threads) {
7879
if (lineage.parentThreadId === null || present.has(lineage.parentThreadId)) continue;
79-
if (lineage.relationshipToParent === "subagent" || lineage.sideChat === true) {
80-
roots.add(lineage.rootThreadId);
80+
if (
81+
(lineage.relationshipToParent === "subagent" || lineage.sideChat === true) &&
82+
!byRoot.has(lineage.rootThreadId)
83+
) {
84+
byRoot.set(lineage.rootThreadId, id);
8185
}
8286
}
83-
return [...roots];
87+
return [...byRoot.values()];
8488
}
8589

8690
/**
@@ -241,8 +245,8 @@ export function createThreadFamilyAtoms<R, ER, E>(
241245
if (orphans?.threads !== snapshot.threads) {
242246
orphans = {
243247
threads: snapshot.threads,
244-
rows: rootsWithMissingParents(snapshot.threads).map((root) =>
245-
familyRowsAtom(familyKey(environmentId, root)),
248+
rows: threadsWithMissingParents(snapshot.threads).map((threadId) =>
249+
familyRowsAtom(familyKey(environmentId, threadId)),
246250
),
247251
};
248252
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.