@buffcore/admin-shell 0.8.44 → 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 (145) 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.js +5 -0
  10. package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +7 -7
  11. package/dist/workbench/app/actions.d.ts +4 -2
  12. package/dist/workbench/app/actions.js +9 -4
  13. package/dist/workbench/app/brief-short.d.ts +14 -0
  14. package/dist/workbench/app/brief-short.js +103 -0
  15. package/dist/workbench/app/chat-session.d.ts +3 -3
  16. package/dist/workbench/app/chat-session.js +8 -3
  17. package/dist/workbench/app/chat.d.ts +15 -2
  18. package/dist/workbench/app/chat.js +9 -4
  19. package/dist/workbench/app/loop.js +2 -18
  20. package/dist/workbench/app/prototype.js +3 -0
  21. package/dist/workbench/app/test/loop-fixture.d.ts +10 -0
  22. package/dist/workbench/app/useStudio.d.ts +2 -1
  23. package/dist/workbench/studio/frame/AgentPanel.js +24 -1
  24. package/dist/workbench/studio/frame/PanelList.js +1 -1
  25. package/dist/workbench/studio/frame/Segmented.d.ts +3 -1
  26. package/dist/workbench/studio/frame/Segmented.js +4 -3
  27. package/dist/workbench/studio/frame/StudioFrame.js +3 -3
  28. package/dist/workbench/studio/frame/StudioRegions.js +4 -1
  29. package/dist/workbench/studio/frame/TurnControls.d.ts +2 -1
  30. package/dist/workbench/studio/frame/TurnControls.js +4 -1
  31. package/dist/workbench/studio/frame/layout.d.ts +2 -0
  32. package/dist/workbench/studio/frame/layout.js +2 -0
  33. package/dist/workbench/studio/frame/panelControls.d.ts +21 -1
  34. package/dist/workbench/studio/frame/scrollbars.d.ts +1 -1
  35. package/dist/workbench/studio/frame/scrollbars.js +5 -3
  36. package/dist/workbench/studio/frame/useTurnDraft.d.ts +20 -2
  37. package/dist/workbench/studio/frame/useTurnDraft.js +39 -10
  38. package/dist/workbench/studio/i18n/index.js +6 -0
  39. package/dist/workbench/studio/i18n/loop.en.d.ts +11 -38
  40. package/dist/workbench/studio/i18n/loop.en.js +11 -38
  41. package/dist/workbench/studio/i18n/loop.es.json +11 -38
  42. package/dist/workbench/studio/i18n/marks.en.d.ts +41 -0
  43. package/dist/workbench/studio/i18n/marks.en.js +42 -0
  44. package/dist/workbench/studio/i18n/marks.es.json +40 -0
  45. package/dist/workbench/studio/i18n/start.en.d.ts +5 -0
  46. package/dist/workbench/studio/i18n/start.en.js +7 -2
  47. package/dist/workbench/studio/i18n/start.es.json +7 -2
  48. package/dist/workbench/studio/i18n/workspace.en.d.ts +45 -0
  49. package/dist/workbench/studio/i18n/workspace.en.js +46 -0
  50. package/dist/workbench/studio/i18n/workspace.es.json +44 -0
  51. package/dist/workbench/studio/loop/BriefDocument.d.ts +9 -6
  52. package/dist/workbench/studio/loop/BriefDocument.js +48 -76
  53. package/dist/workbench/studio/loop/BriefLists.d.ts +11 -0
  54. package/dist/workbench/studio/loop/BriefLists.js +42 -0
  55. package/dist/workbench/studio/loop/BriefPage.d.ts +6 -2
  56. package/dist/workbench/studio/loop/BriefPage.js +32 -4
  57. package/dist/workbench/studio/loop/BriefReading.d.ts +19 -0
  58. package/dist/workbench/studio/loop/BriefReading.js +22 -0
  59. package/dist/workbench/studio/loop/BriefSection.d.ts +22 -0
  60. package/dist/workbench/studio/loop/BriefSection.js +47 -0
  61. package/dist/workbench/studio/loop/BriefWho.d.ts +6 -0
  62. package/dist/workbench/studio/loop/BriefWho.js +56 -0
  63. package/dist/workbench/studio/loop/CanvasBar.d.ts +0 -1
  64. package/dist/workbench/studio/loop/CanvasBar.js +2 -3
  65. package/dist/workbench/studio/loop/ConsoleFrame.d.ts +13 -0
  66. package/dist/workbench/studio/loop/ConsoleFrame.js +29 -0
  67. package/dist/workbench/studio/loop/NotThisCard.d.ts +6 -1
  68. package/dist/workbench/studio/loop/NotThisCard.js +28 -20
  69. package/dist/workbench/studio/loop/ProtoJourneys.d.ts +1 -8
  70. package/dist/workbench/studio/loop/ProtoJourneys.js +0 -14
  71. package/dist/workbench/studio/loop/PrototypeApp.d.ts +3 -1
  72. package/dist/workbench/studio/loop/PrototypeApp.js +24 -9
  73. package/dist/workbench/studio/loop/PrototypeAttempt.js +55 -14
  74. package/dist/workbench/studio/loop/PrototypePage.d.ts +4 -2
  75. package/dist/workbench/studio/loop/PrototypePage.js +25 -1
  76. package/dist/workbench/studio/loop/PrototypePreview.d.ts +35 -6
  77. package/dist/workbench/studio/loop/PrototypePreview.js +126 -80
  78. package/dist/workbench/studio/loop/PrototypePreviewSlot.d.ts +13 -0
  79. package/dist/workbench/studio/loop/PrototypePreviewSlot.js +23 -0
  80. package/dist/workbench/studio/loop/PrototypeScenes.d.ts +1 -1
  81. package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
  82. package/dist/workbench/studio/loop/StudioLoop.d.ts +7 -2
  83. package/dist/workbench/studio/loop/StudioLoop.js +4 -10
  84. package/dist/workbench/studio/loop/WorkspaceBar.d.ts +15 -0
  85. package/dist/workbench/studio/loop/WorkspaceBar.js +52 -0
  86. package/dist/workbench/studio/loop/WorkspaceJourneys.d.ts +17 -0
  87. package/dist/workbench/studio/loop/WorkspaceJourneys.js +99 -0
  88. package/dist/workbench/studio/loop/WorkspaceLeft.d.ts +14 -0
  89. package/dist/workbench/studio/loop/WorkspaceLeft.js +42 -0
  90. package/dist/workbench/studio/loop/WorkspaceStage.d.ts +24 -0
  91. package/dist/workbench/studio/loop/WorkspaceStage.js +142 -0
  92. package/dist/workbench/studio/loop/WorkspaceSteps.d.ts +20 -0
  93. package/dist/workbench/studio/loop/WorkspaceSteps.js +96 -0
  94. package/dist/workbench/studio/loop/moments.js +0 -3
  95. package/dist/workbench/studio/loop/prototype-document.d.ts +2 -0
  96. package/dist/workbench/studio/loop/prototype-document.js +12 -0
  97. package/dist/workbench/studio/loop/prototype-part.d.ts +43 -0
  98. package/dist/workbench/studio/loop/prototype-part.js +104 -0
  99. package/dist/workbench/studio/loop/types.d.ts +26 -26
  100. package/dist/workbench/studio/loop/types.js +0 -3
  101. package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +3 -0
  102. package/dist/workbench/studio/loop/usePrototypeFrame.js +2 -0
  103. package/dist/workbench/studio/loop/workspace-journeys.d.ts +22 -0
  104. package/dist/workbench/studio/loop/workspace-journeys.js +63 -0
  105. package/dist/workbench/studio/loop/workspace-state.d.ts +94 -0
  106. package/dist/workbench/studio/loop/workspace-state.js +50 -0
  107. package/dist/workbench/studio/marks/ChangeList.d.ts +7 -0
  108. package/dist/workbench/studio/marks/ChangeList.js +70 -0
  109. package/dist/workbench/studio/marks/MarkHint.d.ts +18 -0
  110. package/dist/workbench/studio/marks/MarkHint.js +58 -0
  111. package/dist/workbench/studio/marks/MarkNumber.d.ts +6 -0
  112. package/dist/workbench/studio/marks/MarkNumber.js +24 -0
  113. package/dist/workbench/studio/marks/MarksLayer.d.ts +15 -0
  114. package/dist/workbench/studio/marks/MarksLayer.js +144 -0
  115. package/dist/workbench/studio/marks/PinNote.d.ts +13 -0
  116. package/dist/workbench/studio/marks/PinNote.js +49 -0
  117. package/dist/workbench/studio/marks/QueuedChanges.d.ts +6 -0
  118. package/dist/workbench/studio/marks/QueuedChanges.js +51 -0
  119. package/dist/workbench/studio/marks/WorkspaceMarks.d.ts +15 -0
  120. package/dist/workbench/studio/marks/WorkspaceMarks.js +67 -0
  121. package/dist/workbench/studio/marks/marks-message.d.ts +13 -0
  122. package/dist/workbench/studio/marks/marks-message.js +93 -0
  123. package/dist/workbench/studio/marks/marks.d.ts +105 -0
  124. package/dist/workbench/studio/marks/marks.js +133 -0
  125. package/dist/workbench/studio/marks/useMarking.d.ts +36 -0
  126. package/dist/workbench/studio/marks/useMarking.js +111 -0
  127. package/dist/workbench/studio/marks/useSendMarks.d.ts +18 -0
  128. package/dist/workbench/studio/marks/useSendMarks.js +80 -0
  129. package/dist/workbench/studio/work/StudioLater.js +0 -1
  130. package/dist/workbench/studio/work/work-test-data.d.ts +5 -0
  131. package/package.json +6 -6
  132. package/dist/workbench/studio/loop/FsPlan.d.ts +0 -7
  133. package/dist/workbench/studio/loop/FsPlan.js +0 -64
  134. package/dist/workbench/studio/loop/FsStage.d.ts +0 -6
  135. package/dist/workbench/studio/loop/FsStage.js +0 -74
  136. package/dist/workbench/studio/loop/FsToolbar.d.ts +0 -6
  137. package/dist/workbench/studio/loop/FsToolbar.js +0 -61
  138. package/dist/workbench/studio/loop/FullScreen.d.ts +0 -5
  139. package/dist/workbench/studio/loop/FullScreen.js +0 -89
  140. package/dist/workbench/studio/loop/PrototypePreviewMenus.d.ts +0 -18
  141. package/dist/workbench/studio/loop/PrototypePreviewMenus.js +0 -75
  142. package/dist/workbench/studio/loop/PrototypePreviewToolbar.d.ts +0 -27
  143. package/dist/workbench/studio/loop/PrototypePreviewToolbar.js +0 -52
  144. package/dist/workbench/studio/loop/fsViews.d.ts +0 -12
  145. package/dist/workbench/studio/loop/fsViews.js +0 -6
@@ -0,0 +1,142 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The workspace's stage: the shown app in its device, at the device's own size and zoomed to the
3
+ // room it has, with the line saying what you see above it and the journey's step bar under it.
4
+ // The customer app and the console are two frames: the hidden one stays loaded, so switching keeps
5
+ // each one's step and never reloads it.
6
+ import { isRtl } from '@buffcore/i18n';
7
+ import { useLocale, useT } from '@buffcore/i18n/react';
8
+ import { useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
9
+ import { Icon } from '../../../components/Icon.js';
10
+ import { captionText } from '../../../components/styles.js';
11
+ import { NARROW_BELOW } from '../frame/layout.js';
12
+ import { MarkHint } from '../marks/MarkHint.js';
13
+ import { ConsoleFrame } from './ConsoleFrame.js';
14
+ import { useWorkspace, WorkspaceStageContext, } from './workspace-state.js';
15
+ /** Each device's screen in CSS pixels, upright. */
16
+ export const DEVICE_SIZES = {
17
+ mobile: { w: 390, h: 844 },
18
+ tablet: { w: 820, h: 1180 },
19
+ desktop: { w: 1024, h: 640 },
20
+ };
21
+ export function deviceSize(device, orientation) {
22
+ const { w, h } = DEVICE_SIZES[device];
23
+ return device === 'tablet' && orientation === 'landscape' ? { w: h, h: w } : { w, h };
24
+ }
25
+ /** The zoom that fits the screen in the room (never above its own size); 1 where unmeasured. */
26
+ function useFit(w, h) {
27
+ const room = useRef(null);
28
+ const [zoom, setZoom] = useState(1);
29
+ useLayoutEffect(() => {
30
+ const el = room.current;
31
+ if (!el || typeof ResizeObserver === 'undefined')
32
+ return;
33
+ const fit = () => {
34
+ const { width, height } = el.getBoundingClientRect();
35
+ if (width > 0 && height > 0)
36
+ setZoom(Math.min(width / w, height / h, 1));
37
+ };
38
+ fit();
39
+ const watch = new ResizeObserver(fit);
40
+ watch.observe(el);
41
+ return () => watch.disconnect();
42
+ }, [w, h]);
43
+ return { room, zoom };
44
+ }
45
+ const COARSE = '(pointer: coarse)';
46
+ const watchPointer = (update) => {
47
+ const list = globalThis.matchMedia?.(COARSE);
48
+ list?.addEventListener('change', update);
49
+ return () => list?.removeEventListener('change', update);
50
+ };
51
+ /** Whether a finger is the pointer, so the hint says tap rather than click. */
52
+ function useTouch() {
53
+ return useSyncExternalStore(watchPointer, () => globalThis.matchMedia?.(COARSE).matches ?? false, () => false);
54
+ }
55
+ const layer = { position: 'absolute', inset: 0 };
56
+ // The bezel is drawn by a rule, so a page served before the frame measures its width draws a
57
+ // phone-wide studio's phone without one from the first paint (a tablet or desktop keeps it).
58
+ const bezel = `
59
+ [data-preview-device]:not([data-preview-device="unframed"]) {
60
+ border: var(--border-width-panel) solid var(--border-default);
61
+ border-radius: var(--radius-overlay);
62
+ box-shadow: var(--shadow-panel);
63
+ }
64
+ [data-preview-device="mobile"] { border-radius: var(--radius-xl); }
65
+ @media (width < ${NARROW_BELOW}px) {
66
+ [data-preview-device="mobile"]:not([data-prototype-layout-known] *) {
67
+ border: 0;
68
+ border-radius: 0;
69
+ box-shadow: none;
70
+ }
71
+ }`;
72
+ export function WorkspaceStage({ device, orientation, narrow, app, where, partAt, show, below, }) {
73
+ const t = useT();
74
+ const { locale } = useLocale();
75
+ const space = useWorkspace();
76
+ const touch = useTouch();
77
+ // On a phone-wide studio a phone's app takes the page, without a bezel; a tablet or a desktop
78
+ // is drawn in its bezel, zoomed to fit.
79
+ const bare = narrow && device === 'mobile';
80
+ const { w, h } = deviceSize(device, orientation);
81
+ const fit = useFit(w, h);
82
+ const zoom = bare ? 1 : fit.zoom;
83
+ const [screen, setScreen] = useState(null);
84
+ const stage = useMemo(() => ({
85
+ tool: space.tool,
86
+ app: space.app,
87
+ device,
88
+ orientation,
89
+ screen,
90
+ zoom,
91
+ where,
92
+ partAt,
93
+ show,
94
+ }), [space.tool, space.app, device, orientation, screen, zoom, where, partAt, show]);
95
+ const shown = t(space.app === 'app' ? 'studio.workspace.app' : 'studio.workspace.console');
96
+ return (_jsx(WorkspaceStageContext.Provider, { value: stage, children: _jsxs("div", { "data-workspace-stage": true, style: {
97
+ display: 'grid',
98
+ gridTemplateRows: 'auto minmax(0, 1fr) auto',
99
+ gap: 'var(--space-3)',
100
+ minBlockSize: 0,
101
+ minInlineSize: 0,
102
+ padding: bare
103
+ ? 'var(--space-2) 0 0'
104
+ : narrow
105
+ ? 'var(--space-3)'
106
+ : 'var(--space-4) var(--space-6)',
107
+ backgroundImage: 'radial-gradient(var(--border-hairline) 1px, transparent 1px)',
108
+ backgroundSize: 'var(--space-4) var(--space-4)',
109
+ }, children: [_jsxs("p", { "data-workspace-where": true, style: {
110
+ ...captionText,
111
+ margin: 0,
112
+ display: 'flex',
113
+ flexWrap: 'wrap',
114
+ gap: 'var(--space-2)',
115
+ alignItems: 'center',
116
+ justifyContent: 'center',
117
+ // A phone's bare app takes the full width; the line keeps off the edges.
118
+ paddingInline: bare ? 'var(--space-3)' : 0,
119
+ }, children: [_jsx(Icon, { name: space.app === 'app' ? 'smartphone' : 'monitor', size: "var(--icon-sm)" }), t('studio.workspace.screen', {
120
+ app: shown,
121
+ screen: where.screen,
122
+ device: t(`studio.workspace.device.${device}`),
123
+ }), _jsx(MarkHint, { tool: space.tool, touch: touch, console: space.app === 'console' })] }), _jsx("style", { children: bezel }), _jsx("div", { ref: fit.room, style: { minBlockSize: 0, minInlineSize: 0, display: 'grid', placeItems: 'center' }, children: _jsxs("section", { "data-preview-device": bare ? 'unframed' : device, "aria-label": t('simple.frame'), style: {
124
+ position: 'relative',
125
+ boxSizing: 'content-box',
126
+ inlineSize: bare ? '100%' : w * zoom,
127
+ blockSize: bare ? '100%' : h * zoom,
128
+ // Paint containment clips the scaled screen to the bezel without counting the
129
+ // screen's own (unscaled) size as overflow.
130
+ contain: 'paint',
131
+ background: 'var(--surface-canvas)',
132
+ }, children: [_jsxs("div", { ref: setScreen, "data-workspace-screen": true, style: bare
133
+ ? layer
134
+ : {
135
+ ...layer,
136
+ inlineSize: w,
137
+ blockSize: h,
138
+ transform: `scale(${zoom})`,
139
+ // Scaled from the start corner, which the screen sits in.
140
+ transformOrigin: isRtl(locale) ? '100% 0' : '0 0',
141
+ }, children: [_jsx("div", { hidden: space.app !== 'app', style: layer, children: _jsx("div", { style: { blockSize: '100%', overflow: 'auto' }, children: app }) }), space.consoleShown && (_jsx("div", { hidden: space.app !== 'console', style: layer, children: space.setup.console ?? _jsx(ConsoleFrame, { url: space.setup.consoleUrl }) }))] }), space.setup.overlay] }) }), below] }) }));
142
+ }
@@ -0,0 +1,20 @@
1
+ export interface WorkspacePlay {
2
+ journey: string;
3
+ step: number;
4
+ total: number;
5
+ caption: string;
6
+ /** The app is not ready to move yet; the buttons stay but do nothing. */
7
+ pending?: boolean;
8
+ onStep: (step: number) => void;
9
+ }
10
+ /** How long Play shows each step before the next. */
11
+ export declare const PLAY_EVERY = 2500;
12
+ export declare function StepBar({ play, context }: {
13
+ play: WorkspacePlay;
14
+ context: string;
15
+ }): import("react").JSX.Element;
16
+ /** The foot bar on a phone-wide studio: the app takes the page above it. */
17
+ export declare function FootBar({ play, onJourneys }: {
18
+ play?: WorkspacePlay;
19
+ onJourneys: () => void;
20
+ }): import("react").JSX.Element;
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The journey's step bar, under the device and never over it (Back, where you are, Play, Next), and
3
+ // on a phone-wide studio the bar at the app's foot (Journeys, Back, the step, Next, Changes).
4
+ import { formatNumber, isRtl } from '@buffcore/i18n';
5
+ import { useLocale, useT } from '@buffcore/i18n/react';
6
+ import { useContext, useEffect, useState } from 'react';
7
+ import { Button } from '../../../components/Button.js';
8
+ import { IconButton } from '../../../components/IconButton.js';
9
+ import { captionText } from '../../../components/styles.js';
10
+ import { StudioPaneContext } from '../frame/layout.js';
11
+ import { useWorkspace } from './workspace-state.js';
12
+ /** How long Play shows each step before the next. */
13
+ export const PLAY_EVERY = 2500;
14
+ /**
15
+ * Play's state belongs to one journey in one place: `context` names it (the app, the journey, the
16
+ * device), and any switch of it stops Play, so a timer never moves another journey's steps.
17
+ */
18
+ function useAutoPlay({ step, total, pending, onStep }, context) {
19
+ const [state, setState] = useState({ context, playing: false });
20
+ // A switch forgets Play, so coming back to the same journey does not start it again.
21
+ if (state.context !== context)
22
+ setState({ context, playing: false });
23
+ const playing = state.context === context && state.playing;
24
+ const last = step >= total - 1;
25
+ useEffect(() => {
26
+ if (!playing || pending)
27
+ return;
28
+ if (last) {
29
+ setState({ context, playing: false });
30
+ return;
31
+ }
32
+ const timer = setTimeout(() => onStep(step + 1), PLAY_EVERY);
33
+ return () => clearTimeout(timer);
34
+ }, [playing, pending, last, step, onStep, context]);
35
+ return { playing, toggle: () => setState({ context, playing: !playing && !last }) };
36
+ }
37
+ function Where({ play, named }) {
38
+ const t = useT();
39
+ const { locale } = useLocale();
40
+ const n = formatNumber(locale, play.step + 1);
41
+ const total = formatNumber(locale, play.total);
42
+ return (_jsxs("span", { "aria-live": "polite", style: { display: 'grid', textAlign: 'center', minInlineSize: 0 }, children: [_jsx("strong", { style: { ...captionText, color: 'var(--text-strong)', overflowWrap: 'anywhere' }, children: named
43
+ ? t('studio.workspace.stepOf', { journey: play.journey, n, total })
44
+ : t('simple.try.step', { n, total }) }), _jsx("span", { style: {
45
+ ...captionText,
46
+ ...(named
47
+ ? { overflowWrap: 'anywhere' }
48
+ : { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }),
49
+ }, children: play.caption })] }));
50
+ }
51
+ const bar = {
52
+ boxSizing: 'border-box',
53
+ display: 'grid',
54
+ alignItems: 'center',
55
+ gap: 'var(--space-2)',
56
+ padding: 'var(--space-2)',
57
+ background: 'var(--surface-panel)',
58
+ };
59
+ export function StepBar({ play, context }) {
60
+ const t = useT();
61
+ const { locale } = useLocale();
62
+ const rtl = isRtl(locale);
63
+ const auto = useAutoPlay(play, context);
64
+ const go = (step) => {
65
+ if (!play.pending)
66
+ play.onStep(step);
67
+ };
68
+ return (_jsxs("section", { "data-prototype-focus-group": true, "data-preview-player": true, "aria-label": t('simple.player'), style: {
69
+ ...bar,
70
+ inlineSize: '100%',
71
+ maxInlineSize: 'calc(var(--space-6) * 24)',
72
+ justifySelf: 'center',
73
+ gridTemplateColumns: 'auto minmax(0, 1fr) auto auto',
74
+ border: 'var(--border-width-hairline) solid var(--border-default)',
75
+ borderRadius: 'var(--radius-panel)',
76
+ }, children: [_jsx(Button, { variant: "secondary", size: "sm", icon: rtl ? 'chevron-right' : 'chevron-left', disabled: play.step === 0, "aria-disabled": play.pending || undefined, onClick: () => go(play.step - 1), children: t('simple.player.back') }), _jsx(Where, { play: play, named: true }), _jsx(IconButton, { icon: auto.playing ? 'pause' : 'play', size: "sm", label: t(auto.playing ? 'studio.workspace.pause' : 'studio.workspace.play'), pressed: auto.playing, disabled: !auto.playing && play.step >= play.total - 1, onClick: auto.toggle }), _jsx(Button, { variant: "tonal", size: "sm", iconEnd: rtl ? 'chevron-left' : 'chevron-right', disabled: play.step >= play.total - 1, "aria-disabled": play.pending || undefined, onClick: () => go(play.step + 1), children: t('simple.player.next') })] }));
77
+ }
78
+ /** The foot bar on a phone-wide studio: the app takes the page above it. */
79
+ export function FootBar({ play, onJourneys }) {
80
+ const t = useT();
81
+ const { locale } = useLocale();
82
+ const rtl = isRtl(locale);
83
+ const showPane = useContext(StudioPaneContext);
84
+ const count = useWorkspace().setup.changes ?? 0;
85
+ const go = (step) => {
86
+ if (play && !play.pending)
87
+ play.onStep(step);
88
+ };
89
+ return (_jsxs("section", { "data-prototype-focus-group": true, "data-workspace-foot": true, "data-preview-player": play ? '' : undefined, "aria-label": t('simple.player'), style: {
90
+ ...bar,
91
+ gridTemplateColumns: 'auto auto minmax(0, 1fr) auto auto',
92
+ padding: 'var(--space-2) var(--space-3)',
93
+ borderBlockStart: 'var(--border-width-hairline) solid var(--border-hairline)',
94
+ background: 'var(--surface-page)',
95
+ }, children: [_jsx(IconButton, { icon: "list-checks", variant: "secondary", label: t('studio.workspace.journeys'), onClick: onJourneys }), _jsx(IconButton, { icon: rtl ? 'chevron-right' : 'chevron-left', label: t('simple.player.back'), disabled: !play || play.step === 0, onClick: () => play && go(play.step - 1) }), play ? _jsx(Where, { play: play, named: false }) : _jsx("span", {}), _jsx(IconButton, { icon: rtl ? 'chevron-left' : 'chevron-right', label: t('simple.player.next'), disabled: !play || play.step >= play.total - 1, onClick: () => play && go(play.step + 1) }), _jsx(Button, { variant: count ? 'primary' : 'secondary', icon: "message-square", "aria-label": count ? t('studio.workspace.changes.count', { count }) : undefined, disabled: !showPane, onClick: () => showPane?.('agent'), children: count ? formatNumber(locale, count) : t('studio.workspace.changes') })] }));
96
+ }
@@ -31,7 +31,4 @@ export const MOMENTS = {
31
31
  'proto-states': guide('prototype', 'prototype', { onChange: true }),
32
32
  'proto-lanes': { page: 'prototype', rail: places, level: 'guide' },
33
33
  'proto-drift': { page: 'prototype', rail: places, level: 'guide' },
34
- 'fs-tablet': guide('prototype', 'prototype', { onChange: true, cover: true }),
35
- 'fs-overview': guide('prototype', 'prototype', { onChange: true, cover: true }),
36
- 'fs-change': guide('prototype', 'prototype', { onChange: true, cover: true }),
37
34
  };
@@ -1,4 +1,5 @@
1
1
  import { type FrameCause, type PrototypeDiscovery } from './prototype-bridge.ts';
2
+ import { type PrototypePart } from './prototype-part.ts';
2
3
  /** What the studio asks the framed app to show: a journey at a step, or a preview data state. */
3
4
  export type PrototypeShow = {
4
5
  journey?: string;
@@ -22,6 +23,7 @@ type Input = {
22
23
  export declare function watchPrototypeDocument(input: Input): {
23
24
  alive: () => boolean;
24
25
  show: (choice: PrototypeShow) => boolean;
26
+ partAt: (x: number, y: number) => Promise<PrototypePart | undefined>;
25
27
  fail: (failure?: FrameFailure, cause?: FrameCause) => void;
26
28
  timedOutSilently: () => boolean;
27
29
  close: () => void;
@@ -1,4 +1,5 @@
1
1
  import { PROTOTYPE_LIVENESS, PROTOTYPE_WAIT, prototypeHeartbeat, prototypeHello, prototypeNavigationId, prototypePlayer, prototypeReply, } from './prototype-bridge.js';
2
+ import { partAsker } from './prototype-part.js';
2
3
  /** A deadline seen later than this (ms) was missed by the page, not by the app. */
3
4
  const LATE_SLACK = 1_000;
4
5
  /* Event x state -> readiness / nonce issued / controls / deadline
@@ -30,6 +31,8 @@ const LATE_SLACK = 1_000;
30
31
  * show() on a player document -> kept as the wanted choice; sent on the current port once alive
31
32
  * Hello again (the app reloaded) -> the wanted choice is sent again on the new port once alive
32
33
  * show() otherwise, or failed -> false: nothing kept, the caller reloads the frame instead
34
+ * partAt() while alive -> one ask on the current port; its answer (a name, a box) or none
35
+ * partAt() otherwise; new hello -> undefined at once; a waiting ask settles undefined (stale port)
33
36
  * A nonce is not a capability: even one copied into name/storage cannot renew via window messages.
34
37
  * Only that hello's port carries replies/beats; the app closes it and clears its nonce on pagehide.
35
38
  */
@@ -48,7 +51,9 @@ export function watchPrototypeDocument(input) {
48
51
  let sent;
49
52
  let deadline = 0;
50
53
  let timer;
54
+ const parts = partAsker();
51
55
  const revoke = () => {
56
+ parts.cancel();
52
57
  if (port) {
53
58
  port.onmessage = null;
54
59
  port.close();
@@ -146,6 +151,8 @@ export function watchPrototypeDocument(input) {
146
151
  return;
147
152
  // Expiry turns controls off, but a valid late proof on this document's port can revive it.
148
153
  lapsed();
154
+ if (parts.receive(message.data, expected))
155
+ return;
149
156
  if (prototypePlayer(message.data, expected)) {
150
157
  player = true;
151
158
  return;
@@ -253,9 +260,14 @@ export function watchPrototypeDocument(input) {
253
260
  document.addEventListener('visibilitychange', visibility);
254
261
  input.publish({});
255
262
  renew(PROTOTYPE_WAIT);
263
+ /** Asks the running app which part is at (x, y) of its page; undefined when it cannot say. */
264
+ const partAt = (x, y) => port && nonce && alive()
265
+ ? parts.ask(port, { navigation: input.navigation, document: nonce }, x, y)
266
+ : Promise.resolve(undefined);
256
267
  return {
257
268
  alive,
258
269
  show,
270
+ partAt,
259
271
  fail,
260
272
  timedOutSilently: () => timedOutSilently,
261
273
  close: () => {
@@ -0,0 +1,43 @@
1
+ import { type MarkScroll } from '@buffcore/contracts/workbench';
2
+ /**
3
+ * The part at a point of the framed app: its name (when it has one) and its box, in the app's px,
4
+ * and how far the app is scrolled.
5
+ */
6
+ export type PrototypePart = {
7
+ name?: string;
8
+ box: {
9
+ x: number;
10
+ y: number;
11
+ w: number;
12
+ h: number;
13
+ };
14
+ scroll?: MarkScroll;
15
+ };
16
+ /** An answer longer than this is refused whole: a name and a box are far smaller. */
17
+ export declare const PROTOTYPE_PART = 1024;
18
+ /** How long the studio waits for the answer before it says "this spot" instead (ms). */
19
+ export declare const PART_WAIT = 1500;
20
+ type Expected = {
21
+ navigation: string;
22
+ document: string;
23
+ };
24
+ /**
25
+ * One answer read strictly. Undefined when it is not a spot answer at all; `refused` when it is
26
+ * one but too long, malformed, or for another navigation or document; else the part.
27
+ */
28
+ export declare function prototypeSpot(data: unknown, expected: Expected): {
29
+ ask: number;
30
+ part: PrototypePart;
31
+ } | 'refused' | undefined;
32
+ /**
33
+ * The studio's side of "what is at this point": one ask at a time on the current document's
34
+ * private port. A newer ask, a new hello (cancel), an answer that is refused or late all settle
35
+ * the waiting ask with undefined, so the caller says "this spot".
36
+ */
37
+ export declare function partAsker(): {
38
+ ask(port: MessagePort, expected: Expected, x: number, y: number): Promise<PrototypePart | undefined>;
39
+ /** True when the message was a spot answer (taken or refused), so nothing else reads it. */
40
+ receive(data: unknown, expected: Expected): boolean;
41
+ cancel: () => void;
42
+ };
43
+ export {};
@@ -0,0 +1,104 @@
1
+ import { markScroll } from '@buffcore/contracts/workbench';
2
+ import { z } from 'zod';
3
+ /** An answer longer than this is refused whole: a name and a box are far smaller. */
4
+ export const PROTOTYPE_PART = 1_024;
5
+ /** How long the studio waits for the answer before it says "this spot" instead (ms). */
6
+ export const PART_WAIT = 1_500;
7
+ const size = z.number().int().min(0).max(100_000);
8
+ const spot = z.strictObject({
9
+ type: z.literal('ape:prototype:spot'),
10
+ version: z.literal(2),
11
+ navigation: z.string().uuid(),
12
+ document: z.string().uuid(),
13
+ ask: z.number().int().min(1).max(1_000_000),
14
+ // One short line, never control characters: the part's label, not the app's content.
15
+ name: z
16
+ .string()
17
+ .trim()
18
+ .min(1)
19
+ .max(80)
20
+ .regex(/^[^\p{Cc}\p{Cf}]+$/u)
21
+ .optional(),
22
+ box: z.strictObject({ x: size, y: size, w: size, h: size }),
23
+ scroll: markScroll.optional(),
24
+ });
25
+ /**
26
+ * One answer read strictly. Undefined when it is not a spot answer at all; `refused` when it is
27
+ * one but too long, malformed, or for another navigation or document; else the part.
28
+ */
29
+ export function prototypeSpot(data, expected) {
30
+ if (typeof data !== 'string' || !data.includes('"ape:prototype:spot"'))
31
+ return;
32
+ if (data.length > PROTOTYPE_PART)
33
+ return 'refused';
34
+ let value;
35
+ try {
36
+ value = JSON.parse(data);
37
+ }
38
+ catch {
39
+ return 'refused';
40
+ }
41
+ const answer = spot.safeParse(value);
42
+ if (!answer.success ||
43
+ answer.data.navigation !== expected.navigation ||
44
+ answer.data.document !== expected.document)
45
+ return 'refused';
46
+ const { ask, name, box, scroll } = answer.data;
47
+ return { ask, part: { ...(name ? { name } : {}), box, ...(scroll ? { scroll } : {}) } };
48
+ }
49
+ /**
50
+ * The studio's side of "what is at this point": one ask at a time on the current document's
51
+ * private port. A newer ask, a new hello (cancel), an answer that is refused or late all settle
52
+ * the waiting ask with undefined, so the caller says "this spot".
53
+ */
54
+ export function partAsker() {
55
+ let count = 0;
56
+ let waiting;
57
+ const settle = (part) => {
58
+ const current = waiting;
59
+ waiting = undefined;
60
+ current?.done(part);
61
+ };
62
+ return {
63
+ ask(port, expected, x, y) {
64
+ settle();
65
+ count += 1;
66
+ const ask = count;
67
+ return new Promise((resolve) => {
68
+ const timer = setTimeout(() => waiting?.ask === ask && settle(), PART_WAIT);
69
+ waiting = {
70
+ ask,
71
+ done: (part) => {
72
+ clearTimeout(timer);
73
+ resolve(part);
74
+ },
75
+ };
76
+ try {
77
+ port.postMessage(JSON.stringify({
78
+ type: 'ape:prototype:part',
79
+ version: 2,
80
+ ...expected,
81
+ ask,
82
+ x: Math.max(0, Math.round(x)),
83
+ y: Math.max(0, Math.round(y)),
84
+ }));
85
+ }
86
+ catch {
87
+ settle();
88
+ }
89
+ });
90
+ },
91
+ /** True when the message was a spot answer (taken or refused), so nothing else reads it. */
92
+ receive(data, expected) {
93
+ const answer = prototypeSpot(data, expected);
94
+ if (answer === undefined)
95
+ return false;
96
+ if (answer === 'refused')
97
+ settle();
98
+ else if (answer.ask === waiting?.ask)
99
+ settle(answer.part);
100
+ return true;
101
+ },
102
+ cancel: () => settle(),
103
+ };
104
+ }
@@ -1,7 +1,7 @@
1
1
  import type { FoundAgent } from '@buffcore/contracts/workbench';
2
2
  import type { AgentMessage, PlanExtension, PlanMilestone, StudioProduct } from '../types.ts';
3
3
  /** The moments the studio's states panel lists for the loop, in order. */
4
- export declare const LOOP_MOMENTS: readonly ['fresh', 'agents', 'brief', 'autopilot', 'plan', 'brand', 'brand-picked', 'journeys', 'proto-v1', 'proto-comment', 'proto-v2', 'approved', 'proto-states', 'proto-lanes', 'proto-drift', 'fs-tablet', 'fs-overview', 'fs-change'];
4
+ export declare const LOOP_MOMENTS: readonly ['fresh', 'agents', 'brief', 'autopilot', 'plan', 'brand', 'brand-picked', 'journeys', 'proto-v1', 'proto-comment', 'proto-v2', 'approved', 'proto-states', 'proto-lanes', 'proto-drift'];
5
5
  export type LoopMoment = (typeof LOOP_MOMENTS)[number];
6
6
  /** An agent found on this computer. */
7
7
  export interface AgentRow {
@@ -29,6 +29,17 @@ export interface BriefQuestion {
29
29
  /** The choice that answers it, when it is one of the loop's. */
30
30
  choice?: ChoiceKey;
31
31
  }
32
+ /** A section of plan/brief.md: its heading there, and its whole Markdown, to read. */
33
+ export interface BriefPart {
34
+ heading: string;
35
+ text: string;
36
+ }
37
+ /** The sections the Brief shows short, each with its Read more. */
38
+ export type BriefShort = 'what' | 'who' | 'kind' | 'earns' | 'must' | 'later';
39
+ /**
40
+ * The brief, short first: each section's one-line summary (or its first sentence), Must have and
41
+ * Not now as items. An empty field is a section the brief does not have: it is not shown.
42
+ */
32
43
  export interface BriefDoc {
33
44
  what: string;
34
45
  who: readonly {
@@ -37,10 +48,19 @@ export interface BriefDoc {
37
48
  note?: string;
38
49
  }[];
39
50
  kind?: 'B2C' | 'B2B';
51
+ /** The kind section's own line; without it the page says what the kind means. */
52
+ kindLine?: string;
40
53
  earns?: string;
41
54
  must?: readonly string[];
55
+ /** How many items the section holds in all, when more than `must` (its summaries). */
56
+ mustCount?: number;
42
57
  later?: readonly string[];
58
+ laterCount?: number;
43
59
  questions: readonly BriefQuestion[];
60
+ /** Each short section's whole text, for its Read more; none, no Read more. */
61
+ read?: Partial<Record<BriefShort, BriefPart>>;
62
+ /** Every section of plan/brief.md in order, for Read the whole brief. */
63
+ whole?: readonly BriefPart[];
44
64
  }
45
65
  export type ChoiceKey = 'length' | 'm1' | 'first' | 'list';
46
66
  /** A choice in the loop: its options, what the agent picks, and why. */
@@ -136,6 +156,11 @@ export interface ProtoSample {
136
156
  scene: string;
137
157
  label: string;
138
158
  }[];
159
+ /** The console's own scenes, for the workspace's Screens. */
160
+ consoleOthers?: readonly {
161
+ scene: string;
162
+ label: string;
163
+ }[];
139
164
  versions: readonly {
140
165
  v: string;
141
166
  commit: string;
@@ -179,30 +204,6 @@ export interface ProtoSample {
179
204
  added?: string;
180
205
  }[];
181
206
  }
182
- export interface FsMark {
183
- n: number;
184
- kind: 'area' | 'select' | 'draw';
185
- where: string;
186
- device: 'phone' | 'tablet' | 'desktop';
187
- note: string;
188
- /** Where it sits on the screen, as percentages of its width and height; an area has a size. */
189
- at: {
190
- x: number;
191
- y: number;
192
- w?: number;
193
- h?: number;
194
- };
195
- }
196
- export interface FsSample {
197
- marks: readonly FsMark[];
198
- text: string;
199
- plan: {
200
- id: string;
201
- title: string;
202
- steps: readonly string[];
203
- touches: readonly string[];
204
- };
205
- }
206
207
  /** Everything a loop page draws, for one sample product. */
207
208
  export interface LoopSample {
208
209
  contained?: boolean;
@@ -222,7 +223,6 @@ export interface LoopSample {
222
223
  };
223
224
  journeys: readonly JourneyRole[];
224
225
  proto: ProtoSample;
225
- fs: FsSample;
226
226
  /** The agent's panel for each moment. */
227
227
  talk: Record<LoopMoment, readonly AgentMessage[]>;
228
228
  }
@@ -15,7 +15,4 @@ export const LOOP_MOMENTS = [
15
15
  'proto-states',
16
16
  'proto-lanes',
17
17
  'proto-drift',
18
- 'fs-tablet',
19
- 'fs-overview',
20
- 'fs-change',
21
18
  ];
@@ -1,4 +1,5 @@
1
1
  import { type FrameFailure, type PrototypeShow } from './prototype-document.ts';
2
+ import type { PrototypePart } from './prototype-part.ts';
2
3
  /** The session owns document changes; React only publishes its current navigation's answer. */
3
4
  export declare function usePrototypeFrame(origin: string, navigation: string,
4
5
  /** Remember when the switched address stayed silent so the next navigation uses the given one. */
@@ -25,4 +26,6 @@ onSwitch?: () => void, running?: boolean): {
25
26
  /** Sends the choice to the running app; false when it could not, and the frame must reload. */
26
27
  show: (choice: PrototypeShow) => boolean;
27
28
  fail: (status?: FrameFailure) => void | undefined;
29
+ /** The part of the running app at (x, y) of its page: a name and a box, or undefined. */
30
+ partAt: (x: number, y: number) => Promise<PrototypePart | undefined>;
28
31
  };
@@ -57,5 +57,7 @@ onSwitch, running) {
57
57
  /** Sends the choice to the running app; false when it could not, and the frame must reload. */
58
58
  show: (choice) => session.current?.show(choice) ?? false,
59
59
  fail: (status) => session.current?.fail(status),
60
+ /** The part of the running app at (x, y) of its page: a name and a box, or undefined. */
61
+ partAt: (x, y) => session.current?.partAt(x, y) ?? Promise.resolve(undefined),
60
62
  };
61
63
  }
@@ -0,0 +1,22 @@
1
+ import type { PlayableJourney } from './prototype-bridge.ts';
2
+ import type { JourneyRole } from './types.ts';
3
+ import type { WorkspaceApp } from './workspace-state.tsx';
4
+ export interface WorkspaceJourney {
5
+ /** The plan's id, or the app's key for a journey only the app lists. */
6
+ id: string;
7
+ name: string;
8
+ where: WorkspaceApp;
9
+ /** Each step's name from the plan; '' where the plan names none (the app's count is longer). */
10
+ steps: readonly string[];
11
+ /** The running app's key, when it plays this journey. */
12
+ key?: string;
13
+ }
14
+ export interface WorkspaceGroup {
15
+ /** None for the app's journeys that give no role. */
16
+ role?: string;
17
+ where: WorkspaceApp;
18
+ journeys: readonly WorkspaceJourney[];
19
+ }
20
+ export declare function workspaceGroups(roles: readonly JourneyRole[], live: readonly PlayableJourney[]): WorkspaceGroup[];
21
+ /** The journey the shown app has open: the app's playing one or one looked at, or the console's. */
22
+ export declare function openJourney(groups: readonly WorkspaceGroup[], where: WorkspaceApp, id: string | undefined, key?: string): WorkspaceJourney | undefined;