@seriousgaming/sdk-tools 1.3.0 → 1.5.0

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 (176) hide show
  1. package/dist/cli.js +4055 -2646
  2. package/dist/client.js +807 -172
  3. package/dist/core/session-host.d.ts +4 -2
  4. package/dist/core/settings-locks.d.ts +27 -2
  5. package/dist/dev/console/assets/{index-DEV8N0na.js → index-BVF8exas.js} +22 -22
  6. package/dist/dev/console/index.html +1 -1
  7. package/dist/dev/public-origins.d.ts +61 -0
  8. package/dist/dev/routes.d.ts +4 -0
  9. package/dist/dev/shell.d.ts +32 -4
  10. package/dist/dev/view/batch.d.ts +7 -1
  11. package/dist/docs/ai-agents.md +5 -0
  12. package/dist/docs/api/index.md +1 -1
  13. package/dist/docs/api/sdk-tools-client.md +1 -0
  14. package/dist/docs/api/sdk.md +79 -2
  15. package/dist/docs/changelog-0.x.md +2 -2
  16. package/dist/docs/changelog.md +62 -4
  17. package/dist/docs/cli-and-dev-server.md +58 -0
  18. package/dist/docs/cli-error-codes.md +39 -36
  19. package/dist/docs/cli-reference.md +68 -21
  20. package/dist/docs/concepts/terminology.md +1 -1
  21. package/dist/docs/environment-variables.md +10 -5
  22. package/dist/docs/guides/ai-facilitation.md +2 -0
  23. package/dist/docs/guides/capabilities.md +4 -0
  24. package/dist/docs/guides/designing-a-game.md +2 -0
  25. package/dist/docs/guides/designing-screens.md +133 -0
  26. package/dist/docs/guides/endpoints.md +4 -2
  27. package/dist/docs/guides/engine-testing.md +6 -2
  28. package/dist/docs/guides/engine.md +2 -0
  29. package/dist/docs/guides/file-handling.md +116 -22
  30. package/dist/docs/guides/games.md +3 -1
  31. package/dist/docs/guides/global-settings.md +2 -0
  32. package/dist/docs/guides/guide.md +2 -0
  33. package/dist/docs/guides/hooks.md +2 -0
  34. package/dist/docs/guides/index.md +9 -0
  35. package/dist/docs/guides/internationalization.md +2 -0
  36. package/dist/docs/guides/llm-integration.md +5 -3
  37. package/dist/docs/guides/multi-team-games.md +3 -1
  38. package/dist/docs/guides/patterns.md +2 -0
  39. package/dist/docs/guides/presentation.md +1 -1
  40. package/dist/docs/guides/production-constraints.md +2 -0
  41. package/dist/docs/guides/scenario-editor.md +3 -1
  42. package/dist/docs/guides/scenarios.md +15 -3
  43. package/dist/docs/guides/session-game-flow.md +365 -0
  44. package/dist/docs/guides/session-hooks.md +205 -0
  45. package/dist/docs/guides/session.md +27 -565
  46. package/dist/docs/guides/settings.md +64 -2
  47. package/dist/docs/guides/setup.md +3 -1
  48. package/dist/docs/guides/speech-generation.md +2 -0
  49. package/dist/docs/guides/starter-game.md +61 -21
  50. package/dist/docs/guides/testing.md +2 -0
  51. package/dist/docs/guides/tick-controller.md +3 -1
  52. package/dist/docs/guides/type-safety.md +2 -0
  53. package/dist/docs/guides/ui-files-and-llms.md +328 -0
  54. package/dist/docs/guides/ui-participants.md +281 -0
  55. package/dist/docs/guides/ui-styling.md +263 -0
  56. package/dist/docs/guides/ui-ticks.md +247 -0
  57. package/dist/docs/guides/ui.md +11 -1092
  58. package/dist/docs/guides/upgrading.md +2 -0
  59. package/dist/docs/guides/validators.md +64 -4
  60. package/dist/docs/guides/waiting-room.md +1 -1
  61. package/dist/docs/index.md +2 -1
  62. package/dist/docs/page-index.md +145 -0
  63. package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
  64. package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
  65. package/dist/docs/recipes/create-presentation.md +11 -0
  66. package/dist/docs/recipes/create-scenario-editor.md +1 -0
  67. package/dist/docs/recipes/create-session-ui.md +2 -1
  68. package/dist/docs/recipes/create-setup.md +1 -0
  69. package/dist/docs/recipes/create-user-interface.md +1 -0
  70. package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
  71. package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
  72. package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
  73. package/dist/docs/recipes/index.md +3 -0
  74. package/dist/docs/recipes/screenshot-a-surface.md +80 -0
  75. package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
  76. package/dist/docs/recipes/upload-and-display-files.md +7 -7
  77. package/dist/docs/recipes/use-request-tick.md +2 -2
  78. package/dist/docs/recipes/validate-scenarios.md +4 -1
  79. package/dist/execution/config-resolver.d.ts +4 -1
  80. package/dist/execution/endpoint-runner.d.ts +6 -0
  81. package/dist/execution/logic-calls.d.ts +7 -2
  82. package/dist/execution/scenario-gates.d.ts +21 -1
  83. package/dist/guide/settings.d.ts +1 -1
  84. package/dist/host.js +64 -2
  85. package/dist/runtime/manifest-version.d.ts +1 -1
  86. package/dist/runtime.js +7 -2
  87. package/dist/storage/asset-resolver.d.ts +24 -1
  88. package/dist/storage/blob-store.d.ts +7 -0
  89. package/dist/templates/package/CLAUDE.md.template +14 -5
  90. package/dist/templates/package/DESIGN.md.liquid +39 -7
  91. package/dist/templates/package/README.md.liquid +1 -1
  92. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  93. package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
  94. package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
  95. package/dist/templates/starter-game/package.json +2 -0
  96. package/dist/templates/starter-game/presentation/defaults.ts +52 -0
  97. package/dist/templates/starter-game/presentation/index.html +20 -0
  98. package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
  99. package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
  100. package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
  101. package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
  102. package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
  103. package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
  104. package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
  105. package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
  106. package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
  107. package/dist/templates/starter-game/presentation/types.ts +94 -0
  108. package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
  109. package/dist/templates/starter-game/session/defaults.ts +6 -0
  110. package/dist/templates/starter-game/session/index.html +1 -1
  111. package/dist/templates/starter-game/session/session.sdk.json +2 -2
  112. package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
  113. package/dist/templates/starter-game/session/src/App.tsx +372 -222
  114. package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
  115. package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
  116. package/dist/templates/starter-game/session/src/Results.tsx +340 -0
  117. package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
  118. package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
  119. package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
  120. package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
  121. package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
  122. package/dist/templates/starter-game/session/src/i18n.ts +91 -24
  123. package/dist/templates/starter-game/session/src/status.ts +28 -0
  124. package/dist/templates/starter-game/session/types.ts +8 -2
  125. package/dist/templates/starter-game/shared/Awning.tsx +31 -0
  126. package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
  127. package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
  128. package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
  129. package/dist/templates/starter-game/shared/days.ts +11 -0
  130. package/dist/templates/starter-game/shared/format.test.ts +13 -0
  131. package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
  132. package/dist/templates/starter-game/testing/e2e/game.spec.ts +42 -8
  133. package/dist/templates/starter-game/ui/defaults.ts +3 -0
  134. package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
  135. package/dist/templates/starter-game/ui/src/App.tsx +176 -99
  136. package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
  137. package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
  138. package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
  139. package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
  140. package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
  141. package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
  142. package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
  143. package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
  144. package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
  145. package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
  146. package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
  147. package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
  148. package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
  149. package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
  150. package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
  151. package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
  152. package/dist/templates/starter-game/ui/src/days.ts +58 -0
  153. package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
  154. package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
  155. package/dist/templates/starter-game/ui/src/theme.ts +8 -8
  156. package/dist/templates/starter-game/ui/types.ts +6 -0
  157. package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
  158. package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
  159. package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
  160. package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
  161. package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
  162. package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
  163. package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
  164. package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
  165. package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
  166. package/dist/utils/error-codes.d.ts +12 -0
  167. package/dist/utils/local-refs.d.ts +40 -0
  168. package/dist/utils/schema-members.d.ts +19 -0
  169. package/package.json +11 -4
  170. package/dist/templates/starter-game/session/src/Section.tsx +0 -37
  171. package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
  172. package/dist/templates/starter-game/session/src/format.ts +0 -8
  173. package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
  174. package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
  175. package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
  176. package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
@@ -1,21 +1,24 @@
1
+ import AddOutlinedIcon from '@mui/icons-material/AddOutlined';
2
+ import CampaignOutlinedIcon from '@mui/icons-material/CampaignOutlined';
3
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
4
+ import PresentToAllOutlinedIcon from '@mui/icons-material/PresentToAllOutlined';
5
+ import PrintOutlinedIcon from '@mui/icons-material/PrintOutlined';
6
+ import RestartAltOutlinedIcon from '@mui/icons-material/RestartAltOutlined';
1
7
  import {
2
8
  Alert,
3
- AppBar,
4
9
  Box,
5
10
  Button,
6
- Chip,
7
11
  CssBaseline,
12
+ Dialog,
13
+ IconButton,
14
+ ListItemIcon,
15
+ ListItemText,
16
+ Menu,
17
+ MenuItem,
8
18
  Snackbar,
9
- Stack,
10
- Switch,
11
- Table,
12
- TableBody,
13
- TableCell,
14
- TableHead,
15
- TableRow,
16
- TextField,
19
+ Tab,
20
+ Tabs,
17
21
  ThemeProvider,
18
- Toolbar,
19
22
  Tooltip,
20
23
  Typography,
21
24
  } from '@mui/material';
@@ -25,27 +28,40 @@ import {
25
28
  useSessionUserInterfaceHostOverlays,
26
29
  useSessionUserInterfaceMeta,
27
30
  useSessionUserInterfaceParticipants,
31
+ useSessionUserInterfaceTeamConfiguration,
28
32
  useSessionUserInterfaceTeamLinks,
29
33
  useSessionUserInterfaceTeams,
30
34
  } from '@seriousgaming/sdk/ui';
31
35
  import { useState } from 'react';
32
36
  import { useTranslation } from 'react-i18next';
33
37
 
34
- import type { Settings, SessionData, SharedWrites, TeamContext, TeamWrites } from '../types';
35
- import { money } from './format';
36
- import Section from './Section';
37
- import TeamDoor from './TeamDoor';
38
+ import { Awning } from '../../shared/Awning';
39
+ import { money } from '../../shared/format';
40
+ import type { Settings, SessionData, SharedWrites, TeamWrites } from '../types';
41
+ import JoinCodes from './JoinCodes';
42
+ import ManagePanel from './ManagePanel';
43
+ import ResultsView, { latestPlayedDay, ResultsTools } from './Results';
44
+ import SessionBar from './SessionBar';
45
+ import { NoticePanel, StartAgainPanel } from './SessionPanels';
46
+ import StallCard from './StallCard';
47
+ import { stallStatus } from './status';
38
48
  import { useAppTheme } from './theme';
49
+ import TopBar from './TopBar';
50
+
51
+ type Panel = { kind: 'stall'; teamId: string } | { kind: 'notice' } | { kind: 'startAgain' };
39
52
 
40
53
  /**
41
54
  * The facilitator's whole screen.
42
55
  *
43
56
  * A game that ships a session surface replaces the host's roster page outright,
44
- * so everything a facilitator needs during play has to be here: what each stall
45
- * is making, whether anyone has touched it today, and a way into any stall's
46
- * screen. The stalls run their own days, so this watches rather than drives,
47
- * and the two host-owned things it cannot draw itself, the guide and the
48
- * waiting room, it asks the host for.
57
+ * so everything a facilitator needs during play has to be here. The stalls
58
+ * run their own days, so this watches rather than drives: the one lever on
59
+ * the pace of the room is the day limit in the bar, and everything that acts
60
+ * on a single stall waits in its panel rather than crowding the card.
61
+ *
62
+ * It is meant to be calm. A facilitator glances at it between conversations,
63
+ * so every card is the same three rows, every row fits on one line, and
64
+ * nothing moves unless a stall did something.
49
65
  */
50
66
  function Shell() {
51
67
  const { sessionData, settings, setData } = useSessionUserInterfaceData<
@@ -59,230 +75,364 @@ function Shell() {
59
75
  const links = useSessionUserInterfaceTeamLinks();
60
76
  const meta = useSessionUserInterfaceMeta();
61
77
  const overlays = useSessionUserInterfaceHostOverlays();
62
- const { undoTick, openHostOverlay, setWaitingRoom } = useSessionUserInterfaceCallbacks();
78
+ const teamConfiguration = useSessionUserInterfaceTeamConfiguration();
79
+ const callbacks = useSessionUserInterfaceCallbacks();
63
80
  const { t } = useTranslation();
64
81
 
82
+ const [tab, setTab] = useState<'teams' | 'results'>('teams');
83
+ const [panel, setPanel] = useState<Panel | null>(null);
84
+ const [menu, setMenu] = useState<HTMLElement | null>(null);
85
+ const [codesFrom, setCodesFrom] = useState<number | null>(null);
86
+ const [resultsDay, setResultsDay] = useState<number | null>(null);
87
+ const [projecting, setProjecting] = useState(false);
65
88
  const [refusal, setRefusal] = useState<string | null>(null);
66
- const [briefingDraft, setBriefingDraft] = useState<string | null>(null);
67
89
 
68
- // One value for the session, delivered once, whether or not a team exists.
69
- const briefing = sessionData.shared.context.briefing.Message;
90
+ const symbol = settings.session.CurrencySymbol;
91
+ const showLinks = settings.session.ShowJoinLinks;
92
+ const { pacing, briefing } = sessionData.shared.context;
70
93
 
71
94
  // A denial is terminal, so report it rather than retrying. The alternative
72
95
  // is a control that silently does nothing, which is worse than an error.
96
+ const run = async (action: () => Promise<unknown>) => {
97
+ try {
98
+ await action();
99
+ } catch (error) {
100
+ setRefusal(error instanceof Error ? error.message : String(error));
101
+ throw error;
102
+ }
103
+ };
73
104
  const attempt = (action: () => Promise<unknown>) => {
74
- void action().catch((error: unknown) =>
75
- setRefusal(error instanceof Error ? error.message : String(error))
76
- );
105
+ run(action).catch(() => undefined);
77
106
  };
78
107
 
79
- /**
80
- * Whether a stall is still sitting on the numbers it traded yesterday.
81
- *
82
- * There is nothing to press on a player's screen to say 'we are ready', and
83
- * adding one would be a commit step by another name. Comparing today's plan
84
- * against what was actually made yesterday costs no extra state and answers
85
- * the only question a facilitator has before ticking.
86
- */
87
- const untouched = (team: TeamContext | undefined) => {
88
- if (!team) return false;
89
- const lines = Object.entries(team.results.Lines);
90
- if (lines.length === 0) return false;
91
- return lines.every(([id, line]) => (team.plan.Make[id] ?? 0) === line.Made);
92
- };
108
+ const latest = latestPlayedDay(sessionData.teams);
109
+ // Follows the latest day until the facilitator steps back to an earlier one.
110
+ const day = Math.min(resultsDay ?? latest, latest);
111
+
112
+ const canAddStall =
113
+ !meta.readOnly &&
114
+ teamConfiguration.mode === 'independent' &&
115
+ teams.length < teamConfiguration.max;
93
116
 
94
- const movedOn = teams.filter(
95
- (team) => !untouched(sessionData.teams[team.teamId]?.context)
96
- ).length;
117
+ const managed =
118
+ panel?.kind === 'stall' ? teams.find((team) => team.teamId === panel.teamId) : undefined;
119
+ const panelOpen =
120
+ tab === 'teams' && panel !== null && (panel.kind !== 'stall' || managed !== undefined);
97
121
 
98
122
  return (
99
- <Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
100
- <AppBar position="static" color="default" elevation={0}>
101
- <Toolbar sx={{ gap: 2 }}>
102
- <Typography variant="h6" component="h1" sx={{ flexGrow: 1 }} noWrap>
103
- {meta.name}
104
- </Typography>
123
+ <Box
124
+ sx={{
125
+ display: 'flex',
126
+ flexDirection: 'column',
127
+ height: '100vh',
128
+ bgcolor: 'background.default',
129
+ }}
130
+ >
131
+ <TopBar />
132
+ <SessionBar
133
+ lastOpenDay={pacing.LastOpenDay}
134
+ onLastOpenDay={(lastOpenDay) =>
135
+ // The one-argument form is a shared write: one value for
136
+ // the session, which the day-limit validator reads before
137
+ // it lets any stall open a day.
138
+ attempt(() => setData({ pacing: { LastOpenDay: lastOpenDay } }))
139
+ }
140
+ waitingRoomOpen={meta.waitingRoomOpen}
141
+ onWaitingRoom={(open) => attempt(() => callbacks.setWaitingRoom(open))}
142
+ overlays={overlays}
143
+ onOverlay={(overlay) => attempt(() => callbacks.openHostOverlay(overlay))}
144
+ readOnly={meta.readOnly}
145
+ />
105
146
 
106
- <Tooltip title={t('session.waitingRoomHint')}>
107
- <Stack direction="row" spacing={1} sx={{ alignItems: 'center' }}>
108
- <Typography variant="body2">{t('session.waitingRoom')}</Typography>
109
- <Switch
110
- checked={meta.waitingRoomOpen}
147
+ <Box
148
+ sx={{
149
+ mx: { xs: 2, md: 4 },
150
+ minHeight: 48,
151
+ display: 'flex',
152
+ flexWrap: { xs: 'wrap', sm: 'nowrap' },
153
+ alignItems: 'center',
154
+ columnGap: 1,
155
+ borderBottom: 1,
156
+ borderColor: 'divider',
157
+ }}
158
+ >
159
+ <Tabs
160
+ value={tab}
161
+ onChange={(_, value: 'teams' | 'results') => setTab(value)}
162
+ aria-label={t('tabs.label')}
163
+ sx={{ alignSelf: 'stretch', '& .MuiTabs-flexContainer': { gap: 3 } }}
164
+ >
165
+ <Tab
166
+ value="teams"
167
+ label={t('tabs.teams')}
168
+ id="tab-teams"
169
+ aria-controls="panel-teams"
170
+ sx={{ px: 0.5, minWidth: 0 }}
171
+ />
172
+ <Tab
173
+ value="results"
174
+ label={t('tabs.results')}
175
+ id="tab-results"
176
+ aria-controls="panel-results"
177
+ sx={{ px: 0.5, minWidth: 0 }}
178
+ />
179
+ </Tabs>
180
+ <Box sx={{ flex: 1 }} />
181
+ {tab === 'teams' ? (
182
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
183
+ {showLinks && teams.length > 0 && (
184
+ <Button
185
+ color="inherit"
186
+ startIcon={<PresentToAllOutlinedIcon />}
187
+ onClick={() => setCodesFrom(0)}
188
+ sx={{ whiteSpace: 'nowrap', fontWeight: 600 }}
189
+ >
190
+ {t('tools.joinCodes')}
191
+ </Button>
192
+ )}
193
+ <Tooltip title={t('tools.more')}>
194
+ <IconButton
195
+ aria-label={t('tools.more')}
196
+ aria-haspopup="menu"
197
+ onClick={(event) => setMenu(event.currentTarget)}
198
+ >
199
+ <MoreHorizIcon />
200
+ </IconButton>
201
+ </Tooltip>
202
+ <Menu
203
+ anchorEl={menu}
204
+ open={menu !== null}
205
+ onClose={() => setMenu(null)}
206
+ anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
207
+ transformOrigin={{ vertical: 'top', horizontal: 'right' }}
208
+ >
209
+ <MenuItem
210
+ onClick={() => {
211
+ setMenu(null);
212
+ setPanel({ kind: 'notice' });
213
+ }}
214
+ >
215
+ <ListItemIcon>
216
+ <CampaignOutlinedIcon fontSize="small" />
217
+ </ListItemIcon>
218
+ <ListItemText>{t('tools.notice')}</ListItemText>
219
+ </MenuItem>
220
+ {/* The host's sheets carry the brand of whoever runs
221
+ the session, so they are offered wherever the
222
+ host has them, and the game draws none of its own. */}
223
+ {overlays.includes('print-sheets') && (
224
+ <MenuItem
225
+ onClick={() => {
226
+ setMenu(null);
227
+ attempt(() => callbacks.openHostOverlay('print-sheets'));
228
+ }}
229
+ >
230
+ <ListItemIcon>
231
+ <PrintOutlinedIcon fontSize="small" />
232
+ </ListItemIcon>
233
+ <ListItemText>{t('tools.print')}</ListItemText>
234
+ </MenuItem>
235
+ )}
236
+ <MenuItem
237
+ disabled={!canAddStall}
238
+ onClick={() => {
239
+ setMenu(null);
240
+ attempt(() => callbacks.createTeam());
241
+ }}
242
+ >
243
+ <ListItemIcon>
244
+ <AddOutlinedIcon fontSize="small" />
245
+ </ListItemIcon>
246
+ <ListItemText>{t('tools.addStall')}</ListItemText>
247
+ </MenuItem>
248
+ <MenuItem
111
249
  disabled={meta.readOnly}
112
- slotProps={{ input: { 'aria-label': t('session.waitingRoom') } }}
113
- onChange={(event) =>
114
- attempt(() => setWaitingRoom(event.target.checked))
115
- }
116
- />
117
- </Stack>
118
- </Tooltip>
250
+ onClick={() => {
251
+ setMenu(null);
252
+ setPanel({ kind: 'startAgain' });
253
+ }}
254
+ >
255
+ <ListItemIcon>
256
+ <RestartAltOutlinedIcon fontSize="small" />
257
+ </ListItemIcon>
258
+ <ListItemText>{t('tools.startAgain')}</ListItemText>
259
+ </MenuItem>
260
+ </Menu>
261
+ </Box>
262
+ ) : (
263
+ <ResultsTools
264
+ day={day}
265
+ latest={latest}
266
+ onDay={setResultsDay}
267
+ projecting={projecting}
268
+ onProject={setProjecting}
269
+ />
270
+ )}
271
+ </Box>
119
272
 
120
- {/* Only for an overlay this host actually offers: a button
121
- for one it does not have is a button that cannot work. */}
122
- {overlays.includes('facilitator-guide') && (
123
- <Button
124
- variant="outlined"
125
- onClick={() => attempt(() => openHostOverlay('facilitator-guide'))}
126
- >
127
- {t('session.guide')}
128
- </Button>
273
+ <Box sx={{ flex: 1, minHeight: 0, display: 'flex' }}>
274
+ <Box
275
+ role="tabpanel"
276
+ id={`panel-${tab}`}
277
+ aria-labelledby={`tab-${tab}`}
278
+ sx={{
279
+ flex: 1,
280
+ minWidth: 0,
281
+ overflowY: 'auto',
282
+ px: { xs: 2, md: 4 },
283
+ py: 2.5,
284
+ // On a phone the panel takes the page rather than
285
+ // squeezing the cards into a sliver beside it.
286
+ display: { xs: panelOpen ? 'none' : 'block', md: 'block' },
287
+ }}
288
+ >
289
+ {meta.readOnly && (
290
+ <Alert severity="warning" sx={{ mb: 2 }}>
291
+ {t('readOnly')}
292
+ </Alert>
129
293
  )}
130
- </Toolbar>
131
- </AppBar>
132
294
 
133
- <Box sx={{ flex: 1, minHeight: 0, overflowY: 'auto', py: 3 }}>
134
- <Stack spacing={3} sx={{ maxWidth: 1200, mx: 'auto', px: 2 }}>
135
- {meta.readOnly && <Alert severity="warning">{t('session.readOnly')}</Alert>}
136
-
137
- <Section
138
- title={t('session.stalls')}
139
- hint={t('session.movedOn', { movedOn, total: teams.length })}
140
- >
141
- <Box sx={{ overflowX: 'auto' }}>
142
- <Table size="small">
143
- <TableHead>
144
- <TableRow>
145
- <TableCell>{t('session.team')}</TableCell>
146
- <TableCell align="right">{t('session.people')}</TableCell>
147
- <TableCell align="right">{t('session.day')}</TableCell>
148
- <TableCell align="right">{t('session.making')}</TableCell>
149
- <TableCell>{t('session.status')}</TableCell>
150
- <TableCell align="right">{t('session.purse')}</TableCell>
151
- <TableCell>{t('session.wayIn')}</TableCell>
152
- <TableCell align="right">{t('session.controls')}</TableCell>
153
- </TableRow>
154
- </TableHead>
155
- <TableBody>
156
- {teams.map((team) => {
157
- const state = sessionData.teams[team.teamId];
158
- const context = state?.context;
159
- const planned = Object.values(
160
- context?.plan.Make ?? {}
161
- ).reduce((sum, value) => sum + value, 0);
162
- const size = participants.filter(
163
- (person) => person.teamId === team.teamId
164
- ).length;
165
- const stale = untouched(context);
166
-
167
- return (
168
- <TableRow
169
- key={team.teamId}
170
- data-testid={`team-${team.teamId}`}
171
- >
172
- <TableCell>{team.name}</TableCell>
173
- <TableCell align="right">{size}</TableCell>
174
- <TableCell align="right">
175
- {(state?.completedTicks ?? 0) + 1}
176
- </TableCell>
177
- <TableCell
178
- align="right"
179
- sx={{ fontVariantNumeric: 'tabular-nums' }}
180
- >
181
- {t('session.ofCapacity', {
182
- planned,
183
- capacity: settings.menu.Capacity,
184
- })}
185
- </TableCell>
186
- <TableCell>
187
- {stale ? (
188
- <Chip
189
- size="small"
190
- variant="outlined"
191
- label={t('session.unchanged')}
192
- />
193
- ) : (
194
- <Chip
195
- size="small"
196
- color="success"
197
- label={t('session.changed')}
198
- />
199
- )}
200
- </TableCell>
201
- <TableCell align="right">
202
- {money(
203
- settings.session.CurrencySymbol,
204
- context?.results.Purse ?? 0
205
- )}
206
- </TableCell>
207
- <TableCell>
208
- <TeamDoor
209
- links={links.find(
210
- (link) => link.teamId === team.teamId
211
- )}
212
- teamName={team.name}
213
- show={settings.session.ShowJoinLinks}
214
- />
215
- </TableCell>
216
- <TableCell align="right">
217
- {/* No way to run a day from
218
- here. The stalls open
219
- themselves, and a
220
- facilitator who could
221
- run the day would end up
222
- doing it for a group
223
- still deciding. Undo
224
- stays: taking a day back
225
- is a correction, and
226
- nobody else can make it. */}
227
- <Button
228
- size="small"
229
- color="inherit"
230
- disabled={
231
- meta.readOnly ||
232
- (state?.completedTicks ?? 0) === 0
233
- }
234
- onClick={() =>
235
- attempt(() => undoTick(team.teamId))
236
- }
237
- >
238
- {t('session.undo')}
239
- </Button>
240
- </TableCell>
241
- </TableRow>
242
- );
243
- })}
244
- </TableBody>
245
- </Table>
246
- </Box>
247
- </Section>
248
-
249
- <Section title={t('session.notice')} hint={t('session.noticeHint')}>
250
- <Stack direction="row" spacing={1} sx={{ alignItems: 'flex-start' }}>
251
- <TextField
252
- fullWidth
253
- multiline
254
- minRows={2}
255
- size="small"
256
- label={t('session.noticeLabel')}
257
- value={briefingDraft ?? briefing}
258
- disabled={meta.readOnly}
259
- onChange={(event) => setBriefingDraft(event.target.value)}
260
- />
261
- <Button
262
- variant="contained"
263
- disabled={meta.readOnly || briefingDraft === null}
264
- onClick={() => {
265
- // The one-argument form is a shared write:
266
- // one value for the whole session, applied
267
- // to every team at once. Only a session
268
- // surface may make one, which is what makes
269
- // a shared capability safe in a game whose
270
- // teams tick on their own clocks.
271
- attempt(async () => {
272
- await setData({
273
- briefing: { Message: briefingDraft ?? '' },
274
- });
275
- setBriefingDraft(null);
276
- });
295
+ {tab === 'teams' ? (
296
+ teams.length === 0 ? (
297
+ <Typography color="text.secondary">{t('noStalls')}</Typography>
298
+ ) : (
299
+ <Box
300
+ component="section"
301
+ aria-label={t('tabs.teams')}
302
+ sx={{
303
+ display: 'grid',
304
+ gridTemplateColumns:
305
+ 'repeat(auto-fill, minmax(min(100%, 320px), 1fr))',
306
+ gap: 2,
277
307
  }}
278
308
  >
279
- {t('session.send')}
280
- </Button>
281
- </Stack>
282
- </Section>
283
- </Stack>
309
+ {teams.map((team) => {
310
+ const state = sessionData.teams[team.teamId];
311
+ return (
312
+ <StallCard
313
+ key={team.teamId}
314
+ teamId={team.teamId}
315
+ name={team.name}
316
+ status={stallStatus(
317
+ state?.completedTicks ?? 0,
318
+ pacing.LastOpenDay
319
+ )}
320
+ people={participants.filter(
321
+ (person) => person.teamId === team.teamId
322
+ )}
323
+ jar={money(symbol, state?.context.results.Purse ?? 0)}
324
+ links={links.find(
325
+ (link) => link.teamId === team.teamId
326
+ )}
327
+ showLinks={showLinks}
328
+ selected={managed?.teamId === team.teamId}
329
+ onManage={() =>
330
+ setPanel(
331
+ managed?.teamId === team.teamId
332
+ ? null
333
+ : { kind: 'stall', teamId: team.teamId }
334
+ )
335
+ }
336
+ />
337
+ );
338
+ })}
339
+ </Box>
340
+ )
341
+ ) : (
342
+ <ResultsView
343
+ day={day}
344
+ teams={teams}
345
+ states={sessionData.teams}
346
+ symbol={symbol}
347
+ />
348
+ )}
349
+ </Box>
350
+
351
+ {panelOpen && managed && (
352
+ <ManagePanel
353
+ key={managed.teamId}
354
+ team={managed}
355
+ completedTicks={sessionData.teams[managed.teamId]?.completedTicks ?? 0}
356
+ people={participants.filter((person) => person.teamId === managed.teamId)}
357
+ otherTeams={teams.filter((team) => team.teamId !== managed.teamId)}
358
+ readOnly={meta.readOnly}
359
+ onClose={() => setPanel(null)}
360
+ onRename={(name) =>
361
+ attempt(() => callbacks.renameTeam(managed.teamId, name))
362
+ }
363
+ onMove={(participantId, teamId) =>
364
+ attempt(() => callbacks.moveParticipant(participantId, teamId))
365
+ }
366
+ // No way to run a stall's day from here: a facilitator
367
+ // who could would end up doing it for a group still
368
+ // deciding. Undo stays, because taking a day back is a
369
+ // correction and nobody else can make it.
370
+ onUndo={() => run(() => callbacks.undoTick(managed.teamId))}
371
+ />
372
+ )}
373
+ {panelOpen && panel?.kind === 'notice' && (
374
+ <NoticePanel
375
+ message={briefing.Message}
376
+ readOnly={meta.readOnly}
377
+ onClose={() => setPanel(null)}
378
+ onSend={(message) => run(() => setData({ briefing: { Message: message } }))}
379
+ />
380
+ )}
381
+ {panelOpen && panel?.kind === 'startAgain' && (
382
+ <StartAgainPanel
383
+ readOnly={meta.readOnly}
384
+ onClose={() => setPanel(null)}
385
+ onStartAgain={() => run(() => callbacks.resetGame())}
386
+ />
387
+ )}
284
388
  </Box>
285
389
 
390
+ <JoinCodes
391
+ open={codesFrom !== null}
392
+ start={codesFrom ?? 0}
393
+ teams={teams}
394
+ links={links}
395
+ pin={meta.joinPin}
396
+ onClose={() => setCodesFrom(null)}
397
+ />
398
+
399
+ {/* For the projector: the whole frame, so there is no edge for a
400
+ backdrop to stop at. */}
401
+ <Dialog fullScreen open={projecting} onClose={() => setProjecting(false)}>
402
+ <Box sx={{ height: 28, bgcolor: 'primary.main' }} />
403
+ <Awning />
404
+ <Box
405
+ sx={{
406
+ mx: { xs: 2, md: 4 },
407
+ minHeight: 48,
408
+ display: 'flex',
409
+ alignItems: 'center',
410
+ borderBottom: 1,
411
+ borderColor: 'divider',
412
+ }}
413
+ >
414
+ <Typography component="h2" sx={{ fontWeight: 600, fontSize: '1.15rem' }}>
415
+ {t('results.caption', { day })}
416
+ </Typography>
417
+ <Box sx={{ flex: 1 }} />
418
+ <ResultsTools
419
+ day={day}
420
+ latest={latest}
421
+ onDay={setResultsDay}
422
+ projecting
423
+ onProject={setProjecting}
424
+ />
425
+ </Box>
426
+ <Box sx={{ overflowY: 'auto', px: { xs: 2, md: 4 }, py: 2.5 }}>
427
+ <ResultsView
428
+ day={day}
429
+ teams={teams}
430
+ states={sessionData.teams}
431
+ symbol={symbol}
432
+ />
433
+ </Box>
434
+ </Dialog>
435
+
286
436
  <Snackbar
287
437
  open={refusal !== null}
288
438
  autoHideDuration={8000}