@buffcore/admin-shell 0.8.43 → 0.8.44
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/workbench/app/ServedPrototype.d.ts +2 -0
- package/dist/workbench/app/ServedPrototype.js +6 -1
- package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
- package/dist/workbench/app/chat-session.d.ts +2 -2
- package/dist/workbench/app/chat.d.ts +2 -2
- package/dist/workbench/app/frame.js +5 -1
- package/dist/workbench/app/pages.js +10 -2
- package/dist/workbench/app/test/loop-fixture.d.ts +3 -1
- package/dist/workbench/studio/frame/Composer.js +13 -10
- package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
- package/dist/workbench/studio/frame/StudioFrame.js +4 -3
- package/dist/workbench/studio/frame/scrollbars.d.ts +1 -0
- package/dist/workbench/studio/frame/scrollbars.js +10 -0
- package/dist/workbench/studio/frame/useTurnDraft.d.ts +2 -0
- package/dist/workbench/studio/frame/useTurnDraft.js +12 -9
- package/dist/workbench/studio/i18n/frame.en.d.ts +3 -0
- package/dist/workbench/studio/i18n/frame.en.js +4 -1
- package/dist/workbench/studio/i18n/frame.es.json +4 -1
- package/dist/workbench/studio/loop/PrototypeApp.d.ts +9 -0
- package/dist/workbench/studio/loop/PrototypeApp.js +6 -4
- package/dist/workbench/studio/loop/PrototypeAttempt.d.ts +2 -1
- package/dist/workbench/studio/loop/PrototypeAttempt.js +40 -16
- package/dist/workbench/studio/loop/PrototypePreview.js +34 -29
- package/dist/workbench/studio/loop/prototype-bridge.d.ts +8 -0
- package/dist/workbench/studio/loop/prototype-bridge.js +16 -0
- package/dist/workbench/studio/loop/prototype-document.d.ts +7 -0
- package/dist/workbench/studio/loop/prototype-document.js +78 -2
- package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +3 -1
- package/dist/workbench/studio/loop/usePrototypeFrame.js +2 -0
- package/dist/workbench/studio/types.d.ts +2 -0
- package/dist/workbench/studio/work/work-test-data.d.ts +1 -0
- package/package.json +6 -6
|
@@ -79,7 +79,7 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
|
|
|
79
79
|
targets: string[];
|
|
80
80
|
refused?: boolean | undefined;
|
|
81
81
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
82
|
-
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
82
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
83
83
|
} | undefined;
|
|
84
84
|
permission?: {
|
|
85
85
|
path: string;
|
|
@@ -175,7 +175,7 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
|
|
|
175
175
|
targets: string[];
|
|
176
176
|
refused?: boolean | undefined;
|
|
177
177
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
178
|
-
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
178
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
179
179
|
} | undefined;
|
|
180
180
|
permission?: {
|
|
181
181
|
path: string;
|
|
@@ -123,7 +123,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
|
|
|
123
123
|
targets: string[];
|
|
124
124
|
refused?: boolean | undefined;
|
|
125
125
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
126
|
-
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
126
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
127
127
|
} | undefined;
|
|
128
128
|
permission?: {
|
|
129
129
|
path: string;
|
|
@@ -225,7 +225,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
|
|
|
225
225
|
targets: string[];
|
|
226
226
|
refused?: boolean | undefined;
|
|
227
227
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
228
|
-
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
228
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
229
229
|
} | undefined;
|
|
230
230
|
permission?: {
|
|
231
231
|
path: string;
|
|
@@ -56,7 +56,11 @@ export function frameProps(state, ui) {
|
|
|
56
56
|
const level = state.agents.file?.level ?? 'guide';
|
|
57
57
|
return {
|
|
58
58
|
onSend: ui.onSend,
|
|
59
|
-
product: {
|
|
59
|
+
product: {
|
|
60
|
+
...state.product,
|
|
61
|
+
agent: footLine(state, ui.t),
|
|
62
|
+
...(state.hostLaunched ? { hostLaunched: true } : {}),
|
|
63
|
+
},
|
|
60
64
|
level,
|
|
61
65
|
onLevel: (value) => ui.actions.level(value),
|
|
62
66
|
rail: { form: 'loop', stage: 'brief' },
|
|
@@ -43,6 +43,14 @@ export function StudioPages(props) {
|
|
|
43
43
|
pickJourney(id);
|
|
44
44
|
props.actions.go?.('prototype');
|
|
45
45
|
};
|
|
46
|
+
const onPlayed = () => pickJourney(undefined);
|
|
47
|
+
// A Play request lives only until the person leaves Prototype, so it never starts later.
|
|
48
|
+
const shown = useRef(props.page);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (shown.current === 'prototype' && props.page !== 'prototype')
|
|
51
|
+
pickJourney(undefined);
|
|
52
|
+
shown.current = props.page;
|
|
53
|
+
}, [props.page]);
|
|
46
54
|
return (_jsxs(_Fragment, { children: [_jsx(AutoChoices, { viewer: props.state.viewer, choices: props.state.work?.autopilot, page: props.page, onChange: props.onStep &&
|
|
47
55
|
((choice) => props.onStep?.({
|
|
48
56
|
page: choice.step,
|
|
@@ -50,7 +58,7 @@ export function StudioPages(props) {
|
|
|
50
58
|
change: choice.change,
|
|
51
59
|
}, t('studio.auto.changeRequest', {
|
|
52
60
|
step: t(`studio.frame.page.${choice.step === 'merge' ? 'work' : choice.step}`),
|
|
53
|
-
}))) }), _jsx(PageRoute, { ...props, change: change, onChange: props.onChange ?? pickChange, journey: journey, onPlay: onPlay, server: server, onServer: onServer, iconSrc: iconSrc, work: { ui: workUi, onUi: onWorkUi, position: workPosition } })] }));
|
|
61
|
+
}))) }), _jsx(PageRoute, { ...props, change: change, onChange: props.onChange ?? pickChange, journey: journey, onPlay: onPlay, onPlayed: onPlayed, server: server, onServer: onServer, iconSrc: iconSrc, work: { ui: workUi, onUi: onWorkUi, position: workPosition } })] }));
|
|
54
62
|
}
|
|
55
63
|
function PageRoute(props) {
|
|
56
64
|
const { state, page, actions, onComment, onStep, journey, onPlay, server, onServer } = props;
|
|
@@ -63,7 +71,7 @@ function PageRoute(props) {
|
|
|
63
71
|
if (page === 'prototype')
|
|
64
72
|
return (_jsx(ServedPrototype, { every: props.every, change: props.change, version: props.work.position.current.opener === props.change
|
|
65
73
|
? props.work.position.current.version
|
|
66
|
-
: undefined, prototypeTurn: props.prototypeTurn, state: state, actions: actions, onComment: onComment, onStep: onStep, journey: journey }));
|
|
74
|
+
: undefined, prototypeTurn: props.prototypeTurn, state: state, actions: actions, onComment: onComment, onStep: onStep, journey: journey, onPlayed: props.onPlayed }));
|
|
67
75
|
// Fresh means chats known to be none; chats the viewer cannot read are unknown, so the Brief.
|
|
68
76
|
if (page === 'brief' && !briefHasContent(state) && state.chats?.length === 0)
|
|
69
77
|
return _jsx(ServedStart, { state: state, actions: actions, onStep: onStep, onLevel: props.onLevel });
|
|
@@ -8,6 +8,7 @@ export declare function LoopLocale({ children, locale }: {
|
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
9
|
export declare function loopApi(initial?: {
|
|
10
10
|
contained?: boolean | undefined;
|
|
11
|
+
hostLaunched?: boolean | undefined;
|
|
11
12
|
viewer?: {
|
|
12
13
|
name: string;
|
|
13
14
|
email?: string | undefined;
|
|
@@ -440,7 +441,7 @@ export declare function loopApi(initial?: {
|
|
|
440
441
|
targets: string[];
|
|
441
442
|
refused?: boolean | undefined;
|
|
442
443
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
443
|
-
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
444
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
444
445
|
} | undefined;
|
|
445
446
|
permission?: {
|
|
446
447
|
path: string;
|
|
@@ -465,6 +466,7 @@ export declare function loopApi(initial?: {
|
|
|
465
466
|
}>;
|
|
466
467
|
initial: {
|
|
467
468
|
contained?: boolean | undefined;
|
|
469
|
+
hostLaunched?: boolean | undefined;
|
|
468
470
|
viewer?: {
|
|
469
471
|
name: string;
|
|
470
472
|
email?: string | undefined;
|
|
@@ -8,6 +8,7 @@ import { captionText } from '../../../components/styles.js';
|
|
|
8
8
|
import { TextArea } from '../../../components/TextArea.js';
|
|
9
9
|
import { ReasonButton } from './ReasonButton.js';
|
|
10
10
|
import { Unready } from './TurnControls.js';
|
|
11
|
+
import { withTyped } from './useTurnDraft.js';
|
|
11
12
|
function Attachments({ agent, onRemoveAttachment }) {
|
|
12
13
|
const t = useT();
|
|
13
14
|
if (!agent.attachments?.length)
|
|
@@ -45,23 +46,25 @@ function useDraft({ agent, onSend }) {
|
|
|
45
46
|
return;
|
|
46
47
|
if (agent.running)
|
|
47
48
|
return agent.turn?.composer?.onQueue?.();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// The words leave the box at once; a refused send puts them back before anything typed since.
|
|
50
|
+
// A served composer (agent.turn.composer) clears and restores its own draft.
|
|
51
|
+
const words = draft;
|
|
52
|
+
if (!agent.turn?.composer)
|
|
53
|
+
setLocal('');
|
|
54
|
+
const restore = () => {
|
|
55
|
+
if (!agent.turn?.composer)
|
|
56
|
+
setLocal((current) => withTyped(words, current));
|
|
51
57
|
};
|
|
52
58
|
const result = onSend(draft.trim());
|
|
53
59
|
if (!(result instanceof Promise))
|
|
54
|
-
return
|
|
60
|
+
return result === false ? restore() : undefined;
|
|
55
61
|
sending.current = true;
|
|
56
62
|
setPending(true);
|
|
57
63
|
void result
|
|
58
64
|
.then((result) => {
|
|
59
|
-
if (result
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// The served container clears its own draft, including sends made by its queue.
|
|
63
|
-
}
|
|
64
|
-
}, () => { })
|
|
65
|
+
if (result === false)
|
|
66
|
+
restore();
|
|
67
|
+
}, restore)
|
|
65
68
|
.finally(() => {
|
|
66
69
|
sending.current = false;
|
|
67
70
|
setPending(false);
|
|
@@ -16,6 +16,15 @@ const heading = {
|
|
|
16
16
|
padding: 'var(--space-2) var(--space-3) var(--space-1)',
|
|
17
17
|
fontWeight: 'var(--weight-bold)',
|
|
18
18
|
};
|
|
19
|
+
const note = {
|
|
20
|
+
...captionText,
|
|
21
|
+
fontWeight: 'var(--weight-regular)',
|
|
22
|
+
margin: 0,
|
|
23
|
+
padding: '0 var(--space-3)',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
gap: 'var(--space-2)',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
};
|
|
19
28
|
function Section({ title, children }) {
|
|
20
29
|
return (_jsxs("section", { "aria-label": title, style: { display: 'grid', gap: 'var(--space-1)' }, children: [_jsx("h3", { style: heading, children: title }), children] }));
|
|
21
30
|
}
|
|
@@ -29,13 +38,5 @@ export function SettingsSheet({ level, product, places, page, onClose, onLevel,
|
|
|
29
38
|
const name = t(`studio.frame.level.${level}`);
|
|
30
39
|
const never = useContext(LevelChoiceContext)?.neverAsk;
|
|
31
40
|
const computer = places ? COMPUTER.filter(({ id }) => places.includes(id)) : COMPUTER;
|
|
32
|
-
return (_jsx(Sheet, { title: t('studio.frame.settings'), onClose: onClose, children: _jsxs("div", { style: { display: 'grid', gap: 'var(--space-4)' }, children: [_jsxs(Section, { title: t('studio.level.choices'), children: [_jsxs(Row, { onClick: onLevel, children: [_jsx(Icon, { name: "sliders-horizontal", size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: never ? t('studio.level.neverAsk.chip', { level: name }) : name }), _jsx(Icon, { name: "chevron-right", size: "var(--icon-sm)" })] }), _jsxs("p", { style: {
|
|
33
|
-
...captionText,
|
|
34
|
-
fontWeight: 'var(--weight-regular)',
|
|
35
|
-
margin: 0,
|
|
36
|
-
padding: '0 var(--space-3)',
|
|
37
|
-
display: 'flex',
|
|
38
|
-
gap: 'var(--space-2)',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
}, children: [_jsx(Icon, { name: "shield-check", size: "var(--icon-sm)" }), _jsx("span", { children: t('studio.frame.settings.person') })] })] }), computer.length > 0 && (_jsx(Section, { title: machine.name, children: computer.map(({ id, icon }) => (_jsxs(Row, { on: page === id, onClick: onGo && (() => onGo(id)), children: [_jsx(Icon, { name: icon, size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: t(`studio.frame.page.${id}`) })] }, id))) })), onHelp && (_jsxs(Row, { onClick: onHelp, children: [_jsx(Icon, { name: "circle-help", size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: t('studio.frame.help') })] }))] }) }));
|
|
41
|
+
return (_jsx(Sheet, { title: t('studio.frame.settings'), onClose: onClose, children: _jsxs("div", { style: { display: 'grid', gap: 'var(--space-4)' }, children: [_jsxs(Section, { title: t('studio.level.choices'), children: [_jsxs(Row, { onClick: onLevel, children: [_jsx(Icon, { name: "sliders-horizontal", size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: never ? t('studio.level.neverAsk.chip', { level: name }) : name }), _jsx(Icon, { name: "chevron-right", size: "var(--icon-sm)" })] }), _jsxs("p", { style: note, children: [_jsx(Icon, { name: "shield-check", size: "var(--icon-sm)" }), _jsx("span", { children: t('studio.frame.settings.person') })] }), product.hostLaunched && (_jsxs("p", { style: note, children: [_jsx(Icon, { name: "lock", size: "var(--icon-sm)" }), _jsx("span", { children: t('studio.frame.settings.host') })] }))] }), computer.length > 0 && (_jsx(Section, { title: machine.name, children: computer.map(({ id, icon }) => (_jsxs(Row, { on: page === id, onClick: onGo && (() => onGo(id)), children: [_jsx(Icon, { name: icon, size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: t(`studio.frame.page.${id}`) })] }, id))) })), onHelp && (_jsxs(Row, { onClick: onHelp, children: [_jsx(Icon, { name: "circle-help", size: "var(--icon-md)" }), _jsx("span", { style: { flex: 1 }, children: t('studio.frame.help') })] }))] }) }));
|
|
41
42
|
}
|
|
@@ -12,6 +12,7 @@ import { HostPage, Place } from './Place.js';
|
|
|
12
12
|
import { AppUrl } from './RealApp.js';
|
|
13
13
|
import { StudioRail } from './StudioRail.js';
|
|
14
14
|
import { StudioRegions } from './StudioRegions.js';
|
|
15
|
+
import { STUDIO_SCROLLBARS } from './scrollbars.js';
|
|
15
16
|
import { TopBar } from './TopBar.js';
|
|
16
17
|
const WIDE = { narrow: false };
|
|
17
18
|
const NARROW = { narrow: true };
|
|
@@ -22,9 +23,9 @@ export function StudioFrame(props) {
|
|
|
22
23
|
if (host?.parts?.screen?.length)
|
|
23
24
|
return _jsx(Place, { id: "screen" });
|
|
24
25
|
if (props.cover) {
|
|
25
|
-
return (
|
|
26
|
+
return (_jsxs("div", { ref: ref, "data-studio-frame": true, style: { height: '100%', background: 'var(--surface-canvas)' }, children: [_jsx("style", { children: STUDIO_SCROLLBARS }), children] }));
|
|
26
27
|
}
|
|
27
|
-
return (
|
|
28
|
+
return (_jsxs("div", { ref: ref, "data-studio-frame": true, "data-layout": layout, "data-prototype-layout": props.page === 'prototype' ? '' : undefined, "data-prototype-layout-known": props.page === 'prototype' && known ? '' : undefined, style: {
|
|
28
29
|
height: '100%',
|
|
29
30
|
maxHeight: props.page === 'prototype' ? '100dvh' : undefined,
|
|
30
31
|
minHeight: props.page === 'prototype' ? 0 : undefined,
|
|
@@ -33,7 +34,7 @@ export function StudioFrame(props) {
|
|
|
33
34
|
gridTemplateRows: 'auto minmax(0, 1fr)',
|
|
34
35
|
background: 'var(--surface-canvas)',
|
|
35
36
|
color: 'var(--text-body)',
|
|
36
|
-
}, children: _jsxs(StudioLook, { value: layout === 'narrow' ? NARROW : WIDE, children: [_jsx(FrameTop, { props: props, layout: layout }), _jsx(Body, { props: props, layout: layout, children: children })] }) }));
|
|
37
|
+
}, children: [_jsx("style", { children: STUDIO_SCROLLBARS }), _jsxs(StudioLook, { value: layout === 'narrow' ? NARROW : WIDE, children: [_jsx(FrameTop, { props: props, layout: layout }), _jsx(Body, { props: props, layout: layout, children: children })] })] }));
|
|
37
38
|
}
|
|
38
39
|
function FrameTop({ props, layout }) {
|
|
39
40
|
const host = usePlaces();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STUDIO_SCROLLBARS = "\n[data-studio-frame],[data-studio-frame] *{scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent}\n[data-studio-frame] ::-webkit-scrollbar,[data-studio-frame]::-webkit-scrollbar{width:var(--space-2);height:var(--space-2)}\n[data-studio-frame] ::-webkit-scrollbar-track,[data-studio-frame]::-webkit-scrollbar-track{background:transparent}\n[data-studio-frame] ::-webkit-scrollbar-thumb,[data-studio-frame]::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:var(--radius-chip)}\n[data-studio-frame] ::-webkit-scrollbar-thumb:hover{background:var(--text-subtle)}\n[data-studio-frame] ::-webkit-scrollbar-corner{background:transparent}\n";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The studio's scroll bars: thin, in the theme's colors, light and dark, in every panel that
|
|
2
|
+
// scrolls inside the frame. Tokens only, so a host's theme colors them too.
|
|
3
|
+
export const STUDIO_SCROLLBARS = `
|
|
4
|
+
[data-studio-frame],[data-studio-frame] *{scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent}
|
|
5
|
+
[data-studio-frame] ::-webkit-scrollbar,[data-studio-frame]::-webkit-scrollbar{width:var(--space-2);height:var(--space-2)}
|
|
6
|
+
[data-studio-frame] ::-webkit-scrollbar-track,[data-studio-frame]::-webkit-scrollbar-track{background:transparent}
|
|
7
|
+
[data-studio-frame] ::-webkit-scrollbar-thumb,[data-studio-frame]::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:var(--radius-chip)}
|
|
8
|
+
[data-studio-frame] ::-webkit-scrollbar-thumb:hover{background:var(--text-subtle)}
|
|
9
|
+
[data-studio-frame] ::-webkit-scrollbar-corner{background:transparent}
|
|
10
|
+
`;
|
|
@@ -22,4 +22,6 @@ export declare function useTurnDraft(key: string, status: Status, send: (text: s
|
|
|
22
22
|
answer: (context: string, key?: string) => void;
|
|
23
23
|
focus: () => void;
|
|
24
24
|
};
|
|
25
|
+
/** The words of a failed send, then a blank line and what the person typed while it was sending. */
|
|
26
|
+
export declare function withTyped(failed: string, typed: string): string;
|
|
25
27
|
export {};
|
|
@@ -24,19 +24,18 @@ export function useTurnDraft(key, status, send, options = {}) {
|
|
|
24
24
|
return false;
|
|
25
25
|
pending.current = true;
|
|
26
26
|
const draft = current();
|
|
27
|
+
// The words move into the chat at once (shown as sending), so the box clears now. A refused
|
|
28
|
+
// or interrupted send never loses them: they come back first, then anything typed meanwhile.
|
|
29
|
+
update({ value: '' });
|
|
30
|
+
let ok = false;
|
|
27
31
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return false;
|
|
31
|
-
if (ok &&
|
|
32
|
-
current().value === draft.value &&
|
|
33
|
-
current().answerKey === draft.answerKey &&
|
|
34
|
-
current().context === draft.context)
|
|
35
|
-
update({ value: '' });
|
|
36
|
-
return ok;
|
|
32
|
+
ok = await send(draft.context ? `${draft.context}\n\n${text}` : text);
|
|
33
|
+
return ok && active.current === cell;
|
|
37
34
|
}
|
|
38
35
|
finally {
|
|
39
36
|
pending.current = false;
|
|
37
|
+
if (!ok)
|
|
38
|
+
update({ ...draft, queued: false, value: withTyped(draft.value, current().value) });
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
useQueue(status, options, current, update, submit);
|
|
@@ -66,6 +65,10 @@ export function useTurnDraft(key, status, send, options = {}) {
|
|
|
66
65
|
const focus = () => update({ ...current(), focus: (current().focus ?? 0) + 1 });
|
|
67
66
|
return { composer, send: submit, answer, focus };
|
|
68
67
|
}
|
|
68
|
+
/** The words of a failed send, then a blank line and what the person typed while it was sending. */
|
|
69
|
+
export function withTyped(failed, typed) {
|
|
70
|
+
return typed ? `${failed}\n\n${typed}` : failed;
|
|
71
|
+
}
|
|
69
72
|
function useQueue(status, options, current, update, submit) {
|
|
70
73
|
useEffect(() => {
|
|
71
74
|
const draft = current();
|
|
@@ -80,6 +80,7 @@ declare const _default: {
|
|
|
80
80
|
'studio.frame.agent.defaultLine': string;
|
|
81
81
|
'studio.frame.settings': string;
|
|
82
82
|
'studio.frame.settings.person': string;
|
|
83
|
+
'studio.frame.settings.host': string;
|
|
83
84
|
'studio.frame.panel.title': string;
|
|
84
85
|
'studio.frame.panel.where': string;
|
|
85
86
|
'studio.frame.panel.earlier': string;
|
|
@@ -216,6 +217,8 @@ declare const _default: {
|
|
|
216
217
|
'studio.frame.limit.kind.push': string;
|
|
217
218
|
'studio.frame.limit.kind.publish': string;
|
|
218
219
|
'studio.frame.limit.kind.release': string;
|
|
220
|
+
'studio.frame.limit.kind.approval': string;
|
|
221
|
+
'studio.frame.limit.kind.commit': string;
|
|
219
222
|
'studio.frame.limit.next': string;
|
|
220
223
|
'studio.frame.limit.copy': string;
|
|
221
224
|
'studio.frame.limit.copied': string;
|
|
@@ -83,6 +83,7 @@ export default {
|
|
|
83
83
|
'studio.frame.agent.defaultLine': 'Default agent',
|
|
84
84
|
'studio.frame.settings': 'Settings',
|
|
85
85
|
'studio.frame.settings.person': 'Some decisions always wait for a person. The level lists them.',
|
|
86
|
+
'studio.frame.settings.host': 'Your host starts the agents and applies their limits.',
|
|
86
87
|
// The agent's panel
|
|
87
88
|
'studio.frame.panel.title': 'Your agent',
|
|
88
89
|
'studio.frame.panel.where': 'Default agent · on {where}',
|
|
@@ -222,10 +223,12 @@ export default {
|
|
|
222
223
|
'studio.frame.limit.kind.push': 'Pushing with git',
|
|
223
224
|
'studio.frame.limit.kind.publish': 'Publishing a package',
|
|
224
225
|
'studio.frame.limit.kind.release': 'Publishing a release',
|
|
226
|
+
'studio.frame.limit.kind.approval': 'Writing an approval record',
|
|
227
|
+
'studio.frame.limit.kind.commit': 'Committing from a design step on Autopilot',
|
|
225
228
|
'studio.frame.limit.next': 'Only a person does this. Nothing was run: copy the command and run it in your own terminal when you’re ready.',
|
|
226
229
|
'studio.frame.limit.copy': 'Copy the command',
|
|
227
230
|
'studio.frame.limit.copied': 'Command copied.',
|
|
228
231
|
'studio.frame.limit.copyFailed': 'Couldn’t copy. Select the command and copy it.',
|
|
229
232
|
'studio.frame.limit.long': 'This command was shortened in the chat, so it can’t be copied whole from here.',
|
|
230
|
-
'studio.frame.limit.list': 'Never allowed at any level: folders of sign-ins or keys, production settings, deploys, git push, publishing a package or a release.',
|
|
233
|
+
'studio.frame.limit.list': 'Never allowed at any level: folders of sign-ins or keys, production settings, deploys, git push, publishing a package or a release, writing an approval record. On Autopilot, a design step makes no commit.',
|
|
231
234
|
};
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"studio.frame.agent.defaultLine": "Agente por defecto",
|
|
82
82
|
"studio.frame.settings": "Ajustes",
|
|
83
83
|
"studio.frame.settings.person": "Algunas decisiones siempre esperan a una persona. El nivel dice cuáles.",
|
|
84
|
+
"studio.frame.settings.host": "Tu anfitrión inicia los agentes y aplica sus límites.",
|
|
84
85
|
"studio.frame.agent.working": "Trabajando",
|
|
85
86
|
"studio.frame.panel.title": "Tu agente",
|
|
86
87
|
"studio.frame.panel.where": "Agente por defecto · en {where}",
|
|
@@ -212,10 +213,12 @@
|
|
|
212
213
|
"studio.frame.limit.kind.push": "Hacer push con git",
|
|
213
214
|
"studio.frame.limit.kind.publish": "Publicar un paquete",
|
|
214
215
|
"studio.frame.limit.kind.release": "Publicar una versión",
|
|
216
|
+
"studio.frame.limit.kind.approval": "Escribir un registro de aprobación",
|
|
217
|
+
"studio.frame.limit.kind.commit": "Hacer un commit desde un paso de diseño en Piloto automático",
|
|
215
218
|
"studio.frame.limit.next": "Solo una persona hace esto. No se ejecutó nada: copia el comando y ejecútalo en tu propia terminal cuando quieras.",
|
|
216
219
|
"studio.frame.limit.copy": "Copiar el comando",
|
|
217
220
|
"studio.frame.limit.copied": "Comando copiado.",
|
|
218
221
|
"studio.frame.limit.copyFailed": "No se pudo copiar. Selecciona el comando y cópialo.",
|
|
219
222
|
"studio.frame.limit.long": "Este comando se acortó en el chat, así que no se puede copiar entero desde aquí.",
|
|
220
|
-
"studio.frame.limit.list": "Nunca se permite en ningún nivel: carpetas de accesos o claves, ajustes de producción, despliegues, git push, publicar un paquete o una versión."
|
|
223
|
+
"studio.frame.limit.list": "Nunca se permite en ningún nivel: carpetas de accesos o claves, ajustes de producción, despliegues, git push, publicar un paquete o una versión, escribir un registro de aprobación. En Piloto automático, un paso de diseño no hace commits."
|
|
221
224
|
}
|
|
@@ -13,7 +13,16 @@ 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?: {
|
|
@@ -83,14 +83,16 @@ function PlayableApp(props) {
|
|
|
83
83
|
const container = useRef(null);
|
|
84
84
|
if (!navigation)
|
|
85
85
|
return _jsx(UnavailablePreview, { ...props, status: "loading" });
|
|
86
|
-
const navigate = (choice) => {
|
|
86
|
+
const navigate = (choice, shown) => {
|
|
87
87
|
setRestore(false);
|
|
88
|
+
props.onPlayed?.();
|
|
88
89
|
if (identity && selection)
|
|
89
90
|
selection.current = { identity, choice };
|
|
90
|
-
|
|
91
|
+
// A choice the running app was told keeps the document (no reload); any other loads anew.
|
|
92
|
+
setNavigation({ ...choice, id: shown ? navigation.id : prototypeNavigationId() });
|
|
91
93
|
};
|
|
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);
|
|
94
|
+
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) => {
|
|
95
|
+
navigate(choice, shown);
|
|
94
96
|
if (!props.preview)
|
|
95
97
|
container.current
|
|
96
98
|
?.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
|
-
|
|
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;
|
|
@@ -1,37 +1,61 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
2
3
|
import { groupJourneys } from './ProtoJourneys.js';
|
|
3
4
|
import { PrototypeAppFrame } from './PrototypeAppFrame.js';
|
|
4
5
|
import { PrototypeAppView } from './PrototypeAppView.js';
|
|
5
6
|
import { PrototypePreview } from './PrototypePreview.js';
|
|
6
7
|
import { usePrototypeFrame } from './usePrototypeFrame.js';
|
|
7
8
|
export function PrototypeAttempt({ navigation, onNavigate, onSwitch, ...props }) {
|
|
8
|
-
const
|
|
9
|
-
embed: '1',
|
|
10
|
-
apeNav: navigation.id,
|
|
11
|
-
locale: props.locale,
|
|
12
|
-
mode: props.mode,
|
|
13
|
-
...(navigation.journey ? { journey: navigation.journey.key } : {}),
|
|
14
|
-
...(props.preview ? { studioPreview: '1' } : {}),
|
|
15
|
-
...(props.preview && navigation.journey ? { stepCaption: '1' } : {}),
|
|
16
|
-
...(navigation.step !== undefined ? { step: String(navigation.step) } : {}),
|
|
17
|
-
...(navigation.data ? { data: navigation.data } : {}),
|
|
18
|
-
}).toString();
|
|
19
|
-
const url = new URL(props.address);
|
|
20
|
-
url.search = search;
|
|
21
|
-
const model = usePrototypeFrame(url.origin, navigation.id, props.address !== props.given ? onSwitch : undefined,
|
|
9
|
+
const model = usePrototypeFrame(new URL(props.address).origin, navigation.id, props.address !== props.given ? onSwitch : undefined,
|
|
22
10
|
// One missed probe is not "not running" while the app answered lately.
|
|
23
11
|
props.running === false && props.snapshotReady ? undefined : props.running);
|
|
12
|
+
// The address is fixed for each document the frame loads (a navigation, or a retry of it), with
|
|
13
|
+
// the choice of that moment; a later choice the running app was told leaves it, so no reload.
|
|
14
|
+
const previewing = !!props.preview;
|
|
15
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new document takes the current choice
|
|
16
|
+
const url = useMemo(() => frameAddress(props, navigation, previewing), [props.address, props.locale, props.mode, previewing, navigation.id, model.frameKey]);
|
|
24
17
|
const ready = model.journeys !== undefined;
|
|
18
|
+
// In the studio's preview a running app is told the choice; elsewhere the frame reloads with it.
|
|
19
|
+
const go = (choice) => onNavigate(choice, !!props.preview &&
|
|
20
|
+
model.show({ journey: choice.journey?.key, step: choice.step, data: choice.data }));
|
|
25
21
|
const play = (key) => {
|
|
26
22
|
const journey = model.journeys?.find((candidate) => candidate.key === key);
|
|
27
23
|
if (journey && model.alive())
|
|
28
|
-
|
|
24
|
+
go({ journey, overlay: model.preview !== undefined });
|
|
29
25
|
};
|
|
26
|
+
// Play on another page: once the running app lists its journeys, that one starts at step 1.
|
|
27
|
+
const asked = props.play;
|
|
28
|
+
const listed = model.journeys;
|
|
29
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: once per request and journey list
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!asked || !listed || !model.alive())
|
|
32
|
+
return;
|
|
33
|
+
const journey = listed.find((candidate) => candidate.key === asked.id) ??
|
|
34
|
+
listed.find((candidate) => !!asked.name && candidate.title === asked.name);
|
|
35
|
+
if (journey)
|
|
36
|
+
go({ journey, step: 0, overlay: model.preview !== undefined });
|
|
37
|
+
else
|
|
38
|
+
props.onPlayed?.();
|
|
39
|
+
}, [asked, listed]);
|
|
30
40
|
const app = (_jsx(PrototypeAppFrame, { frame: model.frame, url: url.href, href: props.href, product: props.product, ready: ready, enlarged: !!navigation.journey, failure: model.failure, recoverable: model.recoverable, onDev: props.onDev, cause: model.cause, fill: !!props.preview }, model.frameKey));
|
|
31
41
|
if (props.preview)
|
|
32
|
-
return (_jsx(LivePreview, { ...props, preview: props.preview, app, model, navigation,
|
|
42
|
+
return (_jsx(LivePreview, { ...props, preview: props.preview, app, model, navigation, play, onNavigate: go }));
|
|
33
43
|
return (_jsx(PrototypeAppView, { title: props.product, href: props.href, ready: ready, journeys: model.journeys ?? [], left: model.left, onPlay: play, onSignInHelp: () => model.fail('cookies'), app: app, reviewPanel: props.reviewPanel?.(ready, true) }));
|
|
34
44
|
}
|
|
45
|
+
function frameAddress(props, navigation, previewing) {
|
|
46
|
+
const url = new URL(props.address);
|
|
47
|
+
url.search = new URLSearchParams({
|
|
48
|
+
embed: '1',
|
|
49
|
+
apeNav: navigation.id,
|
|
50
|
+
locale: props.locale,
|
|
51
|
+
mode: props.mode,
|
|
52
|
+
...(navigation.journey ? { journey: navigation.journey.key } : {}),
|
|
53
|
+
...(previewing ? { studioPreview: '1', stepCaption: '1' } : {}),
|
|
54
|
+
...(navigation.step !== undefined ? { step: String(navigation.step) } : {}),
|
|
55
|
+
...(navigation.data ? { data: navigation.data } : {}),
|
|
56
|
+
}).toString();
|
|
57
|
+
return url;
|
|
58
|
+
}
|
|
35
59
|
function LivePreview({ app, product, href, preview, model, navigation, onNavigate, play, }) {
|
|
36
60
|
const ready = model.journeys !== undefined;
|
|
37
61
|
const journeys = model.journeys ?? [];
|
|
@@ -29,41 +29,47 @@ export function PrototypePreview({ app, play, ...props }) {
|
|
|
29
29
|
gridTemplateRows: 'auto minmax(0, 1fr)',
|
|
30
30
|
minBlockSize: 0,
|
|
31
31
|
minInlineSize: 0,
|
|
32
|
-
}, children: [_jsx("style", { children: previewBorder }), _jsx(PreviewToolbar, { ...props, narrow: narrow }),
|
|
32
|
+
}, children: [_jsx("style", { children: previewBorder }), _jsx(PreviewToolbar, { ...props, narrow: narrow }), _jsxs("div", { style: {
|
|
33
33
|
display: 'grid',
|
|
34
|
-
|
|
34
|
+
gridTemplateRows: play
|
|
35
|
+
? `${desktop ? 'minmax(0, auto)' : 'minmax(0, 1fr)'} auto`
|
|
36
|
+
: 'minmax(0, 1fr)',
|
|
37
|
+
gridTemplateColumns: 'minmax(0, 1fr)',
|
|
38
|
+
alignContent: 'start',
|
|
35
39
|
justifyItems: 'center',
|
|
40
|
+
rowGap: 'var(--space-2)',
|
|
36
41
|
minBlockSize: 0,
|
|
37
42
|
padding: narrow ? 0 : 'var(--space-3)',
|
|
38
|
-
}, children:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
}, children: [_jsx("section", { "data-preview-device": narrow ? 'unframed' : props.device, "aria-label": t('simple.frame'), style: {
|
|
44
|
+
position: 'relative',
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
minBlockSize: 0,
|
|
47
|
+
minInlineSize: 0,
|
|
48
|
+
blockSize: desktop ? 'auto' : '100%',
|
|
49
|
+
maxBlockSize: '100%',
|
|
50
|
+
maxInlineSize: '100%',
|
|
51
|
+
inlineSize: narrow || desktop ? '100%' : undefined,
|
|
52
|
+
alignSelf: desktop ? 'start' : undefined,
|
|
53
|
+
aspectRatio: narrow
|
|
54
|
+
? undefined
|
|
55
|
+
: desktop
|
|
56
|
+
? '16 / 10'
|
|
57
|
+
: props.device === 'tablet'
|
|
58
|
+
? '3 / 4'
|
|
59
|
+
: '9 / 19',
|
|
60
|
+
overflow: 'hidden',
|
|
61
|
+
background: 'var(--surface-canvas)',
|
|
62
|
+
}, children: _jsx("div", { style: { blockSize: '100%', overflow: 'auto' }, children: app }) }), play && _jsx(PreviewPlayer, { ...play, narrow: narrow })] })] }));
|
|
58
63
|
}
|
|
59
|
-
function PreviewPlayer({ step, total, caption, pending, onStep }) {
|
|
64
|
+
function PreviewPlayer({ step, total, caption, pending, onStep, narrow, }) {
|
|
60
65
|
const t = useT();
|
|
61
66
|
const { locale } = useLocale();
|
|
62
67
|
const rtl = isRtl(locale);
|
|
63
|
-
return (_jsxs("section", { "data-prototype-focus-group": true, "aria-label": t('simple.player'), style: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
return (_jsxs("section", { "data-prototype-focus-group": true, "aria-label": t('simple.player'), "data-preview-player": true, style: {
|
|
69
|
+
boxSizing: 'border-box',
|
|
70
|
+
inlineSize: narrow ? 'calc(100% - var(--space-4))' : '100%',
|
|
71
|
+
maxInlineSize: 'calc(var(--space-6) * 24)',
|
|
72
|
+
marginBlockEnd: narrow ? 'var(--space-2)' : 0,
|
|
67
73
|
display: 'grid',
|
|
68
74
|
gridTemplateColumns: 'auto minmax(0, 1fr) auto',
|
|
69
75
|
alignItems: 'center',
|
|
@@ -71,8 +77,7 @@ function PreviewPlayer({ step, total, caption, pending, onStep }) {
|
|
|
71
77
|
padding: 'var(--space-2)',
|
|
72
78
|
background: 'var(--surface-panel)',
|
|
73
79
|
border: 'var(--border-width-hairline) solid var(--border-default)',
|
|
74
|
-
borderRadius: 'var(--radius-
|
|
75
|
-
boxShadow: 'var(--shadow-overlay)',
|
|
80
|
+
borderRadius: 'var(--radius-panel)',
|
|
76
81
|
}, children: [_jsx(Button, { variant: "secondary", icon: rtl ? 'chevron-right' : 'chevron-left', disabled: step === 0, "aria-disabled": pending || undefined, onClick: () => {
|
|
77
82
|
if (!pending)
|
|
78
83
|
onStep(step - 1);
|
|
@@ -108,6 +108,14 @@ export declare function prototypeReady(data: unknown, expected: {
|
|
|
108
108
|
navigation: string;
|
|
109
109
|
document: string;
|
|
110
110
|
}): PrototypeDiscovery | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* The app says, on its private port and before its reply, that it plays the studio's show
|
|
113
|
+
* messages. An app without it (an older app-shell) is reloaded at each step instead.
|
|
114
|
+
*/
|
|
115
|
+
export declare function prototypePlayer(data: unknown, expected: {
|
|
116
|
+
navigation: string;
|
|
117
|
+
document: string;
|
|
118
|
+
}): boolean;
|
|
111
119
|
/** Heartbeats renew an existing proof; they never discover journeys or enable a waiting frame. */
|
|
112
120
|
export declare function prototypeHeartbeat(data: unknown, expected: {
|
|
113
121
|
navigation: string;
|
|
@@ -218,6 +218,22 @@ export function prototypeReady(data, expected) {
|
|
|
218
218
|
const reply = prototypeReply(data, expected);
|
|
219
219
|
return reply && 'discovery' in reply ? reply.discovery : undefined;
|
|
220
220
|
}
|
|
221
|
+
const player = z.strictObject({
|
|
222
|
+
type: z.literal('ape:prototype:player'),
|
|
223
|
+
version: z.literal(2),
|
|
224
|
+
navigation: z.string().uuid(),
|
|
225
|
+
document: z.string().uuid(),
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* The app says, on its private port and before its reply, that it plays the studio's show
|
|
229
|
+
* messages. An app without it (an older app-shell) is reloaded at each step instead.
|
|
230
|
+
*/
|
|
231
|
+
export function prototypePlayer(data, expected) {
|
|
232
|
+
const answer = player.safeParse(payload(data, 512));
|
|
233
|
+
return (answer.success &&
|
|
234
|
+
answer.data.navigation === expected.navigation &&
|
|
235
|
+
answer.data.document === expected.document);
|
|
236
|
+
}
|
|
221
237
|
/** Heartbeats renew an existing proof; they never discover journeys or enable a waiting frame. */
|
|
222
238
|
export function prototypeHeartbeat(data, expected) {
|
|
223
239
|
const answer = heartbeat.safeParse(payload(data, 512));
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type FrameCause, type PrototypeDiscovery } from './prototype-bridge.ts';
|
|
2
|
+
/** What the studio asks the framed app to show: a journey at a step, or a preview data state. */
|
|
3
|
+
export type PrototypeShow = {
|
|
4
|
+
journey?: string;
|
|
5
|
+
step?: number;
|
|
6
|
+
data?: string;
|
|
7
|
+
};
|
|
2
8
|
/** silent: a hello and then no reply and no beat. reply: the app's reply was refused whole (see cause). */
|
|
3
9
|
export type FrameFailure = 'failed' | 'cookies' | 'silent' | 'reply';
|
|
4
10
|
export type FrameAnswer = Partial<PrototypeDiscovery> & {
|
|
@@ -15,6 +21,7 @@ type Input = {
|
|
|
15
21
|
};
|
|
16
22
|
export declare function watchPrototypeDocument(input: Input): {
|
|
17
23
|
alive: () => boolean;
|
|
24
|
+
show: (choice: PrototypeShow) => boolean;
|
|
18
25
|
fail: (failure?: FrameFailure, cause?: FrameCause) => void;
|
|
19
26
|
timedOutSilently: () => boolean;
|
|
20
27
|
close: () => void;
|