@buffcore/admin-shell 0.8.41 → 0.8.42

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 (115) hide show
  1. package/dist/admin.js +2 -1
  2. package/dist/components/Button.d.ts +2 -2
  3. package/dist/components/Button.js +7 -2
  4. package/dist/components/DeviceFrame.d.ts +6 -1
  5. package/dist/components/DeviceFrame.js +2 -2
  6. package/dist/components/look.d.ts +5 -0
  7. package/dist/components/look.js +5 -0
  8. package/dist/console-settings.js +4 -1
  9. package/dist/design-fonts.d.ts +5 -0
  10. package/dist/design-fonts.js +20 -0
  11. package/dist/prototype/PageLook.js +3 -2
  12. package/dist/prototype/create.d.ts +3 -1
  13. package/dist/prototype/create.js +0 -1
  14. package/dist/prototype/page.d.ts +19 -2
  15. package/dist/prototype/page.js +20 -2
  16. package/dist/prototype/shown.js +1 -1
  17. package/dist/prototype/viewer.d.ts +2 -0
  18. package/dist/prototype/viewer.js +6 -2
  19. package/dist/workbench/app/ServedPrototype.js +19 -1
  20. package/dist/workbench/app/StudioApp.js +29 -20
  21. package/dist/workbench/app/actions.d.ts +3 -1
  22. package/dist/workbench/app/actions.js +8 -2
  23. package/dist/workbench/app/ask-card.d.ts +10 -0
  24. package/dist/workbench/app/ask-card.js +34 -0
  25. package/dist/workbench/app/chat-session.d.ts +32 -0
  26. package/dist/workbench/app/chat.d.ts +37 -0
  27. package/dist/workbench/app/frame.js +4 -2
  28. package/dist/workbench/app/host-part-loader.d.ts +5 -2
  29. package/dist/workbench/app/host-part-module.d.ts +17 -0
  30. package/dist/workbench/app/host-part-module.js +55 -0
  31. package/dist/workbench/app/host-parts.d.ts +2 -11
  32. package/dist/workbench/app/host-parts.js +53 -67
  33. package/dist/workbench/app/level-choice.d.ts +3 -0
  34. package/dist/workbench/app/mount.d.ts +4 -1
  35. package/dist/workbench/app/mount.js +2 -2
  36. package/dist/workbench/app/panel-cards.d.ts +3 -3
  37. package/dist/workbench/app/panel-cards.js +3 -2
  38. package/dist/workbench/app/places.d.ts +17 -2
  39. package/dist/workbench/app/places.js +14 -2
  40. package/dist/workbench/app/scene-address.d.ts +10 -0
  41. package/dist/workbench/app/scene-address.js +14 -0
  42. package/dist/workbench/app/studio-post.js +1 -0
  43. package/dist/workbench/app/test/loop-fixture.d.ts +22 -0
  44. package/dist/workbench/app/usePrototypeUi.js +14 -0
  45. package/dist/workbench/app/work.d.ts +7 -7
  46. package/dist/workbench/host-theme.d.ts +3 -0
  47. package/dist/workbench/host-theme.js +14 -0
  48. package/dist/workbench/index.d.ts +1 -0
  49. package/dist/workbench/index.js +1 -0
  50. package/dist/workbench/studio/frame/HostRailEntries.d.ts +3 -0
  51. package/dist/workbench/studio/frame/HostRailEntries.js +15 -0
  52. package/dist/workbench/studio/frame/HostSide.d.ts +6 -0
  53. package/dist/workbench/studio/frame/HostSide.js +31 -0
  54. package/dist/workbench/studio/frame/LevelChip.js +2 -1
  55. package/dist/workbench/studio/frame/LevelChoices.js +24 -8
  56. package/dist/workbench/studio/frame/NeverAskSetting.d.ts +7 -0
  57. package/dist/workbench/studio/frame/NeverAskSetting.js +24 -0
  58. package/dist/workbench/studio/frame/PanelList.js +5 -2
  59. package/dist/workbench/studio/frame/PanelNotice.js +2 -1
  60. package/dist/workbench/studio/frame/PanelScenes.d.ts +5 -0
  61. package/dist/workbench/studio/frame/PanelScenes.js +38 -0
  62. package/dist/workbench/studio/frame/PermissionAskCard.d.ts +18 -0
  63. package/dist/workbench/studio/frame/PermissionAskCard.js +60 -0
  64. package/dist/workbench/studio/frame/PermissionAskFold.d.ts +12 -0
  65. package/dist/workbench/studio/frame/PermissionAskFold.js +54 -0
  66. package/dist/workbench/studio/frame/Place.d.ts +6 -2
  67. package/dist/workbench/studio/frame/Place.js +13 -5
  68. package/dist/workbench/studio/frame/SettingsSheet.js +6 -1
  69. package/dist/workbench/studio/frame/StudioRail.js +2 -1
  70. package/dist/workbench/studio/frame/panelControls.d.ts +17 -0
  71. package/dist/workbench/studio/i18n/frame.en.d.ts +26 -0
  72. package/dist/workbench/studio/i18n/frame.en.js +26 -0
  73. package/dist/workbench/studio/i18n/frame.es.json +27 -1
  74. package/dist/workbench/studio/i18n/levels.en.d.ts +5 -0
  75. package/dist/workbench/studio/i18n/levels.en.js +5 -0
  76. package/dist/workbench/studio/i18n/levels.es.json +6 -1
  77. package/dist/workbench/studio/i18n/loop.en.d.ts +4 -0
  78. package/dist/workbench/studio/i18n/loop.en.js +4 -0
  79. package/dist/workbench/studio/i18n/loop.es.json +4 -0
  80. package/dist/workbench/studio/i18n/save.en.d.ts +1 -3
  81. package/dist/workbench/studio/i18n/save.en.js +13 -15
  82. package/dist/workbench/studio/i18n/save.es.json +14 -16
  83. package/dist/workbench/studio/i18n/structure.en.d.ts +6 -0
  84. package/dist/workbench/studio/i18n/structure.en.js +6 -0
  85. package/dist/workbench/studio/i18n/structure.es.d.ts +6 -0
  86. package/dist/workbench/studio/i18n/structure.es.js +6 -0
  87. package/dist/workbench/studio/loop/PrototypePage.js +4 -3
  88. package/dist/workbench/studio/loop/PrototypeScenes.js +1 -2
  89. package/dist/workbench/studio/loop/PrototypeSimplePage.js +7 -6
  90. package/dist/workbench/studio/loop/PrototypeSnapshot.js +5 -1
  91. package/dist/workbench/studio/loop/ReviewedSave.d.ts +1 -1
  92. package/dist/workbench/studio/loop/ReviewedSave.js +2 -10
  93. package/dist/workbench/studio/loop/ServedBrand.js +3 -3
  94. package/dist/workbench/studio/loop/StructurePage.d.ts +2 -0
  95. package/dist/workbench/studio/loop/StructurePage.js +1 -1
  96. package/dist/workbench/studio/loop/StructurePreview.js +4 -4
  97. package/dist/workbench/studio/loop/StructurePrompts.js +9 -4
  98. package/dist/workbench/studio/loop/step-state.d.ts +1 -1
  99. package/dist/workbench/studio/loop/step-state.js +9 -8
  100. package/dist/workbench/studio/loop/structure-answers.d.ts +8 -0
  101. package/dist/workbench/studio/loop/structure-answers.js +34 -0
  102. package/dist/workbench/studio/loop/usePlanningDraft.js +2 -1
  103. package/dist/workbench/studio/loop/usePlanningSave.d.ts +16 -2
  104. package/dist/workbench/studio/loop/usePlanningSave.js +40 -2
  105. package/dist/workbench/studio/loop/usePrototypeRecord.js +5 -4
  106. package/dist/workbench/studio/loop/useReviewedSave.d.ts +9 -4
  107. package/dist/workbench/studio/loop/useReviewedSave.js +89 -30
  108. package/dist/workbench/studio/run/LiveServers.js +1 -1
  109. package/dist/workbench/studio/run/ReleasePage.js +1 -1
  110. package/dist/workbench/studio/run/ReleasesPage.js +2 -2
  111. package/dist/workbench/studio/run/ServedRelease.js +1 -1
  112. package/dist/workbench/studio/work/work-test-data.d.ts +3 -0
  113. package/package.json +6 -6
  114. package/vite.d.ts +6 -1
  115. package/vite.js +78 -5
@@ -6,6 +6,8 @@ export interface StructurePlan {
6
6
  who: string;
7
7
  place: string;
8
8
  main: boolean;
9
+ /** The change that adds this first screen, while its route does not exist yet. */
10
+ planned?: string;
9
11
  }[];
10
12
  notes: readonly string[];
11
13
  }
@@ -16,5 +16,5 @@ export function StructurePage(props) {
16
16
  const why = problem ||
17
17
  nextReason(draft, t) ||
18
18
  (progress !== 'saved' ? t('studio.structure.wait') : undefined);
19
- return (_jsxs(Page, { crumbs: [t('studio.frame.rail.step', { n: 5 }), t('studio.frame.page.structure')], title: t('studio.structure.title'), sub: t('studio.structure.sub'), actions: _jsx(ReasonButton, { size: "sm", disabled: !onNext, why: why, onClick: () => onNext?.(label), children: label }), children: [_jsx(Badge, { tone: progress === 'saved' ? 'success' : 'neutral', style: { justifySelf: 'start' }, children: t(`studio.structure.state.${progress}`) }), draft && progress !== 'not-started' && _jsx(StepNotes, { draft: draft, agent: agent }), problem && _jsx(Banner, { tone: "error", children: problem }), _jsx(TwoColumns, { main: _jsx(StructurePrompts, { ...props }), side: _jsx(StructureFile, { structure: structure, problem: problem }) })] }));
19
+ return (_jsxs(Page, { crumbs: [t('studio.frame.rail.step', { n: 5 }), t('studio.frame.page.structure')], title: t('studio.structure.title'), sub: t('studio.structure.sub'), actions: _jsx(ReasonButton, { size: "sm", disabled: !onNext, why: why, onClick: () => onNext?.(label), children: label }), children: [_jsx(Badge, { tone: progress === 'saved' ? 'success' : 'neutral', style: { justifySelf: 'start', alignSelf: 'flex-start' }, children: t(`studio.structure.state.${progress}`) }), draft && progress !== 'not-started' && _jsx(StepNotes, { draft: draft, agent: agent }), problem && _jsx(Banner, { tone: "error", children: problem }), _jsx(TwoColumns, { main: _jsx(StructurePrompts, { ...props }), side: _jsx(StructureFile, { structure: structure, problem: problem }) })] }));
20
20
  }
@@ -1,7 +1,7 @@
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
3
  import { Panel } from '../../../components/Panel.js';
4
- import { bodyText, monoText } from '../../../components/styles.js';
4
+ import { bodyText, captionText, monoText } from '../../../components/styles.js';
5
5
  export function StructureFile({ structure, problem, }) {
6
6
  const t = useT();
7
7
  return (_jsxs(Panel, { title: t('studio.structure.file'), children: [_jsx("code", { translate: "no", style: monoText, children: "plan/structure.md" }), _jsx("p", { style: { margin: 0 }, children: t('studio.structure.fileHelp') }), structure?.rows.length ? (_jsx(StructurePreview, { structure: structure })) : (_jsx("p", { style: { margin: 0 }, children: t(problem ? 'studio.structure.invalid' : 'studio.structure.empty') })), _jsx("p", { style: { ...bodyText, margin: 0 }, children: t('studio.structure.boundary') })] }));
@@ -12,15 +12,15 @@ function StructurePreview({ structure }) {
12
12
  ...bodyText,
13
13
  borderCollapse: 'collapse',
14
14
  inlineSize: '100%',
15
- tableLayout: 'fixed',
16
- overflowWrap: 'anywhere',
15
+ // Words stay whole; a cell too long for a phone scrolls inside the table's own frame.
16
+ overflowWrap: 'break-word',
17
17
  }, children: [_jsx("caption", { style: { textAlign: 'start', paddingBlockEnd: 'var(--space-2)' }, children: t('studio.structure.order') }), _jsx("thead", { children: _jsx("tr", { children: ['section', 'screen', 'who', 'place', 'main'].map((key) => (_jsx("th", { scope: "col", style: { textAlign: 'start', padding: 'var(--space-2)' }, children: t(`studio.structure.column.${key}`) }, key))) }) }), _jsx(StructureRows, { rows: structure.rows })] }) }), structure.notes.map((note) => (_jsx("p", { style: { margin: 0 }, children: note }, note)))] }));
18
18
  }
19
19
  function StructureRows({ rows }) {
20
20
  const t = useT();
21
21
  return (_jsx("tbody", { children: rows.map((row) => (_jsx("tr", { children: [
22
22
  row.section,
23
- row.screen,
23
+ row.planned ? (_jsxs(_Fragment, { children: [row.screen, _jsx("span", { style: { ...captionText, display: 'block' }, children: t('studio.structure.planned', { change: row.planned }) })] })) : (row.screen),
24
24
  row.who,
25
25
  row.place,
26
26
  t(row.main ? 'studio.structure.yes' : 'studio.structure.no'),
@@ -1,18 +1,23 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useT } from '@buffcore/i18n/react';
2
+ import { useLocale, useT } from '@buffcore/i18n/react';
3
3
  import { Panel } from '../../../components/Panel.js';
4
+ import { captionText } from '../../../components/styles.js';
4
5
  import { ReasonButton } from './ReasonButton.js';
6
+ import { structureAnswers } from './structure-answers.js';
5
7
  export function StructurePrompts(props) {
6
- return (_jsxs(_Fragment, { children: [_jsx(StructureQuestions, {}), _jsx(StructureJourneys, { ...props })] }));
8
+ return (_jsxs(_Fragment, { children: [_jsx(StructureQuestions, { structure: props.structure }), _jsx(StructureJourneys, { ...props })] }));
7
9
  }
8
- function StructureQuestions() {
10
+ /** Each question with its answer from `plan/structure.md`, or a pointer to the chat. */
11
+ function StructureQuestions({ structure }) {
9
12
  const t = useT();
13
+ const { locale } = useLocale();
14
+ const answers = structureAnswers(structure, t, locale);
10
15
  return (_jsxs(Panel, { title: t('studio.structure.questions'), children: [_jsx("ul", { style: {
11
16
  margin: 0,
12
17
  paddingInlineStart: 'var(--space-5)',
13
18
  display: 'grid',
14
19
  gap: 'var(--space-3)',
15
- }, children: ['sections', 'main', 'people', 'screens'].map((key) => (_jsx("li", { children: t(`studio.structure.q.${key}`) }, key))) }), _jsx("p", { style: { margin: 0 }, children: t('studio.structure.askAgain') })] }));
20
+ }, children: ['sections', 'main', 'people', 'screens'].map((key) => (_jsxs("li", { style: { display: 'grid', gap: 'var(--space-1)', minInlineSize: 0 }, children: [_jsx("strong", { style: { color: 'var(--text-strong)' }, children: t(`studio.structure.q.${key}`) }), answers[key].length ? (answers[key].map((answer) => (_jsx("span", { style: { overflowWrap: 'anywhere' }, children: answer }, answer)))) : (_jsx("span", { style: captionText, children: t('studio.structure.a.none') }))] }, key))) }), _jsx("p", { style: { margin: 0 }, children: t('studio.structure.askAgain') })] }));
16
21
  }
17
22
  function StructureJourneys({ agent, journeys, draft, onStart, structure, problem, }) {
18
23
  const t = useT();
@@ -4,7 +4,7 @@ type StepReview = Pick<ReviewedSave, 'phase' | 'files' | 'candidates' | 'other'>
4
4
  /**
5
5
  * The one save decision for a step. Planning steps know their own unsaved files from the poll:
6
6
  * none listed (or a review that offers none, also after a recovered commit) is clean, and a poll
7
- * that lists one reopens a finished review. Every step stays unsaved while one of its own files
7
+ * that lists one reopens a finished review; Brand's own list offering none is clean too. Every step stays unsaved while one of its own files
8
8
  * is left out of the save or cannot be saved here.
9
9
  */
10
10
  export declare function stepState<R extends StepReview>(step: SaveStep, unsaved: readonly string[] | undefined, review: R | undefined, hasContent?: boolean, valid?: boolean): {
@@ -2,7 +2,7 @@ import { stepOwnsFile } from '@buffcore/contracts/workbench';
2
2
  /**
3
3
  * The one save decision for a step. Planning steps know their own unsaved files from the poll:
4
4
  * none listed (or a review that offers none, also after a recovered commit) is clean, and a poll
5
- * that lists one reopens a finished review. Every step stays unsaved while one of its own files
5
+ * that lists one reopens a finished review; Brand's own list offering none is clean too. Every step stays unsaved while one of its own files
6
6
  * is left out of the save or cannot be saved here.
7
7
  */
8
8
  export function stepState(step, unsaved, review, hasContent = true, valid = true) {
@@ -11,13 +11,14 @@ export function stepState(step, unsaved, review, hasContent = true, valid = true
11
11
  const left = review?.other?.filter(owns) ?? [];
12
12
  // Protected or secret step files are never offered, so the review leaves them out.
13
13
  const blocked = left.some((file) => !review?.candidates.includes(file));
14
- const nothing = planning &&
15
- (review
16
- ? ['preview', 'reviewed', 'changed', 'saved'].includes(review.phase) &&
17
- !review.files.length &&
18
- !left.length &&
19
- !review.candidates.some(owns)
20
- : unsaved?.some(owns) === false);
14
+ const offersNone = !!review &&
15
+ ['preview', 'changed', 'saved'].includes(review.phase) &&
16
+ !review.files.length &&
17
+ !left.length &&
18
+ !review.candidates.some(owns);
19
+ // Brand has no poll of its own files, but its list (asked for on opening) can offer none.
20
+ const nothing = (planning && (review ? offersNone : unsaved?.some(owns) === false)) ||
21
+ (step === 'brand' && offersNone);
21
22
  const saved = hasContent && valid && !left.length && (nothing || review?.phase === 'saved');
22
23
  return {
23
24
  progress: !hasContent
@@ -0,0 +1,8 @@
1
+ import type { T } from '@buffcore/i18n';
2
+ import type { StructurePlan } from './StructurePage.tsx';
3
+ export type StructureQuestion = 'sections' | 'main' | 'people' | 'screens';
4
+ /**
5
+ * "Your app, in plain words": each question's answer, drawn only from the structure file's rows.
6
+ * No rows (or none that answer it) leaves the question for the chat: an empty list.
7
+ */
8
+ export declare function structureAnswers(structure: StructurePlan | null | undefined, t: T, locale: string): Record<StructureQuestion, string[]>;
@@ -0,0 +1,34 @@
1
+ const unique = (values) => [...new Set(values)];
2
+ /**
3
+ * "Your app, in plain words": each question's answer, drawn only from the structure file's rows.
4
+ * No rows (or none that answer it) leaves the question for the chat: an empty list.
5
+ */
6
+ export function structureAnswers(structure, t, locale) {
7
+ const rows = structure?.rows ?? [];
8
+ const list = (values) => new Intl.ListFormat(locale, { style: 'long', type: 'conjunction' }).format(unique(values));
9
+ const main = rows.filter((row) => row.main);
10
+ const people = unique(rows.map((row) => row.who));
11
+ return {
12
+ sections: rows.length ? [list(rows.map((row) => row.section))] : [],
13
+ main: main[0]
14
+ ? [
15
+ t('studio.structure.a.main', {
16
+ sections: list(main.map((row) => row.section)),
17
+ first: main[0].section,
18
+ }),
19
+ ]
20
+ : [],
21
+ people: people.map((who) => t('studio.structure.a.people', {
22
+ who,
23
+ sections: list(rows.filter((row) => row.who === who).map((row) => row.section)),
24
+ })),
25
+ // Two rows on one section and screen (for two kinds of people) answer once.
26
+ screens: unique(rows.map((row) => row.planned
27
+ ? t('studio.structure.a.planned', {
28
+ section: row.section,
29
+ screen: row.screen,
30
+ change: row.planned,
31
+ })
32
+ : t('studio.structure.a.screen', { section: row.section, screen: row.screen }))),
33
+ };
34
+ }
@@ -3,7 +3,7 @@ import { newChatFor } from '../../app/chat.js';
3
3
  import { briefHasContent, briefProps } from '../../app/loop.js';
4
4
  import { stepWaiting } from '../../app/loop-stage.js';
5
5
  import { nextReason } from './SaveStep.js';
6
- import { usePlanningSave } from './usePlanningSave.js';
6
+ import { useListOnArrival, usePlanningSave, viewerCanBuild } from './usePlanningSave.js';
7
7
  function planningStep(page) {
8
8
  return page === 'structure'
9
9
  ? 'structure'
@@ -28,6 +28,7 @@ export function usePlanningDraft({ state, page, actions, onStep }) {
28
28
  const writing = state.chats?.some((chat) => chat.title === step && !chat.change && chat.state === 'running') ??
29
29
  false;
30
30
  const draft = usePlanningSave(state, step, actions, writing);
31
+ useListOnArrival(draft, step, state.plan?.unsaved, viewerCanBuild(state));
31
32
  const hasContent = planningContent(state, page);
32
33
  draft.why = writing
33
34
  ? t('studio.loop.planning.why.writing', { agent: briefProps(state).product.agent.name })
@@ -1,5 +1,19 @@
1
- import type { StudioState } from '@buffcore/contracts/workbench';
1
+ import { type StudioState } from '@buffcore/contracts/workbench';
2
2
  import type { SaveStep, StudioActions } from '../../app/actions.ts';
3
3
  import type { StepDraft } from './SaveStep.tsx';
4
- /** Every step reviews and confirms through the same save flow. */
4
+ /** Every step saves through the same one-click flow: its files list themselves, then one Save. */
5
5
  export declare function usePlanningSave(state: StudioState, step: SaveStep, actions: StudioActions, writing: boolean): StepDraft;
6
+ /** Saving and listing a step's files need the `build` right; a local studio has every right. */
7
+ export declare function viewerCanBuild(state: Pick<StudioState, 'viewer'>): boolean;
8
+ /**
9
+ * One click saves (0.8.42): on a step page, the step's own unsaved files list themselves, ticked,
10
+ * so the person's one Save commits them. A page calls it beside its save; the save hook alone
11
+ * lists nothing until asked, and a viewer without the `build` right is never asked for a list.
12
+ */
13
+ export declare function useListOnArrival(draft: StepDraft, step: SaveStep, unsaved: readonly string[] | undefined, canBuild: boolean): void;
14
+ /**
15
+ * Brand's one click: the poll has no unsaved-files signal for its design files, so the page asks
16
+ * the server for its list once when it opens, and again when its files change (a new theme
17
+ * fingerprint or a finished turn opens a fresh review). A list offering none reads as saved.
18
+ */
19
+ export declare function useListOnOpen(draft: StepDraft | undefined, canBuild: boolean): void;
@@ -1,8 +1,9 @@
1
+ import { stepOwnsFile } from '@buffcore/contracts/workbench';
1
2
  import { useT } from '@buffcore/i18n/react';
2
- import { useState } from 'react';
3
+ import { useEffect, useState } from 'react';
3
4
  import { stepState } from './step-state.js';
4
5
  import { useReviewedSave } from './useReviewedSave.js';
5
- /** Every step reviews and confirms through the same save flow. */
6
+ /** Every step saves through the same one-click flow: its files list themselves, then one Save. */
6
7
  export function usePlanningSave(state, step, actions, writing) {
7
8
  const t = useT();
8
9
  const saveWriting = state.chats?.some((chat) => !chat.change && chat.state === 'running') ?? false;
@@ -34,3 +35,40 @@ export function usePlanningSave(state, step, actions, writing) {
34
35
  },
35
36
  };
36
37
  }
38
+ /** Saving and listing a step's files need the `build` right; a local studio has every right. */
39
+ export function viewerCanBuild(state) {
40
+ const rights = state.viewer?.rights;
41
+ return !rights || rights === 'all' || rights.includes('build');
42
+ }
43
+ /**
44
+ * One click saves (0.8.42): on a step page, the step's own unsaved files list themselves, ticked,
45
+ * so the person's one Save commits them. A page calls it beside its save; the save hook alone
46
+ * lists nothing until asked, and a viewer without the `build` right is never asked for a list.
47
+ */
48
+ export function useListOnArrival(draft, step, unsaved, canBuild) {
49
+ const listFiles = canBuild &&
50
+ !!draft.save?.unlisted &&
51
+ !draft.writing &&
52
+ draft.save.state !== 'writing' &&
53
+ !!unsaved?.some((file) => stepOwnsFile(step, file));
54
+ const { onSave } = draft;
55
+ // biome-ignore lint/correctness/useExhaustiveDependencies: list once each time it becomes needed.
56
+ useEffect(() => {
57
+ if (listFiles)
58
+ onSave?.();
59
+ }, [listFiles]);
60
+ }
61
+ /**
62
+ * Brand's one click: the poll has no unsaved-files signal for its design files, so the page asks
63
+ * the server for its list once when it opens, and again when its files change (a new theme
64
+ * fingerprint or a finished turn opens a fresh review). A list offering none reads as saved.
65
+ */
66
+ export function useListOnOpen(draft, canBuild) {
67
+ const listFiles = canBuild && !!draft?.save?.unlisted && !draft.writing && draft.save.state !== 'writing';
68
+ const onSave = draft?.onSave;
69
+ // biome-ignore lint/correctness/useExhaustiveDependencies: list once each time it becomes needed.
70
+ useEffect(() => {
71
+ if (listFiles)
72
+ onSave?.();
73
+ }, [listFiles]);
74
+ }
@@ -70,10 +70,11 @@ export function usePrototypeRecord(actions, change, run, approving = false, vers
70
70
  intent.current = { scope: change, record: true };
71
71
  if (status.saved)
72
72
  await saving.start();
73
- else if (status.review?.reviewed)
74
- status.review.confirm();
75
- else if (status.review?.files.length)
76
- status.review.review();
73
+ else if (status.review && ['preview', 'changed', 'refused'].includes(status.review.phase)) {
74
+ // The list shown is what Record saves: one click, its fingerprint checked by the server.
75
+ if (status.review.files.length && !status.review.checking)
76
+ status.review.confirm();
77
+ }
77
78
  else {
78
79
  setResult({ scope: change });
79
80
  await saving.start();
@@ -1,23 +1,28 @@
1
1
  import type { SaveResult, SaveStep, StudioActions } from '../../app/actions.ts';
2
2
  export interface ReviewedSave {
3
3
  step?: SaveStep;
4
- phase: 'loading' | 'preview' | 'reviewed' | 'changed' | 'saving' | 'refused' | 'unknown' | 'saved' | 'recovery';
4
+ phase: 'loading' | 'preview' | 'changed' | 'saving' | 'refused' | 'unknown' | 'saved' | 'recovery';
5
5
  files: readonly string[];
6
6
  candidates: readonly string[];
7
7
  other?: readonly string[];
8
8
  kinds?: SaveResult['kinds'];
9
9
  earlierSnapshots?: readonly string[];
10
+ /** The server's fingerprint of the files shown; Save sends it, and only a match commits. */
10
11
  fingerprint?: string;
11
- reviewed?: string;
12
+ /** Asking for a changed list's fingerprint; Save waits for it. */
13
+ checking?: boolean;
12
14
  commit?: string;
13
15
  refusal?: SaveResult['refused'];
14
16
  detail?: string;
15
17
  toggle: (file: string) => void;
16
- review: () => void;
17
18
  confirm: () => void;
18
19
  reload: () => void;
19
20
  }
20
- /** A review belongs to one visit. Every confirmation rechecks its selected source on the server. */
21
+ /**
22
+ * One click saves (0.8.42): the list loads with the step's files ticked and the server's fingerprint
23
+ * of that list; Save sends it. A changed tick asks for the new list's fingerprint before Save works
24
+ * again. When the files changed since, the server answers with the new list ("changed").
25
+ */
21
26
  export declare function useReviewedSave(actions: StudioActions, step: SaveStep, scope: string, writing?: boolean, onSaved?: (saved: SaveResult) => Promise<void>): {
22
27
  review: ReviewedSave | undefined;
23
28
  start: () => Promise<void>;
@@ -1,6 +1,11 @@
1
1
  import { useT } from '@buffcore/i18n/react';
2
2
  import { useEffect, useRef, useState } from 'react';
3
- /** A review belongs to one visit. Every confirmation rechecks its selected source on the server. */
3
+ const sameFiles = (a, b) => a.length === b.length && a.every((file, index) => file === b[index]);
4
+ /**
5
+ * One click saves (0.8.42): the list loads with the step's files ticked and the server's fingerprint
6
+ * of that list; Save sends it. A changed tick asks for the new list's fingerprint before Save works
7
+ * again. When the files changed since, the server answers with the new list ("changed").
8
+ */
4
9
  export function useReviewedSave(actions, step, scope, writing = false, onSaved) {
5
10
  const t = useT();
6
11
  const [state, setState] = useState({ scope, visit: {} });
@@ -15,33 +20,88 @@ export function useReviewedSave(actions, step, scope, writing = false, onSaved)
15
20
  };
16
21
  }, [state.visit]);
17
22
  const locked = useRef(false);
23
+ const refreshing = useRef(false);
24
+ const again = useRef(false);
25
+ const selection = useRef([]);
18
26
  const visit = state.visit;
19
27
  const update = (patch) => setState((current) => (current.visit === visit ? { ...current, ...patch } : current));
20
- // A failed review or save keeps the person's selection to retry; a failed load lists nothing
28
+ // A failed check or save keeps the person's selection to retry; a failed load lists nothing
21
29
  // old (a recovered commit keeps its files).
22
- const failed = (detail, selection) => selection
23
- ? { phase: 'preview', fingerprint: undefined, reviewed: undefined, detail }
30
+ const failed = (detail, kept) => kept
31
+ ? { phase: 'preview', fingerprint: undefined, detail }
24
32
  : {
25
33
  phase: 'unknown',
26
34
  files: state.recovered ? state.files : [],
27
35
  candidates: state.recovered ? state.candidates : [],
28
36
  fingerprint: undefined,
29
- reviewed: undefined,
30
37
  detail,
31
38
  };
39
+ const listed = (answer, phase) => {
40
+ selection.current = answer.preview ?? [];
41
+ return {
42
+ phase,
43
+ files: answer.preview,
44
+ other: answer.other,
45
+ commit: undefined,
46
+ candidates: answer.candidates ?? answer.preview,
47
+ kinds: answer.kinds,
48
+ earlierSnapshots: answer.earlierSnapshots,
49
+ fingerprint: answer.fingerprint,
50
+ refusal: answer.refused,
51
+ detail: undefined,
52
+ };
53
+ };
54
+ // A changed tick asks for the fingerprint of the new list. One question at a time: ticks made
55
+ // while one is out ask again with the latest list, and only that answer counts.
56
+ const refresh = async (same = 'preview') => {
57
+ if (refreshing.current) {
58
+ again.current = true;
59
+ return;
60
+ }
61
+ refreshing.current = true;
62
+ update({ checking: true });
63
+ try {
64
+ let files;
65
+ let answer;
66
+ do {
67
+ again.current = false;
68
+ files = selection.current;
69
+ if (!files.length)
70
+ return;
71
+ answer =
72
+ step === 'prototype'
73
+ ? await actions.save(step, undefined, files, scope)
74
+ : await actions.save(step, undefined, files);
75
+ if (activeVisit.current !== visit)
76
+ return;
77
+ } while (again.current);
78
+ if (answer.preview && answer.fingerprint)
79
+ update(listed(answer, sameFiles(answer.preview, files) ? same : 'changed'));
80
+ else
81
+ update(failed(answer.detail ?? t('studio.save.failed'), files));
82
+ }
83
+ catch {
84
+ update(failed(t('studio.save.failed'), selection.current));
85
+ }
86
+ finally {
87
+ refreshing.current = false;
88
+ update({ checking: undefined });
89
+ }
90
+ };
32
91
  const request = async (confirm = false, files) => {
33
- if (locked.current || writing)
92
+ if (locked.current || refreshing.current || writing)
34
93
  return;
35
- if (confirm && (!state.reviewed || state.reviewed !== state.fingerprint))
94
+ if (confirm && (!state.fingerprint || !files?.length))
36
95
  return;
37
96
  locked.current = true;
97
+ let recheck = false;
38
98
  update({
39
99
  phase: confirm ? 'saving' : 'loading',
40
100
  detail: undefined,
41
101
  ...(!confirm && !state.recovered ? { commit: undefined } : {}),
42
102
  });
43
103
  try {
44
- const proof = confirm ? state.reviewed : undefined;
104
+ const proof = confirm ? state.fingerprint : undefined;
45
105
  // Only a prototype save names its change, so main can refuse one that lives in a checkout.
46
106
  const answer = step === 'prototype'
47
107
  ? await actions.save(step, proof, files, scope)
@@ -57,7 +117,6 @@ export function useReviewedSave(actions, step, scope, writing = false, onSaved)
57
117
  candidates: undefined,
58
118
  commit: undefined,
59
119
  fingerprint: undefined,
60
- reviewed: undefined,
61
120
  refusal: undefined,
62
121
  detail: undefined,
63
122
  recovered: undefined,
@@ -76,18 +135,12 @@ export function useReviewedSave(actions, step, scope, writing = false, onSaved)
76
135
  await onSaved?.(answer);
77
136
  }
78
137
  else if (answer.preview && answer.fingerprint) {
138
+ // A check that changed the files hands back the fingerprint Save sent: ask for the new
139
+ // list's own, so the one Save after "changed" can commit it.
140
+ recheck = confirm && !answer.refused && answer.fingerprint === proof;
79
141
  update({
80
- phase: answer.refused ? 'refused' : confirm ? 'changed' : files ? 'reviewed' : 'preview',
81
- files: answer.preview,
82
- other: answer.other,
83
- commit: undefined,
84
- candidates: answer.candidates ?? answer.preview,
85
- kinds: answer.kinds,
86
- earlierSnapshots: answer.earlierSnapshots,
87
- fingerprint: answer.fingerprint,
88
- reviewed: answer.refused || (!confirm && files) ? answer.fingerprint : undefined,
89
- refusal: answer.refused,
90
- detail: undefined,
142
+ ...listed(answer, answer.refused ? 'refused' : confirm ? 'changed' : 'preview'),
143
+ ...(recheck ? { fingerprint: undefined } : {}),
91
144
  });
92
145
  }
93
146
  else
@@ -99,6 +152,8 @@ export function useReviewedSave(actions, step, scope, writing = false, onSaved)
99
152
  finally {
100
153
  locked.current = false;
101
154
  }
155
+ if (recheck)
156
+ await refresh('changed');
102
157
  };
103
158
  const current = state.scope === scope ? state : { scope, visit: {} };
104
159
  const review = current.phase && {
@@ -110,28 +165,32 @@ export function useReviewedSave(actions, step, scope, writing = false, onSaved)
110
165
  kinds: current.kinds,
111
166
  earlierSnapshots: current.earlierSnapshots,
112
167
  fingerprint: current.fingerprint,
113
- reviewed: current.reviewed,
168
+ checking: current.checking,
114
169
  commit: current.commit,
115
170
  refusal: current.refusal,
116
171
  detail: current.detail,
117
172
  toggle: (file) => {
118
173
  if (locked.current || writing || current.phase === 'saved')
119
174
  return;
175
+ const ticked = selection.current.includes(file)
176
+ ? selection.current.filter((path) => path !== file)
177
+ : [...selection.current, file];
178
+ // The candidates' order, as the server lists a selection.
179
+ selection.current = (current.candidates ?? ticked).filter((path) => ticked.includes(path));
120
180
  update({
121
181
  phase: 'preview',
122
- reviewed: undefined,
182
+ fingerprint: undefined,
123
183
  refusal: undefined,
124
- files: current.files?.includes(file)
125
- ? current.files.filter((path) => path !== file)
126
- : [...(current.files ?? []), file],
184
+ files: selection.current,
127
185
  });
186
+ void refresh();
128
187
  },
129
- review: () => {
130
- if (current.files?.length)
131
- void request(false, current.files);
132
- },
188
+ // Without a fingerprint (its question failed), Save asks again first; one already out waits.
133
189
  confirm: () => {
134
- void request(true, current.files);
190
+ if (current.fingerprint)
191
+ void request(true, current.files);
192
+ else if (!refreshing.current)
193
+ void refresh();
135
194
  },
136
195
  reload: () => {
137
196
  void request();
@@ -60,7 +60,7 @@ function Server({ v }) {
60
60
  const t = useT();
61
61
  const tx = useTx();
62
62
  const when = useWhen();
63
- return (_jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Icon, { name: "circle-check" }), v.name, " ", _jsx(Mono, { children: v.host })] }), action: _jsxs(Row, { children: [_jsx(Badge, { icon: "user", children: t('studio.later.srv.youRun') }), _jsx(Badge, { children: _jsx(Mono, { children: v.version }) })] }), children: [_jsxs("span", { style: muted, children: [_jsx(D, { children: v.at }), " \u00B7 ", t('studio.later.srv.size', v.size)] }), v.off ? (_jsxs(Banner, { tone: "info", title: tx('studio.later.srv.off', { host: v.host }, { time: when.time(v.since ?? '') }), children: [t('studio.later.srv.offLine'), " ", tx('studio.later.srv.last', { version: v.version })] })) : (_jsxs(_Fragment, { children: [_jsx(Status, { v: v }), _jsx(Actions, { v: v })] })), _jsxs(Foot, { children: [t(v.off ? 'studio.later.srv.readThen' : 'studio.later.srv.read'), ' ', _jsx(Mono, { children: `ssh ${v.host} sudo docker compose logs` })] }), _jsx(Place, { id: "card:server", passed: v })] }));
63
+ return (_jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Icon, { name: "circle-check" }), v.name, " ", _jsx(Mono, { children: v.host })] }), action: _jsxs(Row, { children: [_jsx(Badge, { icon: "user", children: t('studio.later.srv.youRun') }), _jsx(Badge, { children: _jsx(Mono, { children: v.version }) })] }), children: [_jsxs("span", { style: muted, children: [_jsx(D, { children: v.at }), " \u00B7 ", t('studio.later.srv.size', v.size)] }), v.off ? (_jsxs(Banner, { tone: "info", title: tx('studio.later.srv.off', { host: v.host }, { time: when.time(v.since ?? '') }), children: [t('studio.later.srv.offLine'), " ", tx('studio.later.srv.last', { version: v.version })] })) : (_jsxs(_Fragment, { children: [_jsx(Status, { v: v }), _jsx(Actions, { v: v })] })), _jsxs(Foot, { children: [t(v.off ? 'studio.later.srv.readThen' : 'studio.later.srv.read'), ' ', _jsx(Mono, { children: `ssh ${v.host} sudo docker compose logs` })] }), _jsx(Place, { id: "card:server", passed: v, subject: v })] }));
64
64
  }
65
65
  export function LiveServers({ servers }) {
66
66
  const t = useT();
@@ -27,5 +27,5 @@ function SampleRelease({ release: r, needsRight, onAction, }) {
27
27
  gap: 'var(--space-4)',
28
28
  gridTemplateColumns: 'repeat(auto-fit, minmax(min(22rem,100%), 1fr))',
29
29
  alignItems: 'start',
30
- }, children: [_jsxs(Stack, { children: [_jsx(Measured, { r: r }), _jsx(Where, { onAction: onAction, r: r })] }), _jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Seal, {}), t('studio.later.rel.gate')] }), children: [_jsxs("p", { style: muted, children: [t('studio.later.rel.gateLine'), " ", _jsx(Mono, { children: "ape deploy" })] }), _jsx(Row, { children: _jsx(RightAction, { onClick: () => onAction?.('rel.approve'), disabled: !onAction, icon: "shield-check", needsRight: needsRight, children: t('studio.later.rel.approve') }) }), _jsx(Place, { id: "approve:release" }), _jsx(Place, { id: "side:release" })] })] })] }));
30
+ }, children: [_jsxs(Stack, { children: [_jsx(Measured, { r: r }), _jsx(Where, { onAction: onAction, r: r })] }), _jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Seal, {}), t('studio.later.rel.gate')] }), children: [_jsxs("p", { style: muted, children: [t('studio.later.rel.gateLine'), " ", _jsx(Mono, { children: "ape deploy" })] }), _jsx(Row, { children: _jsx(RightAction, { onClick: () => onAction?.('rel.approve'), disabled: !onAction, icon: "shield-check", needsRight: needsRight, children: t('studio.later.rel.approve') }) }), _jsx(Place, { id: "approve:release", subject: { release: r.version } }), _jsx(Place, { id: "side:release" })] })] })] }));
31
31
  }
@@ -26,7 +26,7 @@ function ServerCard({ s, runBy }) {
26
26
  display: 'grid',
27
27
  gap: 'var(--space-1)',
28
28
  borderColor: s.state === 'hurt' ? 'var(--error-border)' : undefined,
29
- }, children: [_jsxs(Row, { style: { justifyContent: 'space-between' }, children: [_jsx("strong", { style: strong, children: s.here ? t('studio.frame.rail.computer') : s.name }), _jsx(Badge, { status: s.state === 'ok' ? 'healthy' : 'down', children: _jsx(Mono, { children: s.version }) })] }), _jsx(Mono, { children: s.host }), _jsx("span", { style: muted, children: s.state === 'hurt' ? t('studio.later.rels.hurt') : s.note ? _jsx(D, { children: s.note }) : null }), runBy && !s.here && _jsx("span", { style: small, children: t('studio.later.rels.youRun') }), _jsx(Place, { id: "card:server", passed: s })] }));
29
+ }, children: [_jsxs(Row, { style: { justifyContent: 'space-between' }, children: [_jsx("strong", { style: strong, children: s.here ? t('studio.frame.rail.computer') : s.name }), _jsx(Badge, { status: s.state === 'ok' ? 'healthy' : 'down', children: _jsx(Mono, { children: s.version }) })] }), _jsx(Mono, { children: s.host }), _jsx("span", { style: muted, children: s.state === 'hurt' ? t('studio.later.rels.hurt') : s.note ? _jsx(D, { children: s.note }) : null }), runBy && !s.here && _jsx("span", { style: small, children: t('studio.later.rels.youRun') }), _jsx(Place, { id: "card:server", passed: s, subject: s })] }));
30
30
  }
31
31
  export function ServerCards({ servers, runBy, }) {
32
32
  const t = useT();
@@ -56,7 +56,7 @@ function History({ rows, onAction, }) {
56
56
  }
57
57
  function Ready({ ready, onAction, }) {
58
58
  const t = useT();
59
- return (_jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Seal, {}), t('studio.later.rels.ready', { v: ready.v })] }), children: [_jsxs("p", { style: muted, children: [_jsx(D, { children: ready.what }), " ", t('studio.later.rels.readyLine')] }), _jsx(Row, { children: _jsx(Button, { onClick: () => onAction?.('rels.approve'), disabled: !onAction, icon: "shield-check", children: t('studio.later.rels.approve', { v: ready.v }) }) }), _jsx(Place, { id: "approve:release" })] }));
59
+ return (_jsxs(Panel, { title: _jsxs(Row, { children: [_jsx(Seal, {}), t('studio.later.rels.ready', { v: ready.v })] }), children: [_jsxs("p", { style: muted, children: [_jsx(D, { children: ready.what }), " ", t('studio.later.rels.readyLine')] }), _jsx(Row, { children: _jsx(Button, { onClick: () => onAction?.('rels.approve'), disabled: !onAction, icon: "shield-check", children: t('studio.later.rels.approve', { v: ready.v }) }) }), _jsx(Place, { id: "approve:release", subject: { release: ready.v } })] }));
60
60
  }
61
61
  function Stores({ stores }) {
62
62
  const t = useT();
@@ -91,5 +91,5 @@ export function ServedRelease({ release, server = { destination: '', addressKind
91
91
  return (_jsxs(Page, { title: t('studio.frame.page.release'), sub: t('studio.release.intro'), actions: _jsx(Button, { disabled: !onReleases, variant: "secondary", onClick: onReleases, style: actionStyle, children: t('studio.frame.place.release') }), children: [_jsx(Place, { id: "tabs:release" }), _jsx(WithHostSide, { id: "side:release", children: _jsxs(Stack, { children: [_jsx(DestinationPanel, { server: server, onServer: onServer, busy: busy, onReview: d.review }), _jsx(ReleasePrerequisites, { rows: rows, main: release.main }), _jsx(Decision, { statusKey: status, reason: reason, blocked: blocked, busy: busy, deploy: release.runs.deploy, onApprove: () => {
92
92
  if (!blocked)
93
93
  void d.decide(() => onRun?.('deploy', { ...server }));
94
- } }), _jsx(Place, { id: "approve:release" })] }) })] }));
94
+ } }), _jsx(Place, { id: "approve:release", subject: release.main ? { release: release.main } : undefined })] }) })] }));
95
95
  }
@@ -23,6 +23,7 @@ export declare function scaleFacts(): {
23
23
  model?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", string>> | undefined;
24
24
  effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
25
25
  level: "auto" | "guide" | "lead" | "review";
26
+ neverAsk?: boolean | undefined;
26
27
  } | null;
27
28
  found: {
28
29
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -220,6 +221,7 @@ export declare function scaleFacts(): {
220
221
  who: string;
221
222
  place: string;
222
223
  main: boolean;
224
+ planned?: string | undefined;
223
225
  }[];
224
226
  notes: string[];
225
227
  problem?: string | undefined;
@@ -329,6 +331,7 @@ export declare function scaleFacts(): {
329
331
  } | undefined;
330
332
  committedLevel?: "auto" | "guide" | "lead" | "review" | undefined;
331
333
  effectiveLevel?: "auto" | "guide" | "lead" | "review" | undefined;
334
+ neverAsk?: boolean | undefined;
332
335
  level?: {
333
336
  source: "host";
334
337
  where: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buffcore/admin-shell",
3
- "version": "0.8.41",
3
+ "version": "0.8.42",
4
4
  "description": "The React DOM admin console for a BuffCore product, with its prototype viewer.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "BuffApe",
@@ -37,11 +37,11 @@
37
37
  "@tanstack/react-router": "1.170.42",
38
38
  "firebase": "12.19.0",
39
39
  "qrcode": "1.5.4",
40
- "@buffcore/sdk": "0.8.41",
41
- "@buffcore/tokens": "0.8.41",
42
- "@buffcore/contracts": "0.8.41",
43
- "@buffcore/i18n": "0.8.41",
44
- "@buffcore/config": "0.8.41"
40
+ "@buffcore/config": "0.8.42",
41
+ "@buffcore/contracts": "0.8.42",
42
+ "@buffcore/tokens": "0.8.42",
43
+ "@buffcore/i18n": "0.8.42",
44
+ "@buffcore/sdk": "0.8.42"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=19",
package/vite.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  // Types for vite.js. The plugin's hooks are Vite's; a Vite config takes it as a plugin.
2
2
  export const SERVICE_WORKER: '/firebase-messaging-sw.js';
3
3
  export const MANIFEST: '/manifest.webmanifest';
4
+ export const FONT_LIST: 'buffcore-fonts';
5
+
6
+ /** The design system's font files (`design/fonts/` beside the product's `buffcore.config.ts`). */
7
+ export function designFontFiles(from: string): string[];
4
8
 
5
9
  /**
6
10
  * Serves BuffCore's files at the console's root, in development and in the build: Firebase's
7
- * service worker for pages on this device, and a web app manifest for the home screen.
11
+ * service worker for pages on this device, a web app manifest for the home screen, and the design
12
+ * system's font files (`/_fonts/`), listed in the page for the console to load.
8
13
  */
9
14
  export function adminConsole(options: { name: string }): { name: string };