@buffcore/admin-shell 0.8.43 → 0.8.45

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.
Files changed (157) hide show
  1. package/dist/components/Markdown.d.ts +9 -3
  2. package/dist/components/Markdown.js +84 -34
  3. package/dist/components/Sheet.d.ts +5 -1
  4. package/dist/components/Sheet.js +8 -2
  5. package/dist/components/TextArea.d.ts +3 -1
  6. package/dist/components/TextArea.js +3 -3
  7. package/dist/components/icons.d.ts +1 -0
  8. package/dist/components/icons.js +1 -0
  9. package/dist/workbench/app/ServedPrototype.d.ts +2 -0
  10. package/dist/workbench/app/ServedPrototype.js +11 -1
  11. package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
  12. package/dist/workbench/app/actions.d.ts +4 -2
  13. package/dist/workbench/app/actions.js +9 -4
  14. package/dist/workbench/app/brief-short.d.ts +14 -0
  15. package/dist/workbench/app/brief-short.js +103 -0
  16. package/dist/workbench/app/chat-session.d.ts +5 -5
  17. package/dist/workbench/app/chat-session.js +8 -3
  18. package/dist/workbench/app/chat.d.ts +17 -4
  19. package/dist/workbench/app/chat.js +9 -4
  20. package/dist/workbench/app/frame.js +5 -1
  21. package/dist/workbench/app/loop.js +2 -18
  22. package/dist/workbench/app/pages.js +10 -2
  23. package/dist/workbench/app/prototype.js +3 -0
  24. package/dist/workbench/app/test/loop-fixture.d.ts +13 -1
  25. package/dist/workbench/app/useStudio.d.ts +2 -1
  26. package/dist/workbench/studio/frame/AgentPanel.js +24 -1
  27. package/dist/workbench/studio/frame/Composer.js +13 -10
  28. package/dist/workbench/studio/frame/PanelList.js +1 -1
  29. package/dist/workbench/studio/frame/Segmented.d.ts +3 -1
  30. package/dist/workbench/studio/frame/Segmented.js +4 -3
  31. package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
  32. package/dist/workbench/studio/frame/StudioFrame.js +7 -6
  33. package/dist/workbench/studio/frame/StudioRegions.js +4 -1
  34. package/dist/workbench/studio/frame/TurnControls.d.ts +2 -1
  35. package/dist/workbench/studio/frame/TurnControls.js +4 -1
  36. package/dist/workbench/studio/frame/layout.d.ts +2 -0
  37. package/dist/workbench/studio/frame/layout.js +2 -0
  38. package/dist/workbench/studio/frame/panelControls.d.ts +21 -1
  39. package/dist/workbench/studio/frame/scrollbars.d.ts +1 -0
  40. package/dist/workbench/studio/frame/scrollbars.js +12 -0
  41. package/dist/workbench/studio/frame/useTurnDraft.d.ts +22 -2
  42. package/dist/workbench/studio/frame/useTurnDraft.js +48 -16
  43. package/dist/workbench/studio/i18n/frame.en.d.ts +3 -0
  44. package/dist/workbench/studio/i18n/frame.en.js +4 -1
  45. package/dist/workbench/studio/i18n/frame.es.json +4 -1
  46. package/dist/workbench/studio/i18n/index.js +6 -0
  47. package/dist/workbench/studio/i18n/loop.en.d.ts +11 -38
  48. package/dist/workbench/studio/i18n/loop.en.js +11 -38
  49. package/dist/workbench/studio/i18n/loop.es.json +11 -38
  50. package/dist/workbench/studio/i18n/marks.en.d.ts +41 -0
  51. package/dist/workbench/studio/i18n/marks.en.js +42 -0
  52. package/dist/workbench/studio/i18n/marks.es.json +40 -0
  53. package/dist/workbench/studio/i18n/start.en.d.ts +5 -0
  54. package/dist/workbench/studio/i18n/start.en.js +7 -2
  55. package/dist/workbench/studio/i18n/start.es.json +7 -2
  56. package/dist/workbench/studio/i18n/workspace.en.d.ts +45 -0
  57. package/dist/workbench/studio/i18n/workspace.en.js +46 -0
  58. package/dist/workbench/studio/i18n/workspace.es.json +44 -0
  59. package/dist/workbench/studio/loop/BriefDocument.d.ts +9 -6
  60. package/dist/workbench/studio/loop/BriefDocument.js +48 -76
  61. package/dist/workbench/studio/loop/BriefLists.d.ts +11 -0
  62. package/dist/workbench/studio/loop/BriefLists.js +42 -0
  63. package/dist/workbench/studio/loop/BriefPage.d.ts +6 -2
  64. package/dist/workbench/studio/loop/BriefPage.js +32 -4
  65. package/dist/workbench/studio/loop/BriefReading.d.ts +19 -0
  66. package/dist/workbench/studio/loop/BriefReading.js +22 -0
  67. package/dist/workbench/studio/loop/BriefSection.d.ts +22 -0
  68. package/dist/workbench/studio/loop/BriefSection.js +47 -0
  69. package/dist/workbench/studio/loop/BriefWho.d.ts +6 -0
  70. package/dist/workbench/studio/loop/BriefWho.js +56 -0
  71. package/dist/workbench/studio/loop/CanvasBar.d.ts +0 -1
  72. package/dist/workbench/studio/loop/CanvasBar.js +2 -3
  73. package/dist/workbench/studio/loop/ConsoleFrame.d.ts +13 -0
  74. package/dist/workbench/studio/loop/ConsoleFrame.js +29 -0
  75. package/dist/workbench/studio/loop/NotThisCard.d.ts +6 -1
  76. package/dist/workbench/studio/loop/NotThisCard.js +28 -20
  77. package/dist/workbench/studio/loop/ProtoJourneys.d.ts +1 -8
  78. package/dist/workbench/studio/loop/ProtoJourneys.js +0 -14
  79. package/dist/workbench/studio/loop/PrototypeApp.d.ts +12 -1
  80. package/dist/workbench/studio/loop/PrototypeApp.js +30 -13
  81. package/dist/workbench/studio/loop/PrototypeAttempt.d.ts +2 -1
  82. package/dist/workbench/studio/loop/PrototypeAttempt.js +94 -29
  83. package/dist/workbench/studio/loop/PrototypePage.d.ts +4 -2
  84. package/dist/workbench/studio/loop/PrototypePage.js +25 -1
  85. package/dist/workbench/studio/loop/PrototypePreview.d.ts +35 -6
  86. package/dist/workbench/studio/loop/PrototypePreview.js +127 -76
  87. package/dist/workbench/studio/loop/PrototypePreviewSlot.d.ts +13 -0
  88. package/dist/workbench/studio/loop/PrototypePreviewSlot.js +23 -0
  89. package/dist/workbench/studio/loop/PrototypeScenes.d.ts +1 -1
  90. package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
  91. package/dist/workbench/studio/loop/StudioLoop.d.ts +7 -2
  92. package/dist/workbench/studio/loop/StudioLoop.js +4 -10
  93. package/dist/workbench/studio/loop/WorkspaceBar.d.ts +15 -0
  94. package/dist/workbench/studio/loop/WorkspaceBar.js +52 -0
  95. package/dist/workbench/studio/loop/WorkspaceJourneys.d.ts +17 -0
  96. package/dist/workbench/studio/loop/WorkspaceJourneys.js +99 -0
  97. package/dist/workbench/studio/loop/WorkspaceLeft.d.ts +14 -0
  98. package/dist/workbench/studio/loop/WorkspaceLeft.js +42 -0
  99. package/dist/workbench/studio/loop/WorkspaceStage.d.ts +24 -0
  100. package/dist/workbench/studio/loop/WorkspaceStage.js +142 -0
  101. package/dist/workbench/studio/loop/WorkspaceSteps.d.ts +20 -0
  102. package/dist/workbench/studio/loop/WorkspaceSteps.js +96 -0
  103. package/dist/workbench/studio/loop/moments.js +0 -3
  104. package/dist/workbench/studio/loop/prototype-bridge.d.ts +8 -0
  105. package/dist/workbench/studio/loop/prototype-bridge.js +16 -0
  106. package/dist/workbench/studio/loop/prototype-document.d.ts +9 -0
  107. package/dist/workbench/studio/loop/prototype-document.js +90 -2
  108. package/dist/workbench/studio/loop/prototype-part.d.ts +43 -0
  109. package/dist/workbench/studio/loop/prototype-part.js +104 -0
  110. package/dist/workbench/studio/loop/types.d.ts +26 -26
  111. package/dist/workbench/studio/loop/types.js +0 -3
  112. package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +6 -1
  113. package/dist/workbench/studio/loop/usePrototypeFrame.js +4 -0
  114. package/dist/workbench/studio/loop/workspace-journeys.d.ts +22 -0
  115. package/dist/workbench/studio/loop/workspace-journeys.js +63 -0
  116. package/dist/workbench/studio/loop/workspace-state.d.ts +94 -0
  117. package/dist/workbench/studio/loop/workspace-state.js +50 -0
  118. package/dist/workbench/studio/marks/ChangeList.d.ts +7 -0
  119. package/dist/workbench/studio/marks/ChangeList.js +70 -0
  120. package/dist/workbench/studio/marks/MarkHint.d.ts +18 -0
  121. package/dist/workbench/studio/marks/MarkHint.js +58 -0
  122. package/dist/workbench/studio/marks/MarkNumber.d.ts +6 -0
  123. package/dist/workbench/studio/marks/MarkNumber.js +24 -0
  124. package/dist/workbench/studio/marks/MarksLayer.d.ts +15 -0
  125. package/dist/workbench/studio/marks/MarksLayer.js +144 -0
  126. package/dist/workbench/studio/marks/PinNote.d.ts +13 -0
  127. package/dist/workbench/studio/marks/PinNote.js +49 -0
  128. package/dist/workbench/studio/marks/QueuedChanges.d.ts +6 -0
  129. package/dist/workbench/studio/marks/QueuedChanges.js +51 -0
  130. package/dist/workbench/studio/marks/WorkspaceMarks.d.ts +15 -0
  131. package/dist/workbench/studio/marks/WorkspaceMarks.js +67 -0
  132. package/dist/workbench/studio/marks/marks-message.d.ts +13 -0
  133. package/dist/workbench/studio/marks/marks-message.js +93 -0
  134. package/dist/workbench/studio/marks/marks.d.ts +105 -0
  135. package/dist/workbench/studio/marks/marks.js +133 -0
  136. package/dist/workbench/studio/marks/useMarking.d.ts +36 -0
  137. package/dist/workbench/studio/marks/useMarking.js +111 -0
  138. package/dist/workbench/studio/marks/useSendMarks.d.ts +18 -0
  139. package/dist/workbench/studio/marks/useSendMarks.js +80 -0
  140. package/dist/workbench/studio/types.d.ts +2 -0
  141. package/dist/workbench/studio/work/StudioLater.js +0 -1
  142. package/dist/workbench/studio/work/work-test-data.d.ts +6 -0
  143. package/package.json +6 -6
  144. package/dist/workbench/studio/loop/FsPlan.d.ts +0 -7
  145. package/dist/workbench/studio/loop/FsPlan.js +0 -64
  146. package/dist/workbench/studio/loop/FsStage.d.ts +0 -6
  147. package/dist/workbench/studio/loop/FsStage.js +0 -74
  148. package/dist/workbench/studio/loop/FsToolbar.d.ts +0 -6
  149. package/dist/workbench/studio/loop/FsToolbar.js +0 -61
  150. package/dist/workbench/studio/loop/FullScreen.d.ts +0 -5
  151. package/dist/workbench/studio/loop/FullScreen.js +0 -89
  152. package/dist/workbench/studio/loop/PrototypePreviewMenus.d.ts +0 -18
  153. package/dist/workbench/studio/loop/PrototypePreviewMenus.js +0 -75
  154. package/dist/workbench/studio/loop/PrototypePreviewToolbar.d.ts +0 -27
  155. package/dist/workbench/studio/loop/PrototypePreviewToolbar.js +0 -52
  156. package/dist/workbench/studio/loop/fsViews.d.ts +0 -12
  157. package/dist/workbench/studio/loop/fsViews.js +0 -6
@@ -1,7 +1,7 @@
1
1
  import type { Level } from '../types.ts';
2
2
  import type { QuestionControls } from './QuestionReply.tsx';
3
3
  import { type StepDraft } from './SaveStep.tsx';
4
- import type { BriefDoc, LoopSample } from './types.ts';
4
+ import type { BriefDoc, BriefShort, LoopSample } from './types.ts';
5
5
  export interface BriefSample {
6
6
  product: {
7
7
  name: string;
@@ -27,6 +27,10 @@ interface BriefPageProps {
27
27
  notThis?: readonly string[];
28
28
  notThisTyping?: string;
29
29
  onAddNot?: (line: string) => void;
30
+ /** Asks the agent to change a line of plan/not-this.md. */
31
+ onEditNot?: (line: string, to: string) => void;
32
+ /** A section open to read at the start (a scene or a test). */
33
+ reading?: BriefShort | 'whole';
30
34
  }
31
- export declare function BriefPage({ sample, level, saved, onNext, onAction, onAnswer, questionControls, draft, notThis, notThisTyping, onAddNot, }: BriefPageProps): import("react").JSX.Element;
35
+ export declare function BriefPage({ sample, level, saved, onNext, onAction, onAnswer, questionControls, draft, notThis, notThisTyping, onAddNot, onEditNot, reading, }: BriefPageProps): import("react").JSX.Element;
32
36
  export {};
@@ -1,18 +1,46 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useT } from '@buffcore/i18n/react';
3
+ import { useState } from 'react';
3
4
  import { Badge } from '../../../components/Badge.js';
4
5
  import { Page } from '../../../components/Page.js';
5
6
  import { Place } from '../frame/Place.js';
6
7
  import { BriefDocument } from './BriefDocument.js';
7
8
  import { BriefSide } from './BriefQuestions.js';
8
- import { NotThisCard } from './NotThisCard.js';
9
- import { Path, TwoColumns } from './parts.js';
9
+ import { BriefReading } from './BriefReading.js';
10
+ import { Path } from './parts.js';
10
11
  import { ReasonButton } from './ReasonButton.js';
11
12
  import { nextReason, StepNotes } from './SaveStep.js';
12
- export function BriefPage({ sample, level, saved = true, onNext, onAction, onAnswer, questionControls, draft, notThis, notThisTyping, onAddNot, }) {
13
+ /** What a section is called on the page, for its reading sheet's title. */
14
+ const NAMES = {
15
+ what: 'studio.loop.brief.what',
16
+ who: 'studio.loop.brief.who',
17
+ kind: 'studio.loop.brief.kind',
18
+ earns: 'studio.loop.brief.earns',
19
+ must: 'studio.loop.brief.must',
20
+ later: 'studio.loop.brief.later',
21
+ };
22
+ export function BriefPage({ sample, level, saved = true, onNext, onAction, onAnswer, questionControls, draft, notThis, notThisTyping, onAddNot, onEditNot, reading, }) {
13
23
  const t = useT();
14
24
  const label = t('studio.loop.brief.next');
15
25
  const { brief } = sample;
16
26
  const agent = sample.product.agent.name;
17
- return (_jsxs(Page, { crumbs: [t('studio.frame.rail.step', { n: 1 }), t('studio.frame.page.brief')], title: t('studio.loop.brief.title', { name: sample.product.name }), sub: saved ? t('studio.loop.brief.lead', { agent }) : undefined, actions: _jsxs(_Fragment, { children: [_jsx(Path, { children: "plan/brief.md" }), saved && !draft?.save && (_jsx(Badge, { tone: "success", icon: "check", children: t('studio.loop.brief.saved') })), _jsx(ReasonButton, { size: "sm", why: nextReason(draft, t), disabled: !onNext, onClick: () => onNext?.(label), children: label })] }), children: [_jsx(Place, { id: "tabs:brief" }), draft && _jsx(StepNotes, { draft: draft, agent: agent }), _jsx(TwoColumns, { main: _jsx(BriefDocument, { brief: brief }), side: _jsxs(_Fragment, { children: [_jsx(BriefSide, { sample: sample, level: level, onAction: onAction, onAnswer: onAnswer, questionControls: questionControls }), notThis && _jsx(NotThisCard, { lines: notThis, typing: notThisTyping, onAdd: onAddNot }), _jsx(Place, { id: "side:brief" })] }) })] }));
27
+ const title = t('studio.loop.brief.title', { name: sample.product.name });
28
+ const [read, setRead] = useState(() => {
29
+ if (reading === 'whole')
30
+ return { title, whole: true };
31
+ const part = reading && brief.read?.[reading];
32
+ return reading && part ? { title: t(NAMES[reading]), part } : undefined;
33
+ });
34
+ return (_jsxs(Page, { crumbs: [t('studio.frame.rail.step', { n: 1 }), t('studio.frame.page.brief')], title: title, sub: saved ? t('studio.loop.brief.lead', { agent }) : undefined, actions: _jsxs(_Fragment, { children: [_jsx(Path, { children: "plan/brief.md" }), saved && !draft?.save && (_jsx(Badge, { tone: "success", icon: "check", children: t('studio.loop.brief.saved') })), _jsx(ReasonButton, { size: "sm", why: nextReason(draft, t), disabled: !onNext, onClick: () => onNext?.(label), children: label })] }), children: [_jsx(Place, { id: "tabs:brief" }), draft && _jsx(StepNotes, { draft: draft, agent: agent }), _jsxs("div", { style: {
35
+ display: 'flex',
36
+ flexWrap: 'wrap',
37
+ gap: 'var(--space-4)',
38
+ alignItems: 'flex-start',
39
+ }, children: [_jsx("div", { style: { flex: '3 1 34rem', minWidth: 0, display: 'grid', gap: 'var(--space-4)' }, children: _jsx(BriefDocument, { brief: brief, title: title, onRead: setRead, notThis: notThis && {
40
+ lines: notThis,
41
+ name: sample.product.name,
42
+ typing: notThisTyping,
43
+ onAdd: onAddNot,
44
+ onEdit: onEditNot,
45
+ } }) }), _jsxs("div", { style: { flex: '1 1 20rem', minWidth: 0, display: 'grid', gap: 'var(--space-4)' }, children: [_jsx(BriefSide, { sample: sample, level: level, onAction: onAction, onAnswer: onAnswer, questionControls: questionControls }), _jsx(Place, { id: "side:brief" })] })] }), read && (_jsx(BriefReading, { read: read, parts: brief.whole ?? [], onAsk: onAnswer, onClose: () => setRead(undefined) }))] }));
18
46
  }
@@ -0,0 +1,19 @@
1
+ import type { BriefPart } from './types.ts';
2
+ /** What the sheet shows: a section by the name the page gives it, or every section in order. */
3
+ export type BriefRead = {
4
+ title: string;
5
+ part: BriefPart;
6
+ } | {
7
+ title: string;
8
+ whole: true;
9
+ };
10
+ /** The whole brief as one text: each section under its own heading. */
11
+ export declare const wholeText: (parts: readonly BriefPart[]) => string;
12
+ export declare function BriefReading({ read, parts, onAsk, onClose, }: {
13
+ read: BriefRead;
14
+ /** Every section, for the whole brief. */
15
+ parts: readonly BriefPart[];
16
+ /** Puts the cursor in the chat about this section; none, no button. */
17
+ onAsk?: (about: string) => void;
18
+ onClose: () => void;
19
+ }): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The reading sheet: one section of the brief, or the whole brief, set for reading (headings, real
3
+ // lists, about 68 characters a line). The product's own Markdown as text: nothing in it can run.
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { Button } from '../../../components/Button.js';
6
+ import { Markdown } from '../../../components/Markdown.js';
7
+ import { Sheet } from '../../../components/Sheet.js';
8
+ import { monoText } from '../../../components/styles.js';
9
+ /** The whole brief as one text: each section under its own heading. */
10
+ export const wholeText = (parts) => parts.map((part) => `## ${part.heading}\n\n${part.text}`).join('\n\n');
11
+ export function BriefReading({ read, parts, onAsk, onClose, }) {
12
+ const t = useT();
13
+ const section = 'part' in read ? read.part : undefined;
14
+ return (_jsx(Sheet, { title: read.title, size: "read", onClose: onClose, sub: _jsx("span", { translate: "no", style: { ...monoText, color: 'var(--text-muted)' }, children: section
15
+ ? t('studio.loop.brief.read.where', { section: section.heading })
16
+ : 'plan/brief.md' }), footer: _jsxs(_Fragment, { children: [onAsk && (_jsx(Button, { variant: "ghost", icon: "message-square", onClick: () => {
17
+ onAsk(section
18
+ ? t('studio.loop.brief.read.about', { section: section.heading })
19
+ : read.title);
20
+ onClose();
21
+ }, children: t('studio.loop.brief.read.ask') })), _jsx(Button, { variant: "secondary", onClick: onClose, children: t('admin.common.close') })] }), children: _jsx(Markdown, { size: "read", source: section ? section.text : wholeText(parts) }) }));
22
+ }
@@ -0,0 +1,22 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ export declare const briefText: CSSProperties;
3
+ export declare const briefMuted: CSSProperties;
4
+ export declare const briefHeading: CSSProperties;
5
+ export declare const plainList: CSSProperties;
6
+ export declare const hairline = "var(--border-width-hairline) solid var(--border-hairline)";
7
+ /** One section: its heading and badge, Read more when there is more, then the short form. */
8
+ export declare function BriefSection({ title, badge, onMore, children, first, }: {
9
+ title: string;
10
+ badge?: ReactNode;
11
+ onMore?: () => void;
12
+ children: ReactNode;
13
+ /** The panel's first section: no rule above it, no room before it. */
14
+ first?: boolean;
15
+ }): import("react").JSX.Element;
16
+ /** "30 more", with the button that opens the section; only the button when nothing is left. */
17
+ export declare function RestLine({ rest, action, label, onClick, }: {
18
+ rest?: string;
19
+ action: string;
20
+ label: string;
21
+ onClick?: () => void;
22
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The Brief's sections share one shape: a heading (with its badge), Read more when the brief has
3
+ // the section's whole text, then the short form. And the line under a short list: "30 more".
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { Button } from '../../../components/Button.js';
6
+ import { captionText } from '../../../components/styles.js';
7
+ export const briefText = {
8
+ margin: 0,
9
+ fontSize: 'var(--font-size-body)',
10
+ lineHeight: 'var(--line-height-body)',
11
+ color: 'var(--text-body)',
12
+ overflowWrap: 'break-word',
13
+ };
14
+ export const briefMuted = { ...briefText, color: 'var(--text-muted)' };
15
+ export const briefHeading = {
16
+ margin: 0,
17
+ fontFamily: 'var(--font-display)',
18
+ fontSize: 'var(--font-size-body-lg)',
19
+ lineHeight: 'var(--line-height-body-lg)',
20
+ fontWeight: 'var(--weight-heading)',
21
+ color: 'var(--text-strong)',
22
+ };
23
+ export const plainList = {
24
+ margin: 0,
25
+ padding: 0,
26
+ listStyle: 'none',
27
+ display: 'grid',
28
+ gap: 'var(--space-2)',
29
+ };
30
+ export const hairline = 'var(--border-width-hairline) solid var(--border-hairline)';
31
+ /** One section: its heading and badge, Read more when there is more, then the short form. */
32
+ export function BriefSection({ title, badge, onMore, children, first, }) {
33
+ const t = useT();
34
+ return (_jsxs("section", { style: {
35
+ display: 'grid',
36
+ gap: 'var(--space-3)',
37
+ paddingBlock: 'var(--space-5)',
38
+ ...(first ? { paddingBlockStart: 0 } : { borderBlockStart: hairline }),
39
+ minWidth: 0,
40
+ }, children: [_jsxs("header", { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 'var(--space-2)' }, children: [_jsx("h2", { style: briefHeading, children: title }), badge, onMore && (_jsx(Button, { variant: "ghost", iconEnd: "chevron-right", "aria-label": t('studio.loop.brief.readMoreAbout', { section: title }), onClick: onMore, style: { marginInlineStart: 'auto', flexShrink: 0 }, children: t('studio.loop.brief.readMore') }))] }), children] }));
41
+ }
42
+ /** "30 more", with the button that opens the section; only the button when nothing is left. */
43
+ export function RestLine({ rest, action, label, onClick, }) {
44
+ if (!rest && !onClick)
45
+ return null;
46
+ return (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-2)', flexWrap: 'wrap' }, children: [rest && _jsx("span", { style: captionText, children: rest }), onClick && (_jsx(Button, { variant: "ghost", iconEnd: "chevron-right", "aria-label": label, onClick: onClick, children: action }))] }));
47
+ }
@@ -0,0 +1,6 @@
1
+ import type { BriefDoc } from './types.ts';
2
+ type Who = BriefDoc['who'];
3
+ export declare function BriefWho({ who }: {
4
+ who: Who;
5
+ }): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Who uses it: a table (role, where, what we know) where there is room, a short card per role on a
3
+ // phone. A column the brief says nothing about is left out.
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { captionText } from '../../../components/styles.js';
6
+ import { useNarrow } from '../../../use-narrow.js';
7
+ import { NARROW_BELOW } from '../frame/layout.js';
8
+ import { briefMuted, briefText, hairline, plainList } from './BriefSection.js';
9
+ /** A long word (a link, a made-up name) wraps instead of pushing the page sideways. */
10
+ const wraps = { overflowWrap: 'anywhere', minWidth: 0 };
11
+ const strong = {
12
+ ...briefText,
13
+ ...wraps,
14
+ color: 'var(--text-strong)',
15
+ fontWeight: 'var(--weight-semibold)',
16
+ };
17
+ function WhoCards({ who }) {
18
+ const t = useT();
19
+ return (_jsx("ul", { style: { ...plainList, gap: 0 }, children: who.map((w, i) => (_jsxs("li", { style: {
20
+ display: 'grid',
21
+ gap: 'var(--space-1)',
22
+ paddingBlock: 'var(--space-3)',
23
+ ...(i ? { borderBlockStart: hairline } : {}),
24
+ }, children: [_jsxs("span", { style: {
25
+ display: 'flex',
26
+ alignItems: 'baseline',
27
+ gap: 'var(--space-2)',
28
+ flexWrap: 'wrap',
29
+ }, children: [_jsx("strong", { style: strong, children: w.role }), w.where && _jsx("span", { style: captionText, children: t(`studio.loop.where.${w.where}`) })] }), w.note && _jsx("span", { style: { ...briefMuted, ...wraps }, children: w.note })] }, i))) }));
30
+ }
31
+ export function BriefWho({ who }) {
32
+ const t = useT();
33
+ const phone = useNarrow(NARROW_BELOW);
34
+ if (phone)
35
+ return _jsx(WhoCards, { who: who });
36
+ const where = who.some((w) => w.where);
37
+ const know = who.some((w) => w.note);
38
+ const cell = {
39
+ ...briefText,
40
+ ...wraps,
41
+ textAlign: 'start',
42
+ verticalAlign: 'top',
43
+ padding: 'var(--space-3) var(--space-3) var(--space-3) 0',
44
+ borderBlockEnd: hairline,
45
+ };
46
+ const head = {
47
+ ...cell,
48
+ ...captionText,
49
+ paddingBlock: 'var(--space-2)',
50
+ fontWeight: 'var(--weight-medium)',
51
+ };
52
+ return (_jsxs("table", { style: { inlineSize: '100%', borderCollapse: 'collapse' }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: head, children: t('studio.loop.brief.who.role') }), where && _jsx("th", { style: head, children: t('studio.loop.brief.who.where') }), know && _jsx("th", { style: head, children: t('studio.loop.brief.who.know') })] }) }), _jsx("tbody", { children: who.map((w, i) => {
53
+ const c = i === who.length - 1 ? { ...cell, borderBlockEnd: 0 } : cell;
54
+ return (_jsxs("tr", { children: [_jsx("th", { scope: "row", style: { ...c, ...strong }, children: w.role }), where && (_jsx("td", { style: { ...c, whiteSpace: 'nowrap' }, children: w.where ? t(`studio.loop.where.${w.where}`) : '' })), know && _jsx("td", { style: { ...c, color: 'var(--text-muted)' }, children: w.note ?? '' })] }, i));
55
+ }) })] }));
56
+ }
@@ -6,7 +6,6 @@ interface Props {
6
6
  onFocus?: (focus: ProtoView['focus']) => void;
7
7
  onData?: (data: DataState) => void;
8
8
  onMarks?: (on: boolean) => void;
9
- onFullScreen?: () => void;
10
9
  }
11
10
  /** All canvas controls use the page's width; marks and playback sit below. */
12
11
  export declare function CanvasBar(props: Props): import("react").JSX.Element;
@@ -7,15 +7,14 @@ import { captionText } from '../../../components/styles.js';
7
7
  import { Tabs } from '../../../components/Tabs.js';
8
8
  import { ControlReason } from './ControlReason.js';
9
9
  import { group, row } from './parts.js';
10
- import { ReasonButton } from './ReasonButton.js';
11
10
  import { TabletOrientation } from './TabletOrientation.js';
12
11
  const DATA = ['full', 'empty', 'loading', 'error'];
13
12
  const SHOW = ['both', 'patient', 'console'];
14
13
  /** All canvas controls use the page's width; marks and playback sit below. */
15
14
  export function CanvasBar(props) {
16
- const { view, onDevice, onFocus, onData, onMarks, onFullScreen } = props;
15
+ const { view, onDevice, onFocus, onData, onMarks } = props;
17
16
  const t = useT();
18
- return (_jsxs("div", { style: { display: 'grid', gap: 'var(--space-2)' }, children: [_jsxs("div", { "data-canvas-controls": true, style: { ...row, gap: 'var(--space-2)', alignItems: 'start' }, children: [_jsx(ControlReason, { disabled: !onFocus, children: _jsx(Tabs, { label: t('studio.loop.proto.show'), value: view.focus, onChange: onFocus, disabled: !onFocus, tabs: SHOW.map((s) => [s, t(`studio.loop.proto.show.${s}`)]) }) }), _jsx(Devices, { view: view, onDevice: onDevice }), _jsx(Select, { size: "sm", labelHidden: true, label: t('studio.loop.proto.data'), value: view.data, disabled: !onData, help: !onData ? t('studio.loop.design.why.unavailable') : undefined, onChange: (value) => onData?.(value), options: DATA.map((s) => ({ value: s, label: t(`studio.loop.proto.data.${s}`) })) }), _jsx("span", { style: { flex: 1 } }), _jsx(ReasonButton, { size: "sm", variant: "secondary", icon: "eye", disabled: !onFullScreen, why: !onFullScreen ? t('studio.loop.design.why.unavailable') : undefined, onClick: onFullScreen, children: t('studio.loop.proto.fullScreen') })] }), _jsx(TabletOrientation, { view: view, onOrientation: props.onOrientation }), _jsx(CanvasStatus, { view: view, onMarks: onMarks })] }));
17
+ return (_jsxs("div", { style: { display: 'grid', gap: 'var(--space-2)' }, children: [_jsxs("div", { "data-canvas-controls": true, style: { ...row, gap: 'var(--space-2)', alignItems: 'start' }, children: [_jsx(ControlReason, { disabled: !onFocus, children: _jsx(Tabs, { label: t('studio.loop.proto.show'), value: view.focus, onChange: onFocus, disabled: !onFocus, tabs: SHOW.map((s) => [s, t(`studio.loop.proto.show.${s}`)]) }) }), _jsx(Devices, { view: view, onDevice: onDevice }), _jsx(Select, { size: "sm", labelHidden: true, label: t('studio.loop.proto.data'), value: view.data, disabled: !onData, help: !onData ? t('studio.loop.design.why.unavailable') : undefined, onChange: (value) => onData?.(value), options: DATA.map((s) => ({ value: s, label: t(`studio.loop.proto.data.${s}`) })) })] }), _jsx(TabletOrientation, { view: view, onOrientation: props.onOrientation }), _jsx(CanvasStatus, { view: view, onMarks: onMarks })] }));
19
18
  }
20
19
  function CanvasStatus({ view, onMarks }) {
21
20
  const t = useT();
@@ -0,0 +1,13 @@
1
+ export declare function consoleAddress(url: string | undefined, locale: string, mode: string): {
2
+ status: 'stopped';
3
+ href?: undefined;
4
+ } | {
5
+ status: 'blocked';
6
+ href?: undefined;
7
+ } | {
8
+ status?: undefined;
9
+ href: string;
10
+ };
11
+ export declare function ConsoleFrame({ url }: {
12
+ url?: string;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // The console in the workspace: the product's own console, framed live at its address, with the
3
+ // same checks as the customer app's frame (never this page's own site, never plain HTTP from HTTPS).
4
+ // The console does not answer the prototype's messages, so its journeys are followed by hand.
5
+ import { useLocale, useT } from '@buffcore/i18n/react';
6
+ import { pageMode } from '../frame/layout.js';
7
+ import { prototypeAddress } from './prototype-bridge.js';
8
+ import { framedAddress } from './prototype-site.js';
9
+ export function consoleAddress(url, locale, mode) {
10
+ const address = prototypeAddress(url);
11
+ if (!address)
12
+ return { status: 'stopped' };
13
+ const framed = framedAddress(address);
14
+ const blocked = [address, framed].some((checked) => checked.host === location.host ||
15
+ (location.protocol === 'https:' && checked.protocol === 'http:'));
16
+ if (blocked)
17
+ return { status: 'blocked' };
18
+ framed.search = new URLSearchParams({ locale, mode }).toString();
19
+ return { href: framed.href };
20
+ }
21
+ export function ConsoleFrame({ url }) {
22
+ const t = useT();
23
+ const { locale } = useLocale();
24
+ // The address is read once per language and look: a new one loads the console afresh.
25
+ const shown = consoleAddress(url, locale, pageMode() ?? 'light');
26
+ if (!shown.href)
27
+ return (_jsx("p", { role: "status", style: { margin: 0, padding: 'var(--space-4)' }, children: t(`studio.workspace.console.${shown.status}`) }));
28
+ return (_jsx("iframe", { "data-workspace-console": true, title: t('studio.workspace.console.frame'), src: shown.href, sandbox: "allow-scripts allow-same-origin", referrerPolicy: "no-referrer", style: { display: 'block', inlineSize: '100%', blockSize: '100%', border: 0 } }));
29
+ }
@@ -1,7 +1,12 @@
1
1
  export interface NotThisCardProps {
2
2
  lines: readonly string[];
3
+ /** The product's name, for the lead. */
4
+ name: string;
3
5
  /** A line being typed at the start (a scene or a test). */
4
6
  typing?: string;
5
7
  onAdd?: (line: string) => void;
8
+ /** Asks the agent to change a line to new words. */
9
+ onEdit?: (line: string, to: string) => void;
10
+ first?: boolean;
6
11
  }
7
- export declare function NotThisCard({ lines, typing, onAdd }: NotThisCardProps): import("react").JSX.Element;
12
+ export declare function NotThisCard({ lines, name, typing, onAdd, onEdit, first }: NotThisCardProps): import("react").JSX.Element;
@@ -1,28 +1,36 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // The Brief's "Not this project": the lines the owner never wants, in their words. Adding one goes
3
- // through the Brief chat (the agent edits plan/not-this.md; Save keeps it), so there is no write here.
2
+ // The Brief's "Not this project": the lines the owner never wants, in their words, each with Edit,
3
+ // and Add a line. An edit or a new line goes through the Brief chat (the agent edits
4
+ // plan/not-this.md; Save keeps it), so there is no write here.
4
5
  import { useT } from '@buffcore/i18n/react';
5
6
  import { useState } from 'react';
7
+ import { Badge } from '../../../components/Badge.js';
6
8
  import { Button } from '../../../components/Button.js';
7
- import { Panel } from '../../../components/Panel.js';
8
- import { bodyText, captionText } from '../../../components/styles.js';
9
+ import { captionText } from '../../../components/styles.js';
9
10
  import { TextField } from '../../../components/TextField.js';
10
- import { Path, row } from './parts.js';
11
- export function NotThisCard({ lines, typing = '', onAdd }) {
11
+ import { BriefSection, briefMuted, briefText, hairline, plainList } from './BriefSection.js';
12
+ import { row } from './parts.js';
13
+ /** A line's words, a field and a send: Add a line and Edit share it. */
14
+ function LineField(props) {
12
15
  const t = useT();
13
- const [draft, setDraft] = useState(typing);
16
+ const [draft, setDraft] = useState(props.start);
14
17
  const line = draft.trim();
15
- const add = () => {
16
- if (!line)
17
- return;
18
- onAdd?.(line);
19
- setDraft('');
20
- };
21
- return (_jsxs(Panel, { title: t('studio.start.not.title'), children: [_jsx("p", { style: { ...bodyText, margin: 0, color: 'var(--text-muted)' }, children: t('studio.start.not.lead') }), lines.length ? (_jsx("ul", { style: {
22
- ...bodyText,
23
- margin: 0,
24
- paddingInlineStart: 'var(--space-5)',
25
- display: 'grid',
26
- gap: 'var(--space-2)',
27
- }, children: lines.map((text, i) => (_jsx("li", { translate: "no", style: { overflowWrap: 'anywhere' }, children: text }, i))) })) : (_jsx("p", { style: { ...bodyText, margin: 0 }, children: t('studio.start.not.empty') })), _jsxs("div", { style: { ...row, alignItems: 'flex-end' }, children: [_jsx(TextField, { label: t('studio.start.not.field'), value: draft, onChange: setDraft, style: { flex: '1 1 12rem' } }), _jsx(Button, { variant: "secondary", disabled: !onAdd || !line, onClick: add, children: t('studio.start.not.add') })] }), _jsx("span", { style: captionText, children: t('studio.start.not.note') }), _jsx(Path, { children: "plan/not-this.md" })] }));
18
+ return (_jsxs("div", { style: { ...row, alignItems: 'flex-end' }, children: [_jsx(TextField, { label: props.label, value: draft, onChange: setDraft, autoFocus: true, style: { flex: '1 1 12rem' } }), _jsx(Button, { variant: "secondary", disabled: !props.onSend || !line || (props.edit && line === props.start.trim()), onClick: () => props.onSend?.(line), children: props.action }), _jsx(Button, { variant: "ghost", onClick: props.onCancel, children: t('admin.common.cancel') })] }));
19
+ }
20
+ export function NotThisCard({ lines, name, typing, onAdd, onEdit, first }) {
21
+ const t = useT();
22
+ const [adding, setAdding] = useState(typing !== undefined);
23
+ const [editing, setEditing] = useState();
24
+ return (_jsxs(BriefSection, { first: first, title: t('studio.start.not.title'), badge: lines.length ? _jsx(Badge, { children: String(lines.length) }) : undefined, children: [_jsx("p", { style: briefMuted, children: t('studio.start.not.lead', { name }) }), lines.length ? (_jsx("ul", { style: { ...plainList, gap: 0 }, children: lines.map((line, i) => (_jsx("li", { style: {
25
+ paddingBlock: 'var(--space-1)',
26
+ ...(i ? { borderBlockStart: hairline } : {}),
27
+ }, children: editing === i ? (_jsx(LineField, { label: t('studio.start.not.editField'), start: line, edit: true, action: t('studio.start.not.editSend'), onSend: onEdit &&
28
+ ((to) => {
29
+ onEdit(line, to);
30
+ setEditing(undefined);
31
+ }), onCancel: () => setEditing(undefined) })) : (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--space-3)' }, children: [_jsx("span", { translate: "no", style: { ...briefText, flex: 1, minWidth: 0, overflowWrap: 'anywhere' }, children: line }), _jsx(Button, { variant: "ghost", icon: "pencil", "aria-label": t('studio.start.not.editAbout', { line }), disabled: !onEdit, onClick: () => setEditing(i), children: t('studio.start.not.edit') })] })) }, i))) })) : (_jsx("p", { style: briefText, children: t('studio.start.not.empty') })), adding ? (_jsx(LineField, { label: t('studio.start.not.field'), start: typing ?? '', action: t('studio.start.not.add'), onSend: onAdd &&
32
+ ((line) => {
33
+ onAdd(line);
34
+ setAdding(false);
35
+ }), onCancel: () => setAdding(false) })) : (_jsx("div", { children: _jsx(Button, { variant: "secondary", icon: "plus", onClick: () => setAdding(true), children: t('studio.start.not.field') }) })), _jsx("span", { style: captionText, children: t('studio.start.not.note') })] }));
28
36
  }
@@ -1,11 +1,4 @@
1
- import type { PreviewGroup } from './PrototypePreviewToolbar.tsx';
2
- import type { PlayableJourney } from './prototype-bridge.ts';
3
- import type { JourneyRole, LoopSample } from './types.ts';
4
- export declare function plannedJourney(roles: readonly JourneyRole[], journey: PlayableJourney): {
5
- role: string;
6
- entry: import("./types.ts").JourneyDef;
7
- } | undefined;
8
- export declare function groupJourneys(journeys: readonly PlayableJourney[], roles: readonly JourneyRole[]): PreviewGroup[];
1
+ import type { LoopSample } from './types.ts';
9
2
  export declare function ProtoJourneys({ sample, step, journey, playing, onJourney, onPlayer, }: {
10
3
  sample: Pick<LoopSample, 'journeys'>;
11
4
  step: number;
@@ -8,20 +8,6 @@ import { Panel } from '../../../components/Panel.js';
8
8
  import { Select } from '../../../components/Select.js';
9
9
  import { bodyText, captionText } from '../../../components/styles.js';
10
10
  import { row } from './parts.js';
11
- export function plannedJourney(roles, journey) {
12
- const matches = roles.flatMap((group) => group.journeys.flatMap((entry) => entry.id === journey.key || entry.name === journey.title ? [{ role: group.role, entry }] : []));
13
- return matches.length === 1 ? matches[0] : undefined;
14
- }
15
- export function groupJourneys(journeys, roles) {
16
- const groups = new Map();
17
- for (const journey of journeys) {
18
- const role = journey.role || plannedJourney(roles, journey)?.role;
19
- const group = groups.get(role) ?? [];
20
- group.push(journey);
21
- groups.set(role, group);
22
- }
23
- return Array.from(groups, ([role, journeys]) => ({ role, journeys }));
24
- }
25
11
  function StepList({ steps, step }) {
26
12
  return (_jsx("ol", { style: { listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 'var(--space-1)' }, children: steps.map((s, n) => (_jsxs("li", { "aria-current": n === step ? 'step' : undefined, style: {
27
13
  ...bodyText,
@@ -13,16 +13,27 @@ export interface PrototypeAppProps {
13
13
  previewIdentity?: string;
14
14
  product: string;
15
15
  onDev?: () => void;
16
+ /** A journey Play asked for on another page: selected at its first step once the app lists it. */
17
+ play?: PlayRequest;
18
+ /** The request was taken (or another choice was made), so it is not played again. */
19
+ onPlayed?: () => void;
16
20
  }
21
+ /** A planned journey: the app's journey with this key, or else with this title, is played. */
22
+ export type PlayRequest = {
23
+ id: string;
24
+ name?: string;
25
+ };
17
26
  export type Props = PrototypeAppProps & {
18
27
  reviewPanel?: (ready: boolean, snapshotOk: boolean) => ReactNode;
19
28
  preview?: {
20
29
  roles: readonly JourneyRole[];
21
30
  device?: ProtoView['device'];
22
31
  onDevice?: (device: NonNullable<ProtoView['device']>) => void;
32
+ orientation?: ProtoView['orientation'];
33
+ onOrientation?: (orientation: NonNullable<ProtoView['orientation']>) => void;
23
34
  };
24
35
  };
25
- export declare function PrototypeApp(props: Props): import("react").JSX.Element;
36
+ export declare function PrototypeApp(props: Props): false | import("react").JSX.Element;
26
37
  export type LoadedProps = Props & {
27
38
  address: string;
28
39
  given: string;
@@ -4,7 +4,7 @@ import { createContext, useCallback, useContext, useEffect, useRef, useState, }
4
4
  import { pageMode } from '../frame/layout.js';
5
5
  import { PrototypeAppView } from './PrototypeAppView.js';
6
6
  import { PrototypeAttempt } from './PrototypeAttempt.js';
7
- import { PrototypePreview } from './PrototypePreview.js';
7
+ import { PreviewSlot } from './PrototypePreviewSlot.js';
8
8
  import { PrototypeUnavailable } from './PrototypeUnavailable.js';
9
9
  import { prototypeAddress, prototypeNavigationId, } from './prototype-bridge.js';
10
10
  import { framedAddress } from './prototype-site.js';
@@ -49,15 +49,30 @@ export function PrototypeApp(props) {
49
49
  : blocked
50
50
  ? 'blocked'
51
51
  : undefined;
52
- if (status || !address || !framed)
53
- return (_jsx(UnavailablePreview, { ...props, status: status ?? 'blocked', href: props.running && (status !== 'refused' || local) ? href?.href : undefined }));
54
- return (_jsx(PlayableApp, { ...props, previewIdentity: previewIdentity, address: framed.href, given: address.href, href: href?.href ?? address.href, locale: locale, mode: mode }, identity));
52
+ const unavailable = !!status || !address || !framed;
53
+ const shownHref = props.running && (status !== 'refused' || local) ? href?.href : undefined;
54
+ const body = status || !address || !framed ? (!props.preview && (_jsx(UnavailablePreview, { ...props, status: status ?? 'blocked', href: shownHref }))) : (_jsx(PlayableApp, { ...props, previewIdentity: previewIdentity, address: framed.href, given: address.href, href: href?.href ?? address.href, locale: locale, mode: mode }, identity));
55
+ if (!props.preview)
56
+ return body;
57
+ // One workspace whatever the app's state: only the app's slot changes, the console stays put.
58
+ return (_jsx(PreviewSlot, { live: !unavailable, waiting: waiting({ ...props, preview: props.preview }, status ?? (unavailable ? 'blocked' : 'loading'), unavailable ? shownHref : (href?.href ?? address?.href)), children: body }));
59
+ }
60
+ /** What the workspace shows while the app is not running in it (or has not answered yet). */
61
+ function waiting(props, status, href) {
62
+ return {
63
+ product: props.product,
64
+ roles: props.preview.roles,
65
+ journeys: [],
66
+ app: (_jsx(PrototypeUnavailable, { status: status, quiet: true, product: props.product, onDev: props.onDev, href: href })),
67
+ ready: false,
68
+ device: props.preview.device ?? 'mobile',
69
+ orientation: props.preview.orientation,
70
+ onDevice: props.preview.onDevice,
71
+ onOrientation: props.preview.onOrientation,
72
+ };
55
73
  }
56
74
  function UnavailablePreview({ status, href, ...props }) {
57
- const app = (_jsx(PrototypeUnavailable, { status: status, quiet: !!props.preview, product: props.product, onDev: props.onDev, href: href }));
58
- if (props.preview)
59
- return (_jsx(PrototypePreview, { product: props.product, groups: [], app: app, ready: false, device: props.preview.device ?? 'mobile', onDevice: props.preview.onDevice }));
60
- return (_jsx(PrototypeAppView, { title: props.product, ready: false, journeys: [], onPlay: () => { }, app: app, reviewPanel: props.reviewPanel?.(false, !!(props.snapshotReady ?? props.running) && status !== 'missing') }));
75
+ return (_jsx(PrototypeAppView, { title: props.product, ready: false, journeys: [], onPlay: () => { }, app: _jsx(PrototypeUnavailable, { status: status, product: props.product, onDev: props.onDev, href: href }), reviewPanel: props.reviewPanel?.(false, !!(props.snapshotReady ?? props.running) && status !== 'missing') }));
61
76
  }
62
77
  export const PreviewChoiceContext = createContext(null);
63
78
  function PlayableApp(props) {
@@ -82,15 +97,17 @@ function PlayableApp(props) {
82
97
  const useGivenAddress = useCallback(() => setAsGiven(true), []);
83
98
  const container = useRef(null);
84
99
  if (!navigation)
85
- return _jsx(UnavailablePreview, { ...props, status: "loading" });
86
- const navigate = (choice) => {
100
+ return props.preview ? null : _jsx(UnavailablePreview, { ...props, status: "loading" });
101
+ const navigate = (choice, shown) => {
87
102
  setRestore(false);
103
+ props.onPlayed?.();
88
104
  if (identity && selection)
89
105
  selection.current = { identity, choice };
90
- setNavigation({ ...choice, id: prototypeNavigationId() });
106
+ // A choice the running app was told keeps the document (no reload); any other loads anew.
107
+ setNavigation({ ...choice, id: shown ? navigation.id : prototypeNavigationId() });
91
108
  };
92
- return (_jsx("div", { ref: container, style: { display: 'contents' }, children: _jsx(PrototypeAttempt, { ...props, address: asGiven ? props.given : props.address, onSwitch: useGivenAddress, navigation: navigation, onNavigate: (choice) => {
93
- navigate(choice);
109
+ return (_jsx("div", { ref: container, style: { display: 'contents' }, children: _jsx(PrototypeAttempt, { ...props, address: asGiven ? props.given : props.address, onSwitch: useGivenAddress, navigation: navigation, onNavigate: (choice, shown) => {
110
+ navigate(choice, shown);
94
111
  if (!props.preview)
95
112
  container.current
96
113
  ?.querySelector('[data-section="app"]')
@@ -1,6 +1,7 @@
1
1
  import type { Choice, LoadedProps, Navigation } from './PrototypeApp.tsx';
2
2
  export declare function PrototypeAttempt({ navigation, onNavigate, onSwitch, ...props }: LoadedProps & {
3
3
  navigation: Navigation;
4
- onNavigate: (choice: Choice) => void;
4
+ /** `shown`: the running app was told by a message, so the frame keeps its document. */
5
+ onNavigate: (choice: Choice, shown: boolean) => void;
5
6
  onSwitch: () => void;
6
7
  }): import("react").JSX.Element;