Skip to content

Commit ba4f45b

Browse files
seefeldbclaude
andcommitted
feat(scheduler): disable pull mode by default and migrate tests to use .pull()
- Change pullMode default to false in scheduler for stability - Remove disablePullMode() from test setup in cell, llm-dialog, fetch-data-mutex, and html-recipes tests - Migrate tests to use .pull() instead of runtime.idle() + .get() - Keep explicit push mode tests in scheduler.test.ts and cell.test.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent e3177ab commit ba4f45b

File tree

8 files changed

+245
-282
lines changed

8 files changed

+245
-282
lines changed

packages/html/test/html-recipes.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ describe("recipes with HTML", () => {
3939
apiUrl: new URL(import.meta.url),
4040
storageManager,
4141
});
42-
// Use push mode for HTML recipe tests
43-
runtime.scheduler.disablePullMode();
4442

4543
tx = runtime.edit();
4644

@@ -71,8 +69,7 @@ describe("recipes with HTML", () => {
7169
);
7270
tx.commit();
7371

74-
await runtime.idle();
75-
const resultValue = result.get();
72+
const resultValue = await result.pull();
7673

7774
assert.matchObject(resultValue, {
7875
[UI]: {
@@ -121,7 +118,7 @@ describe("recipes with HTML", () => {
121118
) as Cell<{ [UI]: VNode }>;
122119
tx.commit();
123120

124-
await runtime.idle();
121+
await result.pull();
125122

126123
const root = document.getElementById("root")!;
127124
const cell = result.key(UI);
@@ -165,7 +162,7 @@ describe("recipes with HTML", () => {
165162
) as Cell<{ [UI]: VNode }>;
166163
tx.commit();
167164

168-
await runtime.idle();
165+
await result.pull();
169166

170167
const root = document.getElementById("root")!;
171168
const cell = result.key(UI);
@@ -187,7 +184,7 @@ describe("recipes with HTML", () => {
187184
) as Cell<{ [UI]: VNode }>;
188185
tx.commit();
189186

190-
await runtime.idle();
187+
await result.pull();
191188

192189
const root = document.getElementById("root")!;
193190
const cell = result.key(UI);
@@ -233,7 +230,7 @@ describe("recipes with HTML", () => {
233230
) as Cell<{ [UI]: VNode }>;
234231
tx.commit();
235232

236-
await runtime.idle();
233+
await result.pull();
237234

238235
const root = document.getElementById("root")!;
239236
const cell = result.key(UI);
@@ -276,7 +273,7 @@ describe("recipes with HTML", () => {
276273
});
277274
tx.commit();
278275

279-
await runtime.idle();
276+
await cell1.pull();
280277

281278
const root = document.getElementById("root")!;
282279
render(root, cell1.key("ui"), renderOptions);

packages/runner/src/scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class Scheduler {
119119
// Track which actions are effects persistently (survives unsubscribe/re-subscribe)
120120
private isEffectAction = new WeakMap<Action, boolean>();
121121
private dirty = new Set<Action>();
122-
private pullMode = true;
122+
private pullMode = false;
123123

124124
// Compute time tracking for cycle-aware scheduling
125125
private actionStats = new WeakMap<Action, ActionStats>();

packages/runner/test/cell.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ describe("Cell", () => {
3535
apiUrl: new URL(import.meta.url),
3636
storageManager,
3737
});
38-
// Use push mode for cell tests
39-
runtime.scheduler.disablePullMode();
40-
4138
tx = runtime.edit();
4239
});
4340

packages/runner/test/fetch-data-mutex.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ describe("fetch-data mutex mechanism", () => {
2525
apiUrl: new URL(import.meta.url),
2626
storageManager,
2727
});
28-
// Use push mode for fetch-data tests
29-
runtime.scheduler.disablePullMode();
3028
tx = runtime.edit();
3129

3230
const { commontools } = createBuilder();

packages/runner/test/llm-dialog.test.ts

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ describe("llmDialog", () => {
3737
apiUrl: new URL(import.meta.url),
3838
storageManager,
3939
});
40-
// Use push mode for llmDialog tests
41-
runtime.scheduler.disablePullMode();
4240
tx = runtime.edit();
4341

4442
const { commontools } = createBuilder();
@@ -156,11 +154,8 @@ describe("llmDialog", () => {
156154
const result = runtime.run(tx, testRecipe, {}, resultCell);
157155
tx.commit();
158156

159-
// Wait for initial processing (if any)
160-
await runtime.idle();
161-
162157
// Get the addMessage handler
163-
const addMessage = result.key("addMessage").get();
158+
const addMessage = await result.key("addMessage").pull();
164159

165160
// Send initial message
166161
addMessage.send({
@@ -302,9 +297,7 @@ describe("llmDialog", () => {
302297
const result = runtime.run(tx, testRecipe, {}, resultCell);
303298
tx.commit();
304299

305-
await runtime.idle();
306-
307-
const addMessage = result.key("addMessage").get();
300+
const addMessage = await result.key("addMessage").pull();
308301

309302
// Send initial message
310303
addMessage.send({
@@ -323,7 +316,7 @@ describe("llmDialog", () => {
323316
expect(toolCalled).toBe(true);
324317

325318
// Verify the conversation history
326-
const messages = result.key("messages").get()!;
319+
const messages = (await result.key("messages").pull())!;
327320
expect(messages).toHaveLength(4);
328321
expect(messages[1].role).toBe("assistant");
329322
const content = messages[1].content as any[];
@@ -437,9 +430,7 @@ describe("llmDialog", () => {
437430
const result = runtime.run(tx, testRecipe, {}, resultCell);
438431
tx.commit();
439432

440-
await runtime.idle();
441-
442-
const addMessage = result.key("addMessage").get();
433+
const addMessage = await result.key("addMessage").pull();
443434

444435
// Send message to trigger pin
445436
addMessage.send({
@@ -451,7 +442,7 @@ describe("llmDialog", () => {
451442
await expect(waitForMessages(result, 4)).resolves.toBeUndefined();
452443

453444
// Verify pinned cells
454-
const pinnedCells = result.key("pinnedCells").get();
445+
const pinnedCells = await result.key("pinnedCells").pull();
455446
expect(pinnedCells).toBeDefined();
456447
expect(Array.isArray(pinnedCells)).toBe(true);
457448
expect(pinnedCells?.length).toBe(1);
@@ -607,9 +598,7 @@ describe("llmDialog", () => {
607598
const result = runtime.run(tx, testRecipe, {}, resultCell);
608599
tx.commit();
609600

610-
await runtime.idle();
611-
612-
const addMessage = result.key("addMessage").get();
601+
const addMessage = await result.key("addMessage").pull();
613602

614603
// First pin a cell
615604
addMessage.send({
@@ -621,7 +610,7 @@ describe("llmDialog", () => {
621610
await expect(waitForMessages(result, 4)).resolves.toBeUndefined();
622611

623612
// Verify cell was pinned
624-
let pinnedCells = result.key("pinnedCells").get();
613+
let pinnedCells = await result.key("pinnedCells").pull();
625614
expect(pinnedCells?.length).toBe(1);
626615
expect(pinnedCells?.[0].path).toBe(cellPath);
627616

@@ -635,7 +624,7 @@ describe("llmDialog", () => {
635624
await expect(waitForMessages(result, 8)).resolves.toBeUndefined();
636625

637626
// Verify pinned cells is now empty
638-
pinnedCells = result.key("pinnedCells").get();
627+
pinnedCells = await result.key("pinnedCells").pull();
639628
expect(pinnedCells).toBeDefined();
640629
expect(Array.isArray(pinnedCells)).toBe(true);
641630
expect(pinnedCells?.length).toBe(0);
@@ -714,9 +703,7 @@ describe("llmDialog", () => {
714703
const result = runtime.run(tx, testRecipe, {}, resultCell);
715704
tx.commit();
716705

717-
await runtime.idle();
718-
719-
const addMessage = result.key("addMessage").get();
706+
const addMessage = await result.key("addMessage").pull();
720707

721708
// Send message
722709
addMessage.send({
@@ -728,7 +715,7 @@ describe("llmDialog", () => {
728715
await expect(waitForMessages(result, 2)).resolves.toBeUndefined();
729716

730717
// Verify context cells appear in pinnedCells output
731-
const pinnedCells = result.key("pinnedCells").get();
718+
const pinnedCells = await result.key("pinnedCells").pull();
732719
expect(pinnedCells).toBeDefined();
733720
expect(Array.isArray(pinnedCells)).toBe(true);
734721
expect(pinnedCells?.length).toBe(1);
@@ -850,9 +837,7 @@ describe("llmDialog", () => {
850837
const result = runtime.run(tx, testRecipe, {}, resultCell);
851838
tx.commit();
852839

853-
await runtime.idle();
854-
855-
const addMessage = result.key("addMessage").get();
840+
const addMessage = await result.key("addMessage").pull();
856841

857842
// Send message to trigger pin
858843
addMessage.send({
@@ -864,7 +849,7 @@ describe("llmDialog", () => {
864849
await expect(waitForMessages(result, 4)).resolves.toBeUndefined();
865850

866851
// Verify pinnedCells output contains both context cell and tool-pinned cell
867-
const pinnedCells = result.key("pinnedCells").get();
852+
const pinnedCells = await result.key("pinnedCells").pull();
868853
expect(pinnedCells).toBeDefined();
869854
expect(Array.isArray(pinnedCells)).toBe(true);
870855
expect(pinnedCells?.length).toBe(2);

0 commit comments

Comments
 (0)