Skip to content

Commit 99d4e00

Browse files
committed
feat(storybook): add a process-isolated block-memo comparison
- BlockMemoCompareIsolated renders each side in a cross-site iframe with a THREE-WAY split — host on localhost, memo side on 127.0.0.1, legacy side on [::1] — so Chrome's site isolation gives every party its own renderer process: no shared main thread, GC, or frame loop between the sides, and fps / slow frames / long tasks become genuinely per-side metrics. - three-way is load-bearing, not decoration: with a two-way split the side sharing the host page's process absorbs the host UI's work, measured as a stable ~330 ms penalty (~60% of a small-payload run) whose sign flipped exactly when the side hosts were swapped. [::1] availability is probed at mount with a degraded, explicitly flagged two-way fallback; the host also quiesces during runs (snapshots buffer in refs, flushed at 500 ms) so its own rendering stays out of the measurement window. - BlockMemoSide is the addressable single-side story (configured via bmcMode/bmcSpy/bmcScheme URL params, driven over postMessage); isolatedProtocol.ts documents the message contract and the cross-site rationale. The verdict/summary/history UI is shared with the same-page story — keep both: same-page is the fairest JS-layer A/B, isolated answers per-side browser-level questions, and disagreement between them measures the coupling itself.
1 parent 73c8eba commit 99d4e00

4 files changed

Lines changed: 768 additions & 0 deletions

File tree

packages/core/stories/AIMarkdown.stories.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { withThemedBackground } from './decorators';
77
import { useStreamedContent } from './streamingHelpers';
88
import { StreamingPlayground } from './streaming/StreamingPlayground';
99
import { BlockMemoComparison } from './streaming/BlockMemoComparison';
10+
import { IsolatedComparison } from './streaming/IsolatedComparison';
11+
import { IsolatedSide } from './streaming/IsolatedSide';
1012
import { DEFAULT_PAYLOAD } from './streaming/scenarios';
1113
import { getStreamingTheme } from './streaming/theme';
1214

@@ -188,6 +190,58 @@ export const BlockMemoCompare: Story = {
188190
},
189191
};
190192

193+
/**
194+
* Process-ISOLATED variant of {@link BlockMemoCompare}: each side runs in a
195+
* cross-site iframe (`localhost` vs `127.0.0.1`), which Chrome's Site
196+
* Isolation places in separate renderer processes — no shared main thread,
197+
* GC, or frame loop between the sides, so fps / slow frames / long tasks
198+
* become genuinely per-side. See IsolatedComparison.tsx for the full
199+
* tradeoff notes. Keep both stories: same-page = fairest JS-layer A/B;
200+
* isolated = the only shape that answers per-side browser-level questions.
201+
*/
202+
export const BlockMemoCompareIsolated: Story = {
203+
args: {
204+
content: DEFAULT_PAYLOAD,
205+
},
206+
argTypes: {
207+
content: {
208+
control: 'text',
209+
description: 'Markdown payload streamed by every scenario. Edit to test your own content.',
210+
},
211+
streaming: { table: { disable: true } },
212+
},
213+
parameters: {
214+
controls: { exclude: ['streaming'] },
215+
layout: 'fullscreen',
216+
},
217+
render: (args, context) => {
218+
const currentTheme = context.globals.theme === 'dark' ? 'dark' : 'light';
219+
return (
220+
<IsolatedComparison
221+
colorScheme={currentTheme}
222+
initialScenario="randomTokens"
223+
payload={args.content ?? DEFAULT_PAYLOAD}
224+
/>
225+
);
226+
},
227+
};
228+
229+
/**
230+
* One SIDE of {@link BlockMemoCompareIsolated} — loaded by that story's
231+
* iframes with config in the URL (`bmcMode` / `bmcSpy` / `bmcScheme`).
232+
* Also usable standalone to profile a single render path in isolation.
233+
*/
234+
export const BlockMemoSide: Story = {
235+
args: {
236+
content: '',
237+
},
238+
parameters: {
239+
controls: { disable: true },
240+
layout: 'fullscreen',
241+
},
242+
render: () => <IsolatedSide />,
243+
};
244+
191245
export const CJKRenderErrorFix: Story = {
192246
args: {
193247
content:

0 commit comments

Comments
 (0)