@marimo-team/islands 0.25.3-dev447 → 0.25.3-dev455
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ErrorBoundary-DVbdKroW.js → ErrorBoundary-EIKYL5I7.js} +1 -1
- package/dist/assets/__vite-browser-external-D2z_TiUO.js +1 -0
- package/dist/assets/{worker-BUqfWMtI.js → worker-DLJ9P24O.js} +2 -2
- package/dist/{chat-ui-9oyUBL6M.js → chat-ui-DEHpKH2l.js} +17 -19
- package/dist/{code-visibility-DmsDqWUx.js → code-visibility-y-sxdqzm.js} +7 -7
- package/dist/{common-BDo_Jwoz.js → common-CN0Vi2sf.js} +4902 -4893
- package/dist/{data-grid-overlay-editor-CpHB_knU.js → data-grid-overlay-editor-DS87hE3v.js} +1 -1
- package/dist/{error-entries-CWdDf7iZ.js → error-entries-BG7ifiDg.js} +1368 -996
- package/dist/{feedback-button-B_Wmi4to.js → feedback-button-BLEwyTRA.js} +129 -129
- package/dist/{glide-data-editor-CMiIW5WP.js → glide-data-editor-Bmv61gX_.js} +3 -3
- package/dist/{globals-DaC3pk9F.js → globals-CIXjTv9d.js} +1 -1
- package/dist/{html-to-image-CexRSGAZ.js → html-to-image-9HLBGrIx.js} +4115 -4103
- package/dist/main.js +6562 -6671
- package/dist/{number-overlay-editor-Dd4cOJ5I.js → number-overlay-editor-TNyxrFMM.js} +1 -1
- package/dist/{process-output-hcyVRJCC.js → process-output-B8HPq5iZ.js} +2 -2
- package/dist/{reveal-component-CTmvBdvu.js → reveal-component-Ds7he0Dj.js} +166 -167
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +7 -4
- package/src/__mocks__/notebook.ts +20 -4
- package/src/components/editor/cell/DeleteButton.tsx +2 -2
- package/src/components/editor/cell/StopButton.tsx +2 -2
- package/src/components/editor/cell/useRunCells.ts +0 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +1 -1
- package/src/components/editor/notebook-cell.tsx +4 -35
- package/src/components/editor/output/ansi-reduce.ts +124 -61
- package/src/components/editor/output/console/ConsoleOutput.tsx +7 -25
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +15 -44
- package/src/components/editor/renderers/cells-renderer.tsx +2 -5
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +1 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -6
- package/src/components/editor/stdin-blocking-alert.tsx +14 -18
- package/src/components/scratchpad/scratchpad.test.tsx +1 -1
- package/src/components/scratchpad/scratchpad.tsx +5 -6
- package/src/components/slides/__tests__/cell-output-block.test.tsx +2 -2
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +2 -2
- package/src/components/tracing/tracing-spec.ts +11 -1
- package/src/components/tracing/tracing.tsx +4 -0
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +10 -20
- package/src/core/ai/context/providers/__tests__/error.test.ts +5 -27
- package/src/core/ai/context/providers/cell-output.ts +4 -12
- package/src/core/cells/__tests__/cell.test.ts +1 -169
- package/src/core/cells/__tests__/cells.test.ts +32 -709
- package/src/core/cells/__tests__/clear-outputs.test.ts +21 -14
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +71 -2
- package/src/core/cells/__tests__/logs.test.ts +18 -29
- package/src/core/cells/__tests__/runs.test.ts +128 -431
- package/src/core/cells/__tests__/session.test.ts +9 -9
- package/src/core/cells/actions.ts +29 -7
- package/src/core/cells/cell.ts +1 -96
- package/src/core/cells/cells.ts +147 -117
- package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
- package/src/core/cells/command-console.ts +46 -0
- package/src/core/cells/execution-console.ts +230 -0
- package/src/core/cells/focus.ts +9 -29
- package/src/core/cells/logs.ts +10 -2
- package/src/core/cells/runs.ts +62 -118
- package/src/core/cells/session.ts +2 -2
- package/src/core/cells/types.ts +30 -23
- package/src/core/cells/useAnswerPrompt.ts +29 -0
- package/src/core/errors/error-entries.ts +3 -4
- package/src/core/executions/__tests__/atoms.test.ts +6 -20
- package/src/core/executions/__tests__/input.test.ts +3 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +2 -8
- package/src/core/executions/atoms.ts +2 -21
- package/src/core/executions/index.ts +2 -1
- package/src/core/executions/input.ts +4 -3
- package/src/core/executions/output.ts +3 -3
- package/src/core/islands/__tests__/bridge.test.ts +59 -0
- package/src/core/islands/bootstrap.ts +29 -12
- package/src/core/islands/bridge.ts +67 -13
- package/src/core/kernel/handlers.ts +2 -21
- package/src/core/kernel/messages.ts +0 -1
- package/src/core/network/types.ts +0 -1
- package/src/core/notebook/document/__tests__/codemirror.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/executions.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +113 -0
- package/src/core/notebook/replica/replica.ts +106 -12
- package/src/core/notebook/replica/resources/executions.ts +57 -4
- package/src/core/session/__tests__/backend.test.ts +2 -4
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +1 -0
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +601 -35
- package/src/core/session/useNotebookReplica.ts +20 -6
- package/src/core/session/useNotebookSession.tsx +63 -33
- package/src/core/static/virtual-file-tracker.ts +26 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +18 -12
- package/dist/assets/__vite-browser-external-CpRgw4M_.js +0 -1
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -68
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -703
|
@@ -40,12 +40,16 @@ import { Deferred } from "@/utils/Deferred";
|
|
|
40
40
|
import { cellId } from "@/__tests__/branded";
|
|
41
41
|
import { alertAtom, getPackageAlert } from "@/core/alerts/state";
|
|
42
42
|
import { stagedAICellsAtom } from "@/core/ai/staged-cells";
|
|
43
|
+
import { cellRuntimeAtom } from "@/core/cells/cells";
|
|
44
|
+
import { clearCellConsoleOutputAtom } from "@/core/cells/actions";
|
|
43
45
|
import { notebookAtom } from "@/core/cells/cells";
|
|
46
|
+
import { SCRATCH_CELL_ID } from "@/core/cells/ids";
|
|
44
47
|
import {
|
|
45
48
|
breakpointsAtom,
|
|
46
49
|
pendingPdbInputAtom,
|
|
47
50
|
} from "@/core/codemirror/cells/debugger-state";
|
|
48
51
|
import { AppConfigSchema } from "@/core/config/config-schema";
|
|
52
|
+
import { hasBlockingStdinAtom } from "@/components/editor/stdin-blocking-alert";
|
|
49
53
|
import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
|
|
50
54
|
import { kernelStartupErrorAtom } from "@/core/errors/state";
|
|
51
55
|
import type { NotificationPayload } from "@/core/kernel/messages";
|
|
@@ -462,55 +466,538 @@ it("does not mark the session connected on kernel-ready alone", async () => {
|
|
|
462
466
|
expect(store.get(connectionAtom).state).toBe(ConnectionState.CONNECTING);
|
|
463
467
|
});
|
|
464
468
|
|
|
465
|
-
it("
|
|
469
|
+
it.each(["", "latest"])(
|
|
470
|
+
"restores only the latest scratch console (%j) on resume and reset",
|
|
471
|
+
async (text) => {
|
|
472
|
+
const store = createStore();
|
|
473
|
+
const fake = withTransport();
|
|
474
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
475
|
+
renderConnectionHook(store);
|
|
476
|
+
await started();
|
|
477
|
+
const conn = connection(fake);
|
|
478
|
+
const rows = () =>
|
|
479
|
+
store
|
|
480
|
+
.get(cellRuntimeAtom(SCRATCH_CELL_ID))
|
|
481
|
+
.consoleOutputs.map((entry) => entry.data);
|
|
482
|
+
await act(async () => conn.open());
|
|
483
|
+
act(() => {
|
|
484
|
+
for (const frame of fixtureMessages("notebook-events.sse")) {
|
|
485
|
+
conn.receive(frame);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
expect(rows()).toEqual(["2\n"]);
|
|
489
|
+
const scratch = {
|
|
490
|
+
...MockExecutions.completed(cellId("c1")),
|
|
491
|
+
cell_id: null,
|
|
492
|
+
id: "second-scratch",
|
|
493
|
+
started_at: "2026-10-01T09:21:01Z",
|
|
494
|
+
completed_at: "2026-10-01T09:21:02Z",
|
|
495
|
+
};
|
|
496
|
+
act(() => {
|
|
497
|
+
conn.receive({
|
|
498
|
+
event: "execution",
|
|
499
|
+
data: {
|
|
500
|
+
execution: {
|
|
501
|
+
...scratch,
|
|
502
|
+
status: "running",
|
|
503
|
+
outcome: null,
|
|
504
|
+
completed_at: null,
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
if (text) {
|
|
509
|
+
conn.receive({
|
|
510
|
+
event: "console",
|
|
511
|
+
data: {
|
|
512
|
+
console: {
|
|
513
|
+
id: "second-line",
|
|
514
|
+
execution_id: scratch.id,
|
|
515
|
+
seq: 0,
|
|
516
|
+
name: "stdout",
|
|
517
|
+
text,
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
conn.receive({ event: "execution", data: { execution: scratch } });
|
|
523
|
+
});
|
|
524
|
+
expect(rows()).toEqual(text ? [text] : []);
|
|
525
|
+
const kernelReady = () =>
|
|
526
|
+
conn.send({
|
|
527
|
+
op: "kernel-ready",
|
|
528
|
+
resumed: true,
|
|
529
|
+
ui_values: {},
|
|
530
|
+
layout: null,
|
|
531
|
+
app_config: { width: "normal" },
|
|
532
|
+
kiosk: false,
|
|
533
|
+
capabilities: {},
|
|
534
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
535
|
+
});
|
|
536
|
+
act(kernelReady);
|
|
537
|
+
expect(rows()).toEqual(text ? [text] : []);
|
|
538
|
+
act(() => {
|
|
539
|
+
conn.receive({ event: "reset", data: {} });
|
|
540
|
+
for (const frame of fixtureMessages("notebook-events.sse")) {
|
|
541
|
+
if (!["run", "execution", "console"].includes(frame.event)) {
|
|
542
|
+
conn.receive(frame);
|
|
543
|
+
}
|
|
544
|
+
if (frame.event === "ready") {
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
kernelReady();
|
|
549
|
+
});
|
|
550
|
+
expect(rows()).toEqual(text ? [text] : []);
|
|
551
|
+
},
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
it("keeps a browser-cleared console hidden when the running execution is replayed", async () => {
|
|
466
555
|
const store = createStore();
|
|
467
556
|
const fake = withTransport();
|
|
468
557
|
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
469
558
|
renderConnectionHook(store);
|
|
470
559
|
await started();
|
|
471
560
|
const conn = connection(fake);
|
|
561
|
+
const rows = () =>
|
|
562
|
+
store
|
|
563
|
+
.get(cellRuntimeAtom(SCRATCH_CELL_ID))
|
|
564
|
+
.consoleOutputs.map((row) => row.data);
|
|
472
565
|
await act(async () => conn.open());
|
|
473
566
|
act(() => conn.ready());
|
|
567
|
+
expect(rows()).toEqual(["2\n"]);
|
|
568
|
+
act(() => {
|
|
569
|
+
store.set(clearCellConsoleOutputAtom, { cellId: SCRATCH_CELL_ID });
|
|
570
|
+
conn.receive({ event: "reset", data: {} });
|
|
571
|
+
conn.ready();
|
|
572
|
+
conn.send({
|
|
573
|
+
op: "kernel-ready",
|
|
574
|
+
resumed: true,
|
|
575
|
+
ui_values: {},
|
|
576
|
+
layout: null,
|
|
577
|
+
app_config: { width: "normal" },
|
|
578
|
+
kiosk: false,
|
|
579
|
+
capabilities: {},
|
|
580
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
expect(rows()).toEqual([]);
|
|
584
|
+
act(() =>
|
|
585
|
+
conn.receive({
|
|
586
|
+
event: "console",
|
|
587
|
+
data: {
|
|
588
|
+
console: {
|
|
589
|
+
id: "new-line",
|
|
590
|
+
execution_id: "e7",
|
|
591
|
+
seq: 1,
|
|
592
|
+
name: "stdout",
|
|
593
|
+
text: "after the clear",
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
}),
|
|
597
|
+
);
|
|
598
|
+
expect(rows()).toEqual(["after the clear"]);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
it.each(["browser", "kernel"])(
|
|
602
|
+
"keeps rows cleared by the %s hidden when a prompt is answered",
|
|
603
|
+
async (source) => {
|
|
604
|
+
const store = createStore();
|
|
605
|
+
const fake = withTransport();
|
|
606
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
607
|
+
renderConnectionHook(store);
|
|
608
|
+
await started();
|
|
609
|
+
const conn = connection(fake);
|
|
610
|
+
const cell = cellId("c1");
|
|
611
|
+
const execution = {
|
|
612
|
+
...MockExecutions.completed(cell),
|
|
613
|
+
status: "running",
|
|
614
|
+
completed_at: null,
|
|
615
|
+
outcome: null,
|
|
616
|
+
};
|
|
617
|
+
const first = {
|
|
618
|
+
id: "first",
|
|
619
|
+
seq: 0,
|
|
620
|
+
execution_id: execution.id,
|
|
621
|
+
prompt: "first?",
|
|
622
|
+
password: false,
|
|
623
|
+
status: "answered",
|
|
624
|
+
};
|
|
625
|
+
const second = {
|
|
626
|
+
...first,
|
|
627
|
+
id: "second",
|
|
628
|
+
seq: 1,
|
|
629
|
+
prompt: "second?",
|
|
630
|
+
status: "pending",
|
|
631
|
+
};
|
|
632
|
+
const cleared = {
|
|
633
|
+
op: "console-inputs-cleared",
|
|
634
|
+
cell_id: cell,
|
|
635
|
+
execution_id: execution.id,
|
|
636
|
+
input_ids: [first.id],
|
|
637
|
+
};
|
|
638
|
+
const rows = () => store.get(cellRuntimeAtom(cell)).consoleOutputs;
|
|
639
|
+
await act(async () => conn.open());
|
|
640
|
+
act(() => {
|
|
641
|
+
conn.ready();
|
|
642
|
+
conn.receive({ event: "execution", data: { execution } });
|
|
643
|
+
conn.receive({ event: "input", data: { input: first } });
|
|
644
|
+
conn.receive({ event: "input", data: { input: second } });
|
|
645
|
+
if (source === "browser") {
|
|
646
|
+
store.set(clearCellConsoleOutputAtom, { cellId: cell });
|
|
647
|
+
} else {
|
|
648
|
+
conn.send(cleared);
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
expect(store.get(hasBlockingStdinAtom)).toBe(true);
|
|
652
|
+
expect(rows()).toMatchObject([{ input_id: "second", response: undefined }]);
|
|
653
|
+
act(() =>
|
|
654
|
+
conn.receive({
|
|
655
|
+
event: "input",
|
|
656
|
+
data: { input: { ...second, status: "answered" } },
|
|
657
|
+
}),
|
|
658
|
+
);
|
|
659
|
+
expect(store.get(hasBlockingStdinAtom)).toBe(false);
|
|
660
|
+
expect(rows()).toMatchObject([{ input_id: "second", response: null }]);
|
|
661
|
+
if (source === "browser") {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
act(() => {
|
|
665
|
+
conn.send({
|
|
666
|
+
op: "kernel-ready",
|
|
667
|
+
resumed: true,
|
|
668
|
+
ui_values: {},
|
|
669
|
+
layout: null,
|
|
670
|
+
app_config: { width: "normal" },
|
|
671
|
+
kiosk: false,
|
|
672
|
+
capabilities: {},
|
|
673
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
674
|
+
});
|
|
675
|
+
conn.send(cleared);
|
|
676
|
+
});
|
|
677
|
+
expect(rows()).toMatchObject([{ input_id: "second", response: null }]);
|
|
678
|
+
},
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
it.each(["callback-output", "pdb-output"] as const)(
|
|
682
|
+
"keeps cleared %s writes hidden on replay and shows later identical writes",
|
|
683
|
+
async (op) => {
|
|
684
|
+
const store = createStore();
|
|
685
|
+
const fake = withTransport();
|
|
686
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
687
|
+
renderConnectionHook(store);
|
|
688
|
+
await started();
|
|
689
|
+
const conn = connection(fake);
|
|
690
|
+
const cell = cellId("c1");
|
|
691
|
+
const rows = () =>
|
|
692
|
+
store.get(cellRuntimeAtom(cell)).consoleOutputs.map((row) => row.data);
|
|
693
|
+
const send = (replace: boolean, ...ids: string[]) =>
|
|
694
|
+
conn.send({
|
|
695
|
+
op,
|
|
696
|
+
cell_id: cell,
|
|
697
|
+
replace,
|
|
698
|
+
after_seq: ids.map(() => 0),
|
|
699
|
+
entries: ids.map((command_id) => ({
|
|
700
|
+
command_id,
|
|
701
|
+
channel: "stdout",
|
|
702
|
+
mimetype: "text/plain",
|
|
703
|
+
data: "same",
|
|
704
|
+
timestamp: 1,
|
|
705
|
+
})),
|
|
706
|
+
});
|
|
707
|
+
await act(async () => conn.open());
|
|
708
|
+
act(() => {
|
|
709
|
+
conn.ready();
|
|
710
|
+
send(false, "one");
|
|
711
|
+
store.set(clearCellConsoleOutputAtom, { cellId: cell });
|
|
712
|
+
});
|
|
713
|
+
expect(rows()).toEqual([]);
|
|
714
|
+
act(() => {
|
|
715
|
+
conn.receive({ event: "reset", data: {} });
|
|
716
|
+
conn.ready();
|
|
717
|
+
conn.send({
|
|
718
|
+
op: "kernel-ready",
|
|
719
|
+
resumed: true,
|
|
720
|
+
ui_values: {},
|
|
721
|
+
layout: null,
|
|
722
|
+
app_config: { width: "normal" },
|
|
723
|
+
kiosk: false,
|
|
724
|
+
capabilities: {},
|
|
725
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
726
|
+
});
|
|
727
|
+
send(true, "one", "two");
|
|
728
|
+
});
|
|
729
|
+
expect(rows()).toEqual(["same"]);
|
|
730
|
+
act(() => {
|
|
731
|
+
store.set(clearCellConsoleOutputAtom, { cellId: cell });
|
|
732
|
+
// The host cleared its transcript while this editor was disconnected.
|
|
733
|
+
send(true, "three");
|
|
734
|
+
});
|
|
735
|
+
expect(rows()).toEqual(["same"]);
|
|
736
|
+
},
|
|
737
|
+
);
|
|
738
|
+
|
|
739
|
+
it.each(["live", "replay"])(
|
|
740
|
+
"interleaves %s command output with untimed execution items",
|
|
741
|
+
async (mode) => {
|
|
742
|
+
const store = createStore();
|
|
743
|
+
const fake = withTransport();
|
|
744
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
745
|
+
renderConnectionHook(store);
|
|
746
|
+
await started();
|
|
747
|
+
const conn = connection(fake);
|
|
748
|
+
const id = cellId("c1");
|
|
749
|
+
const execution = MockExecutions.completed(id, { id: "mixed-writes" });
|
|
750
|
+
const line = (seq: number, text: string) => ({
|
|
751
|
+
event: "console",
|
|
752
|
+
data: {
|
|
753
|
+
console: {
|
|
754
|
+
id: `line-${seq}`,
|
|
755
|
+
execution_id: execution.id,
|
|
756
|
+
seq,
|
|
757
|
+
name: "stdout",
|
|
758
|
+
text,
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
});
|
|
762
|
+
const rows = () =>
|
|
763
|
+
store.get(cellRuntimeAtom(id)).consoleOutputs.map((row) => row.data);
|
|
764
|
+
await act(async () => conn.open());
|
|
765
|
+
act(() => {
|
|
766
|
+
for (const event of fixtureMessages("notebook-events.sse")) {
|
|
767
|
+
if (event.event === "ready") {
|
|
768
|
+
conn.receive({ event: "execution", data: { execution } });
|
|
769
|
+
conn.receive(line(0, "A"));
|
|
770
|
+
if (mode === "replay") {
|
|
771
|
+
conn.receive(line(1, "C"));
|
|
772
|
+
}
|
|
773
|
+
conn.receive(event);
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
conn.receive(event);
|
|
777
|
+
}
|
|
778
|
+
conn.send({
|
|
779
|
+
op: "callback-output",
|
|
780
|
+
cell_id: id,
|
|
781
|
+
replace: mode === "replay",
|
|
782
|
+
entries: [
|
|
783
|
+
{
|
|
784
|
+
channel: "stdout",
|
|
785
|
+
mimetype: "text/plain",
|
|
786
|
+
data: "B",
|
|
787
|
+
timestamp: 2_000_000_000,
|
|
788
|
+
},
|
|
789
|
+
],
|
|
790
|
+
after_seq: [0],
|
|
791
|
+
});
|
|
792
|
+
if (mode === "live") {
|
|
793
|
+
conn.receive(line(1, "C"));
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
expect(rows()).toEqual(["ABC"]);
|
|
797
|
+
act(() => {
|
|
798
|
+
conn.receive({ event: "console.removed", data: { id: "line-0" } });
|
|
799
|
+
conn.receive({ event: "console.removed", data: { id: "line-1" } });
|
|
800
|
+
conn.receive(line(2, "D"));
|
|
801
|
+
});
|
|
802
|
+
expect(rows()).toEqual(["BD"]);
|
|
803
|
+
},
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
it("replays execution, debugger, and callback output independently", async () => {
|
|
807
|
+
const store = createStore();
|
|
808
|
+
const fake = withTransport();
|
|
809
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
810
|
+
renderConnectionHook(store);
|
|
811
|
+
await started();
|
|
812
|
+
const conn = connection(fake);
|
|
474
813
|
const id = cellId("c1");
|
|
475
|
-
const
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
814
|
+
const execution = MockExecutions.failed(id, {}, { id: "failed-cell" });
|
|
815
|
+
const line = {
|
|
816
|
+
id: "line",
|
|
817
|
+
execution_id: execution.id,
|
|
818
|
+
seq: 0,
|
|
819
|
+
name: "stdout",
|
|
820
|
+
text: "before pdb",
|
|
821
|
+
};
|
|
822
|
+
const input = {
|
|
823
|
+
id: "request",
|
|
824
|
+
execution_id: execution.id,
|
|
825
|
+
seq: 1,
|
|
826
|
+
prompt: "secret?",
|
|
827
|
+
password: true,
|
|
828
|
+
status: "answered",
|
|
829
|
+
};
|
|
830
|
+
const afterExecution = Date.parse(execution.completed_at!) / 1000;
|
|
831
|
+
const session = {
|
|
832
|
+
op: "pdb-output",
|
|
833
|
+
cell_id: id,
|
|
834
|
+
entries: [
|
|
835
|
+
{
|
|
836
|
+
channel: "stdout",
|
|
837
|
+
mimetype: "text/plain",
|
|
838
|
+
data: "pdb reply",
|
|
839
|
+
timestamp: afterExecution + 1,
|
|
840
|
+
},
|
|
841
|
+
],
|
|
842
|
+
replace: true,
|
|
843
|
+
};
|
|
844
|
+
const runtime = () => store.get(cellRuntimeAtom(id));
|
|
845
|
+
await act(async () => conn.open());
|
|
846
|
+
act(() => {
|
|
847
|
+
for (const frame of fixtureMessages("notebook-events.sse")) {
|
|
848
|
+
if (frame.event === "ready") {
|
|
849
|
+
conn.receive({ event: "execution", data: { execution } });
|
|
850
|
+
conn.receive({ event: "console", data: { console: line } });
|
|
851
|
+
conn.receive({ event: "input", data: { input } });
|
|
852
|
+
conn.receive(frame);
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
conn.receive(frame);
|
|
856
|
+
}
|
|
857
|
+
conn.send({
|
|
858
|
+
op: "kernel-ready",
|
|
859
|
+
resumed: true,
|
|
860
|
+
ui_values: {},
|
|
861
|
+
layout: null,
|
|
862
|
+
app_config: { width: "normal" },
|
|
863
|
+
kiosk: false,
|
|
864
|
+
capabilities: {},
|
|
865
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
866
|
+
});
|
|
867
|
+
conn.send({
|
|
868
|
+
...session,
|
|
869
|
+
entries: [
|
|
870
|
+
session.entries[0],
|
|
871
|
+
{
|
|
872
|
+
...session.entries[0],
|
|
873
|
+
data: "next pdb reply",
|
|
874
|
+
timestamp: afterExecution + 3,
|
|
875
|
+
},
|
|
876
|
+
],
|
|
877
|
+
});
|
|
878
|
+
conn.send({
|
|
879
|
+
...session,
|
|
880
|
+
op: "callback-output",
|
|
881
|
+
entries: [
|
|
882
|
+
{
|
|
883
|
+
...session.entries[0],
|
|
884
|
+
data: "callback reply",
|
|
885
|
+
timestamp: afterExecution + 2,
|
|
886
|
+
},
|
|
887
|
+
],
|
|
888
|
+
});
|
|
889
|
+
conn.send({
|
|
890
|
+
...session,
|
|
891
|
+
entries: [
|
|
892
|
+
session.entries[0],
|
|
893
|
+
{
|
|
894
|
+
...session.entries[0],
|
|
895
|
+
data: "next pdb reply",
|
|
896
|
+
timestamp: afterExecution + 3,
|
|
897
|
+
},
|
|
898
|
+
],
|
|
899
|
+
});
|
|
481
900
|
});
|
|
901
|
+
expect(runtime().consoleOutputs.map((v) => v.data)).toEqual([
|
|
902
|
+
"before pdb",
|
|
903
|
+
"secret?",
|
|
904
|
+
"pdb replycallback replynext pdb reply",
|
|
905
|
+
]);
|
|
906
|
+
expect(runtime().consoleOutputs[1].response).toBeNull();
|
|
482
907
|
act(() =>
|
|
483
908
|
conn.receive({
|
|
484
|
-
event: "
|
|
485
|
-
|
|
486
|
-
data: { execution: record },
|
|
909
|
+
event: "console",
|
|
910
|
+
data: { console: { ...line, text: "replaced" } },
|
|
487
911
|
}),
|
|
488
912
|
);
|
|
489
|
-
expect(
|
|
490
|
-
|
|
491
|
-
|
|
913
|
+
expect(runtime().consoleOutputs.map((v) => v.data)).toEqual([
|
|
914
|
+
"replaced",
|
|
915
|
+
"secret?",
|
|
916
|
+
"pdb replycallback replynext pdb reply",
|
|
917
|
+
]);
|
|
918
|
+
act(() => conn.receive({ event: "console.removed", data: { id: line.id } }));
|
|
919
|
+
await vi.waitFor(() =>
|
|
920
|
+
expect(runtime().consoleOutputs.map((v) => v.data)).toEqual([
|
|
921
|
+
"secret?",
|
|
922
|
+
"pdb replycallback replynext pdb reply",
|
|
923
|
+
]),
|
|
924
|
+
);
|
|
492
925
|
});
|
|
493
926
|
|
|
494
|
-
it(
|
|
927
|
+
it.each([
|
|
928
|
+
"live removal",
|
|
929
|
+
"snapshot without an execution",
|
|
930
|
+
"snapshot with an empty execution",
|
|
931
|
+
])("discards the previous execution console on %s", async (transition) => {
|
|
495
932
|
const store = createStore();
|
|
496
933
|
const fake = withTransport();
|
|
497
934
|
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
498
935
|
renderConnectionHook(store);
|
|
499
936
|
await started();
|
|
500
937
|
const conn = connection(fake);
|
|
938
|
+
const cell = cellId("c1");
|
|
939
|
+
const execution = MockExecutions.completed(cell, { id: "previous-run" });
|
|
940
|
+
const runtime = () => store.get(cellRuntimeAtom(cell));
|
|
501
941
|
await act(async () => conn.open());
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
942
|
+
act(() => {
|
|
943
|
+
conn.ready();
|
|
944
|
+
conn.receive({ event: "execution", data: { execution } });
|
|
945
|
+
conn.receive({
|
|
946
|
+
event: "console",
|
|
947
|
+
data: {
|
|
948
|
+
console: {
|
|
949
|
+
id: "old-line",
|
|
950
|
+
execution_id: execution.id,
|
|
951
|
+
seq: 0,
|
|
952
|
+
name: "stdout",
|
|
953
|
+
text: "previous run",
|
|
954
|
+
},
|
|
955
|
+
},
|
|
956
|
+
});
|
|
957
|
+
conn.send({
|
|
958
|
+
op: "callback-output",
|
|
959
|
+
cell_id: cell,
|
|
960
|
+
entries: [
|
|
961
|
+
{
|
|
962
|
+
channel: "stdout",
|
|
963
|
+
mimetype: "text/plain",
|
|
964
|
+
data: "callback",
|
|
965
|
+
timestamp: 1,
|
|
966
|
+
},
|
|
967
|
+
],
|
|
968
|
+
});
|
|
969
|
+
});
|
|
970
|
+
expect(runtime().consoleOutputs.map((output) => output.data)).toEqual([
|
|
971
|
+
"callbackprevious run",
|
|
972
|
+
]);
|
|
973
|
+
act(() => {
|
|
974
|
+
if (transition === "live removal") {
|
|
975
|
+
conn.receive({ event: "execution.removed", data: { id: execution.id } });
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
conn.receive({ event: "reset", data: {} });
|
|
979
|
+
for (const event of fixtureMessages("notebook-events.sse")) {
|
|
980
|
+
if (
|
|
981
|
+
event.event === "ready" &&
|
|
982
|
+
transition === "snapshot with an empty execution"
|
|
983
|
+
) {
|
|
984
|
+
conn.receive({
|
|
985
|
+
event: "execution",
|
|
986
|
+
data: { execution: { ...execution, id: "replacement" } },
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
conn.receive(event);
|
|
990
|
+
if (event.event === "ready") {
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
expect(runtime().consoleOutputs.map((output) => output.data)).toEqual([
|
|
996
|
+
"callback",
|
|
997
|
+
]);
|
|
511
998
|
});
|
|
512
999
|
|
|
513
|
-
it("clears the debugger prompt and
|
|
1000
|
+
it("clears the private debugger prompt and transcript when editing moves to another tab", async () => {
|
|
514
1001
|
const store = createStore();
|
|
515
1002
|
const fake = withTransport();
|
|
516
1003
|
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
@@ -521,24 +1008,23 @@ it("clears the debugger prompt and private transcript when editing moves to anot
|
|
|
521
1008
|
const entry = {
|
|
522
1009
|
channel: "stdout",
|
|
523
1010
|
mimetype: "text/plain",
|
|
524
|
-
data: "
|
|
1011
|
+
data: "public callback",
|
|
525
1012
|
timestamp: 1,
|
|
526
1013
|
};
|
|
527
1014
|
await act(async () => conn.open());
|
|
528
1015
|
act(() => {
|
|
529
1016
|
conn.ready();
|
|
530
|
-
conn.send({ op: "
|
|
1017
|
+
conn.send({ op: "callback-output", cell_id: id, entries: [entry] });
|
|
531
1018
|
conn.send({
|
|
532
1019
|
op: "pdb-output",
|
|
533
1020
|
cell_id: id,
|
|
534
|
-
entries: [{ ...entry, data: "private debugger" }],
|
|
1021
|
+
entries: [{ ...entry, data: "private debugger", timestamp: 2 }],
|
|
535
1022
|
});
|
|
536
1023
|
conn.send({ op: "pdb-input", cell_id: id, input_id: "pending" });
|
|
537
1024
|
});
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
]);
|
|
1025
|
+
const rows = () =>
|
|
1026
|
+
store.get(cellRuntimeAtom(id)).consoleOutputs.map((row) => row.data);
|
|
1027
|
+
expect(rows()?.join("")).toContain("private debugger");
|
|
542
1028
|
expect(store.get(pendingPdbInputAtom)?.inputId).toBe("pending");
|
|
543
1029
|
act(() =>
|
|
544
1030
|
conn.send({
|
|
@@ -546,16 +1032,96 @@ it("clears the debugger prompt and private transcript when editing moves to anot
|
|
|
546
1032
|
consumer_capabilities: { edit: false, interact: true },
|
|
547
1033
|
}),
|
|
548
1034
|
);
|
|
549
|
-
expect(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
1035
|
+
expect(rows()).toEqual(["public callback"]);
|
|
1036
|
+
act(() => {
|
|
1037
|
+
conn.send({ op: "pdb-output", cell_id: id, entries: [entry] });
|
|
1038
|
+
conn.send({ op: "callback-output", cell_id: id, entries: [] });
|
|
1039
|
+
});
|
|
1040
|
+
expect(rows()).toEqual([]);
|
|
553
1041
|
expect(
|
|
554
1042
|
store.get(notebookAtom).cellLogs.map((log) => log.message),
|
|
555
1043
|
).not.toContain("private debugger");
|
|
556
1044
|
expect(store.get(pendingPdbInputAtom)).toBeNull();
|
|
557
1045
|
});
|
|
558
1046
|
|
|
1047
|
+
it("collects exported files from execution values and public callback media", async () => {
|
|
1048
|
+
const store = createStore();
|
|
1049
|
+
const fake = withTransport();
|
|
1050
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
1051
|
+
renderConnectionHook(store);
|
|
1052
|
+
await started();
|
|
1053
|
+
const conn = connection(fake);
|
|
1054
|
+
await act(async () => conn.open());
|
|
1055
|
+
act(() => conn.ready());
|
|
1056
|
+
const id = cellId("c1");
|
|
1057
|
+
const file = "/@file/stream-image.png";
|
|
1058
|
+
const callbackFile = "/@file/callback-image.png";
|
|
1059
|
+
const previousFile = "/@file/previous-callback.png";
|
|
1060
|
+
const debuggerFile = "/@file/debugger-image.png";
|
|
1061
|
+
const record = MockExecutions.completed(id, {
|
|
1062
|
+
outcome: {
|
|
1063
|
+
kind: "value",
|
|
1064
|
+
display: { mimetype: "text/html", data: `<img src="${file}">` },
|
|
1065
|
+
},
|
|
1066
|
+
});
|
|
1067
|
+
act(() => {
|
|
1068
|
+
conn.receive({
|
|
1069
|
+
event: "execution",
|
|
1070
|
+
id: "updated",
|
|
1071
|
+
data: { execution: record },
|
|
1072
|
+
});
|
|
1073
|
+
const media = (path: string) => ({
|
|
1074
|
+
channel: "media",
|
|
1075
|
+
mimetype: "text/html",
|
|
1076
|
+
data: `<img src="${path}">`,
|
|
1077
|
+
timestamp: 1,
|
|
1078
|
+
});
|
|
1079
|
+
conn.send({
|
|
1080
|
+
op: "callback-output",
|
|
1081
|
+
cell_id: id,
|
|
1082
|
+
entries: [media(previousFile)],
|
|
1083
|
+
});
|
|
1084
|
+
conn.send({
|
|
1085
|
+
op: "callback-output",
|
|
1086
|
+
cell_id: id,
|
|
1087
|
+
entries: [media(callbackFile)],
|
|
1088
|
+
replace: true,
|
|
1089
|
+
});
|
|
1090
|
+
conn.send({
|
|
1091
|
+
op: "pdb-output",
|
|
1092
|
+
cell_id: id,
|
|
1093
|
+
entries: [media(debuggerFile)],
|
|
1094
|
+
});
|
|
1095
|
+
});
|
|
1096
|
+
expect(VirtualFileTracker.INSTANCE.filenames()).toEqual(
|
|
1097
|
+
expect.arrayContaining([file, callbackFile]),
|
|
1098
|
+
);
|
|
1099
|
+
expect(VirtualFileTracker.INSTANCE.filenames()).not.toContain(debuggerFile);
|
|
1100
|
+
expect(VirtualFileTracker.INSTANCE.filenames()).not.toContain(previousFile);
|
|
1101
|
+
act(() => conn.send({ op: "remove-ui-elements", cell_id: id }));
|
|
1102
|
+
expect(VirtualFileTracker.INSTANCE.filenames()).not.toContain(file);
|
|
1103
|
+
expect(VirtualFileTracker.INSTANCE.filenames()).not.toContain(callbackFile);
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
it("opens and closes the debugger prompt on the failed cell", async () => {
|
|
1107
|
+
const store = createStore();
|
|
1108
|
+
const fake = withTransport();
|
|
1109
|
+
vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
|
|
1110
|
+
renderConnectionHook(store);
|
|
1111
|
+
await started();
|
|
1112
|
+
const conn = connection(fake);
|
|
1113
|
+
await act(async () => conn.open());
|
|
1114
|
+
const id = cellId("failed");
|
|
1115
|
+
act(() => conn.send({ op: "pdb-input", cell_id: id, input_id: "p1" }));
|
|
1116
|
+
expect(store.get(pendingPdbInputAtom)).toEqual({ cellId: id, inputId: "p1" });
|
|
1117
|
+
act(() => conn.receive({ event: "reset", data: {} }));
|
|
1118
|
+
expect(store.get(pendingPdbInputAtom)).toBeNull();
|
|
1119
|
+
act(() => conn.send({ op: "pdb-input", cell_id: id, input_id: "p2" }));
|
|
1120
|
+
expect(store.get(pendingPdbInputAtom)?.inputId).toBe("p2");
|
|
1121
|
+
act(() => conn.send({ op: "pdb-input", cell_id: id, input_id: null }));
|
|
1122
|
+
expect(store.get(pendingPdbInputAtom)).toBeNull();
|
|
1123
|
+
});
|
|
1124
|
+
|
|
559
1125
|
it("replaces gutter breakpoints with the session's replayed state", async () => {
|
|
560
1126
|
const store = createStore();
|
|
561
1127
|
const staleCell = cellId("stale");
|